Make WordPress Core

Ticket #27088: 27088.diff

File 27088.diff, 1.7 KB (added by nacin, 11 years ago)
  • src/wp-includes/query.php

     
    29742974
    29752975                // Check post status to determine if post should be displayed.
    29762976                if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) {
     2977                        $display = true;
    29772978                        $status = get_post_status($this->posts[0]);
    29782979                        $post_status_obj = get_post_status_object($status);
    2979                         //$type = get_post_type($this->posts[0]);
    29802980                        if ( !$post_status_obj->public ) {
    29812981                                if ( ! is_user_logged_in() ) {
    29822982                                        // User must be logged in to view unpublished posts.
    2983                                         $this->posts = array();
     2983                                        $display = false;
    29842984                                } else {
    29852985                                        if  ( $post_status_obj->protected ) {
    29862986                                                // User must have edit permissions on the draft to preview.
    29872987                                                if ( ! current_user_can($edit_cap, $this->posts[0]->ID) ) {
    2988                                                         $this->posts = array();
     2988                                                        $display = false;
    29892989                                                } else {
    29902990                                                        $this->is_preview = true;
    29912991                                                        if ( 'future' != $status )
     
    29932993                                                }
    29942994                                        } elseif ( $post_status_obj->private ) {
    29952995                                                if ( ! current_user_can($read_cap, $this->posts[0]->ID) )
    2996                                                         $this->posts = array();
     2996                                                        $display = false;
    29972997                                        } else {
    2998                                                 $this->posts = array();
     2998                                                $display = false;
    29992999                                        }
    30003000                                }
    30013001                        }
    30023002
     3003                        if ( ! apply_filters( 'user_can_view_post', $display, $post_status_obj ) ) {
     3004                                $this->posts = array();
     3005                                // and/or: store the old results in a WP_Query property? could be resurrected on the the_posts filter
     3006                        }
     3007
    30033008                        if ( $this->is_preview && $this->posts && current_user_can( $edit_cap, $this->posts[0]->ID ) )
    30043009                                $this->posts[0] = get_post( apply_filters_ref_array( 'the_preview', array( $this->posts[0], &$this ) ) );
    30053010                }