From 8d815269ddc69553ca2182e826b522917827122a Mon Sep 17 00:00:00 2001 From: Ari Stathopoulos Date: Tue, 3 May 2022 10:14:56 +0300 Subject: [PATCH] Add a current-menu-ancestor class to menus --- packages/block-library/src/navigation-submenu/index.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/block-library/src/navigation-submenu/index.php b/packages/block-library/src/navigation-submenu/index.php index 2eba72bcbc5541..659a75cb6c6370 100644 --- a/packages/block-library/src/navigation-submenu/index.php +++ b/packages/block-library/src/navigation-submenu/index.php @@ -239,6 +239,10 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) { $inner_blocks_html .= $inner_block->render(); } + if ( strpos( $inner_blocks_html, 'current-menu-item' ) ) { + $html = str_replace( 'wp-block-navigation-item__content', 'wp-block-navigation-item__content current-menu-ancestor', $html ); + } + $html .= sprintf( '', $inner_blocks_html