diff --git a/composer.json b/composer.json index 74c708b61..89559f71a 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "license": "GPLv3", "require": { "convertkit/convertkit-wordpress-libraries": "2.6.0", - "wordpress/mcp-adapter": "^0.5.0" + "wordpress/mcp-adapter": "^0.6.1" }, "require-dev": { "php-webdriver/webdriver": "^1.0", @@ -97,7 +97,8 @@ }, "config": { "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true + "dealerdirect/phpcodesniffer-composer-installer": true, + "automattic/jetpack-autoloader": true } }, "repositories": [ diff --git a/includes/class-wp-convertkit.php b/includes/class-wp-convertkit.php index 39f8338ab..e0898a941 100644 --- a/includes/class-wp-convertkit.php +++ b/includes/class-wp-convertkit.php @@ -245,15 +245,23 @@ public function initialize_mcp() { return; } - // Bail if the WordPress MCP Adapter autoloader is missing. - if ( ! file_exists( CONVERTKIT_PLUGIN_PATH . '/vendor/autoload.php' ) ) { - return; - } + // Load MCP Adapter if another Plugin hasn't already loaded it. + if ( ! class_exists( 'WP\\MCP\\Core\\McpAdapter' ) ) { + // Bail if the WordPress MCP Adapter autoloader is missing. + if ( ! file_exists( CONVERTKIT_PLUGIN_PATH . '/vendor/autoload.php' ) ) { + return; + } - // Load MCP Adapter. - require_once CONVERTKIT_PLUGIN_PATH . '/vendor/autoload.php'; + // Load MCP Adapter. + require_once CONVERTKIT_PLUGIN_PATH . '/vendor/autoload.php'; + + // Bail if the MCP Adapter class doesn't exist - something went wrong with the autoloader. + if ( ! class_exists( 'WP\\MCP\\Core\\McpAdapter' ) ) { + return; + } + } - // Bail if the MCP Adapter class doesn't exist - something went wrong with the autoloader. + // Sanity check MCP Adapter is loaded. if ( ! class_exists( 'WP\\MCP\\Core\\McpAdapter' ) ) { return; }