'object', 'properties' => $props ?: new \stdClass()]; if ($required) $schema['required'] = $required; return ['name' => $name, 'description' => $desc, 'scope' => $scope, 'handler' => 'AskTamMCP\\Extensions\\Batch38::' . $method, 'inputSchema' => $schema]; }; $registry->register($def('funnelkit_detect', 'Report whether FunnelKit (Funnel Builder) is active and its version.', [], [], 'read', 'detect')); $registry->register($def('funnelkit_list_funnels', 'List FunnelKit funnels (id, title). Reads the funnels table or CPT, whichever this install uses.', ['per_page' => ['type' => 'integer', 'default' => 50]], [], 'read', 'listFunnels')); } public static function detect(array $args): array { return ['active' => defined('WFFN_VERSION'), 'version' => defined('WFFN_VERSION') ? WFFN_VERSION : null]; } public static function listFunnels(array $args): array { global $wpdb; $per = max(1, (int) ($args['per_page'] ?? 50)); $t = $wpdb->prefix . 'wffn_funnels'; if ($wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s', $t)) === $t) { $rows = $wpdb->get_results($wpdb->prepare("SELECT id, title FROM {$t} ORDER BY id DESC LIMIT %d", $per), ARRAY_A); $out = []; foreach ((array) $rows as $r) $out[] = ['id' => (int) $r['id'], 'title' => $r['title']]; return ['supported' => true, 'source' => 'table', 'count' => count($out), 'funnels' => $out]; } if (post_type_exists('wffn_funnel')) { $posts = get_posts(['post_type' => 'wffn_funnel', 'post_status' => 'any', 'numberposts' => $per, 'orderby' => 'date', 'order' => 'DESC']); $out = []; foreach ($posts as $p) $out[] = ['id' => $p->ID, 'title' => $p->post_title]; return ['supported' => true, 'source' => 'cpt', 'count' => count($out), 'funnels' => $out]; } return ['supported' => false, 'note' => 'FunnelKit funnels storage not found on this install.', 'funnels' => []]; } }