From 9d19a9cb9c1916e3af6f55e213b99c11da390cf0 Mon Sep 17 00:00:00 2001 From: colorlink Date: Fri, 16 Oct 2026 04:50:54 +0000 Subject: [PATCH] Batch50: Beaver Builder tools (guarded, net-new) Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Q8t9GEyyLZbUQu26na1JQg --- includes/Extensions/Batch50.php | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 includes/Extensions/Batch50.php diff --git a/includes/Extensions/Batch50.php b/includes/Extensions/Batch50.php new file mode 100644 index 0000000..a17ab1c --- /dev/null +++ b/includes/Extensions/Batch50.php @@ -0,0 +1,47 @@ + 'object', 'properties' => $props ?: new \stdClass()]; + if ($required) $schema['required'] = $required; + return ['name' => $name, 'description' => $desc, 'scope' => $scope, + 'handler' => 'AskTamMCP\\Extensions\\Batch50::' . $method, 'inputSchema' => $schema]; + }; + + $registry->register($def('bb_detect', 'Report whether Beaver Builder is active and its version.', [], [], 'read', 'detect')); + $registry->register($def('bb_list_templates', 'List Beaver Builder saved templates (id, title).', + ['per_page' => ['type' => 'integer', 'default' => 100]], [], 'read', 'listTemplates')); + $registry->register($def('bb_is_built', 'Report whether Beaver Builder is enabled on a post.', + ['post_id' => ['type' => 'integer']], ['post_id'], 'read', 'isBuilt')); + } + + public static function detect(array $args): array { + return ['active' => defined('FL_BUILDER_VERSION'), 'version' => defined('FL_BUILDER_VERSION') ? FL_BUILDER_VERSION : null]; + } + + public static function listTemplates(array $args): array { + $posts = get_posts(['post_type' => 'fl-builder-template', 'post_status' => ['publish', 'draft'], + 'numberposts' => (int) ($args['per_page'] ?? 100), 'orderby' => 'title', 'order' => 'ASC']); + $out = []; + foreach ($posts as $p) $out[] = ['id' => $p->ID, 'title' => $p->post_title]; + return ['count' => count($out), 'templates' => $out]; + } + + public static function isBuilt(array $args): array { + $id = (int) ($args['post_id'] ?? 0); + if (!get_post($id)) throw new \RuntimeException("Post not found: {$id}"); + return ['post_id' => $id, 'beaver_built' => (bool) get_post_meta($id, '_fl_builder_enabled', true)]; + } +}