Opened 21 months ago

Last modified 5 weeks ago

#18584 new enhancement

Nav menu UI needs more hooks

Reported by: Viper007Bond 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)

nav_menu.diff (2.2 KB) - added by ddean 21 months ago.
nav menu hooks proposal
18584.diff (2.0 KB) - added by DrewAPicture 3 months ago.

Download all attachments as: .zip

Change History (22)

  • Cc marko@… added

ddean21 months ago

nav menu hooks proposal

  • Cc sirzooro added

This is the plugin I was working on and my use case:

http://wordpress.org/extend/plugins/add-descendants-as-submenu-items/

Last edited 20 months ago by Viper007Bond (previous) (diff)
  • Keywords has-patch needs-testing added; needs-patch removed
  • Cc info@… added
  • 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.

  • Cc xoodrew@… added
  • 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.

Version 0, edited 3 months ago by DrewAPicture (next)

Nacin noted that issues like #14134 stand in the way of making adding more fields a really good idea.

The menu item link attributes filter proposed in the first patch was added in [23565].

#21898 was marked as a duplicate.

  • Cc frederic.demarle@… added

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);
  • Keywords 3.6-menus removed

#23741 was marked as a duplicate.

@Chouby's proposed hooks for back-compat-ish with the locations settings from #23741: ticket:23741:23741.diff

  • Cc pippin@… added

Is this going to make it into 3.6?

  • Cc justin@… added
Note: See TracTickets for help on using tickets.