From baef2619d79a1fcdd54c1b0d4dfdc64d481a4d76 Mon Sep 17 00:00:00 2001 From: Ari Stathopoulos Date: Thu, 1 Dec 2022 09:28:54 +0200 Subject: [PATCH] bugfix --- .../block-library/src/navigation-submenu/index.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/navigation-submenu/index.php b/packages/block-library/src/navigation-submenu/index.php index 34166764e057c5..be6046076e76e1 100644 --- a/packages/block-library/src/navigation-submenu/index.php +++ b/packages/block-library/src/navigation-submenu/index.php @@ -255,11 +255,13 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) { $inner_blocks_html .= $inner_block->render(); } - $tag_processor = new WP_HTML_Tag_Processor( $inner_blocks_html ); - while ( $tag_processor->next_tag( array( 'class_name' => 'wp-block-navigation-item__content' ) ) ) { - $tag_processor->add_class( 'current-menu-ancestor' ); + if ( strpos( $inner_blocks_html, 'current-menu-item' ) ) { + $tag_processor = new WP_HTML_Tag_Processor( $html ); + while ( $tag_processor->next_tag( array( 'class_name' => 'wp-block-navigation-item__content' ) ) ) { + $tag_processor->add_class( 'current-menu-ancestor' ); + } + $html = $tag_processor->get_updated_html(); } - $inner_blocks_html = $tag_processor->get_updated_html(); $html .= sprintf( '',