From aad32fd0f1b117fe75fb9ed74827ec5f107bf17d Mon Sep 17 00:00:00 2001 From: "j.foucher" Date: Fri, 15 May 2026 07:48:50 +0200 Subject: [PATCH] fix(bricks): remove bricks_template from REST bridge entirely MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Even adding only 'custom-fields' to bricks_template's supports turned out to break the Bricks builder ("Invalid post type" on Edit with Bricks for all templates including pre-existing Header / Footer). bricks_template is now left exactly as Bricks registers it natively : supports : author, revisions, thumbnail, title show_in_rest : false The MCP server route to bricks_template was experimental and we don't use it actively — direct PHP scripts (av-fix-template-meta, av-generate-*, av-add-submenus) handle template management. Templates are exposed only to the Bricks builder, not external REST clients. case_study + scenario CPTs keep REST exposure (used for content type generators later). Co-Authored-By: Claude Opus 4.7 (1M context) --- tools/av-bricks-rest-bridge.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/av-bricks-rest-bridge.php b/tools/av-bricks-rest-bridge.php index 8987e79..cc9ba63 100644 --- a/tools/av-bricks-rest-bridge.php +++ b/tools/av-bricks-rest-bridge.php @@ -20,20 +20,21 @@ defined('ABSPATH') || exit; ---------------------------------------------------------------- */ add_filter('register_post_type_args', function ($args, $post_type) { - $needs_rest = ['bricks_template', 'case_study', 'scenario']; + // bricks_template intentionally excluded : touching its supports/show_in_rest + // breaks Bricks's own builder (it expects the original registration verbatim). + // The MCP server doesn't need REST access to templates anyway — we use direct + // PHP scripts to manage them. Only case_study + scenario stay REST-exposed. + $needs_rest = ['case_study', 'scenario']; if (! in_array($post_type, $needs_rest, true)) { return $args; } $args['show_in_rest'] = true; - $args['rest_base'] = $post_type === 'bricks_template' ? 'bricks_template' : ($post_type . 's'); + $args['rest_base'] = $post_type . 's'; $args['rest_controller_class'] = 'WP_REST_Posts_Controller'; - // Only ADD 'custom-fields' (required so /wp/v2/ exposes the meta field). - // Do NOT add 'editor' or override the whole supports array — that breaks the - // Bricks builder for bricks_template (Bricks's CPT supports = author/revisions/ - // thumbnail/title — no 'editor', deliberately). + // Only add 'custom-fields' so the meta field is exposed via REST. $existing_supports = $args['supports'] ?? []; if (! in_array('custom-fields', $existing_supports, true)) { $existing_supports[] = 'custom-fields';