[wp-trac] [WordPress Trac] #40872: Add $item argument to start_lvl (nav menu walker)

WordPress Trac noreply at wordpress.org
Wed Jun 28 07:45:41 UTC 2017


#40872: Add $item argument to start_lvl (nav menu walker)
-------------------------------+-----------------------------------
 Reporter:  mireillesan        |       Owner:
     Type:  feature request    |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Menus              |     Version:  4.7.5
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:  javascript, template
-------------------------------+-----------------------------------

Comment (by mireillesan):

 Normally, a custom walker can be like this:

 {{{
 public function start_lvl( &$output, $depth = 0, $args = array() ) {

         if ($this->has_children && $depth >= 1) {
                         $output .= "{$indent}<div class='uk-navbar-
 dropdown'>{$n}";
             $output .= "{$n}{$indent}<ul class='uk-nav uk-navbar-dropdown-
 nav'>{$n}";
         }
                 ...

     }
 }}}



 If we can also use the '''$item''' argument here, I could easily change
 the output.

 {{{
 if ( $this->has_children && $depth >= 1 && in_array( 'uk-columns', (array)
 $item->classes ) ) {
                 $output .= "{$indent}<div class='uk-navbar-dropdown-
 grid'>{$n}";
         ...
         }
 }}}


 I kept the code simply for easy understanding;
 the original code is a bit more complex and not just about a different css
 class name (as the above example).

 Right now, I was able to rely on jquery to unwrap/wrap code as a
 workaround but I prefer to do this inside the custom walker instead.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40872#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list