Repository navigation
Expand file tree
/
Copy pathmcp-adapters.php
More file actions
82 lines (75 loc) · 2.41 KB
/
Copy pathmcp-adapters.php
File metadata and controls
82 lines (75 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* Plugin Name: MCP Adapters
* Plugin URI: https://github.com/code-atlantic/mcp-adapters
* Description: MCP adapters for WordPress plugins using the new WordPress Abilities API and MCP Adapter system.
* Version: 0.1.0
* Requires at least: 6.4
* Requires PHP: 8.0
* Author: Code Atlantic LLC
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: mcp-adapters
* Domain Path: /languages
* Requires Plugins: wordpress/abilities-api, wordpress/mcp-adapter
* GitHub Plugin URI: code-atlantic/mcp-adapters
* Primary Branch: main
*
* @package MCP\Adapters
*/
declare(strict_types=1);
// Prevent direct access
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Define plugin constants
define( 'MCP_ADAPTERS_VERSION', '0.1.0' );
define( 'MCP_ADAPTERS_PLUGIN_FILE', __FILE__ );
define( 'MCP_ADAPTERS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'MCP_ADAPTERS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
// Load Composer autoloader
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
include_once __DIR__ . '/vendor/autoload.php';
} else {
// Show admin notice if autoloader is missing
add_action(
'admin_notices', function () {
echo '<div class="notice notice-error"><p>';
echo '<strong>MCP Adapters:</strong> Composer dependencies not installed. ';
echo 'Please run <code>composer install</code> in the plugin directory.';
echo '</p></div>';
}
);
return;
}
// Check for required dependencies
add_action(
'plugins_loaded', function () {
// Check if WordPress Abilities API is available
if ( ! function_exists( 'wp_register_ability' ) ) {
add_action(
'admin_notices', function () {
echo '<div class="notice notice-error"><p>';
echo '<strong>MCP Adapters:</strong> WordPress Abilities API is required but not available. ';
echo 'Please ensure the wordpress/abilities-api package is properly installed.';
echo '</p></div>';
}
);
return;
}
// Check if MCP Adapter is available
if ( ! class_exists( 'WP\\MCP\\Plugin' ) ) {
add_action(
'admin_notices', function () {
echo '<div class="notice notice-error"><p>';
echo '<strong>MCP Adapters:</strong> MCP Adapter plugin is required but not available. ';
echo 'Please install and activate the mcp-adapter plugin.';
echo '</p></div>';
}
);
return;
}
// Initialize the plugin
new MCP\Adapters\Plugin();
}, 20
); // Load after other plugins