Changeset 64225
- Timestamp:
- 10/07/2026 09:28:31 AM (10 hours ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/wp-includes/block-bindings.php (modified) (2 diffs)
-
tests/phpunit/tests/block-bindings/render.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-bindings.php
r62518 r64225 136 136 * @since 6.9.0 137 137 * @since 7.1.0 Added support for the List Item block. 138 * @since 7.2.0 Added support for the Icon block. 138 139 * 139 140 * @param string $block_type The block type whose supported attributes are being retrieved. … … 150 151 'core/navigation-link' => array( 'url' ), 151 152 'core/navigation-submenu' => array( 'url' ), 153 'core/icon' => array( 'icon' ), 152 154 ); 153 155 -
trunk/tests/phpunit/tests/block-bindings/render.php
r62522 r64225 353 353 354 354 /** 355 * Tests if the Icon block's icon attribute is updated with the value 356 * returned by a block bindings source. 357 * 358 * @ticket 65725 359 * 360 * @covers ::register_block_bindings_source 361 */ 362 public function test_update_icon_block_with_value_from_source() { 363 $get_value_callback = function () { 364 return 'test-icons/test-icon'; 365 }; 366 367 wp_register_icon_collection( 368 'test-icons', 369 array( 'label' => 'Test Icons' ) 370 ); 371 372 wp_register_icon( 373 'test-icons/test-icon', 374 array( 375 'label' => 'Test Icon', 376 'content' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="currentColor"/></svg>', 377 ) 378 ); 379 380 register_block_bindings_source( 381 self::SOURCE_NAME, 382 array( 383 'label' => self::SOURCE_LABEL, 384 'get_value_callback' => $get_value_callback, 385 ) 386 ); 387 388 try { 389 $block_content = <<<HTML 390 <!-- wp:icon {"metadata":{"bindings":{"icon":{"source":"test/source"}}}} --> 391 <div class="wp-block-icon"></div> 392 <!-- /wp:icon --> 393 HTML; 394 $parsed_blocks = parse_blocks( $block_content ); 395 $block = new WP_Block( $parsed_blocks[0] ); 396 $result = $block->render(); 397 398 $this->assertSame( 399 'test-icons/test-icon', 400 $block->attributes['icon'], 401 "The 'icon' attribute should be updated with the value returned by the source." 402 ); 403 $this->assertStringContainsString( 404 '<svg', 405 $result, 406 'The rendered output should contain an SVG element.' 407 ); 408 $this->assertStringContainsString( 409 'wp-block-icon', 410 $result, 411 'The rendered output should contain the wp-block-icon class.' 412 ); 413 } finally { 414 wp_unregister_icon( 'test-icons/test-icon' ); 415 wp_unregister_icon_collection( 'test-icons' ); 416 } 417 } 418 419 /** 355 420 * Tests if the `__default` attribute is replaced with real attributes for 356 421 * pattern overrides.
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)