PluginProbe
Plugin Check (PCP) / 1.7.0
Plugin Check (PCP) v1.7.0
2.1.0 trunk 0.1 0.2.0 0.2.1 0.2.2 0.2.3 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.3.0 1.3.1 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 1.9.0 2.0.0 ci-artifacts
plugin-check / includes / Plugin_Main.php

Plugin_Main.php in Plugin Check (PCP) 1.7.0, at includes/Plugin_Main.php

72 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class WordPress\Plugin_Check\Plugin_Main
4 *
5 * @package plugin-check
6 */
7
8 namespace WordPress\Plugin_Check;
9
10 use WordPress\Plugin_Check\Admin\Admin_AJAX;
11 use WordPress\Plugin_Check\Admin\Admin_Page;
12
13 /**
14 * Main class for the plugin.
15 *
16 * @since 1.0.0
17 */
18 class Plugin_Main {
19
20 /**
21 * Context instance for the plugin.
22 *
23 * @since 1.0.0
24 * @var Plugin_Context
25 */
26 protected $context;
27
28 /**
29 * Constructor. Set the plugin main file.
30 *
31 * @since 1.0.0
32 *
33 * @param string $main_file Absolute path of the plugin main file.
34 */
35 public function __construct( $main_file ) {
36 $this->context = new Plugin_Context( $main_file );
37 }
38
39 /**
40 * Returns the Plugin Context.
41 *
42 * @since 1.0.0
43 *
44 * @return Plugin_Context
45 */
46 public function context() {
47 return $this->context;
48 }
49
50 /**
51 * Registers WordPress hooks for the plugin.
52 *
53 * @since 1.0.0
54 *
55 * @global Plugin_Context $context The plugin context instance.
56 */
57 public function add_hooks() {
58 if ( defined( 'WP_CLI' ) && WP_CLI ) {
59 global $context;
60
61 // Setup the CLI command.
62 $context = $this->context();
63 require_once WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . 'cli.php';
64 }
65
66 $admin_ajax = new Admin_AJAX();
67 // Create the Admin page.
68 $admin_page = new Admin_Page( $admin_ajax );
69 $admin_page->add_hooks();
70 }
71 }
72