Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/wp-includes/block-bindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ function get_block_bindings_supported_attributes( $block_type ) {
'core/post-date' => array( 'datetime' ),
'core/navigation-link' => array( 'url' ),
'core/navigation-submenu' => array( 'url' ),
'core/verse' => array( 'content' ),
);

$supported_block_attributes =
Expand Down
54 changes: 54 additions & 0 deletions tests/phpunit/tests/block-bindings/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ public function data_update_block_with_value_from_source() {
,
'<p class="wp-block-paragraph">test source value</p>',
),
'verse block' => array(
'content',
<<<HTML
<!-- wp:verse -->
<pre class="wp-block-verse">This should not appear</pre>
<!-- /wp:verse -->
HTML
,
'<pre class="wp-block-verse">test source value</pre>',
),
'button block' => array(
'text',
<<<HTML
Expand Down Expand Up @@ -381,6 +391,50 @@ public function test_default_binding_for_pattern_overrides() {
);
}

/**
* Tests that the Verse block supports the default binding for pattern
* overrides.
*
* @covers WP_Block::process_block_bindings
*/
public function test_default_binding_for_pattern_overrides_verse() {
$block_content = <<<HTML
<!-- wp:verse {"metadata":{"bindings":{"__default":{"source":"core/pattern-overrides"}},"name":"Test verse"}} -->
<pre class="wp-block-verse">This should not appear</pre>
<!-- /wp:verse -->
HTML;

$expected_content = 'This is the verse content value';
$parsed_blocks = parse_blocks( $block_content );
$block = new WP_Block(
$parsed_blocks[0],
array(
'pattern/overrides' => array(
'Test verse' => array(
'content' => $expected_content,
),
),
)
);

$result = $block->render();

$this->assertSame(
"<pre class=\"wp-block-verse\">$expected_content</pre>",
trim( $result ),
'The `__default` attribute should be replaced with the verse content binding.'
);

$expected_bindings_metadata = array(
'content' => array( 'source' => 'core/pattern-overrides' ),
);
$this->assertSame(
$expected_bindings_metadata,
$block->attributes['metadata']['bindings'],
'The __default binding should be updated with the Verse content binding.'
);
}

/**
* Tests that filter `block_bindings_source_value` is applied.
*
Expand Down
Loading