From: Laury GvR Date: Wed, 4 May 2016 20:05:48 +0000 (-0400) Subject: Attempting to fix the drop-left top-nav issue X-Git-Tag: v1.0.0^2~49 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=83c3a8860dc43be7a0ca0386d3d594374a332f82;p=WP-Themes%2Fthinkdunes.git Attempting to fix the drop-left top-nav issue --- diff --git a/functions.php b/functions.php index dae1c7c..ec913e1 100644 --- a/functions.php +++ b/functions.php @@ -148,4 +148,34 @@ function mytheme_search_loop() { add_action('thematic_searchloop', 'mytheme_search_loop'); // End of the Contextual/Highlight Search functions +// + +//function get_menu_parent_ID($menu_name){ +// if(!isset($menu_name)){ +// return "No menu name provided in arguments"; +// } +// $menu_slug = $menu_name; +// $locations = get_nav_menu_locations(); +// $menu_id = $locations[$menu_slug]; +// $post_id = get_the_ID(); +// $menu_items = wp_get_nav_menu_items($menu_id); +// $parent_item_id = wp_filter_object_list($menu_items,array('object_id'=>$post_id),'and','menu_item_parent'); +// $parent_item_id = array_shift( $parent_item_id ); +// function checkForParent($parent_item_id,$menu_items){ +// $parent_post_id = wp_filter_object_list( $menu_items, array( 'ID' => $parent_item_id ), 'and', 'object_id' ); +// $parent_item_id = wp_filter_object_list($menu_items,array('ID'=>$parent_item_id),'and','menu_item_parent'); +// $parent_item_id = array_shift( $parent_item_id ); +// if($parent_item_id=="0"){ +// $parent_post_id = array_shift($parent_post_id); +// return $parent_post_id; +// }else{ +// return checkForParent($parent_item_id,$menu_items); +// } +// } +// if(!empty($parent_item_id)){ +// return checkForParent($parent_item_id,$menu_items); +// }else{ +// return $post_id; +// } +// } ?> diff --git a/lib/menu-walker.php b/lib/menu-walker.php index 0fa3a7c..21d7e29 100644 --- a/lib/menu-walker.php +++ b/lib/menu-walker.php @@ -5,14 +5,14 @@ if ( ! class_exists( 'Glm_Theme_Top_Bar_Walker' ) ) : class Glm_Theme_Top_Bar_Walker extends Walker_Nav_Menu { function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) { - static $mainLevelCounter = 0; + static $mainLevelCounter; if ($depth == 0) { ++$mainLevelCounter; } $element->has_children = ! empty( $children_elements[ $element->ID ] ); $element->classes[] = ( $element->current || $element->current_item_ancestor ) ? 'active' : ''; $element->classes[] = ( $element->has_children && 1 !== $max_depth ) ? 'has-dropdown' : ''; - $element->classes[] = ( $element->post_parent == 0 && ($mainLevelCounter == 6 || $mainLevelCounter == 5 )) ? 'drop-left' : ''; + $element->classes[] = ( $depth == 0 && $mainLevelCounter < 5 ) ? '' : 'drop-left'; parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); }