Make WordPress Core

Ticket #23022: 23022.3.patch

File 23022.3.patch, 1.2 KB (added by jaredcobb, 7 years ago)

When applied, this causes posts to be assigned a post_status of draft by default when they are untrashed (restored). Also adds a new filter for the post status called wp_untrash_post_status to allow customization of this post status.

  • src/wp-includes/post.php

     
    26482648         */
    26492649        do_action( 'untrash_post', $post_id );
    26502650
    2651         $post_status = get_post_meta($post_id, '_wp_trash_meta_status', true);
     2651        $previous_status = get_post_meta( $post_id, '_wp_trash_meta_status', true );
    26522652
    2653         $post['post_status'] = $post_status;
     2653        /**
     2654         * Filter the `post_status` for a post when it is untrashed (restored).
     2655         *
     2656         * By default, posts that are restored will be assigned a post_status
     2657         * of `draft`. Return the `$previous_status` in order to assign the
     2658         * post status that the post had before it was trashed.
     2659         *
     2660         * @param string $new_status The status for a restored post.
     2661         * @param int    $post_id The post id of the post being restored.
     2662         * @param string $previous_status The status of the post before it was trashed.
     2663         */
     2664        $post['post_status'] = apply_filters( 'wp_untrash_post_status', 'draft', $post_id, $previous_status );
    26542665
    26552666        delete_post_meta($post_id, '_wp_trash_meta_status');
    26562667        delete_post_meta($post_id, '_wp_trash_meta_time');