#27280 closed enhancement (duplicate)
Apply filter for Walker_Nav_Menu_Edit start_el output
Reported by: | kaptinlin | Owned by: | 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)
Change History (13)
#2
@
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
@
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.
@
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:
↓ 11
@
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.
#14
@
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.
#15
@
9 years ago
- Owner set to johnbillion
- Status changed from reopened to reviewing
- Version changed from 3.8.1 to 2.1
#16
@
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.
Related: #18584, #27066.