Skip to content

Registered block attributes are ignored at render unless nested under blockstudio.attributes (v7.6.9) #90

Closed

Description

@elliottmangham

Blockstudio registers each of a block's attributes individually on the WP_Block_Type — they appear in WP_Block_Type_Registry with a type and a default — but render() reads none of them. Only values nested under the blockstudio attribute are used.

For a human in the editor this never surfaces, because the editor always writes the nested shape. It surfaces the moment anything writes a block programmatically: the REST API, WP-CLI, a content migration, or an MCP server. The registry is exactly where such a writer looks to discover what a block accepts, so it reads a public schema that turns out to be inert.

Where

includes/classes/block.php, ~line 1824 (v7.6.9):

$attributes = array_merge(
    $attr,                                        // defaults
    $attributes['blockstudio']['attributes'] ?? array()
);

Defaults, then only the nested payload. Anything at the top level is dropped before transform_attributes() ever sees it.

Repro

With any Blockstudio block that has a select — here one with visual_type offering webgl (default) and media:

// Ignored — renders the `webgl` default.
$flat = '<!-- wp:acme/hero {"visual_type":"media"} /-->';

// Honoured — renders `media`.
$nested = '<!-- wp:acme/hero {"blockstudio":{"attributes":{"visual_type":"media"}}} /-->';

echo do_blocks( $flat );
echo do_blocks( $nested );

visual_type is present in WP_Block_Type_Registry::get_instance()->get_registered( 'acme/hero' )->attributes in both cases.

Why it's worth a look

The failure is completely silent. The post saves, parse_blocks() round-trips the attribute byte-identically, the editor opens the block without a validation notice, and the block renders its default. There is no error, no warning, and no way to notice except rendering the block and comparing the output against what you sent — which is how we found it, after confirming against block.json that the value we'd sent was a valid option.

Possible resolutions

  1. Merge top-level attributes as a lower-priority source, so an explicitly nested value still wins:

    $attributes = array_merge(
        $attr,
        array_intersect_key( $attributes, $attr ),
        $attributes['blockstudio']['attributes'] ?? array()
    );

    array_intersect_key against the defaults keeps this scoped to ids the block actually declares, so it cannot pick up anchor, className or anything else WordPress owns.

  2. Or stop registering the individual attributes on the WP_Block_Type, so the registry stops advertising a schema that isn't read.

Either makes the behaviour discoverable. (1) is backward compatible as far as I can tell — every block the editor has ever saved carries the nested shape, so the new branch only fires for attributes that are currently being discarded.

Happy to open a PR for (1) if that's the direction you'd prefer — just say which.

Workaround, for anyone who lands here

Nest on write. We normalise in our MCP layer: move every id the block declares under blockstudio.attributes, leave WordPress's own attributes (anchor, className, lock, metadata, style, align) at the top level, and let an explicitly nested value win over a flat one of the same name.

Version: blockstudio/blockstudio v7.6.9, WordPress 7.x, PHP 8.3.

Activity

  1. dnnsjsk commented on Sep 9, 2026

    @dnnsjsk
    Contributor

    hmm, i think 1 makes more sense. 2 is a breaking change.

    PR welcome @elliottmangham

  2. elliottmangham commented on Sep 9, 2026

    @elliottmangham
    ContributorAuthor

    hmm, i think 1 makes more sense. 2 is a breaking change.

    PR welcome @elliottmangham

    PR #91 opened 👍

  3. added 3 commits that reference this issue on Sep 11, 2026
    9de4112
    372004b
    8ea3081
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions