Changeset 60798
- Timestamp:
- 09/25/2025 09:00:11 AM (5 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/wp-includes/class-wp-block.php (modified) (1 diff)
-
tests/phpunit/tests/block-bindings/render.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-block.php
r60790 r60798 110 110 'core/paragraph' => array( 'content' ), 111 111 'core/heading' => array( 'content' ), 112 'core/image' => array( 'id', 'url', 'title', 'alt' ),112 'core/image' => array( 'id', 'url', 'title', 'alt', 'caption' ), 113 113 'core/button' => array( 'url', 'text', 'linkTarget', 'rel' ), 114 114 'core/post-date' => array( 'datetime' ), -
trunk/tests/phpunit/tests/block-bindings/render.php
r60720 r60798 103 103 '<div class="wp-block-button"><a class="wp-block-button__link wp-element-button">test source value</a></div>', 104 104 ), 105 'image block' => array( 106 'caption', 107 <<<HTML 108 <!-- wp:image {"id":66,"sizeSlug":"large","linkDestination":"none"} --> 109 <figure class="wp-block-image size-large"><img src="breakfast.jpg" alt="" class="wp-image-1"/><figcaption class="wp-element-caption">Breakfast at a <em>café</em> in Wrocław.</figcaption></figure> 110 <!-- /wp:image --> 111 HTML 112 , 113 '<figure class="wp-block-image size-large"><img src="breakfast.jpg" alt="" class="wp-image-1"/><figcaption class="wp-element-caption">test source value</figcaption></figure>', 114 ), 105 115 'test block' => array( 106 116 'myAttribute', … … 283 293 * for the Image block in the placeholder state. 284 294 * 295 * Furthermore tests if the caption attribute is correctly processed. 296 * 285 297 * @ticket 60282 298 * @ticket 64031 286 299 * 287 300 * @covers ::register_block_bindings_source 288 301 */ 289 302 public function test_update_block_with_value_from_source_image_placeholder() { 290 $get_value_callback = function () { 291 return 'https://example.com/image.jpg'; 303 $get_value_callback = function ( $source_args, $block_instance, $attribute_name ) { 304 if ( 'url' === $attribute_name ) { 305 return 'https://example.com/image.jpg'; 306 } 307 if ( 'caption' === $attribute_name ) { 308 return 'Example Image'; 309 } 292 310 }; 293 311 … … 301 319 302 320 $block_content = <<<HTML 303 <!-- wp:image {"metadata":{"bindings":{"url":{"source":"test/source"} }}} -->304 <figure class="wp-block-image"><img alt=""/>< /figure>321 <!-- wp:image {"metadata":{"bindings":{"url":{"source":"test/source"},"caption":{"source":"test/source"}}}} --> 322 <figure class="wp-block-image"><img alt=""/><figcaption class="wp-element-caption"></figcaption></figure> 305 323 <!-- /wp:image --> 306 324 HTML; … … 315 333 ); 316 334 $this->assertSame( 317 '<figure class="wp-block-image"><img src="https://example.com/image.jpg" alt=""/></figure>', 335 'Example Image', 336 $block->attributes['caption'], 337 "The 'caption' attribute should be updated with the value returned by the source." 338 ); 339 $this->assertSame( 340 '<figure class="wp-block-image"><img src="https://example.com/image.jpg" alt=""/><figcaption class="wp-element-caption">Example Image</figcaption></figure>', 318 341 trim( $result ), 319 342 'The block content should be updated with the value returned by the source.'
Note: See TracChangeset
for help on using the changeset viewer.