PluginProbe ʕ •ᴥ•ʔ
CommerceBird – AI Command Center, ERP Integrations & B2B for WooCommerce (Zoho, Exact Online). / trunk
CommerceBird – AI Command Center, ERP Integrations & B2B for WooCommerce (Zoho, Exact Online). vtrunk
3.0.3 3.0.2 3.0.1 trunk 2.2.14 2.2.15 2.2.16 2.2.17 2.2.18 2.2.19 2.3.0 2.3.1 2.3.10 2.3.11 2.3.12 2.3.13 2.3.14 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5.0 2.5.1 2.5.2 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.7.91 2.7.92 2.7.93 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.9.0 2.9.1 2.9.2 2.9.3 3.0.0
commercebird / vendor / wordpress / mcp-adapter / includes / Plugin.php
commercebird / vendor / wordpress / mcp-adapter / includes Last commit date
Abilities 2 months ago Cli 2 months ago Core 2 months ago Domain 2 months ago Handlers 2 months ago Infrastructure 2 months ago Servers 2 months ago Transport 2 months ago Autoloader.php 2 months ago Plugin.php 2 months ago
Plugin.php
121 lines
1 <?php
2 /**
3 * The main plugin file.
4 *
5 * If we evolve from a canonical plugin into WordPress core, this file would be left behind.
6 *
7 * @package WP\MCP
8 */
9
10 declare( strict_types=1 );
11
12 namespace WP\MCP;
13
14 use WP\MCP\Core\McpAdapter;
15
16 /**
17 * Class - Plugin
18 */
19 final class Plugin {
20 /**
21 * The one true plugin.
22 *
23 * @var static
24 */
25 private static self $instance;
26
27 /**
28 * Gets the singleton instance of the plugin.
29 *
30 * @return self The plugin instance.
31 */
32 public static function instance(): self {
33 if ( ! isset( self::$instance ) ) {
34 self::$instance = new self();
35 self::$instance->setup();
36
37 /**
38 * Fires after the main plugin class has been initialized.
39 *
40 * @since 0.1.0
41 *
42 * @param self $instance The main plugin class instance.
43 */
44 do_action( 'wp_mcp_init', self::$instance );
45 }
46
47 return self::$instance;
48 }
49
50 /**
51 * Sets up the plugin.
52 */
53 private function setup(): void {
54 // Bail if dependencies are not met.
55 if ( ! $this->has_dependencies() ) {
56 return;
57 }
58
59 McpAdapter::instance();
60 }
61
62 /**
63 * Checks if all required dependencies are available.
64 *
65 * Will log an admin notice if dependencies are missing.
66 *
67 * @return bool True if all dependencies are met, false otherwise.
68 */
69 private function has_dependencies(): bool {
70 // Check if Abilities API is available.
71 if ( ! function_exists( 'wp_register_ability' ) ) {
72 add_action(
73 'admin_notices',
74 static function () {
75 wp_admin_notice(
76 __( 'Abilities API not available (wp_register_ability function not found)', 'mcp-adapter' ),
77 array(
78 'type' => 'error',
79 'dismiss' => false,
80 ),
81 );
82 }
83 );
84
85 return false;
86 }
87
88 return true;
89 }
90
91 /**
92 * Prevents the class from being cloned.
93 */
94 public function __clone() {
95 _doing_it_wrong(
96 __FUNCTION__,
97 sprintf(
98 // translators: %s: Class name.
99 esc_html__( 'The %s class should not be cloned.', 'mcp-adapter' ),
100 esc_html( self::class ),
101 ),
102 '0.1.0'
103 );
104 }
105
106 /**
107 * Prevents the class from being deserialized.
108 */
109 public function __wakeup() {
110 _doing_it_wrong(
111 __FUNCTION__,
112 sprintf(
113 // translators: %s: Class name.
114 esc_html__( 'De-serializing instances of %s is not allowed.', 'mcp-adapter' ),
115 esc_html( self::class ),
116 ),
117 '0.1.0'
118 );
119 }
120 }
121