Ticket #28620: 28620-alt.diff
| File 28620-alt.diff, 1.8 KB (added by , 10 years ago) |
|---|
-
wp-includes/nav-menu-template.php
161 161 // Set up the $menu_item variables 162 162 _wp_menu_item_classes_by_context( $menu_items ); 163 163 164 $sorted_menu_items = $menu_items_with_children = array(); 164 // Sort the items by menu order and identify tree structure 165 $sorted_menu_items = $menu_items_tree = $menu_items_with_children = array(); 165 166 foreach ( (array) $menu_items as $menu_item ) { 166 167 $sorted_menu_items[ $menu_item->menu_order ] = $menu_item; 168 $menu_items_tree[ $menu_item->ID ] = $menu_item->menu_item_parent; 167 169 if ( $menu_item->menu_item_parent ) 168 $menu_items_with_children[ $menu_item->menu_item_parent ] = true;170 $menu_items_with_children[ $menu_item->menu_item_parent ] = 1; 169 171 } 170 172 173 // Calculate the depth of each menu item with children 174 foreach ( $menu_items_with_children as $menu_item_key => &$menu_item_depth ) { 175 $menu_item_parent = $menu_items_tree[ $menu_item_key ]; 176 while ( $menu_item_parent ) { 177 $menu_item_depth = $menu_item_depth + 1; 178 $menu_item_parent = $menu_items_tree[ $menu_item_parent ]; 179 } 180 } 181 171 182 // Add the menu-item-has-children class where applicable 172 183 if ( $menu_items_with_children ) { 173 184 foreach ( $sorted_menu_items as &$menu_item ) { 174 if ( isset( $menu_items_with_children[ $menu_item->ID ] ) )185 if ( isset( $menu_items_with_children[ $menu_item->ID ] ) && ( $args->depth <= 0 || $menu_items_with_children[ $menu_item->ID ] < $args->depth ) ) 175 186 $menu_item->classes[] = 'menu-item-has-children'; 176 187 } 177 188 } 178 189 179 unset( $menu_items , $menu_item );190 unset( $menu_items_tree, $menu_items_with_children, $menu_items, $menu_item ); 180 191 181 192 /** 182 193 * Filters the sorted list of menu item objects before generating the menu's HTML.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)