Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#32699 closed defect (bug) (fixed)

Menus Administration screen, notice error when adding an item

Reported by: imath's profile imath Owned by: obenland's profile obenland
Milestone: 4.3 Priority: normal
Severity: normal Version: 4.3
Component: Menus Keywords: has-patch
Focuses: Cc:

Description

When not using the customizer to set a nav menu, adding a new menu item is generating this notice error :
Notice: Undefined index: menu in pathto\wp-admin\includes\ajax-actions.php on line 1137

That's because in /wp-admin/js/nav-menu.js the function addItemToMenu tries to get the #menu ID that is not existing if there is less than one menu to edit. In this case the select box to select a menu to edit is not displayed.

In other words, if you have this select box (more than 1 nav menu) :
https://cldup.com/RPT2CdjqP9.png
There is no notice error.

But if you have no nav menu or only one, this select box doesn't appear and you only have this :
https://cldup.com/uAFCtb-JBS.png
In this case you get the notice error

Before 4.3 dev cycle, there was a #menu ID in an hidden field of the form#update-nav-menu. I guess it has been removed due to duplicate ids as soon as the select box appears.

Using the attached patch seems to fix the issue.

Attachments (2)

32699.patch (809 bytes) - added by imath 9 years ago.
32699.2.patch (546 bytes) - added by metodiew 9 years ago.

Download all attachments as: .zip

Change History (10)

@imath
9 years ago

#1 @ocean90
9 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 4.3

Related: #31816, [32695].

@metodiew
9 years ago

#2 @metodiew
9 years ago

I still have the notice when I applied the patch. Wouldn't be easier if we update $_POST['menu'] with $_POST['menu-item']? This patch fixed the notice for me.

This ticket was mentioned in Slack in #core by metodiew. View the logs.


9 years ago

#4 @obenland
9 years ago

  • Owner set to ocean90
  • Status changed from new to assigned

#5 @obenland
9 years ago

  • Owner changed from ocean90 to obenland

#6 @obenland
9 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 33161:

Nav menus: Restore menu id in hidden input.

wp-admin/js/nav-menu.js uses the value as context for quick searches and when
adding menu items.

Reverts [32695], see #31816.
Fixes #32699.

#7 @ocean90
9 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

The label "Select a menu to edit:" is now linked with a hidden input field. We should add a new ID to the select form and use the same ID in the for attribute.

#8 @ocean90
9 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 33174:

Nav menus: Add an ID attribute to the menu select box to link it with the label.

see #31816.
fixes #32699.

Note: See TracTickets for help on using tickets.