Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
<?php
|
|
|
|
/**
|
2025-07-16 03:48:47 +08:00
|
|
|
* Plugin Name: WPTag
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
* Plugin URI: https://wptag.com
|
2025-07-16 03:48:47 +08:00
|
|
|
* Description: Professional tracking codes and analytics management plugin for WordPress
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
* Version: 1.1.0
|
2025-07-16 03:48:47 +08:00
|
|
|
* Author: WPTag.com
|
|
|
|
* Author URI: https://wptag.com
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
* Text Domain: wptag
|
2025-07-16 03:48:47 +08:00
|
|
|
* License: GPL v2 or later
|
|
|
|
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
* Requires at least: 5.0
|
|
|
|
* Tested up to: 6.4
|
|
|
|
* Requires PHP: 7.4
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
*/
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
namespace WPTag;
|
|
|
|
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
if (!defined('ABSPATH')) {
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2025-07-26 12:13:11 +08:00
|
|
|
define('WPTAG_VERSION', '1.1.0');
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
define('WPTAG_PLUGIN_FILE', __FILE__);
|
|
|
|
define('WPTAG_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
|
|
|
define('WPTAG_PLUGIN_URL', plugin_dir_url(__FILE__));
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
final class WPTag {
|
|
|
|
private static $instance = null;
|
|
|
|
private $config;
|
|
|
|
private $admin;
|
|
|
|
private $frontend;
|
|
|
|
|
|
|
|
public static function instance() {
|
|
|
|
if (null === self::$instance) {
|
|
|
|
self::$instance = new self();
|
|
|
|
}
|
|
|
|
return self::$instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function __construct() {
|
|
|
|
$this->define_constants();
|
|
|
|
$this->load_dependencies();
|
|
|
|
$this->init_hooks();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function define_constants() {
|
|
|
|
if (!defined('WPTAG_ABSPATH')) {
|
|
|
|
define('WPTAG_ABSPATH', dirname(WPTAG_PLUGIN_FILE) . '/');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function load_dependencies() {
|
|
|
|
require_once WPTAG_PLUGIN_DIR . 'includes/class-config.php';
|
|
|
|
require_once WPTAG_PLUGIN_DIR . 'includes/class-validator.php';
|
|
|
|
require_once WPTAG_PLUGIN_DIR . 'includes/class-output-manager.php';
|
|
|
|
|
|
|
|
$this->config = new Config();
|
|
|
|
|
|
|
|
if (is_admin()) {
|
|
|
|
require_once WPTAG_PLUGIN_DIR . 'includes/class-admin.php';
|
|
|
|
$this->admin = new Admin($this->config);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_admin() || wp_doing_ajax()) {
|
|
|
|
require_once WPTAG_PLUGIN_DIR . 'includes/class-frontend.php';
|
|
|
|
$this->frontend = new Frontend($this->config);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function init_hooks() {
|
|
|
|
register_activation_hook(WPTAG_PLUGIN_FILE, array($this, 'activate'));
|
|
|
|
register_deactivation_hook(WPTAG_PLUGIN_FILE, array($this, 'deactivate'));
|
|
|
|
|
|
|
|
add_action('init', array($this, 'init'), 0);
|
|
|
|
add_action('plugins_loaded', array($this, 'plugins_loaded'));
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
add_action('wptag_clear_cache', array($this, 'clear_all_cache'));
|
2025-07-16 03:48:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public function activate() {
|
|
|
|
if (!get_option('wptag_version')) {
|
|
|
|
$this->config->install_default_settings();
|
|
|
|
add_option('wptag_version', WPTAG_VERSION);
|
|
|
|
}
|
|
|
|
|
|
|
|
flush_rewrite_rules();
|
|
|
|
}
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
public function deactivate() {
|
|
|
|
flush_rewrite_rules();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function init() {
|
|
|
|
do_action('wptag_init');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function plugins_loaded() {
|
|
|
|
do_action('wptag_loaded');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function get_config() {
|
|
|
|
return $this->config;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function get_version() {
|
|
|
|
return WPTAG_VERSION;
|
|
|
|
}
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
|
|
|
|
public function clear_all_cache() {
|
|
|
|
if ($this->frontend) {
|
|
|
|
$this->frontend->clear_cache();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (function_exists('wp_cache_flush')) {
|
|
|
|
wp_cache_flush();
|
|
|
|
}
|
|
|
|
}
|
2025-07-16 03:48:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function wptag() {
|
|
|
|
return WPTag::instance();
|
|
|
|
}
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
wptag();
|