When querying for a specific post, allow posts with a non-public status to be returned as long as that status is specified.
This makes it possible to, for example, retrieve a specific post using the `p` parameter of `WP_Query`, even if the post is in the Trash, by including the `post_status=trash` parameter. Props ebinnion. Fixes #29167. Built from https://develop.svn.wordpress.org/trunk@31321 git-svn-id: http://core.svn.wordpress.org/trunk@31302 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a82763b7b6
commit
55dafd966b
|
@ -2963,6 +2963,7 @@ class WP_Query {
|
|||
|
||||
$user_id = get_current_user_id();
|
||||
|
||||
$q_status = array();
|
||||
if ( ! empty( $q['post_status'] ) ) {
|
||||
$statuswheres = array();
|
||||
$q_status = $q['post_status'];
|
||||
|
@ -3527,7 +3528,10 @@ class WP_Query {
|
|||
$status = get_post_status($this->posts[0]);
|
||||
$post_status_obj = get_post_status_object($status);
|
||||
//$type = get_post_type($this->posts[0]);
|
||||
if ( !$post_status_obj->public ) {
|
||||
|
||||
// If the post_status was specifically requested, let it pass through.
|
||||
if ( !$post_status_obj->public && ! in_array( $status, $q_status ) ) {
|
||||
|
||||
if ( ! is_user_logged_in() ) {
|
||||
// User must be logged in to view unpublished posts.
|
||||
$this->posts = array();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.2-alpha-31320';
|
||||
$wp_version = '4.2-alpha-31321';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue