From cb0d284747c9c1e9e8d6cd396beae6d3fa19b77e Mon Sep 17 00:00:00 2001 From: colorlink Date: Fri, 16 Oct 2026 04:44:59 +0000 Subject: [PATCH] Batch39: Mailchimp for WordPress tools (guarded, net-new) Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Q8t9GEyyLZbUQu26na1JQg --- includes/Extensions/Batch39.php | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 includes/Extensions/Batch39.php diff --git a/includes/Extensions/Batch39.php b/includes/Extensions/Batch39.php new file mode 100644 index 0000000..3409b03 --- /dev/null +++ b/includes/Extensions/Batch39.php @@ -0,0 +1,48 @@ + 'object', 'properties' => $props ?: new \stdClass()]; + if ($required) $schema['required'] = $required; + return ['name' => $name, 'description' => $desc, 'scope' => $scope, + 'handler' => 'AskTamMCP\\Extensions\\Batch39::' . $method, 'inputSchema' => $schema]; + }; + + $registry->register($def('mc4wp_detect', 'Report whether Mailchimp for WordPress is active and its version.', [], [], 'read', 'detect')); + $registry->register($def('mc4wp_list_forms', 'List Mailchimp for WP forms (id, title).', + ['per_page' => ['type' => 'integer', 'default' => 50]], [], 'read', 'listForms')); + $registry->register($def('mc4wp_get_form', 'Get one mc4wp form: title plus its raw form markup.', + ['form_id' => ['type' => 'integer']], ['form_id'], 'read', 'getForm')); + } + + public static function detect(array $args): array { + return ['active' => defined('MC4WP_VERSION'), 'version' => defined('MC4WP_VERSION') ? MC4WP_VERSION : null]; + } + + public static function listForms(array $args): array { + $posts = get_posts(['post_type' => 'mc4wp-form', 'post_status' => ['publish', 'draft'], + 'numberposts' => (int) ($args['per_page'] ?? 50), 'orderby' => 'title', 'order' => 'ASC']); + $out = []; + foreach ($posts as $p) $out[] = ['id' => $p->ID, 'title' => $p->post_title]; + return ['count' => count($out), 'forms' => $out]; + } + + public static function getForm(array $args): array { + $id = (int) ($args['form_id'] ?? 0); + $p = get_post($id); + if (!$p || $p->post_type !== 'mc4wp-form') throw new \RuntimeException("mc4wp form not found: {$id}"); + return ['id' => $id, 'title' => $p->post_title, 'markup' => (string) $p->post_content]; + } +}