Changeset 11960 for trunk/wp-includes/query.php
- Timestamp:
- 09/22/2009 10:57:01 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/query.php
r11930 r11960 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'"; … … 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 … … 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 … … 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 … … 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 … … 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 { … … 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 } … … 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 }
Note: See TracChangeset
for help on using the changeset viewer.