[wp-trac] [WordPress Trac] #28620: When $depth argument is used in wp_nav_menu last level menu items still have .menu-item-has-children class
WordPress Trac
noreply at wordpress.org
Tue Jun 24 11:04:02 UTC 2014
#28620: When $depth argument is used in wp_nav_menu last level menu items still
have .menu-item-has-children class
---------------------------+-----------------------------
Reporter: slobodanmanic | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Menus | Version: trunk
Severity: normal | Keywords:
Focuses: ui |
---------------------------+-----------------------------
Example:
* Set wp_nav_menu {{{$depth}}} to 3
* A theme has some CSS to indicate submenus (e.g. Twenty Fourteen)
* If last level (as allowed by $depth argument) items still have children,
they will not be shown, but {{{.menu-item-has-children}}} class is still
there
I don't think the class itself is the problem, because the menu item does
have children, they're just not being displayed. It might be good to add a
new class that would help theme developers disable submenu indicator for
menu items in which {{{$depth}}} prevents sub-items to be shown.
Maybe something like this (in nav-menu-template.php):
{{{
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$sub_menu_class = ( $depth + 2 == $args->depth ? 'submenu menu-
last-level-parent' : 'submenu' );
$output .= "\n$indent<ul class=\"$sub_menu_class\">\n";
}
}}}
This would allow {{{.menu-last-level-parent li}}} selector to disable
dropdown indicator, since the indicator is not needed when sub-items are
not shown.
$depth +2 feels hacky to me, but this is by far the easiest way to add the
class. Ideally, class would be added to last level {{{<li>}}} elements,
but I think that would require updates to Walker class.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/28620>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list