Make WordPress Core

Ticket #33306: only query logged in users if member of site.diff

File only query logged in users if member of site.diff, 1.5 KB (added by sboisvert, 10 years ago)
  • wp-includes/query.php

     
    30463046                       if ( is_user_logged_in() ) {
    30473047                               // Add private states that are limited to viewing by the author of a post or someone who has caps to read private states.
    30483048                               $private_states = get_post_stati( array('private' => true) );
    3049                                foreach ( (array) $private_states as $state )
    3050                                        $where .= current_user_can( $read_private_cap ) ? " OR $wpdb->posts.post_status = '$state'" : " OR $wpdb->posts.post_author = $user_id AND $wpdb->posts.post_status = '$state'";
    3051                        }
     3049                                foreach ( (array) $private_states as $state ) {
     3050                                        if ( current_user_can( $read_private_cap ) ) {
     3051                                                $where .= " OR $wpdb->posts.post_status = '$state'";
     3052                                        } else if ( ! is_multisite() || ( is_multisite() && is_user_member_of_blog() ) ) {
     3053                                                $where .= " OR $wpdb->posts.post_author = $user_id AND $wpdb->posts.post_status = '$state'";
     3054                                        }
     3055                                }
    30523056
    30533057                       $where .= ')';
    30543058               }