Make WordPress Core

Ticket #11235: 11235.post.php.patch

File 11235.post.php.patch, 2.3 KB (added by muxahuk1214, 8 years ago)
  • src/wp-includes/post.php

     
    57415741                if ( '' == get_the_guid($post->ID) )
    57425742                        $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) );
    57435743
     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
    57445751                /**
    57455752                 * Fires when a post's status is transitioned from private to published.
    57465753                 *
     
    57505757                 * @param int $post_id Post ID.
    57515758                 */
    57525759                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                }
    57535765        }
    57545766
    57555767        // If published posts changed clear the lastpostmodified cache.
     
    57715783}
    57725784
    57735785/**
     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 */
     5792function __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 */
     5806function __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/**
    57745814 * Hook used to schedule publication for a post marked for the future.
    57755815 *
    57765816 * The $post properties used and must exist are 'ID' and 'post_date_gmt'.