WordPress.org

Make WordPress Core

Ticket #8592: 8592-post.php.diff

File 8592-post.php.diff, 974 bytes (added by mtekk, 10 years ago)
  • post.php

     
    22392239        if ( $parent >= 0 )
    22402240                $where .= $wpdb->prepare(' AND post_parent = %d ', $parent);
    22412241
    2242         $query = "SELECT * FROM $wpdb->posts $join WHERE (post_type = 'page' AND post_status = 'publish') $where ";
    2243         $query .= $author_query;
     2242        $query = "SELECT * FROM $wpdb->posts $join WHERE (post_type = 'page'";
     2243        $where .= " AND (post_status = 'publish'";
     2244        if ( is_admin() )
     2245                $where .= " OR post_status = 'future' OR post_status = 'draft' OR post_status = 'pending'";
     2246        if ( is_user_logged_in() ) {
     2247                $where .= current_user_can( "read_private_pages" ) ? " OR post_status = 'private'" : " OR post_author = $user_ID AND post_status = 'private'";
     2248        }
     2249        $where .= ')';
     2250               
     2251        $query .= " $where )" . $author_query;
    22442252        $query .= " ORDER BY " . $sort_column . " " . $sort_order ;
    22452253
    22462254        $pages = $wpdb->get_results($query);