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

WordPress Trac noreply at wordpress.org
Thu Dec 1 16:22:07 UTC 2016


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

 * keywords:   => needs-patch
 * status:  closed => reopened
 * resolution:  invalid =>
 * milestone:   => Future Release


Comment:

 Nav menus in the customizer can be previewed with selective refresh when
 the `walker` is JSON-serializable per
 https://make.wordpress.org/core/2015/07/29/fast-previewing-changes-to-
 menus-in-the-customizer/

 The logic in `\WP_Customize_Nav_Menus::filter_wp_nav_menu_args()` allows
 selective refresh if `walker` is empty or a class string. If
 `wp_nav_menu()` is called with an instantiated walker object, this cannot
 be JSON-serialized, and so it cannot be selectively refreshed. Therefore,
 a string should be able to be passed in in addition to passing in a pre-
 instantiated object.

 The patch in [attachment:nav-menu-template.diff] isn't quite right. It
 should do this instead:

 {{{#!diff
 - $walker = ( empty($r->walker) ) ? new Walker_Nav_Menu : $r->walker;
 + $walker = $r->walker;
 + if ( is_string( $r->walker ) ) {
 +     $walker = new $walker;
 + }
 }}}

 The phpdoc `@param` also need to be updated.

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


More information about the wp-trac mailing list