86 lines
2.6 KiB
PHP
86 lines
2.6 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: Plugin Compass Headers and footers and ad pixels
|
|
* Plugin URI: https://plugincompass.com/plugins/pc-headers-and-footers-and-ad-pixels-5ake
|
|
* Description: Insert custom code snippets into your site's header and footer. Manage all snippets from a clean admin interface.
|
|
* Version: 1.0.0
|
|
* Author: Plugin Compass
|
|
* Author URI: https://plugincompass.com
|
|
* Text Domain: pc-headers-and-footers-and-ad-pixels-5ake
|
|
* Domain Path: /languages
|
|
* Update URI: false
|
|
* License: GPL v2 or later
|
|
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
|
*/
|
|
|
|
// Prevent direct access
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
// Define plugin constants
|
|
define('PC_HFAP_VERSION', '1.0.0');
|
|
define('PC_HFAP_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
|
define('PC_HFAP_PLUGIN_URL', plugin_dir_url(__FILE__));
|
|
define('PC_HFAP_PLUGIN_BASENAME', plugin_basename(__FILE__));
|
|
|
|
// Prevent WordPress.org update checks
|
|
add_filter('site_transient_update_plugins', function($value) {
|
|
$plugin_file = plugin_basename(__FILE__);
|
|
if (isset($value->response[$plugin_file])) {
|
|
unset($value->response[$plugin_file]);
|
|
}
|
|
return $value;
|
|
});
|
|
|
|
// Include required files
|
|
require_once PC_HFAP_PLUGIN_DIR . 'includes/class-database.php';
|
|
require_once PC_HFAP_PLUGIN_DIR . 'includes/class-snippet.php';
|
|
require_once PC_HFAP_PLUGIN_DIR . 'admin/class-admin.php';
|
|
require_once PC_HFAP_PLUGIN_DIR . 'public/class-public.php';
|
|
|
|
// Initialize the plugin
|
|
class PC_Headers_Footers_Ad_Pixels {
|
|
|
|
private static $instance = null;
|
|
|
|
public static function get_instance() {
|
|
if (null === self::$instance) {
|
|
self::$instance = new self();
|
|
}
|
|
return self::$instance;
|
|
}
|
|
|
|
private function __construct() {
|
|
$this->init_hooks();
|
|
}
|
|
|
|
private function init_hooks() {
|
|
// Activation and deactivation hooks
|
|
register_activation_hook(__FILE__, array($this, 'activate'));
|
|
register_deactivation_hook(__FILE__, array($this, 'deactivate'));
|
|
|
|
// Initialize admin and public classes
|
|
add_action('plugins_loaded', array($this, 'load_classes'));
|
|
}
|
|
|
|
public function activate() {
|
|
require_once PC_HFAP_PLUGIN_DIR . 'includes/class-database.php';
|
|
PC_HFAP_Database::create_tables();
|
|
}
|
|
|
|
public function deactivate() {
|
|
// Cleanup on deactivation if needed
|
|
}
|
|
|
|
public function load_classes() {
|
|
if (is_admin()) {
|
|
new PC_HFAP_Admin();
|
|
}
|
|
new PC_HFAP_Public();
|
|
}
|
|
}
|
|
|
|
// Initialize the plugin
|
|
PC_Headers_Footers_Ad_Pixels::get_instance();
|