|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* The core plugin class. |
|
4
|
|
|
* |
|
5
|
|
|
* This is used to define internationalization, admin-specific hooks, and |
|
6
|
|
|
* public-facing site hooks. |
|
7
|
|
|
* |
|
8
|
|
|
* Also maintains the unique identifier of this plugin as well as the current |
|
9
|
|
|
* version of the plugin. |
|
10
|
|
|
* |
|
11
|
|
|
* @package WPSiteMonitor |
|
12
|
|
|
* @link https://github.com/BWibrew/WP-Site-Monitor/ |
|
13
|
|
|
* @author Benjamin Wibrew <[email protected]> |
|
14
|
|
|
* @since 1.0.0 |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
namespace WPSiteMonitor; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Class WP_Site_Monitor |
|
21
|
|
|
* |
|
22
|
|
|
* @package WPSiteMonitor |
|
23
|
|
|
*/ |
|
24
|
|
|
class WP_Site_Monitor { |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Setting options group name. |
|
28
|
|
|
* |
|
29
|
|
|
* @var string |
|
30
|
|
|
* @since 1.0.0 |
|
31
|
|
|
*/ |
|
32
|
|
|
const OPTION_GROUP = 'wp_site_monitor'; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* The setting option name. |
|
36
|
|
|
* |
|
37
|
|
|
* @var string |
|
38
|
|
|
* @since 1.0.0 |
|
39
|
|
|
*/ |
|
40
|
|
|
const OPTION_NAME = self::OPTION_GROUP . '_enable'; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* The loader that's responsible for registering all hooks and filters. |
|
44
|
|
|
* |
|
45
|
|
|
* @var Hook_Loader $loader Maintains and registers all hooks for the plugin. |
|
46
|
|
|
* @since 1.0.0 |
|
47
|
|
|
*/ |
|
48
|
|
|
protected $loader; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Define the core functionality of the plugin. |
|
52
|
|
|
* |
|
53
|
|
|
* @since 1.0.0 |
|
54
|
|
|
*/ |
|
55
|
6 |
|
public function __construct() { |
|
56
|
6 |
|
$this->loader = new Hook_Loader(); |
|
57
|
|
|
|
|
58
|
6 |
|
$this->init(); |
|
59
|
6 |
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Initialise plugin files. |
|
63
|
|
|
* |
|
64
|
|
|
* @since 1.0.0 |
|
65
|
|
|
*/ |
|
66
|
6 |
|
public function init() { |
|
67
|
6 |
|
if ( is_admin() ) { |
|
68
|
|
|
$menu = new Settings_Menu(); |
|
69
|
|
|
|
|
70
|
|
|
$this->loader->add_action( 'admin_init', $menu, 'init_settings' ); |
|
71
|
|
|
$this->loader->add_action( 'admin_menu', $menu, 'display_settings_page' ); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
6 |
|
if ( get_option( self::OPTION_NAME ) ) { |
|
75
|
2 |
|
$api = new API(); |
|
76
|
|
|
|
|
77
|
2 |
|
$this->loader->add_action( 'rest_api_init', $api, 'register_routes' ); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
6 |
|
$this->loader->run(); |
|
81
|
6 |
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Fired during plugin deactivation, |
|
85
|
|
|
* |
|
86
|
|
|
* @since 1.0.0 |
|
87
|
|
|
*/ |
|
88
|
1 |
|
public static function deactivate() { |
|
89
|
1 |
|
unregister_setting( 'wp_site_monitor', 'wp_site_monitor_enable' ); |
|
90
|
1 |
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Fired during plugin deletion. |
|
94
|
|
|
* |
|
95
|
|
|
* @since 1.0.0 |
|
96
|
|
|
*/ |
|
97
|
1 |
|
public static function uninstall() { |
|
98
|
1 |
|
delete_option( 'wp_site_monitor_enable' ); |
|
99
|
1 |
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|