Opened 21 months ago
Last modified 5 weeks ago
#18584 new enhancement
Nav menu UI needs more hooks
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 3.6 |
| Component: | Menus | Version: | 3.3 |
| Severity: | minor | Keywords: | has-patch needs-testing |
| Cc: | marko@…, sirzooro, info@…, xoodrew@…, helgatheviking@…, frederic.demarle@…, pippin@…, justin@… |
Description
I'm trying to add some additional fields to the nav menu blocks but sadly there are no hooks for doing so. Zero.
We should add some and get in a better habit of just doing so when the code is written.
My specific suggestions are before the Remove/Cancel links (i.e. for adding standard stuff), one above the "original" field, and one after those action links (to add more actions).
Attachments (2)
Change History (22)
comment:2
markoheijnen — 21 months ago
- Cc marko@… added
comment:4
Viper007Bond — 19 months ago
This is the plugin I was working on and my use case:
http://wordpress.org/extend/plugins/add-descendants-as-submenu-items/
comment:7
helgatheviking — 3 months ago
- Cc helgatheviking@… added
I need this hook for my plugin as well:
http://wordpress.org/extend/plugins/nav-menu-roles/
Right now a user cannot use my plugin in conjunction with @Viper007Bond's because we're both required to use a custom walker instead of simply adding our fields to a hook.
comment:8
DrewAPicture — 3 months ago
- Cc xoodrew@… added
DrewAPicture — 3 months ago
comment:9
DrewAPicture — 3 months ago
- Keywords 3.6-menus added
- Milestone changed from Awaiting Review to 3.6
18584.diff removes the filter (handled in ticket:16738:16738.3.diff) and also adds a couple of actions to the overall menu editor.
Lets see if we can't get some of these in, especially in light of the 3.6-menus refresh.
comment:10
helen — 3 months ago
Nacin noted that issues like #14134 stand in the way of making adding more fields a really good idea.
comment:11
DrewAPicture — 3 months ago
The menu item link attributes filter proposed in the first patch was added in [23565].
comment:12
SergeyBiryukov — 3 months ago
#21898 was marked as a duplicate.
comment:13
Chouby — 3 months ago
- Cc frederic.demarle@… added
comment:14
Chouby — 3 months ago
The proposed filters are great to add some new custom fields but they don't permit to create fully customized menu items.
What I would like to do is to create a group of menu items, more or less the way done by Viper007Bond in his plugin (one "group" item on backend, several items on frontend). In his case keeping the existing navigation label, title attribute and so on makes sense because the plugin has one and only one top level item. But if we want a plugin beeing able to create a group of several top level items, these fields do not make sense anymore.
So we should be able to completely customize the output of the walker (I know it is already possible by deriving a new class, but as mentionned by helgatheviking it leads to plugin conflicts).
So the easiest way I can propose is to filter the whole output at the end of the start_el function with something like:
$output .= ob_get_clean();
$output = apply_filters('walker_nav_menu_edit', $output, $item, $depth, $args);
comment:15
DrewAPicture — 3 months ago
- Keywords 3.6-menus removed
comment:16
DrewAPicture — 2 months ago
#23741 was marked as a duplicate.
comment:17
DrewAPicture — 2 months ago
@Chouby's proposed hooks for back-compat-ish with the locations settings from #23741: ticket:23741:23741.diff
comment:18
mordauk — 7 weeks ago
- Cc pippin@… added
comment:19
helgatheviking — 7 weeks ago
Is this going to make it into 3.6?
comment:20
greenshady — 5 weeks ago
- Cc justin@… added

Related: #18527, #16738, #14414, #16691