diff --git a/backport-changelog/7.1/12041.md b/backport-changelog/7.1/12041.md new file mode 100644 index 00000000000000..e9af68392b9322 --- /dev/null +++ b/backport-changelog/7.1/12041.md @@ -0,0 +1,3 @@ +https://github.com/WordPress/wordpress-develop/pull/12041 + +* https://github.com/WordPress/gutenberg/pull/78860 diff --git a/lib/compat/wordpress-7.1/block-bindings.php b/lib/compat/wordpress-7.1/block-bindings.php new file mode 100644 index 00000000000000..3dbf0c73426dcf --- /dev/null +++ b/lib/compat/wordpress-7.1/block-bindings.php @@ -0,0 +1,21 @@ +test source value

', ), + 'verse block' => array( + 'content', + << +
This should not appear
+ +HTML + , + '
test source value
', + ), 'button block' => array( 'text', << +
This should not appear
+ +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( + "
$expected_content
", + 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. */ diff --git a/test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js b/test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js index 91baf62b8fd325..096cb57156cc26 100644 --- a/test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js +++ b/test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js @@ -883,6 +883,20 @@ test.describe( 'Registered sources', () => { await expect( contentAttribute ).toBeVisible(); } ); + test( 'should be possible to connect the verse content', async ( { + editor, + page, + } ) => { + await editor.insertBlock( { + name: 'core/verse', + } ); + await page.getByLabel( 'Attributes options' ).click(); + const contentAttribute = page.getByRole( 'menuitemcheckbox', { + name: 'Show content', + } ); + await expect( contentAttribute ).toBeVisible(); + } ); + test( 'should be possible to connect the button supported attributes', async ( { editor, page,