Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Add test to cover existing issue
  • Loading branch information
SantosGuillamot committed Jun 6, 2024
commit 8f8c7eb13d4e766a4011c30b053a659367718707
1 change: 1 addition & 0 deletions src/wp-includes/class-wp-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ private function replace_html( string $block_content, string $attribute_name, $s
}
$block_reader->release_bookmark( 'iterate-selectors' );
return $block_content;

case 'attribute':
$amended_content = new WP_HTML_Tag_Processor( $block_content );
if ( ! $amended_content->next_tag(
Expand Down
36 changes: 36 additions & 0 deletions tests/phpunit/tests/block-bindings/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,42 @@ public function test_source_value_with_unsafe_html_is_sanitized() {
);
}

/**
* Tests that including symbols and numbers works well with bound attributes.
*
* @ticket 61385
*
* @covers WP_Block::process_block_bindings
*/
public function test_using_symbols_in_block_bindings_value() {
$get_value_callback = function () {
return '$12.50';
};

register_block_bindings_source(
self::SOURCE_NAME,
array(
'label' => self::SOURCE_LABEL,
'get_value_callback' => $get_value_callback,
)
);

$block_content = <<<HTML
<!-- wp:paragraph {"metadata":{"bindings":{"content":{"source":"test/source"}}}} -->
<p>Default content</p>
<!-- /wp:paragraph -->
HTML;
$parsed_blocks = parse_blocks( $block_content );
$block = new WP_Block( $parsed_blocks[0] );
$result = $block->render();

$this->assertSame(
'<p>$12.50</p>',
trim( $result ),
'The block content should properly show the symbol and numbers.'
);
}

/**
* Tests if the `__default` attribute is replaced with real attribues for
* pattern overrides.
Expand Down