From 6a3697913a04b129caf744e3debcf403421b422c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Mon, 23 Oct 2023 17:17:24 +0200 Subject: [PATCH 01/17] fix use tag processor instead of hardcoded list of list item blocks in navigation block render callback fix phpcs issue From d8af377db20992a17441c9c4ad7d66890b326ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Wed, 22 Nov 2023 08:52:37 +0100 Subject: [PATCH 02/17] fix whitespace issue From b542e41e7ee2268f56cf02bc5c46a08d727e7cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Sat, 3 Feb 2024 10:21:28 +0100 Subject: [PATCH 03/17] fix apply patch for using tag processor instead of hardcoded list of blocks to moved WP_Navigation_Block_Renderer class --- .../block-library/src/navigation/index.php | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index f3afb19676775..9a70b5ba33e28 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -10,24 +10,6 @@ */ class WP_Navigation_Block_Renderer { - /** - * Used to determine whether or not a navigation has submenus. - */ - private static $has_submenus = false; - - /** - * Used to determine which blocks are wrapped in an
  • . - * - * @var array - */ - private static $nav_blocks_wrapped_in_list_item = array( - 'core/navigation-link', - 'core/home-link', - 'core/site-title', - 'core/site-logo', - 'core/navigation-submenu', - ); - /** * Used to determine which blocks need an
  • wrapper. * @@ -161,7 +143,9 @@ private static function get_inner_blocks_html( $attributes, $inner_blocks ) { $is_list_open = false; foreach ( $inner_blocks as $inner_block ) { - $is_list_item = in_array( $inner_block->name, static::$nav_blocks_wrapped_in_list_item, true ); + $inner_block_markup = static::get_markup_for_inner_block( $inner_block ); + $p = new WP_HTML_Tag_Processor( $inner_block_markup ); + $is_list_item = $p->next_tag( 'LI' ); if ( $is_list_item && ! $is_list_open ) { $is_list_open = true; @@ -176,7 +160,7 @@ private static function get_inner_blocks_html( $attributes, $inner_blocks ) { $inner_blocks_html .= ''; } - $inner_blocks_html .= static::get_markup_for_inner_block( $inner_block ); + $inner_blocks_html .= $inner_block_markup; } if ( $is_list_open ) { From 66316ea41b88e5f40488557a1b7819a94a06f8de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Sat, 3 Feb 2024 10:23:47 +0100 Subject: [PATCH 04/17] fix whitespace issue --- packages/block-library/src/navigation/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index 9a70b5ba33e28..20baae40554ec 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -144,8 +144,8 @@ private static function get_inner_blocks_html( $attributes, $inner_blocks ) { foreach ( $inner_blocks as $inner_block ) { $inner_block_markup = static::get_markup_for_inner_block( $inner_block ); - $p = new WP_HTML_Tag_Processor( $inner_block_markup ); - $is_list_item = $p->next_tag( 'LI' ); + $p = new WP_HTML_Tag_Processor( $inner_block_markup ); + $is_list_item = $p->next_tag( 'LI' ); if ( $is_list_item && ! $is_list_open ) { $is_list_open = true; From f66a7310d820d1c09b3fcb32ca3ccd9865be091b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Sat, 3 Feb 2024 16:43:03 +0100 Subject: [PATCH 05/17] fix add back has_submenus propertry --- packages/block-library/src/navigation/index.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index 20baae40554ec..38b7cd46d7fa4 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -10,6 +10,11 @@ */ class WP_Navigation_Block_Renderer { + /** + * Used to determine whether or not a navigation has submenus. + */ + private static $has_submenus = false; + /** * Used to determine which blocks need an
  • wrapper. * From da242ab208b9abe0592269c62d8833dfeb238d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 6 Feb 2024 15:34:57 +0100 Subject: [PATCH 06/17] add filter to allow modification of which blocks get wrapped in a list item --- packages/block-library/src/navigation/index.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index 38b7cd46d7fa4..dc8290ab60f18 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -104,7 +104,22 @@ private static function is_interactive( $attributes, $inner_blocks ) { * @return bool Returns whether or not a block needs a list item wrapper. */ private static function does_block_need_a_list_item_wrapper( $block ) { - return in_array( $block->name, static::$needs_list_item_wrapper, true ); + + /** + * Filter the list of blocks that need a list item wrapper. + * + * This filter allows developers to add or remove blocks that need a list item wrapper. + * This is useful for blocks that are not list items but should be wrapped in a list + * item when used as a child of a navigation block. + * + * @since 6.5.0 + * + * @param array $needs_list_item_wrapper The list of blocks that need a list item wrapper. + * @return array The list of blocks that need a list item wrapper. + */ + $needs_list_item_wrapper = apply_filters( 'block_core_navigation_needs_list_item_wrapper', static::$needs_list_item_wrapper ); + + return in_array( $block->name, $needs_list_item_wrapper, true ); } /** From 222e4098a03ea6efac49d5fe51cf1dae4f279393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 6 Feb 2024 18:22:26 +0100 Subject: [PATCH 07/17] add test case for needs list item wrapper filter --- ...lass-wp-navigation-block-renderer-test.php | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/phpunit/blocks/class-wp-navigation-block-renderer-test.php b/phpunit/blocks/class-wp-navigation-block-renderer-test.php index 6bcf08c179e90..5670dcb5eed8b 100644 --- a/phpunit/blocks/class-wp-navigation-block-renderer-test.php +++ b/phpunit/blocks/class-wp-navigation-block-renderer-test.php @@ -63,6 +63,76 @@ public function test_gutenberg_get_markup_for_inner_block_site_title() { $this->assertEquals( $expected, $result ); } + /** + * Test that the heading block isn't wrapped in a list item to preserve accessible markup + * + * @group navigation-renderer + * + * @covers WP_Navigation_Block_Renderer::get_markup_for_inner_block + */ + public function test_gutenberg_get_markup_for_inner_block_heading() { + + // We are testing the site title block because we manually add list items around it. + $parsed_blocks = parse_blocks( + '

    Hello World

    ' + ); + $parsed_block = $parsed_blocks[0]; + $context = array(); + $heading_block = new WP_Block( $parsed_block, $context ); + + // Setup an empty testing instance of `WP_Navigation_Block_Renderer` and save the original. + $reflection = new ReflectionClass( 'WP_Navigation_Block_Renderer_Gutenberg' ); + $method = $reflection->getMethod( 'get_markup_for_inner_block' ); + $method->setAccessible( true ); + // Invoke the private method. + $result = $method->invoke( $reflection, $heading_block ); + + $expected = '

    Hello World

    '; + $this->assertEquals( $expected, $result ); + } + + /** + * Test that the heading block is wrapped in a list item when filtered to preserve accessible markup + * + * @group navigation-renderer + * + * @covers WP_Navigation_Block_Renderer::get_markup_for_inner_block + */ + public function test_gutenberg_get_markup_for_inner_block_heading_filtered() { + + $filter_needs_list_item_wrapper_function = static function ( $needs_list_item_wrapper ) { + $needs_list_item_wrapper[] = 'core/heading'; + return $needs_list_item_wrapper; + }; + + add_filter( + 'block_core_navigation_needs_list_item_wrapper', + $filter_needs_list_item_wrapper_function, + 10, + 1 + ); + + // We are testing the site title block because we manually add list items around it. + $parsed_blocks = parse_blocks( + '

    Hello Filtered World

    ' + ); + $parsed_block = $parsed_blocks[0]; + $context = array(); + $heading_block = new WP_Block( $parsed_block, $context ); + + // Setup an empty testing instance of `WP_Navigation_Block_Renderer` and save the original. + $reflection = new ReflectionClass( 'WP_Navigation_Block_Renderer_Gutenberg' ); + $method = $reflection->getMethod( 'get_markup_for_inner_block' ); + $method->setAccessible( true ); + // Invoke the private method. + $result = $method->invoke( $reflection, $heading_block ); + + $expected = '
  • Hello Filtered World

  • '; + $this->assertEquals( $expected, $result ); + + remove_filter( 'block_core_navigation_needs_list_item_wrapper', $filter_needs_list_item_wrapper_function, 10, 1 ); + } + /** * Test that the `get_inner_blocks_from_navigation_post` method returns an empty block list for a non-existent post. * From e3511a55e11b465910f39c994814301e1e8e5e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Tue, 6 Feb 2024 18:30:36 +0100 Subject: [PATCH 08/17] fix whitespace --- .../class-wp-navigation-block-renderer-test.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/phpunit/blocks/class-wp-navigation-block-renderer-test.php b/phpunit/blocks/class-wp-navigation-block-renderer-test.php index 5670dcb5eed8b..28e41faf11f34 100644 --- a/phpunit/blocks/class-wp-navigation-block-renderer-test.php +++ b/phpunit/blocks/class-wp-navigation-block-renderer-test.php @@ -73,11 +73,11 @@ public function test_gutenberg_get_markup_for_inner_block_site_title() { public function test_gutenberg_get_markup_for_inner_block_heading() { // We are testing the site title block because we manually add list items around it. - $parsed_blocks = parse_blocks( + $parsed_blocks = parse_blocks( '

    Hello World

    ' ); - $parsed_block = $parsed_blocks[0]; - $context = array(); + $parsed_block = $parsed_blocks[0]; + $context = array(); $heading_block = new WP_Block( $parsed_block, $context ); // Setup an empty testing instance of `WP_Navigation_Block_Renderer` and save the original. @@ -113,11 +113,11 @@ public function test_gutenberg_get_markup_for_inner_block_heading_filtered() { ); // We are testing the site title block because we manually add list items around it. - $parsed_blocks = parse_blocks( + $parsed_blocks = parse_blocks( '

    Hello Filtered World

    ' ); - $parsed_block = $parsed_blocks[0]; - $context = array(); + $parsed_block = $parsed_blocks[0]; + $context = array(); $heading_block = new WP_Block( $parsed_block, $context ); // Setup an empty testing instance of `WP_Navigation_Block_Renderer` and save the original. From 1334a3324623d6651d6098b60c95b038ec982f99 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Wed, 7 Feb 2024 15:21:05 +0000 Subject: [PATCH 09/17] Update filter docblock --- packages/block-library/src/navigation/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index dc8290ab60f18..78b5d44923b1b 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -108,7 +108,8 @@ private static function does_block_need_a_list_item_wrapper( $block ) { /** * Filter the list of blocks that need a list item wrapper. * - * This filter allows developers to add or remove blocks that need a list item wrapper. + * Affords ability to customize which blocks need a list item wrapper when rendered + * within a core/navigation block. * This is useful for blocks that are not list items but should be wrapped in a list * item when used as a child of a navigation block. * From 6eb26ae1898c5f8abcf384e909324f28b578bc2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Wed, 7 Feb 2024 16:45:43 +0100 Subject: [PATCH 10/17] fix update test cases to be more clear --- ...lass-wp-navigation-block-renderer-test.php | 44 +++++++++++++++---- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/phpunit/blocks/class-wp-navigation-block-renderer-test.php b/phpunit/blocks/class-wp-navigation-block-renderer-test.php index 28e41faf11f34..2698e032698b4 100644 --- a/phpunit/blocks/class-wp-navigation-block-renderer-test.php +++ b/phpunit/blocks/class-wp-navigation-block-renderer-test.php @@ -64,17 +64,27 @@ public function test_gutenberg_get_markup_for_inner_block_site_title() { } /** - * Test that the heading block isn't wrapped in a list item to preserve accessible markup + * Test that a given block will not be automatically wrapped in a list item by default. * * @group navigation-renderer * * @covers WP_Navigation_Block_Renderer::get_markup_for_inner_block */ - public function test_gutenberg_get_markup_for_inner_block_heading() { + public function test_gutenberg_block_not_automatically_wrapped_with_li_tag() { + + register_block_type( + 'testsuite/sample-block', + array( + 'api_version' => 2, + 'render_callback' => function ( $attributes, $content ) { + return '
    ' . $content . '
    '; + }, + ) + ); // We are testing the site title block because we manually add list items around it. $parsed_blocks = parse_blocks( - '

    Hello World

    ' + '
    Hello World
    ' ); $parsed_block = $parsed_blocks[0]; $context = array(); @@ -87,21 +97,35 @@ public function test_gutenberg_get_markup_for_inner_block_heading() { // Invoke the private method. $result = $method->invoke( $reflection, $heading_block ); - $expected = '

    Hello World

    '; + $expected = '
    Hello World
    '; $this->assertEquals( $expected, $result ); + + unregister_block_type( 'testsuite/sample-block' ); } /** - * Test that the heading block is wrapped in a list item when filtered to preserve accessible markup + * Test that a block can be added to the list of blocks which require a wrapping list item. + * This allows extenders to opt in to the rendering behavior of the Navigation block + * which helps to preserve accessible markup. * * @group navigation-renderer * * @covers WP_Navigation_Block_Renderer::get_markup_for_inner_block */ - public function test_gutenberg_get_markup_for_inner_block_heading_filtered() { + public function test_gutenberg_block_is_automatically_wrapped_with_li_tag_when_filtered() { + + register_block_type( + 'testsuite/sample-block', + array( + 'api_version' => 2, + 'render_callback' => function ( $attributes, $content ) { + return '
    ' . $content . '
    '; + }, + ) + ); $filter_needs_list_item_wrapper_function = static function ( $needs_list_item_wrapper ) { - $needs_list_item_wrapper[] = 'core/heading'; + $needs_list_item_wrapper[] = 'testsuite/sample-block'; return $needs_list_item_wrapper; }; @@ -114,7 +138,7 @@ public function test_gutenberg_get_markup_for_inner_block_heading_filtered() { // We are testing the site title block because we manually add list items around it. $parsed_blocks = parse_blocks( - '

    Hello Filtered World

    ' + '
    Hello World
    ' ); $parsed_block = $parsed_blocks[0]; $context = array(); @@ -127,10 +151,12 @@ public function test_gutenberg_get_markup_for_inner_block_heading_filtered() { // Invoke the private method. $result = $method->invoke( $reflection, $heading_block ); - $expected = '
  • Hello Filtered World

  • '; + $expected = '
  • Hello World
  • '; $this->assertEquals( $expected, $result ); remove_filter( 'block_core_navigation_needs_list_item_wrapper', $filter_needs_list_item_wrapper_function, 10, 1 ); + + unregister_block_type( 'testsuite/sample-block' ); } /** From 9da5725bb7261f9c16316974ae4afca134f3641f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Wed, 7 Feb 2024 16:46:36 +0100 Subject: [PATCH 11/17] fix rename filter for greater clarity --- packages/block-library/src/navigation/index.php | 2 +- phpunit/blocks/class-wp-navigation-block-renderer-test.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index 78b5d44923b1b..6fd8b55d61236 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -118,7 +118,7 @@ private static function does_block_need_a_list_item_wrapper( $block ) { * @param array $needs_list_item_wrapper The list of blocks that need a list item wrapper. * @return array The list of blocks that need a list item wrapper. */ - $needs_list_item_wrapper = apply_filters( 'block_core_navigation_needs_list_item_wrapper', static::$needs_list_item_wrapper ); + $needs_list_item_wrapper = apply_filters( 'block_core_navigation_blocks_requiring_list_item_wrapper', static::$needs_list_item_wrapper ); return in_array( $block->name, $needs_list_item_wrapper, true ); } diff --git a/phpunit/blocks/class-wp-navigation-block-renderer-test.php b/phpunit/blocks/class-wp-navigation-block-renderer-test.php index 2698e032698b4..6126827e90513 100644 --- a/phpunit/blocks/class-wp-navigation-block-renderer-test.php +++ b/phpunit/blocks/class-wp-navigation-block-renderer-test.php @@ -130,7 +130,7 @@ public function test_gutenberg_block_is_automatically_wrapped_with_li_tag_when_f }; add_filter( - 'block_core_navigation_needs_list_item_wrapper', + 'block_core_navigation_blocks_requiring_list_item_wrapper', $filter_needs_list_item_wrapper_function, 10, 1 @@ -154,7 +154,7 @@ public function test_gutenberg_block_is_automatically_wrapped_with_li_tag_when_f $expected = '
  • Hello World
  • '; $this->assertEquals( $expected, $result ); - remove_filter( 'block_core_navigation_needs_list_item_wrapper', $filter_needs_list_item_wrapper_function, 10, 1 ); + remove_filter( 'block_core_navigation_blocks_requiring_list_item_wrapper', $filter_needs_list_item_wrapper_function, 10, 1 ); unregister_block_type( 'testsuite/sample-block' ); } From f43e9025df64c2e4b220776ea4f3ab76e9b04f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Wed, 7 Feb 2024 16:49:56 +0100 Subject: [PATCH 12/17] fix whitespace and grammar --- packages/block-library/src/navigation/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index 6fd8b55d61236..76634a3c9466c 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -108,7 +108,7 @@ private static function does_block_need_a_list_item_wrapper( $block ) { /** * Filter the list of blocks that need a list item wrapper. * - * Affords ability to customize which blocks need a list item wrapper when rendered + * Affords the ability to customize which blocks need a list item wrapper when rendered * within a core/navigation block. * This is useful for blocks that are not list items but should be wrapped in a list * item when used as a child of a navigation block. From 49e5ae956919bb5c59680ba8205d3f67cd1eeb36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Wed, 7 Feb 2024 17:02:48 +0100 Subject: [PATCH 13/17] fix whitespace --- phpunit/blocks/class-wp-navigation-block-renderer-test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpunit/blocks/class-wp-navigation-block-renderer-test.php b/phpunit/blocks/class-wp-navigation-block-renderer-test.php index 6126827e90513..95f75e4622505 100644 --- a/phpunit/blocks/class-wp-navigation-block-renderer-test.php +++ b/phpunit/blocks/class-wp-navigation-block-renderer-test.php @@ -104,9 +104,9 @@ public function test_gutenberg_block_not_automatically_wrapped_with_li_tag() { } /** - * Test that a block can be added to the list of blocks which require a wrapping list item. - * This allows extenders to opt in to the rendering behavior of the Navigation block - * which helps to preserve accessible markup. + * Test that a block can be added to the list of blocks which require a wrapping list item. + * This allows extenders to opt in to the rendering behavior of the Navigation block + * which helps to preserve accessible markup. * * @group navigation-renderer * From 5326aecc4c46e73ac9927cb7ed16b670bdd653da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Wed, 7 Feb 2024 17:06:05 +0100 Subject: [PATCH 14/17] fix markup of demo block --- phpunit/blocks/class-wp-navigation-block-renderer-test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpunit/blocks/class-wp-navigation-block-renderer-test.php b/phpunit/blocks/class-wp-navigation-block-renderer-test.php index 95f75e4622505..0ad98c623eee8 100644 --- a/phpunit/blocks/class-wp-navigation-block-renderer-test.php +++ b/phpunit/blocks/class-wp-navigation-block-renderer-test.php @@ -84,7 +84,7 @@ public function test_gutenberg_block_not_automatically_wrapped_with_li_tag() { // We are testing the site title block because we manually add list items around it. $parsed_blocks = parse_blocks( - '
    Hello World
    ' + '' ); $parsed_block = $parsed_blocks[0]; $context = array(); @@ -138,7 +138,7 @@ public function test_gutenberg_block_is_automatically_wrapped_with_li_tag_when_f // We are testing the site title block because we manually add list items around it. $parsed_blocks = parse_blocks( - '
    Hello World
    ' + '' ); $parsed_block = $parsed_blocks[0]; $context = array(); From bc34eca8a1abe72f02e303da61ec01f58cb139a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Wed, 7 Feb 2024 17:17:43 +0100 Subject: [PATCH 15/17] fix test case --- phpunit/blocks/class-wp-navigation-block-renderer-test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpunit/blocks/class-wp-navigation-block-renderer-test.php b/phpunit/blocks/class-wp-navigation-block-renderer-test.php index 0ad98c623eee8..6196af855e784 100644 --- a/phpunit/blocks/class-wp-navigation-block-renderer-test.php +++ b/phpunit/blocks/class-wp-navigation-block-renderer-test.php @@ -76,8 +76,8 @@ public function test_gutenberg_block_not_automatically_wrapped_with_li_tag() { 'testsuite/sample-block', array( 'api_version' => 2, - 'render_callback' => function ( $attributes, $content ) { - return '
    ' . $content . '
    '; + 'render_callback' => function ( $attributes ) { + return '
    ' . $attributes['content'] . '
    '; }, ) ); From 74e45c2a4113e8ebc6c73ad692736c68d9bd93f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Wed, 7 Feb 2024 17:29:36 +0100 Subject: [PATCH 16/17] fix test case --- phpunit/blocks/class-wp-navigation-block-renderer-test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpunit/blocks/class-wp-navigation-block-renderer-test.php b/phpunit/blocks/class-wp-navigation-block-renderer-test.php index 6196af855e784..14e552cfa9ceb 100644 --- a/phpunit/blocks/class-wp-navigation-block-renderer-test.php +++ b/phpunit/blocks/class-wp-navigation-block-renderer-test.php @@ -118,8 +118,8 @@ public function test_gutenberg_block_is_automatically_wrapped_with_li_tag_when_f 'testsuite/sample-block', array( 'api_version' => 2, - 'render_callback' => function ( $attributes, $content ) { - return '
    ' . $content . '
    '; + 'render_callback' => function ( $attributes ) { + return '
    ' . $attributes['content'] . '
    '; }, ) ); From 222ef57251b052aa33316b434d32f8803c6711f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Thu, 8 Feb 2024 12:02:58 +0100 Subject: [PATCH 17/17] fix rename the new filter to block_core_navigation_listable_blocks --- packages/block-library/src/navigation/index.php | 2 +- phpunit/blocks/class-wp-navigation-block-renderer-test.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index 76634a3c9466c..07379b2bb94e8 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -118,7 +118,7 @@ private static function does_block_need_a_list_item_wrapper( $block ) { * @param array $needs_list_item_wrapper The list of blocks that need a list item wrapper. * @return array The list of blocks that need a list item wrapper. */ - $needs_list_item_wrapper = apply_filters( 'block_core_navigation_blocks_requiring_list_item_wrapper', static::$needs_list_item_wrapper ); + $needs_list_item_wrapper = apply_filters( 'block_core_navigation_listable_blocks', static::$needs_list_item_wrapper ); return in_array( $block->name, $needs_list_item_wrapper, true ); } diff --git a/phpunit/blocks/class-wp-navigation-block-renderer-test.php b/phpunit/blocks/class-wp-navigation-block-renderer-test.php index 14e552cfa9ceb..63efc3bfe35de 100644 --- a/phpunit/blocks/class-wp-navigation-block-renderer-test.php +++ b/phpunit/blocks/class-wp-navigation-block-renderer-test.php @@ -130,7 +130,7 @@ public function test_gutenberg_block_is_automatically_wrapped_with_li_tag_when_f }; add_filter( - 'block_core_navigation_blocks_requiring_list_item_wrapper', + 'block_core_navigation_listable_blocks', $filter_needs_list_item_wrapper_function, 10, 1 @@ -154,7 +154,7 @@ public function test_gutenberg_block_is_automatically_wrapped_with_li_tag_when_f $expected = '
  • Hello World
  • '; $this->assertEquals( $expected, $result ); - remove_filter( 'block_core_navigation_blocks_requiring_list_item_wrapper', $filter_needs_list_item_wrapper_function, 10, 1 ); + remove_filter( 'block_core_navigation_listable_blocks', $filter_needs_list_item_wrapper_function, 10, 1 ); unregister_block_type( 'testsuite/sample-block' ); }