-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathPlugin_Main.php
71 lines (62 loc) · 1.28 KB
/
Plugin_Main.php
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
<?php
/**
* Class WordPress\Plugin_Check\Plugin_Main
*
* @package plugin-check
*/
namespace WordPress\Plugin_Check;
use WordPress\Plugin_Check\Admin\Admin_AJAX;
use WordPress\Plugin_Check\Admin\Admin_Page;
/**
* Main class for the plugin.
*
* @since 1.0.0
*/
class Plugin_Main {
/**
* Context instance for the plugin.
*
* @since 1.0.0
* @var Plugin_Context
*/
protected $context;
/**
* Constructor. Set the plugin main file.
*
* @since 1.0.0
*
* @param string $main_file Absolute path of the plugin main file.
*/
public function __construct( $main_file ) {
$this->context = new Plugin_Context( $main_file );
}
/**
* Returns the Plugin Context.
*
* @since 1.0.0
*
* @return Plugin_Context
*/
public function context() {
return $this->context;
}
/**
* Registers WordPress hooks for the plugin.
*
* @since 1.0.0
*
* @global Plugin_Context $context The plugin context instance.
*/
public function add_hooks() {
if ( defined( 'WP_CLI' ) && WP_CLI ) {
global $context;
// Setup the CLI command.
$context = $this->context();
require_once WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . 'cli.php';
}
$admin_ajax = new Admin_AJAX();
// Create the Admin page.
$admin_page = new Admin_Page( $admin_ajax );
$admin_page->add_hooks();
}
}