fix(bricks): remove bricks_template from REST bridge entirely
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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/<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).
|
||||
// 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';
|
||||
|
||||
Reference in New Issue
Block a user