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 | Owned by: | 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) :
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 :
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)
Change History (10)
#2
@
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.
Related: #31816, [32695].