Skip to content

Commit

Permalink
Merge pull request #9 from underdude/master
Browse files Browse the repository at this point in the history
Add 'menu-item-has-children' class to parent items like in nav-menu-template.php
  • Loading branch information
Sean McCafferty committed Jun 16, 2014
2 parents 31c855d + 96dbb78 commit 21d8b61
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion voce-cached-nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,19 @@ public static function menu( $args = array() ) {
_wp_menu_item_classes_by_context( $menu_items );

$sorted_menu_items = array();
foreach ( (array) $menu_items as $key => $menu_item ) $sorted_menu_items[ $menu_item->menu_order ] = $menu_item;
foreach ( (array) $menu_items as $key => $menu_item ) {
$sorted_menu_items[ $menu_item->menu_order ] = $menu_item;
if ( $menu_item->menu_item_parent )
$menu_items_with_children[ $menu_item->menu_item_parent ] = true;
}

// Add the menu-item-has-children class where applicable
if ( $menu_items_with_children ) {
foreach ( $sorted_menu_items as &$menu_item ) {
if ( isset( $menu_items_with_children[ $menu_item->ID ] ) )
$menu_item->classes[] = 'menu-item-has-children';
}
}

unset( $menu_items );

Expand Down

0 comments on commit 21d8b61

Please sign in to comment.