From 53f452a9c54b49fbcd4fad68b5676153c0059dd1 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] 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 4fa954b8deb4bc..405a6e16a54fd4 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 ) {