WordPress.org

Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/nav-menu-template.php

    r25410 r25602  
    272272    _wp_menu_item_classes_by_context( $menu_items );
    273273
    274     $sorted_menu_items = array();
    275     foreach ( (array) $menu_items as $key => $menu_item )
    276         $sorted_menu_items[$menu_item->menu_order] = $menu_item;
    277 
    278     unset($menu_items);
     274    $sorted_menu_items = $menu_items_with_children = array();
     275    foreach ( (array) $menu_items as $menu_item ) {
     276        $sorted_menu_items[ $menu_item->menu_order ] = $menu_item;
     277        if ( $menu_item->menu_item_parent )
     278            $menu_items_with_children[ $menu_item->menu_item_parent ] = true;
     279    }
     280
     281    // Add the menu-item-has-children class where applicable
     282    if ( $menu_items_with_children ) {
     283        foreach ( $sorted_menu_items as &$menu_item ) {
     284            if ( isset( $menu_items_with_children[ $menu_item->ID ] ) )
     285                $menu_item->classes[] = 'menu-item-has-children';
     286        }
     287    }
     288
     289    unset( $menu_items, $menu_item );
    279290
    280291    /**
Note: See TracChangeset for help on using the changeset viewer.