Opened 3 years ago

Closed 15 months ago

#14527 closed defect (bug) (fixed)

ajax call for add-menu-item doesnt supprot wp_edit_nav_menu_walker filter

Reported by: wonderslug Owned by: nacin
Priority: normal Milestone: 3.4
Component: Menus Version: 3.0.1
Severity: normal Keywords: has-patch commit
Cc:

Description

The wp_get_nav_menu_to_edit function (wp-admin/includes/nav-menu.php) supports a filter on the wp_edit_nav_menu_walker in order for plugins to pass a different walker class to the menu item admin.

The ajax call (add-menu-item) supporting the creation of a new menu-item that uses this same walker is not supporting the filter.

In order to make it so that both and and existing menu items support are calling the same walker to get the html for menu items this filter need to be added to the ajax.

I am attaching a patch that works.

Attachments (3)

walker_nav_menu_edit-ajax.patch (619 bytes) - added by wonderslug 3 years ago.
Patch
14527.patch (685 bytes) - added by ocean90 17 months ago.
Check if class exists
14527.2.patch (1.2 KB) - added by ocean90 15 months ago.

Download all attachments as: .zip

Change History (9)

  • Keywords has-patch 3.2-early commit added; nav_menu walker removed
  • Milestone changed from Awaiting Review to Future Release
  • Component changed from Administration to Menus
  • Keywords 3.2-early removed
  • Milestone changed from Future Release to 3.4

I just run into this issue.

Check if class exists

-1 implies a permissions issue, 0 is generally used for failures. (Does the code that triggers this ajax know to look for -1/0?)

Normally, we'd probably avoid the class_exists() (and show devs their error), since this is already in a released version, it makes sense to avoid the errors.

A few plugins use the wp_edit_nav_menu_walker filter. How many of them don't load the class they want via Ajax?

./plugins/gantry/widgets/menu.php:51:            add_filter('wp_edit_nav_menu_walker', array("GantryWidgetMenu", "setupWalker"), 1000, 2);
./plugins/gecka-submenu/models/NavMenuHacks.php:10:            add_filter( 'wp_edit_nav_menu_walker', array($this, 'custom_walker') );
./plugins/menu-items-visibility-control/menu-items-visibility.php:26:	add_filter( 'wp_edit_nav_menu_walker', 'boom_nav_menu_edit_custom_walker' );
  • Keywords needs-refresh added

Let's get this in as is. Needs refresh.

  • Keywords needs-refresh removed
  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In [20072]:

Add the wp_edit_nav_menu_walker filter to the ajax request. props wonderslug, ocean90. fixes #14527.

Note: See TracTickets for help on using tickets.