From 37ce29d66798420aec5499b5f78baf6431cb852a Mon Sep 17 00:00:00 2001 From: colorlink Date: Fri, 16 Oct 2026 04:44:49 +0000 Subject: [PATCH] Batch38: FunnelKit tools (guarded, net-new) Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Q8t9GEyyLZbUQu26na1JQg --- includes/Extensions/Batch38.php | 50 +++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 includes/Extensions/Batch38.php diff --git a/includes/Extensions/Batch38.php b/includes/Extensions/Batch38.php new file mode 100644 index 0000000..0895224 --- /dev/null +++ b/includes/Extensions/Batch38.php @@ -0,0 +1,50 @@ + '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' => []]; + } +}