Ticket #13822: generalize-object-change-logic.2.diff
File generalize-object-change-logic.2.diff, 1.1 KB (added by , 14 years ago) |
---|
-
wp-includes/nav-menu.php
780 780 781 781 // give menu items draft status if their associated post objects change from "publish" to "draft", or vice versa (draft item being re-published) 782 782 if ( 783 ! empty( $post->ID) &&784 ( 785 ( 'publish' == $old_status && 'draft' == $new_status ) ||786 ( 'draft' == $old_status && 'publish' == $new_status )787 )783 ( 'trash' != $new_status ) && 784 ( $new_status != $old_status ) && 785 ! empty( $post->ID ) && ! empty( $post->post_type ) && 786 'nav_menu_item' != $post->post_type && 787 ( 'publish' == $old_status || 'publish' == $new_status ) 788 788 ) { 789 789 $menu_items = get_posts(array( 790 790 'meta_key' => '_menu_item_object_id', … … 796 796 foreach( (array) $menu_items as $menu_item ) { 797 797 if ( ! empty( $menu_item->ID ) ) { 798 798 $properties = get_object_vars( $menu_item ); 799 $properties['post_status'] = $new_status;799 $properties['post_status'] = 'publish' == $new_status ? 'publish' : 'draft'; 800 800 801 801 wp_insert_post( $properties ); 802 802 }