| 1 |
<?php |
| 2 |
/** |
| 3 |
* Ability: wpdatatables/get-mcp-license-matrix |
| 4 |
* |
| 5 |
* Read-only matrix of MCP abilities vs integration files / tier hints for this site. |
| 6 |
* |
| 7 |
* @package wpDataTables_MCP_Server |
| 8 |
*/ |
| 9 |
|
| 10 |
defined('ABSPATH') || exit; |
| 11 |
|
| 12 |
add_action('wp_abilities_api_init', 'wdtmcp_register_get_mcp_license_matrix_ability'); |
| 13 |
|
| 14 |
function wdtmcp_register_get_mcp_license_matrix_ability() |
| 15 |
{ |
| 16 |
wp_register_ability( |
| 17 |
'wpdatatables/get-mcp-license-matrix', |
| 18 |
array( |
| 19 |
'label' => __('Get MCP Licence Matrix', 'wpdatatables'), |
| 20 |
'description' => __( |
| 21 |
'Read-only map of wpDataTables MCP abilities vs this installation: which integration files are missing, tier hints, pricing URL, and whether each ability is fully supported here. WHEN TO CALL: after a wdtmcp_tier_required / integration_missing error, or before planning upgrades. WORKFLOW: get-system-info → get-mcp-license-matrix. PARAMETERS: none (pass {}). RETURNS: pricing_url, detected_tier, integrations map, supports_non_wp_db_connections, abilities[].', |
| 22 |
'wpdatatables' |
| 23 |
), |
| 24 |
'category' => 'wpdatatables-data', |
| 25 |
|
| 26 |
'input_schema' => array( |
| 27 |
'type' => 'object', |
| 28 |
'properties' => array(), |
| 29 |
), |
| 30 |
|
| 31 |
'output_schema' => array( |
| 32 |
'type' => 'object', |
| 33 |
'properties' => array( |
| 34 |
'pricing_url' => array('type' => 'string'), |
| 35 |
'detected_tier' => array('type' => 'string'), |
| 36 |
'tier_order' => array( |
| 37 |
'type' => 'array', |
| 38 |
'items' => array('type' => 'string'), |
| 39 |
), |
| 40 |
'upgrade_hint' => array('type' => 'string'), |
| 41 |
'integrations' => array('type' => 'object'), |
| 42 |
'supports_non_wp_db_connections' => array('type' => 'boolean'), |
| 43 |
'abilities' => array('type' => 'array'), |
| 44 |
), |
| 45 |
), |
| 46 |
|
| 47 |
'execute_callback' => 'wdtmcp_execute_get_mcp_license_matrix', |
| 48 |
|
| 49 |
'permission_callback' => function () { |
| 50 |
return current_user_can('manage_options'); |
| 51 |
}, |
| 52 |
|
| 53 |
'meta' => array( |
| 54 |
'annotations' => array( |
| 55 |
'instructions' => __('Pass {}. Use when diagnosing licence/integration limits on MCP abilities.', 'wpdatatables'), |
| 56 |
'readonly' => true, |
| 57 |
'destructive' => false, |
| 58 |
'idempotent' => true, |
| 59 |
), |
| 60 |
), |
| 61 |
) |
| 62 |
); |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* Execute wpdatatables/get-mcp-license-matrix. |
| 67 |
* |
| 68 |
* @param array $input |
| 69 |
* @return array|\WP_Error |
| 70 |
*/ |
| 71 |
function wdtmcp_execute_get_mcp_license_matrix($input) |
| 72 |
{ |
| 73 |
if (! function_exists('wdtmcp_detect_integrations') || ! function_exists('wdtmcp_detect_tier')) { |
| 74 |
return new \WP_Error( |
| 75 |
'wdtmcp_missing_helper', |
| 76 |
__('System integration detector is not loaded; ensure get-system-info ability is registered.', 'wpdatatables') |
| 77 |
); |
| 78 |
} |
| 79 |
|
| 80 |
if (! class_exists('\WDTMCP\Helpers\McpHelpers\WdtmcpLicenseGuideHelper')) { |
| 81 |
return new \WP_Error( |
| 82 |
'wdtmcp_missing_helper', |
| 83 |
__('Licence guide helper is not loaded.', 'wpdatatables') |
| 84 |
); |
| 85 |
} |
| 86 |
|
| 87 |
$integrations = wdtmcp_detect_integrations(); |
| 88 |
$tier = wdtmcp_detect_tier($integrations); |
| 89 |
|
| 90 |
return \WDTMCP\Helpers\McpHelpers\WdtmcpLicenseGuideHelper::buildLicenseMatrixPayload( |
| 91 |
$integrations, |
| 92 |
$tier |
| 93 |
); |
| 94 |
} |
| 95 |
|