Skip to content
This repository has been archived by the owner on Feb 10, 2020. It is now read-only.

Arrow near items with children showed even if depth=1 #12

Open
globdug opened this issue Nov 28, 2019 · 0 comments
Open

Arrow near items with children showed even if depth=1 #12

globdug opened this issue Nov 28, 2019 · 0 comments

Comments

@globdug
Copy link

globdug commented Nov 28, 2019

Hello,
I tried to set depth=1 when I call wp_nav_menu.
The elements that have childrens, do not open the dropdown menu has expected, but the arrow near the item it is showed anyway.

I added this checks in function start_el .

Could this be a solution?

Here:

if ( $args->walker->has_children ) {
$classes[] = 'dropdown';
}
if ( 0 < $depth ) {
$classes[] = 'dropdown-menu';
}

if( $args->depth !== 1 ):
  if ( $args->walker->has_children ) {
    $classes[] = 'dropdown';
  }
  if ( 0 < $depth ) {
    $classes[] = 'dropdown-menu';
  }
endif;

Here:

if ( $args->walker->has_children ) {

if ( $args->walker->has_children && $args->depth!==1 ) {

And here:

if ( $args->walker->has_children ) {
$item_classes[] = 'dropdown-toggle';
}
if ( 0 < $depth ) {
$item_classes = array_diff( $item_classes, [ 'nav-link' ] );
$item_classes[] = 'dropdown-item';
}

if( $args->depth !== 1 ):
  if ( $args->walker->has_children ) {
    $item_classes[] = 'dropdown-toggle';
  }
  if ( 0 < $depth ) {
    $item_classes = array_diff( $item_classes, [ 'nav-link' ] );
    $item_classes[] = 'dropdown-item';
  }
endif;
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant