Repository navigation
Expand file tree
/
Copy pathapi-watchdog.php
More file actions
86 lines (75 loc) · 2.41 KB
/
Copy pathapi-watchdog.php
File metadata and controls
86 lines (75 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* Plugin Name: API Watchdog
* Plugin URI: https://apiwatchdog.dev
* Description: Scans your WordPress installation for API usage, checks for deprecations, and provides prioritized recommendations for updates.
* Version: 1.0.0
* Author: API Watchdog
* Author URI: https://apiwatchdog.dev
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: api-watchdog
* Domain Path: /languages
*
* @package API_Watchdog
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
/**
* Currently plugin version.
*/
define( 'API_WATCHDOG_VERSION', '1.0.0' );
define( 'API_WATCHDOG_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'API_WATCHDOG_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
/**
* Premium feature flags.
* TODO: Add premium license check when monetization enabled
*/
define( 'APIWATCHDOG_PREMIUM_ENABLED', false );
/**
* The code that runs during plugin activation.
*/
function activate_api_watchdog() {
require_once API_WATCHDOG_PLUGIN_DIR . 'includes/class-database.php';
API_Watchdog_Database::create_tables();
}
/**
* The code that runs during plugin deactivation.
*/
function deactivate_api_watchdog() {
// Clean up scheduled events if any
wp_clear_scheduled_hook( 'api_watchdog_scheduled_scan' );
}
register_activation_hook( __FILE__, 'activate_api_watchdog' );
register_deactivation_hook( __FILE__, 'deactivate_api_watchdog' );
/**
* Load plugin classes
*/
require_once API_WATCHDOG_PLUGIN_DIR . 'includes/class-database.php';
require_once API_WATCHDOG_PLUGIN_DIR . 'includes/class-scanner.php';
require_once API_WATCHDOG_PLUGIN_DIR . 'includes/class-ai-checker.php';
require_once API_WATCHDOG_PLUGIN_DIR . 'includes/class-prioritizer.php';
require_once API_WATCHDOG_PLUGIN_DIR . 'includes/class-settings.php';
require_once API_WATCHDOG_PLUGIN_DIR . 'includes/class-scheduler.php';
/**
* Load admin classes if in admin area
*/
if ( is_admin() ) {
require_once API_WATCHDOG_PLUGIN_DIR . 'admin/class-admin.php';
$api_watchdog_admin = new API_Watchdog_Admin();
}
/**
* Initialize the plugin
*/
function run_api_watchdog() {
// Ensure database migrations run on load for existing installs.
if ( class_exists( 'API_Watchdog_Database' ) ) {
API_Watchdog_Database::run_migrations();
}
if ( class_exists( 'API_Watchdog_Scheduler' ) ) {
API_Watchdog_Scheduler::register_hooks();
}
}
add_action( 'plugins_loaded', 'run_api_watchdog' );