WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 6 months ago

#34657 new defect (bug)

WordPress doesn't set object terms for menu items so pending items not working

Reported by: rss_samuel Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.3.1
Component: Menus Keywords: dev-feedback has-patch reporter-feedback
Focuses: administration Cc:
PR Number:

Description (last modified by SergeyBiryukov)

When I create menu items and refresh admin page without saving menu, wordpress can not show pending menu items.

At line 1127 of 'wp-admin/includes/ajax-functions.php' file there is wp_save_nav_menu_items function, the first argument for this function is always zero, so At line 441 of 'wp-includes/nav-menu.php' file wp_set_object_terms function doesn't work.

I add my menu id to

$item_ids = wp_save_nav_menu_items( 97, $menu_items_data );

function, and it working for me. :)

Attachments (1)

34657.patch (1.2 KB) - added by rss_samuel 3 years ago.
I change /wp-admin/includes/ajax-actions.php file.

Download all attachments as: .zip

Change History (6)

#1 @SergeyBiryukov
4 years ago

  • Description modified (diff)
  • Summary changed from Wordpress doesn't set object terms for menu items so pending items not working to WordPress doesn't set object terms for menu items so pending items not working

#2 @welcher
3 years ago

Hi!

Thanks for the ticket! It looks like you have an idea of how to address this - did you want to submit a patch?

#3 @welcher
3 years ago

  • Keywords needs-patch added

@rss_samuel
3 years ago

I change /wp-admin/includes/ajax-actions.php file.

#4 @rss_samuel
3 years ago

After changes it works for me.
https://i.imgsafe.org/3ee6fa389a.png

#5 @welcher
3 years ago

  • Keywords dev-feedback has-patch reporter-feedback added; needs-patch removed

Thanks for the patch!

Just one thing - I'm not sure we should be dying if $_POST['menu'] is not set. That block is meant to check whether the user has the capability to do this and it shouldn't ( in my opinion ) care if that item is set.

If we're just wanting to be sure that there is a value passed to the wp_save_nav_menu_items it might be a good idea to use a ternary instead.

i.e $menu_id = ( isset( $_POST['menu'] ) ) ? absint( $_POST['menu'] ) : 0;

Last edited 3 years ago by welcher (previous) (diff)
Note: See TracTickets for help on using tickets.