| 2231 | | $where = apply_filters('posts_where_paged', $where); |
| 2232 | | $groupby = apply_filters('posts_groupby', $groupby); |
| 2233 | | $join = apply_filters('posts_join_paged', $join); |
| | 2237 | $distinct = apply_filters('posts_distinct', $distinct, false); |
| | 2238 | $quick_distinct = apply_filters('posts_distinct', $quick_distinct, true); |
| | 2239 | |
| | 2240 | $fields = apply_filters('posts_fields', $fields, false); |
| | 2241 | $quick_fields = apply_filters('posts_fields', $quick_fields, true); |
| | 2242 | |
| | 2243 | $join = apply_filters('posts_join_paged', $join, false); |
| | 2244 | $quick_join = apply_filters('posts_join_paged', $quick_join, true); |
| | 2245 | |
| | 2246 | $where = apply_filters('posts_where_paged', $where, false); |
| | 2247 | $quick_where = apply_filters('posts_where_paged', $quick_where, true); |
| | 2248 | |
| | 2249 | $groupby = apply_filters('posts_groupby', $groupby, true); |
| | 2250 | $quick_groupby = apply_filters('posts_groupby', $quick_groupby, true); |
| | 2251 | |
| 2246 | | $where = apply_filters('posts_where_request', $where); |
| 2247 | | $groupby = apply_filters('posts_groupby_request', $groupby); |
| 2248 | | $join = apply_filters('posts_join_request', $join); |
| | 2261 | $distinct = apply_filters('posts_distinct_request', $distinct, false); |
| | 2262 | $quick_distinct = apply_filters('posts_distinct_request', $quick_distinct, true); |
| | 2263 | |
| | 2264 | $fields = apply_filters('posts_fields_request', $fields, false); |
| | 2265 | $quick_fields = apply_filters('posts_fields_request', $quick_fields, true); |
| | 2266 | |
| | 2267 | $join = apply_filters('posts_join_request', $join, false); |
| | 2268 | $quick_join = apply_filters('posts_join_request', $quick_join, true); |
| | 2269 | |
| | 2270 | $where = apply_filters('posts_where_request', $where, false); |
| | 2271 | $quick_where = apply_filters('posts_where_request', $quick_where, true); |
| | 2272 | |
| | 2273 | $groupby = apply_filters('posts_groupby_request', $groupby, false); |
| | 2274 | $quick_groupby = apply_filters('posts_groupby_request', $quick_groupby, true); |
| | 2275 | |
| 2263 | | $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; |
| 2264 | | if ( !$q['suppress_filters'] ) |
| 2265 | | $this->request = apply_filters('posts_request', $this->request); |
| | 2288 | if ( empty($limits) ) { |
| | 2289 | // do a direct query, as there is no benefit in fetching a huge load of IDs in an IN clause |
| | 2290 | $this->request = " SELECT $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby"; |
| | 2291 | $this->quick_request = " SELECT $distinct $quick_fields FROM $wpdb->posts $quick_join WHERE 1=1 $quick_where $quick_groupby $orderby"; |
| | 2292 | |
| | 2293 | if ( !$q['suppress_filters'] ) { |
| | 2294 | $this->request = apply_filters('posts_request', $this->request, false); |
| | 2295 | $this->quick_request = apply_filters('posts_request', $this->quick_request, true); |
| | 2296 | } |
| | 2297 | |
| | 2298 | |
| | 2299 | $this->posts = $wpdb->get_results($this->quick_request); |
| | 2300 | |
| | 2301 | $this->found_posts = count($this->posts); |
| | 2302 | $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); |
| | 2303 | $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); |
| | 2304 | } else { |
| | 2305 | $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits "; |
| | 2306 | if ( !$q['suppress_filters'] ) |
| | 2307 | $this->request = apply_filters('posts_request', $this->request, false); |
| | 2308 | |
| | 2309 | $post_ids = $wpdb->get_col($this->request); |
| | 2310 | |
| | 2311 | if ( !$post_ids ) { |
| | 2312 | $this->found_posts = 0; |
| | 2313 | $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); |
| | 2314 | $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); |
| 2267 | | $this->posts = $wpdb->get_results($this->request); |
| | 2316 | $this->quick_request = " SELECT $distinct $quick_fields FROM $wpdb->posts $quick_join WHERE 1=1 $quick_where $quick_groupby $orderby"; |
| | 2317 | if ( !$q['suppress_filters'] ) |
| | 2318 | $this->quick_request = apply_filters('posts_request', $this->quick_request, true); |
| | 2319 | $this->posts = array(); // no point in querying, since there are no posts |
| | 2320 | } else { |
| | 2321 | $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' ); |
| | 2322 | $this->found_posts = $wpdb->get_var( $found_posts_query ); |
| | 2323 | $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); |
| | 2324 | $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); |
| | 2325 | |
| | 2326 | $this->quick_request = " SELECT $quick_distinct $quick_fields FROM $wpdb->posts $quick_join WHERE 1 = 1 $quick_where AND $wpdb->posts.ID IN ( " . implode(',', $post_ids) . " ) $quick_groupby $orderby "; |
| | 2327 | if ( !$q['suppress_filters'] ) |
| | 2328 | $this->quick_request = apply_filters('posts_request', $this->quick_request, true); |
| | 2329 | |
| | 2330 | $this->posts = $wpdb->get_results($this->quick_request); |
| | 2331 | } |
| | 2332 | } |
| | 2333 | |