From 930ff899b5b4abaf8ed566a32a2aaf6027c705c8 Mon Sep 17 00:00:00 2001 From: yashjawale Date: Mon, 27 Jul 2026 14:00:17 +0530 Subject: [PATCH 1/7] feat: add core/icon - icon attribute to list of supported block binding attributes --- src/wp-includes/block-bindings.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wp-includes/block-bindings.php b/src/wp-includes/block-bindings.php index 5a20c023149d7..23c99651912de 100644 --- a/src/wp-includes/block-bindings.php +++ b/src/wp-includes/block-bindings.php @@ -149,6 +149,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/icon' => array( 'icon' ), ); $supported_block_attributes = From f1a6e819fc934912c7477691684bf5e3409d2e5e Mon Sep 17 00:00:00 2001 From: yashjawale Date: Mon, 27 Jul 2026 16:32:11 +0530 Subject: [PATCH 2/7] test: add test case for icon attribute binding --- tests/phpunit/tests/block-bindings/render.php | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/tests/phpunit/tests/block-bindings/render.php b/tests/phpunit/tests/block-bindings/render.php index 3ce1993e4c351..461071a3b2ff9 100644 --- a/tests/phpunit/tests/block-bindings/render.php +++ b/tests/phpunit/tests/block-bindings/render.php @@ -351,6 +351,63 @@ public function test_update_block_with_value_from_source_image_placeholder() { ); } + /** + * Tests if the Icon block's icon attribute is updated with the value + * returned by a block bindings source. + * + * @ticket 65406 + * + * @covers ::register_block_bindings_source + */ + public function test_update_icon_block_with_value_from_source() { + $get_value_callback = function () { + return 'core/test-icon'; + }; + + wp_register_icon( + 'core/test-icon', + array( + 'label' => 'Test Icon', + 'content' => '', + ) + ); + + register_block_bindings_source( + self::SOURCE_NAME, + array( + 'label' => self::SOURCE_LABEL, + 'get_value_callback' => $get_value_callback, + ) + ); + + $block_content = << +
+ +HTML; + $parsed_blocks = parse_blocks( $block_content ); + $block = new WP_Block( $parsed_blocks[0] ); + $result = $block->render(); + + $this->assertSame( + 'core/test-icon', + $block->attributes['icon'], + "The 'icon' attribute should be updated with the value returned by the source." + ); + $this->assertStringContainsString( + 'assertStringContainsString( + 'wp-block-icon', + $result, + 'The rendered output should contain the wp-block-icon class.' + ); + + wp_unregister_icon( 'core/test-icon' ); + } + /** * Tests if the `__default` attribute is replaced with real attributes for * pattern overrides. From 6fe84662b7fe134b00d259683e79a3299af01f8f Mon Sep 17 00:00:00 2001 From: yashjawale Date: Mon, 27 Jul 2026 16:41:34 +0530 Subject: [PATCH 3/7] fix: issue number in docblock comment --- tests/phpunit/tests/block-bindings/render.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/block-bindings/render.php b/tests/phpunit/tests/block-bindings/render.php index 461071a3b2ff9..2a9bce9b759ea 100644 --- a/tests/phpunit/tests/block-bindings/render.php +++ b/tests/phpunit/tests/block-bindings/render.php @@ -355,7 +355,7 @@ public function test_update_block_with_value_from_source_image_placeholder() { * Tests if the Icon block's icon attribute is updated with the value * returned by a block bindings source. * - * @ticket 65406 + * @ticket 65725 * * @covers ::register_block_bindings_source */ From 2e736aaca1bc6a887b412edd58e17c05e6e2f6a9 Mon Sep 17 00:00:00 2001 From: yashjawale Date: Mon, 27 Jul 2026 16:42:16 +0530 Subject: [PATCH 4/7] docs: update docblock to include @since tag --- src/wp-includes/block-bindings.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wp-includes/block-bindings.php b/src/wp-includes/block-bindings.php index 23c99651912de..572142251555f 100644 --- a/src/wp-includes/block-bindings.php +++ b/src/wp-includes/block-bindings.php @@ -135,6 +135,7 @@ function get_block_bindings_source( string $source_name ) { * * @since 6.9.0 * @since 7.1.0 Added support for the List Item block. + * @since 7.1.0 Added support for Icon block. * * @param string $block_type The block type whose supported attributes are being retrieved. * @return array The list of block attributes that are supported by block bindings. From efda743471e8b8fc71764e0c9775188bbd8c6a00 Mon Sep 17 00:00:00 2001 From: yashjawale Date: Mon, 27 Jul 2026 16:44:37 +0530 Subject: [PATCH 5/7] test: make Icon block binding test use self-contained icon collection Use a test-specific icon collection instead of depending on the core collection, which may be unregistered by other test suites running in the same process. --- tests/phpunit/tests/block-bindings/render.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/tests/block-bindings/render.php b/tests/phpunit/tests/block-bindings/render.php index 2a9bce9b759ea..7b3b36bde466f 100644 --- a/tests/phpunit/tests/block-bindings/render.php +++ b/tests/phpunit/tests/block-bindings/render.php @@ -361,11 +361,16 @@ public function test_update_block_with_value_from_source_image_placeholder() { */ public function test_update_icon_block_with_value_from_source() { $get_value_callback = function () { - return 'core/test-icon'; + return 'test-icons/test-icon'; }; + wp_register_icon_collection( + 'test-icons', + array( 'label' => 'Test Icons' ) + ); + wp_register_icon( - 'core/test-icon', + 'test-icons/test-icon', array( 'label' => 'Test Icon', 'content' => '', @@ -390,7 +395,7 @@ public function test_update_icon_block_with_value_from_source() { $result = $block->render(); $this->assertSame( - 'core/test-icon', + 'test-icons/test-icon', $block->attributes['icon'], "The 'icon' attribute should be updated with the value returned by the source." ); @@ -405,7 +410,8 @@ public function test_update_icon_block_with_value_from_source() { 'The rendered output should contain the wp-block-icon class.' ); - wp_unregister_icon( 'core/test-icon' ); + wp_unregister_icon( 'test-icons/test-icon' ); + wp_unregister_icon_collection( 'test-icons' ); } /** From 83cafe3b1ece650a7b3205eb82c29ea44a6e0ae5 Mon Sep 17 00:00:00 2001 From: yashjawale Date: Mon, 27 Jul 2026 16:45:34 +0530 Subject: [PATCH 6/7] fix: wrap test in try/catch block --- tests/phpunit/tests/block-bindings/render.php | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/tests/phpunit/tests/block-bindings/render.php b/tests/phpunit/tests/block-bindings/render.php index 7b3b36bde466f..f363cd6cf2019 100644 --- a/tests/phpunit/tests/block-bindings/render.php +++ b/tests/phpunit/tests/block-bindings/render.php @@ -385,33 +385,35 @@ public function test_update_icon_block_with_value_from_source() { ) ); - $block_content = <<
HTML; - $parsed_blocks = parse_blocks( $block_content ); - $block = new WP_Block( $parsed_blocks[0] ); - $result = $block->render(); - - $this->assertSame( - 'test-icons/test-icon', - $block->attributes['icon'], - "The 'icon' attribute should be updated with the value returned by the source." - ); - $this->assertStringContainsString( - 'assertStringContainsString( - 'wp-block-icon', - $result, - 'The rendered output should contain the wp-block-icon class.' - ); - - wp_unregister_icon( 'test-icons/test-icon' ); - wp_unregister_icon_collection( 'test-icons' ); + $parsed_blocks = parse_blocks( $block_content ); + $block = new WP_Block( $parsed_blocks[0] ); + $result = $block->render(); + + $this->assertSame( + 'test-icons/test-icon', + $block->attributes['icon'], + "The 'icon' attribute should be updated with the value returned by the source." + ); + $this->assertStringContainsString( + 'assertStringContainsString( + 'wp-block-icon', + $result, + 'The rendered output should contain the wp-block-icon class.' + ); + } finally { + wp_unregister_icon( 'test-icons/test-icon' ); + wp_unregister_icon_collection( 'test-icons' ); + } } /** From 8695b622317a593d6ec894045ec0a681513d89ae Mon Sep 17 00:00:00 2001 From: Yash Jawale Date: Mon, 27 Jul 2026 16:53:00 +0530 Subject: [PATCH 7/7] fix: typo in docblock Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/wp-includes/block-bindings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/block-bindings.php b/src/wp-includes/block-bindings.php index 572142251555f..e4a371bdfa0b8 100644 --- a/src/wp-includes/block-bindings.php +++ b/src/wp-includes/block-bindings.php @@ -135,7 +135,7 @@ function get_block_bindings_source( string $source_name ) { * * @since 6.9.0 * @since 7.1.0 Added support for the List Item block. - * @since 7.1.0 Added support for Icon block. + * @since 7.1.0 Added support for the Icon block. * * @param string $block_type The block type whose supported attributes are being retrieved. * @return array The list of block attributes that are supported by block bindings.