ucwords(str_replace('_', ' ', $action)), 'description' => (string) ($a['description'] ?? ''), 'category' => in_array($action, $form_actions, true) ? 'content' : 'woocommerce', 'input_schema' => is_array($a['input_schema'] ?? null) ? $a['input_schema'] : ['type' => 'object'], 'output_schema' => ['type' => 'object', 'additionalProperties' => true], 'execute_callback' => static function ($input) use ($action) { $res = Ai2Web_Actions::run($action, is_array($input) ? $input : []); return is_array($res) ? ($res['body'] ?? null) : null; }, // Authenticated WP-native surface: WordPress gates who may run abilities. 'permission_callback' => static function () { return is_user_logged_in(); }, // show_in_rest lives under meta; annotations hint the AI about side effects. 'meta' => [ 'show_in_rest' => true, 'annotations' => [ 'readonly' => !$approval, 'idempotent' => !$approval, 'destructive' => $risk === 'high', ], ], ]); } } /** * Our read actions that WooCommerce 10.9+ exposes canonically, so we do not register a * near-duplicate on the WordPress-native Abilities surface (the WP MCP Adapter / AI Client). * Only reads are deferred: our request-only writes (returns, refunds, checkout, contact) and * our custom reads (return status) have no WooCommerce canonical equivalent and are kept. * Empty when WooCommerce's canonical abilities are absent, or when a site opts back in. * * @return array our action name => the WooCommerce ability it defers to */ private static function superseded_by_woocommerce(): array { $map = []; // WC 10.9 (June 2026) is the first release to ship the canonical product/order abilities. if (defined('WC_VERSION') && version_compare((string) WC_VERSION, '10.9', '>=')) { $map = [ 'search_products' => 'woocommerce/products-query', 'check_stock' => 'woocommerce/products-query', 'track_order' => 'woocommerce/orders-query', ]; } // Return [] to list every ai2web/* ability alongside WooCommerce's canonical ones. $out = apply_filters('ai2web_abilities_superseded_by_woocommerce', $map); return is_array($out) ? $out : []; } }