Make WordPress Core


Ignore:
Timestamp:
11/11/2022 02:40:54 AM (2 years ago)
Author:
desrosj
Message:

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, peterwilsoncc.
Merges [54801] to the 6.1 branch.
Fixes #56946.
See #28620.

Location:
branches/6.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.1

  • branches/6.1/src/wp-includes/nav-menu-template.php

    r54478 r54809  
    205205            $menu_items_with_children[ $menu_item->menu_item_parent ] = 1;
    206206        }
    207 
    208         // Calculate the depth of each menu item with children
    209         foreach ( $menu_items_with_children as $menu_item_key => &$menu_item_depth ) {
    210             $menu_item_parent = $menu_items_tree[ $menu_item_key ];
    211             while ( $menu_item_parent ) {
    212                 $menu_item_depth  = $menu_item_depth + 1;
    213                 $menu_item_parent = $menu_items_tree[ $menu_item_parent ];
    214             }
     207    }
     208
     209    // Calculate the depth of each menu item with children.
     210    foreach ( $menu_items_with_children as $menu_item_key => &$menu_item_depth ) {
     211        $menu_item_parent = $menu_items_tree[ $menu_item_key ];
     212        while ( $menu_item_parent ) {
     213            $menu_item_depth  = $menu_item_depth + 1;
     214            $menu_item_parent = $menu_items_tree[ $menu_item_parent ];
    215215        }
    216216    }
Note: See TracChangeset for help on using the changeset viewer.