Menus: Apply `menu-item-has-children` class in sub-menus.

Ensure the `menu-item-has-children` class is added to sub-menu items when `wp_nav_menu()` is called with the `depth` parameter specified to a non-zero value.

Follow up to [54478].

Props davidvongries, fpodhorsky, hellofromTonya, innovext, larsmqller, LeonidasMilossis, mattkeys, mukesh27, nuvoPoint, ocean90, outrankjames, petitphp, SergeyBiryukov, sippis, webmandesign.
Fixes #56946.
See #28620.

Built from https://develop.svn.wordpress.org/trunk@54801


git-svn-id: http://core.svn.wordpress.org/trunk@54353 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2022-11-11 00:06:14 +00:00
parent 2a57dd7f86
commit 9a2189e880
2 changed files with 8 additions and 8 deletions

View File

@ -204,14 +204,14 @@ function wp_nav_menu( $args = array() ) {
if ( $menu_item->menu_item_parent ) {
$menu_items_with_children[ $menu_item->menu_item_parent ] = 1;
}
}
// Calculate the depth of each menu item with children
foreach ( $menu_items_with_children as $menu_item_key => &$menu_item_depth ) {
$menu_item_parent = $menu_items_tree[ $menu_item_key ];
while ( $menu_item_parent ) {
$menu_item_depth = $menu_item_depth + 1;
$menu_item_parent = $menu_items_tree[ $menu_item_parent ];
}
// Calculate the depth of each menu item with children.
foreach ( $menu_items_with_children as $menu_item_key => &$menu_item_depth ) {
$menu_item_parent = $menu_items_tree[ $menu_item_key ];
while ( $menu_item_parent ) {
$menu_item_depth = $menu_item_depth + 1;
$menu_item_parent = $menu_items_tree[ $menu_item_parent ];
}
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.2-alpha-54799';
$wp_version = '6.2-alpha-54801';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.