Ticket #27113: 27113.2.diff
| File 27113.2.diff, 1.2 KB (added by , 12 years ago) |
|---|
-
src/wp-includes/nav-menu.php
357 357 358 358 $update = 0 != $menu_item_db_id; 359 359 360 // Only set the menu term if it isn't set to avoid unnecessary wp_get_object_terms()361 if ( $menu_id && ( ! $update || ! is_object_in_term( $menu_item_db_id, 'nav_menu', (int) $menu->term_id ) ) )362 $post['tax_input'] = array( 'nav_menu' => array( intval( $menu->term_id ) ) );363 364 360 // New menu item. Default is draft status 365 361 if ( ! $update ) { 366 362 $post['ID'] = 0; … … 368 364 $menu_item_db_id = wp_insert_post( $post ); 369 365 if ( ! $menu_item_db_id || is_wp_error( $menu_item_db_id ) ) 370 366 return $menu_item_db_id; 367 371 368 } 372 369 370 // Associate the menu item with the menu term 371 if ( $menu_id && ( ! $update || ! is_object_in_term( $menu_item_db_id, 'nav_menu', (int) $menu->term_id ) ) ) { 372 wp_set_object_terms( $menu_item_db_id, array( $menu->term_id ), 'nav_menu' ); 373 } 374 373 375 if ( 'custom' == $args['menu-item-type'] ) { 374 376 $args['menu-item-object-id'] = $menu_item_db_id; 375 377 $args['menu-item-object'] = 'custom';