| @@ -63,8 +63,9 @@ | ||
| 63 | 63 | $this->initialize_admin_or_frontend_editor(); |
| 64 | 64 | $this->initialize_cli_cron(); |
| 65 | 65 | $this->initialize_frontend(); |
| 66 | 66 | $this->initialize_global(); |
| 67 | + $this->initialize_mcp(); | |
| 67 | 68 | |
| 68 | 69 | } |
| 69 | 70 | |
| 70 | 71 | /** |
| @@ -193,8 +194,9 @@ | ||
| 193 | 194 | $this->classes['blocks_convertkit_form_builder'] = new ConvertKit_Block_Form_Builder(); |
| 194 | 195 | $this->classes['blocks_convertkit_form_builder_field_email'] = new ConvertKit_Block_Form_Builder_Field_Email(); |
| 195 | 196 | $this->classes['blocks_convertkit_form_builder_field_name'] = new ConvertKit_Block_Form_Builder_Field_Name(); |
| 196 | 197 | $this->classes['blocks_convertkit_form_builder_field_custom'] = new ConvertKit_Block_Form_Builder_Field_Custom(); |
| 198 | + $this->classes['blocks_convertkit_member_content_login'] = new ConvertKit_Block_Member_Content_Login(); | |
| 197 | 199 | $this->classes['blocks_convertkit_product'] = new ConvertKit_Block_Product(); |
| 198 | 200 | $this->classes['block_formatter_form_link'] = new ConvertKit_Block_Formatter_Form_Link(); |
| 199 | 201 | $this->classes['block_formatter_product_link'] = new ConvertKit_Block_Formatter_Product_Link(); |
| 200 | 202 | $this->classes['pre_publish_action_broadcast_export'] = new ConvertKit_Pre_Publish_Action_Broadcast_Export(); |
| @@ -202,15 +204,16 @@ | ||
| 202 | 204 | $this->classes['broadcasts_exporter'] = new ConvertKit_Broadcasts_Exporter(); |
| 203 | 205 | $this->classes['broadcasts_importer'] = new ConvertKit_Broadcasts_Importer(); |
| 204 | 206 | $this->classes['elementor'] = new ConvertKit_Elementor(); |
| 205 | 207 | $this->classes['gutenberg'] = new ConvertKit_Gutenberg(); |
| 206 | - $this->classes['media_library'] = new ConvertKit_Media_Library(); | |
| 207 | - $this->classes['output_restrict_content'] = new ConvertKit_Output_Restrict_Content(); | |
| 208 | - $this->classes['restrict_content_cache'] = new ConvertKit_Restrict_Content_Cache(); | |
| 209 | - $this->classes['review_request'] = new ConvertKit_Review_Request( 'Kit', 'convertkit', CONVERTKIT_PLUGIN_PATH ); | |
| 210 | - $this->classes['preview_output'] = new ConvertKit_Preview_Output(); | |
| 211 | - $this->classes['setup'] = new ConvertKit_Setup(); | |
| 212 | - $this->classes['shortcodes'] = new ConvertKit_Shortcodes(); | |
| 208 | + $this->classes['mcp'] = new ConvertKit_MCP(); | |
| 209 | + $this->classes['media_library'] = new ConvertKit_Media_Library(); | |
| 210 | + $this->classes['output_restrict_content'] = new ConvertKit_Output_Restrict_Content(); | |
| 211 | + $this->classes['restrict_content_cache'] = new ConvertKit_Restrict_Content_Cache(); | |
| 212 | + $this->classes['review_request'] = new ConvertKit_Review_Request( 'Kit', 'convertkit', CONVERTKIT_PLUGIN_PATH ); | |
| 213 | + $this->classes['preview_output'] = new ConvertKit_Preview_Output(); | |
| 214 | + $this->classes['setup'] = new ConvertKit_Setup(); | |
| 215 | + $this->classes['shortcodes'] = new ConvertKit_Shortcodes(); | |
| 213 | 216 | |
| 214 | 217 | /** |
| 215 | 218 | * Initialize integration classes for the frontend web site. |
| 216 | 219 | * |
| @@ -216,8 +219,54 @@ | ||
| 216 | 219 | * |
| 217 | 220 | * @since 1.9.6 |
| 218 | 221 | */ |
| 219 | 222 | do_action( 'convertkit_initialize_global' ); |
| 223 | + | |
| 224 | + } | |
| 225 | + | |
| 226 | + /** | |
| 227 | + * Initializes the MCP server if enabled in the Plugin's settings. | |
| 228 | + * | |
| 229 | + * @since 3.4.0 | |
| 230 | + */ | |
| 231 | + public function initialize_mcp() { | |
| 232 | + | |
| 233 | + // Bail if the MCP server is not enabled. | |
| 234 | + $settings = new ConvertKit_Settings_MCP(); | |
| 235 | + if ( ! $settings->enabled() ) { | |
| 236 | + return; | |
| 237 | + } | |
| 238 | + | |
| 239 | + // Bail if the Abilities API is unavailable (WordPress < 6.9). | |
| 240 | + if ( ! function_exists( 'wp_register_ability' ) ) { | |
| 241 | + return; | |
| 242 | + } | |
| 243 | + | |
| 244 | + // Bail if PHP 7.4+ is not installed, as this is required for the MCP Adapter classes. | |
| 245 | + if ( version_compare( PHP_VERSION, '7.4', '<' ) ) { | |
| 246 | + return; | |
| 247 | + } | |
| 248 | + | |
| 249 | + // Load MCP Adapter if another Plugin hasn't already loaded it. | |
| 250 | + if ( ! class_exists( 'WP\\MCP\\Core\\McpAdapter' ) ) { | |
| 251 | + // Bail if the WordPress MCP Adapter autoloader is missing. | |
| 252 | + if ( ! file_exists( CONVERTKIT_PLUGIN_PATH . '/vendor/autoload.php' ) ) { | |
| 253 | + return; | |
| 254 | + } | |
| 255 | + | |
| 256 | + // Load MCP Adapter. | |
| 257 | + require_once CONVERTKIT_PLUGIN_PATH . '/vendor/autoload.php'; | |
| 258 | + | |
| 259 | + // Bail if the MCP Adapter class doesn't exist - something went wrong with the autoloader. | |
| 260 | + if ( ! class_exists( 'WP\\MCP\\Core\\McpAdapter' ) ) { // @phpstan-ignore-line | |
| 261 | + return; | |
| 262 | + } | |
| 263 | + } | |
| 264 | + | |
| 265 | + // Bootstrap the MCP Adapter, per WordPress/mcp-adapter's recommended | |
| 266 | + // integration pattern. | |
| 267 | + // @see https://github.com/WordPress/mcp-adapter#using-mcp-adapter-in-your-plugin. | |
| 268 | + \WP\MCP\Core\McpAdapter::instance(); | |
| 220 | 269 | |
| 221 | 270 | } |
| 222 | 271 | |
| 223 | 272 | /** |