fix(bricks): stop overriding bricks_template supports — only add custom-fields
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/<type>/<id> 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) <noreply@anthropic.com>
This commit is contained in:
@@ -29,10 +29,16 @@ add_filter('register_post_type_args', function ($args, $post_type) {
|
|||||||
$args['show_in_rest'] = true;
|
$args['show_in_rest'] = true;
|
||||||
$args['rest_base'] = $post_type === 'bricks_template' ? 'bricks_template' : ($post_type . 's');
|
$args['rest_base'] = $post_type === 'bricks_template' ? 'bricks_template' : ($post_type . 's');
|
||||||
$args['rest_controller_class'] = 'WP_REST_Posts_Controller';
|
$args['rest_controller_class'] = 'WP_REST_Posts_Controller';
|
||||||
$args['supports'] = array_unique(array_merge(
|
|
||||||
$args['supports'] ?? [],
|
// Only ADD 'custom-fields' (required so /wp/v2/<type> exposes the meta field).
|
||||||
['title', 'editor', 'author', 'custom-fields'] // custom-fields needed so /wp/v2/<type> 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;
|
return $args;
|
||||||
}, 10, 2);
|
}, 10, 2);
|
||||||
|
|||||||
Reference in New Issue
Block a user