[wp-trac] [WordPress Trac] #27280: Apply filter for Walker_Nav_Menu_Edit start_el output

WordPress Trac noreply at wordpress.org
Wed Mar 5 16:06:27 UTC 2014


#27280: Apply filter for  Walker_Nav_Menu_Edit start_el output
----------------------------+-----------------------------
 Reporter:  kaptinlin       |      Owner:
     Type:  enhancement     |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Menus           |    Version:  3.8.1
 Severity:  normal          |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 Hi there,

 Can you give a filter for start_el output for Walker_Nav_Menu_Edit() class
 just as you does for Walker_Nav_Menu?

 e.g.
 line 226 of wp-admin/includes/nav-menu.php file in wp 3.8.1

 change the code from
 {{{
 $output .= ob_get_clean();
 }}}

 to

 {{{
 $output .= ob_get_clean();
 $output = apply_filters( 'walker_nav_menu_edit_start_el', $output, $item,
 $depth, $args , $id);
 }}}

 In this way, we can easily add custom settings for the menu item.

 I know we can use custom Menu_Walker_Nav_Menu_Edit override the start_el
 function, and use wp_edit_nav_menu_walker filter to choose the custom
 walker. But, it will only works with one instance.


 {{{
 $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker',
 'Walker_Nav_Menu_Edit', $menu_id );
 }}}


 If multiple plugins try use this filter adding the settings, it will only
 work once.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27280>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list