Ticket #10807: 10807.3.diff
File 10807.3.diff, 3.5 KB (added by , 15 years ago) |
---|
-
wp-includes/query.php
2070 2070 $q['orderby'] = "$wpdb->posts.post_date ".$q['order']; 2071 2071 } 2072 2072 2073 $post_type_cap = $post_type; 2074 2073 2075 if ( 'any' == $post_type ) { 2074 2076 $where .= " AND $wpdb->posts.post_type != 'revision'"; 2075 2077 } elseif ( ! empty( $post_type ) ) { 2076 2078 $where .= " AND $wpdb->posts.post_type = '$post_type'"; 2077 2079 } elseif ( $this->is_attachment ) { 2078 2080 $where .= " AND $wpdb->posts.post_type = 'attachment'"; 2081 $post_type_cap = 'post'; 2079 2082 } elseif ($this->is_page) { 2080 2083 $where .= " AND $wpdb->posts.post_type = 'page'"; 2084 $post_type_cap = 'page'; 2081 2085 } else { 2082 2086 $where .= " AND $wpdb->posts.post_type = 'post'"; 2083 $post_type = 'post';2087 $post_type_cap = 'post'; 2084 2088 } 2085 2089 2086 2090 if ( isset($q['post_status']) && '' != $q['post_status'] ) { … … 2109 2113 } 2110 2114 2111 2115 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") ) 2113 2117 $statuswheres[] = "($wpdb->posts.post_author = $user_ID " . "AND (" . join( ' OR ', $r_status ) . "))"; 2114 2118 else 2115 2119 $statuswheres[] = "(" . join( ' OR ', $r_status ) . ")"; 2116 2120 } 2117 2121 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") ) 2119 2123 $statuswheres[] = "($wpdb->posts.post_author = $user_ID " . "AND (" . join( ' OR ', $p_status ) . "))"; 2120 2124 else 2121 2125 $statuswheres[] = "(" . join( ' OR ', $p_status ) . ")"; … … 2134 2138 $where .= " OR $wpdb->posts.post_status = 'future' OR $wpdb->posts.post_status = 'draft' OR $wpdb->posts.post_status = 'pending'"; 2135 2139 2136 2140 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'"; 2138 2142 } 2139 2143 2140 2144 $where .= ')'; … … 2292 2296 } else { 2293 2297 if (in_array($status, array('draft', 'pending')) ) { 2294 2298 // User must have edit permissions on the draft to preview. 2295 if (! current_user_can( 'edit_post', $this->posts[0]->ID)) {2299 if (! current_user_can("edit_$post_type_cap", $this->posts[0]->ID)) { 2296 2300 $this->posts = array(); 2297 2301 } else { 2298 2302 $this->is_preview = true; … … 2300 2304 } 2301 2305 } else if ('future' == $status) { 2302 2306 $this->is_preview = true; 2303 if (!current_user_can( 'edit_post', $this->posts[0]->ID)) {2307 if (!current_user_can("edit_$post_type_cap", $this->posts[0]->ID)) { 2304 2308 $this->posts = array ( ); 2305 2309 } 2306 2310 } else { 2307 if (! current_user_can( 'read_post', $this->posts[0]->ID))2311 if (! current_user_can("read_$post_type_cap", $this->posts[0]->ID)) 2308 2312 $this->posts = array(); 2309 2313 } 2310 2314 } 2311 2315 } 2312 2316 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 ) ) 2314 2318 $this->posts[0] = apply_filters('the_preview', $this->posts[0]); 2315 2319 } 2316 2320