Make WordPress Core

Opened 11 years ago

Closed 8 years ago

Last modified 8 years ago

#27280 closed enhancement (duplicate)

Apply filter for Walker_Nav_Menu_Edit start_el output

Reported by: kaptinlin's profile kaptinlin Owned by: johnbillion's profile johnbillion
Milestone: Priority: normal
Severity: normal Version: 2.1
Component: Menus Keywords: has-patch
Focuses: administration Cc:

Description

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.

Attachments (1)

27280.patch (1.2 KB) - added by tyxla 9 years ago.
Introducing a walker_nav_menu_edit_start_el filter to allow filtering the HTML of the admin menu items in the start_el() of the default walker Walker_Nav_Menu_Edit.

Download all attachments as: .zip

Change History (13)

#2 @chriscct7
9 years ago

  • Keywords needs-patch added
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Closing as wontfix. Complete lack of interest on the feature on the ticket over the last 2 years. Feel free to reopen when more interest re-emerges (particularly if there's a patch)

#3 @tyxla
9 years ago

  • Resolution wontfix deleted
  • Status changed from closed to reopened

I need this since 2011, and i guess this ticket has been slipping through my fingers so far.

It is often necessary to modify the admin menu item forms.

The current solution is to use a custom admin walker, which does not always work nicely, and is often not compatible with plugins. A filter hook would work much better in most cases, so we really should get this into the core.

With a filter anyone would be able to insert any custom fields anywhere in the admin menu item form.

@tyxla
9 years ago

Introducing a walker_nav_menu_edit_start_el filter to allow filtering the HTML of the admin menu items in the start_el() of the default walker Walker_Nav_Menu_Edit.

#4 follow-up: @tyxla
9 years ago

  • Keywords has-patch added; needs-patch removed

Let's get this into the core, I would love to see it in 4.4.

#7 @dilirity
9 years ago

It would be great if this is added to the core!

#11 in reply to: ↑ 4 @m1r0
9 years ago

This is a good idea. Hate those custom walkers...

#14 @chriscct7
9 years ago

  • Milestone set to Future Release

The enhancement patch window closed last week with the launch of beta 1 (https://make.wordpress.org/core/version-4-4-project-schedule/). Also please do not comment with "+1"'s per the Trac forum policy. They don't add anything to the conversation and just serve to clutter things up. The next milestone this could be considered for would be 4.5.

Version 0, edited 9 years ago by chriscct7 (next)

#15 @johnbillion
9 years ago

  • Owner set to johnbillion
  • Status changed from reopened to reviewing
  • Version changed from 3.8.1 to 2.1

#16 @entr
9 years ago

I don't know how useful a filter would be in this situation. Filtering an already generated html is not ideal. A set of actions on the other hand will be really handy. I suppose most of the developers would like just to introduce custom options in the .menu-item-settings section. We could go even further and refactor how .menu-item-settings is generated using just a single action for the whole section and prioritized bindings for every .description in it. Then adding custom menu settings or removing built-in ones would be a breeze.

#17 @grapplerulrich
8 years ago

  • Resolution set to duplicate
  • Status changed from reviewing to closed

Duplicate of #18584.

#18 @swissspidy
8 years ago

  • Milestone Future Release deleted

#19 @timersys
8 years ago

I see a cleaner way in #38904 . Adding a couple more filters should cover most user cases.

Note: See TracTickets for help on using tickets.