Make WordPress Core

Ticket #10807: 10807.2.diff

File 10807.2.diff, 2.7 KB (added by ryan, 15 years ago)
  • wp-includes/query.php

     
    20702070                                $q['orderby'] = "$wpdb->posts.post_date ".$q['order'];
    20712071                }
    20722072
     2073                $post_type_cap = $post_type;
     2074
    20732075                if ( 'any' == $post_type ) {
    20742076                        $where .= " AND $wpdb->posts.post_type != 'revision'";
    20752077                } elseif ( ! empty( $post_type ) ) {
    20762078                        $where .= " AND $wpdb->posts.post_type = '$post_type'";
    20772079                } elseif ( $this->is_attachment ) {
    20782080                        $where .= " AND $wpdb->posts.post_type = 'attachment'";
     2081                        $post_type_cap = 'post';
    20792082                } elseif ($this->is_page) {
    20802083                        $where .= " AND $wpdb->posts.post_type = 'page'";
     2084                        $post_type_cap = 'page';
    20812085                } else {
    20822086                        $where .= " AND $wpdb->posts.post_type = 'post'";
    2083                         $post_type = 'post';
     2087                        $post_type_cap = 'post';
    20842088                }
    20852089
    20862090                if ( isset($q['post_status']) && '' != $q['post_status'] ) {
     
    21092113                        }
    21102114
    21112115                        if ( !empty($r_status) ) {
    2112                                 if ( !empty($q['perm'] ) && 'editable' == $q['perm'] && !current_user_can("edit_others_{$post_type}s") )
     2116                                if ( !empty($q['perm'] ) && 'editable' == $q['perm'] && !current_user_can("edit_others_{$post_type_cap}s") )
    21132117                                        $statuswheres[] = "($wpdb->posts.post_author = $user_ID " .  "AND (" . join( ' OR ', $r_status ) . "))";
    21142118                                else
    21152119                                        $statuswheres[] = "(" . join( ' OR ', $r_status ) . ")";
    21162120                        }
    21172121                        if ( !empty($p_status) ) {
    2118                                 if ( !empty($q['perm'] ) && 'readable' == $q['perm'] && !current_user_can("read_private_{$post_type}s") )
     2122                                if ( !empty($q['perm'] ) && 'readable' == $q['perm'] && !current_user_can("read_private_{$post_type_cap}s") )
    21192123                                        $statuswheres[] = "($wpdb->posts.post_author = $user_ID " .  "AND (" . join( ' OR ', $p_status ) . "))";
    21202124                                else
    21212125                                        $statuswheres[] = "(" . join( ' OR ', $p_status ) . ")";
     
    21342138                                $where .= " OR $wpdb->posts.post_status = 'future' OR $wpdb->posts.post_status = 'draft' OR $wpdb->posts.post_status = 'pending'";
    21352139
    21362140                        if ( is_user_logged_in() ) {
    2137                                 $where .= current_user_can( "read_private_{$post_type}s" ) ? " OR $wpdb->posts.post_status = 'private'" : " OR $wpdb->posts.post_author = $user_ID AND $wpdb->posts.post_status = 'private'";
     2141                                $where .= current_user_can( "read_private_{$post_type_cap}s" ) ? " OR $wpdb->posts.post_status = 'private'" : " OR $wpdb->posts.post_author = $user_ID AND $wpdb->posts.post_status = 'private'";
    21382142                        }
    21392143
    21402144                        $where .= ')';
     
    23102314                                }
    23112315                        }
    23122316
    2313                         if ( $this->is_preview && current_user_can( "edit_{$post_type}", $this->posts[0]->ID ) )
     2317                        if ( $this->is_preview && current_user_can( "edit_{$post_type_cap}", $this->posts[0]->ID ) )
    23142318                                $this->posts[0] = apply_filters('the_preview', $this->posts[0]);
    23152319                }
    23162320