Changeset 16105
- Timestamp:
- 10/30/2010 10:41:52 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r16104 r16105 747 747 // The following is a hacky way to restore them when adding non-custom items. 748 748 749 $menu_items_data = (array) $_POST['menu-item']; 750 $menu_item_data = array_shift( $menu_items_data ); 751 if ( 752 ! empty( $menu_item_data['menu-item-type'] ) && 753 'custom' != $menu_item_data['menu-item-type'] && 754 ! empty( $menu_item_data['menu-item-object-id'] ) 755 ) { 756 switch( $menu_item_data['menu-item-type'] ) { 757 case 'post_type' : 758 $_object = get_post( $menu_item_data['menu-item-object-id'] ); 759 break; 760 761 case 'taxonomy' : 762 $_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] ); 763 break; 764 } 765 766 $_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) ); 767 $_menu_item = array_shift( $_menu_items ); 768 769 // Restore the missing menu item properties 770 $menu_item_data['menu-item-description'] = $_menu_item->description; 771 } 772 773 $menu_items_data = array( $menu_item_data ); 749 $menu_items_data = array(); 750 foreach ( (array) $_POST['menu-item'] as $menu_item_data ) { 751 if ( 752 ! empty( $menu_item_data['menu-item-type'] ) && 753 'custom' != $menu_item_data['menu-item-type'] && 754 ! empty( $menu_item_data['menu-item-object-id'] ) 755 ) { 756 switch( $menu_item_data['menu-item-type'] ) { 757 case 'post_type' : 758 $_object = get_post( $menu_item_data['menu-item-object-id'] ); 759 break; 760 761 case 'taxonomy' : 762 $_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] ); 763 break; 764 } 765 766 $_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) ); 767 $_menu_item = array_shift( $_menu_items ); 768 769 // Restore the missing menu item properties 770 $menu_item_data['menu-item-description'] = $_menu_item->description; 771 } 772 773 $menu_items_data[] = $menu_item_data; 774 } 774 775 775 776 $item_ids = wp_save_nav_menu_items( 0, $menu_items_data );
Note: See TracChangeset
for help on using the changeset viewer.