From 86cd37ed8060edcfd957d257ddd1364f88efea91 Mon Sep 17 00:00:00 2001 From: "j.foucher" Date: Fri, 15 May 2026 07:39:44 +0200 Subject: [PATCH] =?UTF-8?q?fix(bricks):=20stop=20overriding=20bricks=5Ftem?= =?UTF-8?q?plate=20supports=20=E2=80=94=20only=20add=20custom-fields?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The REST bridge was rewriting the `supports` array on bricks_template (and case_study, scenario) by force-adding ['title','editor','author','custom-fields']. For bricks_template specifically, Bricks's own registration sets supports = ['author','revisions','thumbnail','title'] — deliberately WITHOUT 'editor', because the post type is meant to be edited only via the Bricks builder, not the WP block editor. Adding 'editor' confused Bricks's builder : it would refuse to open the template with "Invalid post type" because the post type now claimed to support two incompatible editors. Fix : keep the original supports list untouched, only append 'custom-fields' (which IS required for /wp/v2// to expose the `meta` field). All templates (Header #25, Footer #46, Single Post #154) should now open in the Bricks builder again. Co-Authored-By: Claude Opus 4.7 (1M context) --- tools/av-bricks-rest-bridge.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/av-bricks-rest-bridge.php b/tools/av-bricks-rest-bridge.php index e581ea6..8987e79 100644 --- a/tools/av-bricks-rest-bridge.php +++ b/tools/av-bricks-rest-bridge.php @@ -29,10 +29,16 @@ add_filter('register_post_type_args', function ($args, $post_type) { $args['show_in_rest'] = true; $args['rest_base'] = $post_type === 'bricks_template' ? 'bricks_template' : ($post_type . 's'); $args['rest_controller_class'] = 'WP_REST_Posts_Controller'; - $args['supports'] = array_unique(array_merge( - $args['supports'] ?? [], - ['title', 'editor', 'author', 'custom-fields'] // custom-fields needed so /wp/v2/ exposes the `meta` field - )); + + // 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). + $existing_supports = $args['supports'] ?? []; + if (! in_array('custom-fields', $existing_supports, true)) { + $existing_supports[] = 'custom-fields'; + } + $args['supports'] = $existing_supports; return $args; }, 10, 2);