PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / vendor / wordpress / mcp-adapter / includes / Plugin.php

Plugin.php in Elementor Website Builder – more than just a page builder 4.3.0-beta3, at vendor/wordpress/mcp-adapter/includes/Plugin.php

124 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 // Exit if accessed directly.
17 defined( 'ABSPATH' ) || exit;
18
19 /**
20 * Class - Plugin
21 */
22 final class Plugin {
23 /**
24 * The one true plugin.
25 *
26 * @var static
27 */
28 private static self $instance;
29
30 /**
31 * Gets the singleton instance of the plugin.
32 *
33 * @return self The plugin instance.
34 */
35 public static function instance(): self {
36 if ( ! isset( self::$instance ) ) {
37 self::$instance = new self();
38 self::$instance->setup();
39
40 /**
41 * Fires after the main plugin class has been initialized.
42 *
43 * @since 0.1.0
44 *
45 * @param self $instance The main plugin class instance.
46 */
47 do_action( 'wp_mcp_init', self::$instance );
48 }
49
50 return self::$instance;
51 }
52
53 /**
54 * Sets up the plugin.
55 */
56 private function setup(): void {
57 // Bail if dependencies are not met.
58 if ( ! $this->has_dependencies() ) {
59 return;
60 }
61
62 McpAdapter::instance();
63 }
64
65 /**
66 * Checks if all required dependencies are available.
67 *
68 * Will log an admin notice if dependencies are missing.
69 *
70 * @return bool True if all dependencies are met, false otherwise.
71 */
72 private function has_dependencies(): bool {
73 // Check if Abilities API is available.
74 if ( ! function_exists( 'wp_register_ability' ) ) {
75 add_action(
76 'admin_notices',
77 static function () {
78 wp_admin_notice(
79 __( 'MCP Adapter requires WordPress 6.9 or newer. The Abilities API is included in WordPress core.', 'mcp-adapter' ),
80 array(
81 'type' => 'error',
82 'dismiss' => false,
83 ),
84 );
85 }
86 );
87
88 return false;
89 }
90
91 return true;
92 }
93
94 /**
95 * Prevents the class from being cloned.
96 */
97 public function __clone() {
98 _doing_it_wrong(
99 __FUNCTION__,
100 sprintf(
101 // translators: %s: Class name.
102 esc_html__( 'The %s class should not be cloned.', 'mcp-adapter' ),
103 esc_html( self::class ),
104 ),
105 '0.1.0'
106 );
107 }
108
109 /**
110 * Prevents the class from being deserialized.
111 */
112 public function __wakeup() {
113 _doing_it_wrong(
114 __FUNCTION__,
115 sprintf(
116 // translators: %s: Class name.
117 esc_html__( 'De-serializing instances of %s is not allowed.', 'mcp-adapter' ),
118 esc_html( self::class ),
119 ),
120 '0.1.0'
121 );
122 }
123 }
124