diff --git a/packages/block-library/src/navigation-submenu/index.php b/packages/block-library/src/navigation-submenu/index.php index 87c7c91481cddb..be6046076e76e1 100644 --- a/packages/block-library/src/navigation-submenu/index.php +++ b/packages/block-library/src/navigation-submenu/index.php @@ -255,6 +255,14 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) { $inner_blocks_html .= $inner_block->render(); } + 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(); + } + $html .= sprintf( '
', $inner_blocks_html