Menu-walker code for woo dropdown cleaned up
authorLaury GvR <laury@gaslightmedia.com>
Mon, 4 Feb 2019 22:18:18 +0000 (17:18 -0500)
committerLaury GvR <laury@gaslightmedia.com>
Mon, 4 Feb 2019 22:18:18 +0000 (17:18 -0500)
lib/menu-walker.php

index f09cc01..d2a1a6f 100644 (file)
@@ -22,7 +22,7 @@ class Glm_Theme_Top_Bar_Walker extends Walker_Nav_Menu {
         $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 < 3 ) ? '' : 'drop-left';
+        $element->classes[] = ( $element->post_parent == 0 && $mainLevelCounter <= 3 ) ? '' : 'drop-left';
         $element->classes[] = ( $element->object_id == get_option( 'woocommerce_shop_page_id' )) ? 'menu-item-has-children has-dropdown glm-woocommerce-dropdown' : '';
         parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );    
     }
@@ -30,10 +30,8 @@ class Glm_Theme_Top_Bar_Walker extends Walker_Nav_Menu {
     function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {
         $item_html = '';
         parent::start_el( $item_html, $object, $depth, $args );
-         
-        // Insert style to display page's thumbnail
-        //$element->classes[] = $object->object_id;
 
+        // Insert woocommerce dropdown
         if ((int)$object->object_id == get_option( 'woocommerce_shop_page_id' )) {
             global $woocommerce;
             $wooCategories = do_shortcode('[product_categories number="" orderby="name" order="asc" columns="1" hide_empty="0" parent="0" ids=""]');