Ticket #11235: 11235.post.php.patch
File 11235.post.php.patch, 2.3 KB (added by , 8 years ago) |
---|
-
src/wp-includes/post.php
5741 5741 if ( '' == get_the_guid($post->ID) ) 5742 5742 $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) ); 5743 5743 5744 if( is_post_type_hierarchical( $post->post_type ) ) { 5745 $child_posts = get_posts( array( 'meta_key' => '_wp_post_parent_fallback', 'meta_value' => $post->ID, 'post_type' => $post->post_type ) ); 5746 if( 0 < count( $child_posts ) ) { 5747 array_map( 'wp_update_post', array_map( '__restore_post_parent', $child_posts ) ); 5748 } 5749 } 5750 5744 5751 /** 5745 5752 * Fires when a post's status is transitioned from private to published. 5746 5753 * … … 5750 5757 * @param int $post_id Post ID. 5751 5758 */ 5752 5759 do_action('private_to_published', $post->ID); 5760 } elseif( 'publish' !== $new_status && 'publish' === $old_status && is_post_type_hierarchical( $post->post_type ) ) { 5761 $child_posts = get_posts( array( 'post_parent' => $post->ID, 'post_status' => 'any', 'post_type' => $post->post_type ) ); 5762 if( 0 < count( $child_posts ) ) { 5763 array_map( 'wp_update_post', array_map( '__unset_post_parent', $child_posts ) ); 5764 } 5753 5765 } 5754 5766 5755 5767 // If published posts changed clear the lastpostmodified cache. … … 5771 5783 } 5772 5784 5773 5785 /** 5786 * Function to set post parent to none. 5787 * 5788 * @param WP_Post $post Post object. 5789 * 5790 * @return WP_Post $post Modified post object. 5791 */ 5792 function __unset_post_parent( $post ) { 5793 update_post_meta( $post->ID, '_wp_post_parent_fallback', $post->post_parent ); 5794 $post->post_parent = 0; 5795 5796 return apply_filters( 'wp_unset_post_parent', $post ); 5797 } 5798 5799 /** 5800 * Function to reset post parent to prev. 5801 * 5802 * @param WP_Post $post Post object. 5803 * 5804 * @return WP_Post $post Modified post object. 5805 */ 5806 function __restore_post_parent( $post ) { 5807 $post->post_parent = get_post_meta( $post->ID, '_wp_post_parent_fallback', true ); 5808 delete_post_meta( $post->ID, '_wp_post_parent_fallback' ); 5809 5810 return apply_filters( 'wp_restore_post_parent', $post ); 5811 } 5812 5813 /** 5774 5814 * Hook used to schedule publication for a post marked for the future. 5775 5815 * 5776 5816 * The $post properties used and must exist are 'ID' and 'post_date_gmt'.