Changeset 15249
- Timestamp:
- 06/14/2010 08:33:48 AM (15 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/default-filters.php
r15219 r15249 232 232 233 233 // Navigation menu actions 234 add_action( 'trash_post', '_wp_trash_menu_item' );235 add_action( 'untrash_post', '_wp_untrash_menu_item' );236 234 add_action( 'delete_post', '_wp_delete_post_menu_item' ); 237 235 add_action( 'delete_term', '_wp_delete_tax_menu_item' ); -
trunk/wp-includes/nav-menu.php
r15235 r15249 312 312 $original_parent = (int) $original_object->post_parent; 313 313 $original_title = $original_object->post_title; 314 315 if ( 'trash' == get_post_status( $args['menu-item-object-id'] ) )316 return new WP_Error('update_nav_menu_item_failed', sprintf(__('The menu item "%1$s" belongs to something that is in the trash, so it cannot be updated.'), $args['menu-item-title'] ) );317 314 } 318 315 … … 653 650 654 651 return array_unique( $menu_item_ids ); 655 }656 657 /**658 * Callback for handling a menu item when its original object is trashed.659 *660 * @since 3.0.0661 * @access private662 *663 * @param int $object_id The ID of the original object being trashed.664 *665 */666 function _wp_trash_menu_item( $object_id = 0 ) {667 $object_id = (int) $object_id;668 669 $menu_item_ids = wp_get_associated_nav_menu_items( $object_id );670 671 foreach( (array) $menu_item_ids as $menu_item_id ) {672 $menu_item = get_post( $menu_item_id, ARRAY_A );673 $menu_item['post_status'] = 'pending';674 wp_insert_post($menu_item);675 }676 }677 678 /**679 * Callback for handling a menu item when its original object is un-trashed.680 *681 * @since 3.0.0682 * @access private683 *684 * @param int $object_id The ID of the original object being untrashed.685 *686 */687 function _wp_untrash_menu_item( $object_id = 0 ) {688 $object_id = (int) $object_id;689 690 $menu_item_ids = wp_get_associated_nav_menu_items( $object_id );691 692 foreach( (array) $menu_item_ids as $menu_item_id ) {693 $menu_item = get_post( $menu_item_id, ARRAY_A );694 $menu_item['post_status'] = 'publish';695 wp_insert_post($menu_item);696 }697 652 } 698 653 … … 781 736 // give menu items draft status if their associated post objects change from "publish" to "draft", or vice versa (draft item being re-published) 782 737 if ( 783 ! empty( $post->ID ) && 784 ( 785 ( 'publish' == $old_status && 'draft' == $new_status ) || 786 ( 'draft' == $old_status && 'publish' == $new_status ) 787 ) 738 ( $new_status != $old_status ) && 739 ! empty( $post->ID ) && ! empty( $post->post_type ) && 740 'nav_menu_item' != $post->post_type && 741 ( 'publish' == $old_status || 'publish' == $new_status ) 788 742 ) { 789 743 $menu_items = get_posts(array( … … 797 751 if ( ! empty( $menu_item->ID ) ) { 798 752 $properties = get_object_vars( $menu_item ); 799 $properties['post_status'] = $new_status;753 $properties['post_status'] = 'publish' == $new_status ? 'publish' : 'draft'; 800 754 801 755 wp_insert_post( $properties );
Note: See TracChangeset
for help on using the changeset viewer.