Ticket #9886: 9886.diff
File 9886.diff, 6.9 KB (added by , 14 years ago) |
---|
-
wp-includes/query.php
1765 1765 $search .= " AND ($wpdb->posts.post_password = '') "; 1766 1766 } 1767 1767 } 1768 $search = apply_filters('posts_search', $search, $this);1768 $search = apply_filters('posts_search', $search, &$this); 1769 1769 1770 1770 // Category stuff 1771 1771 … … 2196 2196 // Apply filters on where and join prior to paging so that any 2197 2197 // manipulations to them are reflected in the paging by day queries. 2198 2198 if ( !$q['suppress_filters'] ) { 2199 $where = apply_filters('posts_where', $where );2200 $join = apply_filters('posts_join', $join );2199 $where = apply_filters('posts_where', $where, &$this); 2200 $join = apply_filters('posts_join', $join, &$this); 2201 2201 } 2202 2202 2203 2203 // Paging … … 2231 2231 } 2232 2232 2233 2233 if ( !$q['suppress_filters'] ) { 2234 $cjoin = apply_filters('comment_feed_join', $cjoin );2235 $cwhere = apply_filters('comment_feed_where', $cwhere );2236 $cgroupby = apply_filters('comment_feed_groupby', $cgroupby );2237 $corderby = apply_filters('comment_feed_orderby', 'comment_date_gmt DESC' );2238 $climits = apply_filters('comment_feed_limits', 'LIMIT ' . get_option('posts_per_rss') );2234 $cjoin = apply_filters('comment_feed_join', $cjoin, &$this); 2235 $cwhere = apply_filters('comment_feed_where', $cwhere, &$this); 2236 $cgroupby = apply_filters('comment_feed_groupby', $cgroupby, &$this); 2237 $corderby = apply_filters('comment_feed_orderby', 'comment_date_gmt DESC', &$this); 2238 $climits = apply_filters('comment_feed_limits', 'LIMIT ' . get_option('posts_per_rss'), &$this); 2239 2239 } 2240 2240 $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : ''; 2241 2241 $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : ''; … … 2261 2261 // Apply post-paging filters on where and join. Only plugins that 2262 2262 // manipulate paging queries should use these hooks. 2263 2263 if ( !$q['suppress_filters'] ) { 2264 $where = apply_filters('posts_where_paged', $where); 2265 $groupby = apply_filters('posts_groupby', $groupby); 2266 $join = apply_filters('posts_join_paged', $join); 2267 $orderby = apply_filters('posts_orderby', $orderby); 2268 $distinct = apply_filters('posts_distinct', $distinct); 2269 $limits = apply_filters( 'post_limits', $limits ); 2270 2271 $fields = apply_filters('posts_fields', $fields); 2264 $where = apply_filters('posts_where_paged', $where, &$this); 2265 $groupby = apply_filters('posts_groupby', $groupby, &$this); 2266 $join = apply_filters('posts_join_paged', $join, &$this); 2267 $orderby = apply_filters('posts_orderby', $orderby, &$this); 2268 $distinct = apply_filters('posts_distinct', $distinct, &$this); 2269 $limits = apply_filters('post_limits', $limits, &$this); 2270 $fields = apply_filters('posts_fields', $fields, &$this); 2272 2271 } 2273 2272 2274 2273 // Announce current selection parameters. For use by caching plugins. … … 2276 2275 2277 2276 // Filter again for the benefit of caching plugins. Regular plugins should use the hooks above. 2278 2277 if ( !$q['suppress_filters'] ) { 2279 $where = apply_filters('posts_where_request', $where );2280 $groupby = apply_filters('posts_groupby_request', $groupby );2281 $join = apply_filters('posts_join_request', $join );2282 $orderby = apply_filters('posts_orderby_request', $orderby );2283 $distinct = apply_filters('posts_distinct_request', $distinct );2284 $fields = apply_filters('posts_fields_request', $fields );2285 $limits = apply_filters( 'post_limits_request', $limits);2278 $where = apply_filters('posts_where_request', $where, &$this); 2279 $groupby = apply_filters('posts_groupby_request', $groupby, &$this); 2280 $join = apply_filters('posts_join_request', $join, &$this); 2281 $orderby = apply_filters('posts_orderby_request', $orderby, &$this); 2282 $distinct = apply_filters('posts_distinct_request', $distinct, &$this); 2283 $fields = apply_filters('posts_fields_request', $fields, &$this); 2284 $limits = apply_filters('post_limits_request', $limits, &$this); 2286 2285 } 2287 2286 2288 2287 if ( ! empty($groupby) ) … … 2295 2294 2296 2295 $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; 2297 2296 if ( !$q['suppress_filters'] ) 2298 $this->request = apply_filters('posts_request', $this->request );2297 $this->request = apply_filters('posts_request', $this->request, &$this); 2299 2298 2300 2299 $this->posts = $wpdb->get_results($this->request); 2301 2300 // Raw results filter. Prior to status checks. 2302 2301 if ( !$q['suppress_filters'] ) 2303 $this->posts = apply_filters('posts_results', $this->posts );2302 $this->posts = apply_filters('posts_results', $this->posts, &$this); 2304 2303 2305 2304 if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) { 2306 $cjoin = apply_filters('comment_feed_join', '' );2307 $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'" );2308 $cgroupby = apply_filters('comment_feed_groupby', '' );2305 $cjoin = apply_filters('comment_feed_join', '', &$this); 2306 $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this); 2307 $cgroupby = apply_filters('comment_feed_groupby', '', &$this); 2309 2308 $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : ''; 2310 $corderby = apply_filters('comment_feed_orderby', 'comment_date_gmt DESC' );2309 $corderby = apply_filters('comment_feed_orderby', 'comment_date_gmt DESC', &$this); 2311 2310 $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : ''; 2312 $climits = apply_filters('comment_feed_limits', 'LIMIT ' . get_option('posts_per_rss') );2311 $climits = apply_filters('comment_feed_limits', 'LIMIT ' . get_option('posts_per_rss'), &$this); 2313 2312 $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits"; 2314 2313 $this->comments = $wpdb->get_results($comments_request); 2315 2314 $this->comment_count = count($this->comments); 2316 2315 } 2317 2316 2318 2317 if ( !empty($limits) ) { 2319 $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()');2318 $found_posts_query = apply_filters('found_posts_query', 'SELECT FOUND_ROWS()', &$this); 2320 2319 $this->found_posts = $wpdb->get_var( $found_posts_query ); 2321 $this->found_posts = apply_filters( 'found_posts', $this->found_posts);2320 $this->found_posts = apply_filters('found_posts', $this->found_posts, &$this); 2322 2321 $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); 2323 2322 } 2324 2323 … … 2351 2350 } 2352 2351 2353 2352 if ( $this->is_preview && current_user_can( $edit_cap, $this->posts[0]->ID ) ) 2354 $this->posts[0] = apply_filters('the_preview', $this->posts[0] );2353 $this->posts[0] = apply_filters('the_preview', $this->posts[0], &$this); 2355 2354 } 2356 2355 2357 2356 // Put sticky posts at the top of the posts array … … 2400 2399 } 2401 2400 2402 2401 if ( !$q['suppress_filters'] ) 2403 $this->posts = apply_filters('the_posts', $this->posts );2402 $this->posts = apply_filters('the_posts', $this->posts, &$this); 2404 2403 2405 2404 $this->post_count = count($this->posts); 2406 2405