2360 | | $where = apply_filters_ref_array( 'posts_where_paged', array( $where, &$this ) ); |
2361 | | $groupby = apply_filters_ref_array( 'posts_groupby', array( $groupby, &$this ) ); |
2362 | | $join = apply_filters_ref_array( 'posts_join_paged', array( $join, &$this ) ); |
2363 | | $orderby = apply_filters_ref_array( 'posts_orderby', array( $orderby, &$this ) ); |
2364 | | $distinct = apply_filters_ref_array( 'posts_distinct', array( $distinct, &$this ) ); |
2365 | | $limits = apply_filters_ref_array( 'post_limits', array( $limits, &$this ) ); |
2366 | | $fields = apply_filters_ref_array( 'posts_fields', array( $fields, &$this ) ); |
| 2366 | $distinct = apply_filters_ref_array('posts_distinct', array( $distinct, &$this ) ); |
| 2367 | $quick_distinct = apply_filters_ref_array('posts_distinct', array( $quick_distinct, &$this ) ); |
| 2368 | |
| 2369 | $fields = apply_filters_ref_array('posts_fields', array( $fields, &$this ) ); |
| 2370 | $quick_fields = apply_filters_ref_array('posts_fields', array( $quick_fields, &$this ) ); |
| 2371 | |
| 2372 | $join = apply_filters_ref_array('posts_join_paged', array( $join, &$this ) ); |
| 2373 | $quick_join = apply_filters_ref_array('posts_join_paged', array( $quick_join, &$this) ); |
| 2374 | |
| 2375 | $where = apply_filters_ref_array('posts_where_paged', array( $where, &$this ) ); |
| 2376 | $quick_where = apply_filtersref_array('posts_where_paged', array( $quick_where, &$this ) ); |
| 2377 | |
| 2378 | $groupby = apply_filters_ref_array('posts_groupby', array( $groupby, &$this ) ); |
| 2379 | $quick_groupby = apply_filters_ref_array('posts_groupby', $quick_groupby, &$this ) ); |
| 2380 | |
| 2381 | $orderby = apply_filters_ref_array('posts_orderby', array( $orderby, &$this ) ); |
| 2382 | $limits = apply_filters_ref_array( 'post_limits', array( $limits, &$this ) ); |
2374 | | $where = apply_filters_ref_array( 'posts_where_request', array( $where, &$this ) ); |
2375 | | $groupby = apply_filters_ref_array( 'posts_groupby_request', array( $groupby, &$this ) ); |
2376 | | $join = apply_filters_ref_array( 'posts_join_request', array( $join, &$this ) ); |
2377 | | $orderby = apply_filters_ref_array( 'posts_orderby_request', array( $orderby, &$this ) ); |
2378 | | $distinct = apply_filters_ref_array( 'posts_distinct_request', array( $distinct, &$this ) ); |
2379 | | $fields = apply_filters_ref_array( 'posts_fields_request', array( $fields, &$this ) ); |
2380 | | $limits = apply_filters_ref_array( 'post_limits_request', array( $limits, &$this ) ); |
| 2390 | $distinct = apply_filters_ref_array('posts_distinct_request', array( $distinct, &$this ) ); |
| 2391 | $quick_distinct = apply_filters_ref_array('posts_distinct_request', $array( quick_distinct, &$this ) ); |
| 2392 | |
| 2393 | $fields = apply_filters_ref_array('posts_fields_request', array( $fields, &$this ) ); |
| 2394 | $quick_fields = apply_filters_ref_array('posts_fields_request', array( $quick_fields, &$this ) ); |
| 2395 | |
| 2396 | $join = apply_filters_ref_array('posts_join_request', array( $join, &$this ) ); |
| 2397 | $quick_join = apply_filters_ref_array('posts_join_request', array( $quick_join, &$this ) ); |
| 2398 | |
| 2399 | $where = apply_filters_ref_array('posts_where_request', array( $where, &$this ) ); |
| 2400 | $quick_where = apply_filters_ref_array('posts_where_request', array( $quick_where, &$this ) ); |
| 2401 | |
| 2402 | $groupby = apply_filters_ref_array('posts_groupby_request', array( $groupby, &$this ) ); |
| 2403 | $quick_groupby = apply_filters_ref_array('posts_groupby_request', array( $quick_groupby, &$this ) ); |
| 2404 | |
| 2405 | $orderby = apply_filters_ref_array('posts_orderby_request', array( $orderby, &$this ) ); |
| 2406 | $limits = apply_filters_ref_array( 'post_limits_request', array( $limits, &$this ) ); |
| 2417 | if ( empty($limits) ) { |
| 2418 | // do a direct query, as there is no benefit in fetching a huge load of IDs in an IN clause |
| 2419 | $this->request = " SELECT $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby"; |
| 2420 | $this->quick_request = " SELECT $distinct $quick_fields FROM $wpdb->posts $quick_join WHERE 1=1 $where $quick_groupby $orderby"; |
| 2421 | |
| 2422 | if ( !$q['suppress_filters'] ) { |
| 2423 | $this->request = apply_filters('posts_request', $this->request, false); |
| 2424 | $this->quick_request = apply_filters('posts_request', $this->quick_request, true); |
| 2425 | } |
| 2426 | |
| 2427 | $this->posts = $wpdb->get_results($this->quick_request); |
| 2428 | |
| 2429 | $this->found_posts = count($this->posts); |
| 2430 | $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); |
| 2431 | $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); |
| 2432 | } else { |
2395 | | $this->posts = $wpdb->get_results($this->request); |
| 2439 | if ( !$post_ids ) { |
| 2440 | $this->found_posts = 0; |
| 2441 | $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); |
| 2442 | $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); |
| 2443 | |
| 2444 | $this->quick_request = " SELECT $distinct $quick_fields FROM $wpdb->posts $quick_join WHERE 1=1 $quick_where $quick_groupby $orderby"; |
| 2445 | if ( !$q['suppress_filters'] ) |
| 2446 | $this->quick_request = apply_filters('posts_request', $this->quick_request, true); |
| 2447 | $this->posts = array(); // no point in querying, since there are no posts |
| 2448 | } else { |
| 2449 | $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' ); |
| 2450 | $this->found_posts = $wpdb->get_var( $found_posts_query ); |
| 2451 | $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); |
| 2452 | $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); |
| 2453 | |
| 2454 | $this->quick_request = " SELECT $quick_distinct * 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) . ") "; |
| 2455 | |
| 2456 | if ( !$q['suppress_filters'] ) |
| 2457 | $this->quick_request = apply_filters('posts_request', $this->quick_request, true); |
| 2458 | |
| 2459 | $this->posts = $wpdb->get_results($this->quick_request); |
| 2460 | } |
| 2461 | } |