Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Navbar items break if the menu depth is set to exclude children #707

Merged
merged 1 commit into from

3 participants

@kara-todd

Navbar items with children broke if the menu depth excluded the children.
Such as: wp_nav_menu(array('depth' => 1)); where 2nd level children exist

@kara-todd kara-todd Fix for navbar dropdowns
Navbar items with children broke if the menu depth excluded the children.
Such as: wp_nav_menu(array('depth' => 1)) where 2nd level children exist
3025797
@retlehs
Owner

trying to create the issue on my dev environment - i set the wp_nav_menu depth to 1 and have a menu that has several items with children + more children, but can't see any issue occurring

could you show me how to reproduce the problem?

@Foxaii
Collaborator

This is a good spot.

With depth set less than three, the nav will still be there but you get all the drop down menu markup (classes and carets) even when the children are being excluded and there's nothing to drop down to. This means you would have to lose the menu hierarchy if you only wanted only top level links.

If the logic seems off, $depth + 1 is to account for Roots treating walker depth as zero-based, whereas WordPress treats 1 as the index.

@retlehs retlehs merged commit c3e7861 into from
@retlehs
Owner

ahhh. thx @kara-todd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 8, 2013
  1. @kara-todd

    Fix for navbar dropdowns

    kara-todd authored
    Navbar items with children broke if the menu depth excluded the children.
    Such as: wp_nav_menu(array('depth' => 1)) where 2nd level children exist
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/nav.php
View
2  lib/nav.php
@@ -38,7 +38,7 @@ function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
}
function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output) {
- $element->is_dropdown = !empty($children_elements[$element->ID]);
+ $element->is_dropdown = ((!empty($children_elements[$element->ID]) && (($depth + 1) < $max_depth)));
if ($element->is_dropdown) {
if ($depth === 0) {
Something went wrong with that request. Please try again.