[wp-trac] [WordPress Trac] #14142: Custom Walker class for navigation menus

WordPress Trac noreply at wordpress.org
Fri Apr 19 18:31:41 UTC 2019

#14142: Custom Walker class for navigation menus
 Reporter:  dennis.winter  |       Owner:  (none)
     Type:  defect (bug)   |      Status:  reopened
 Priority:  normal         |   Milestone:  Future Release
Component:  Menus          |     Version:  3.0
 Severity:  normal         |  Resolution:
 Keywords:  needs-patch    |     Focuses:

Comment (by saas):

 Custom walker won't be to utilize "Partial Refresh", if walker object is

 So after reading reviewing

 I passed "Walker Class name as string" and it didn't worked either, was

 PHP Fatal error:  Using $this when not in object context

 Then I saw this post

 And in combination with passing walker as string and applying this filter
 solves my issue.

 So patching this function

 function walk_nav_menu_tree( $items, $depth, $r ) {

   $walker = $r->walker;
   if ( ! empty( $r->walker ) && is_string( $r->walker ) ) {
       $walker = new $walker;
   } else {
       $walker = new Walker_Nav_Menu;

   $args   = array( $items, $depth, $r );

   return call_user_func_array( array( $walker, 'walk' ), $args );

 solves the issue.

Ticket URL: <https://core.trac.wordpress.org/ticket/14142#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list