2213 | | $where = apply_filters('posts_where_paged', $where); |
2214 | | $groupby = apply_filters('posts_groupby', $groupby); |
2215 | | $join = apply_filters('posts_join_paged', $join); |
| 2221 | $distinct = apply_filters('posts_distinct', $distinct, false); |
| 2222 | $quick_distinct = apply_filters('posts_distinct', $quick_distinct, true); |
| 2223 | |
| 2224 | $fields = apply_filters('posts_fields', $fields, false); |
| 2225 | $quick_fields = apply_filters('posts_fields', $quick_fields, true); |
| 2226 | |
| 2227 | $join = apply_filters('posts_join_paged', $join, false); |
| 2228 | $quick_join = apply_filters('posts_join_paged', $quick_join, true); |
| 2229 | |
| 2230 | $where = apply_filters('posts_where_paged', $where, false); |
| 2231 | $quick_where = apply_filters('posts_where_paged', $quick_where, true); |
| 2232 | |
| 2233 | $groupby = apply_filters('posts_groupby', $groupby, false); |
| 2234 | $quick_groupby = apply_filters('posts_groupby', $quick_groupby, true); |
| 2235 | |
2228 | | $where = apply_filters('posts_where_request', $where); |
2229 | | $groupby = apply_filters('posts_groupby_request', $groupby); |
2230 | | $join = apply_filters('posts_join_request', $join); |
| 2245 | $distinct = apply_filters('posts_distinct_request', $distinct, false); |
| 2246 | $quick_distinct = apply_filters('posts_distinct_request', $quick_distinct, true); |
| 2247 | |
| 2248 | $fields = apply_filters('posts_fields_request', $fields, false); |
| 2249 | $quick_fields = apply_filters('posts_fields_request', $quick_fields, true); |
| 2250 | |
| 2251 | $join = apply_filters('posts_join_request', $join, false); |
| 2252 | $quick_join = apply_filters('posts_join_request', $quick_join, true); |
| 2253 | |
| 2254 | $where = apply_filters('posts_where_request', $where, false); |
| 2255 | $quick_where = apply_filters('posts_where_request', $quick_where, true); |
| 2256 | |
| 2257 | $groupby = apply_filters('posts_groupby_request', $groupby, false); |
| 2258 | $quick_groupby = apply_filters('posts_groupby_request', $quick_groupby, true); |
| 2259 | |
2249 | | $this->posts = $wpdb->get_results($this->request); |
| 2279 | if ( !$q['suppress_filters'] ) { |
| 2280 | $this->request = apply_filters('posts_request', $this->request, false); |
| 2281 | $this->quick_request = apply_filters('posts_request', $this->quick_request, true); |
| 2282 | } |
| 2283 | |
| 2284 | $this->posts = $wpdb->get_results($this->quick_request); |
| 2285 | |
| 2286 | $this->found_posts = count($this->posts); |
| 2287 | $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); |
| 2288 | $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); |
| 2289 | } else { |
| 2290 | $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; |
| 2291 | if ( !$q['suppress_filters'] ) |
| 2292 | $this->request = apply_filters('posts_request', $this->request); |
| 2293 | |
| 2294 | $post_ids = $wpdb->get_col($this->request); |
| 2295 | |
| 2296 | if ( !$post_ids ) { |
| 2297 | $this->found_posts = 0; |
| 2298 | $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); |
| 2299 | $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); |
| 2300 | |
| 2301 | $this->quick_request = " SELECT $quick_distinct $quick_fields FROM $wpdb->posts $quick_join WHERE 1=1 $quick_where $quick_groupby $orderby"; |
| 2302 | if ( !$q['suppress_filters'] ) |
| 2303 | $this->quick_request = apply_filters('posts_request', $this->quick_request, true); |
| 2304 | $this->posts = array(); // no point in querying, since there are no posts |
| 2305 | } else { |
| 2306 | $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' ); |
| 2307 | $this->found_posts = $wpdb->get_var( $found_posts_query ); |
| 2308 | $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); |
| 2309 | $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); |
| 2310 | |
| 2311 | $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 ORDER BY FIELD( $wpdb->posts.ID, " . implode(',', $post_ids) . ") "; |
| 2312 | |
| 2313 | if ( !$q['suppress_filters'] ) |
| 2314 | $this->quick_request = apply_filters('posts_request', $this->quick_request, true); |
| 2315 | |
| 2316 | $this->posts = $wpdb->get_results($this->quick_request); |
| 2317 | } |
| 2318 | } |
| 2319 | |