Correctly associate new menu items with a menu when using wp_update_nav_menu_item()

wp_update_nav_menu_item() must pass tax_input to wp_insert_post() when creating items
otherwise the menu-item relationship isn't made.

See #22189.


git-svn-id: http://core.svn.wordpress.org/trunk@22399 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Jon Cave 2012-11-06 14:46:56 +00:00
parent 86d88f8b2d
commit ae96b842f9
1 changed files with 4 additions and 3 deletions

View File

@ -347,11 +347,12 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item
'post_type' => 'nav_menu_item',
);
if ( $menu_id && ! is_object_in_term( $menu_item_db_id, 'nav_menu', (int) $menu->term_id ) )
$post['tax_input'] = array( 'nav_menu' => array( intval( $menu->term_id ) ) );
$update = 0 != $menu_item_db_id;
// Only set the menu term if it isn't set to avoid unnecessary wp_get_object_terms()
if ( $menu_id && ( ! $update || ! is_object_in_term( $menu_item_db_id, 'nav_menu', (int) $menu->term_id ) ) )
$post['tax_input'] = array( 'nav_menu' => array( intval( $menu->term_id ) ) );
// New menu item. Default is draft status
if ( ! $update ) {
$post['ID'] = 0;