| 2381 | | $where = apply_filters_ref_array( 'posts_where_paged', array( $where, &$this ) ); |
| 2382 | | $groupby = apply_filters_ref_array( 'posts_groupby', array( $groupby, &$this ) ); |
| 2383 | | $join = apply_filters_ref_array( 'posts_join_paged', array( $join, &$this ) ); |
| 2384 | | $orderby = apply_filters_ref_array( 'posts_orderby', array( $orderby, &$this ) ); |
| 2385 | | $distinct = apply_filters_ref_array( 'posts_distinct', array( $distinct, &$this ) ); |
| 2386 | | $limits = apply_filters_ref_array( 'post_limits', array( $limits, &$this ) ); |
| 2387 | | $fields = apply_filters_ref_array( 'posts_fields', array( $fields, &$this ) ); |
| | 2389 | $distinct = apply_filters_ref_array( 'posts_distinct', array( $distinct, &$this, false ) ); |
| | 2390 | $quick_distinct = apply_filters_ref_array( 'posts_distinct', array( $quick_distinct, &$this, true ) ); |
| | 2391 | |
| | 2392 | $fields = apply_filters_ref_array( 'posts_fields', array( $fields, &$this, false ) ); |
| | 2393 | $quick_fields = apply_filters_ref_array( 'posts_fields', array( $quick_fields, &$this, true ) ); |
| | 2394 | |
| | 2395 | $join = apply_filters_ref_array( 'posts_join_paged', array( $join, &$this, false ) ); |
| | 2396 | $quick_join = apply_filters_ref_array( 'posts_join_paged', array( $quick_join, &$this, true ) ); |
| | 2397 | |
| | 2398 | $where = apply_filters_ref_array( 'posts_where_paged', array( $where, &$this, false ) ); |
| | 2399 | $quick_where = apply_filters_ref_array( 'posts_where_paged', array( $quick_where, &$this, true ) ); |
| | 2400 | |
| | 2401 | $groupby = apply_filters_ref_array( 'posts_groupby', array( $groupby, &$this, false ) ); |
| | 2402 | $quick_groupby = apply_filters_ref_array( 'posts_groupby', array( $quick_groupby, &$this, true ) ); |
| | 2403 | |
| | 2404 | $orderby = apply_filters_ref_array( 'posts_orderby', array( $orderby, &$this ) ); |
| | 2405 | $limits = apply_filters_ref_array( 'post_limits', array( $limits, &$this ) ); |
| 2395 | | $where = apply_filters_ref_array( 'posts_where_request', array( $where, &$this ) ); |
| 2396 | | $groupby = apply_filters_ref_array( 'posts_groupby_request', array( $groupby, &$this ) ); |
| 2397 | | $join = apply_filters_ref_array( 'posts_join_request', array( $join, &$this ) ); |
| 2398 | | $orderby = apply_filters_ref_array( 'posts_orderby_request', array( $orderby, &$this ) ); |
| 2399 | | $distinct = apply_filters_ref_array( 'posts_distinct_request', array( $distinct, &$this ) ); |
| 2400 | | $fields = apply_filters_ref_array( 'posts_fields_request', array( $fields, &$this ) ); |
| 2401 | | $limits = apply_filters_ref_array( 'post_limits_request', array( $limits, &$this ) ); |
| | 2413 | $distinct = apply_filters_ref_array( 'posts_distinct_request', array( $distinct, &$this, false ) ); |
| | 2414 | $quick_distinct = apply_filters_ref_array( 'posts_distinct_request', array( $quick_distinct, &$this, true ) ); |
| | 2415 | |
| | 2416 | $fields = apply_filters_ref_array( 'posts_fields_request', array( $fields, &$this, false ) ); |
| | 2417 | $quick_fields = apply_filters_ref_array( 'posts_fields_request', array( $quick_fields, &$this, true ) ); |
| | 2418 | |
| | 2419 | $join = apply_filters_ref_array( 'posts_join_request', array( $join, &$this, false ) ); |
| | 2420 | $quick_join = apply_filters_ref_array( 'posts_join_request', array( $quick_join, &$this, true ) ); |
| | 2421 | |
| | 2422 | $where = apply_filters_ref_array( 'posts_where_request', array( $where, &$this, false ) ); |
| | 2423 | $quick_where = apply_filters_ref_array( 'posts_where_request', array( $quick_where, &$this, true ) ); |
| | 2424 | |
| | 2425 | $groupby = apply_filters_ref_array( 'posts_groupby_request', array( $groupby, &$this, false ) ); |
| | 2426 | $quick_groupby = apply_filters_ref_array( 'posts_groupby_request', array( $quick_groupby, &$this, true ) ); |
| | 2427 | |
| | 2428 | $orderby = apply_filters_ref_array( 'posts_orderby_request', array( $orderby, &$this ) ); |
| | 2429 | $limits = apply_filters_ref_array( 'post_limits_request', array( $limits, &$this ) ); |
| 2412 | | $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; |
| 2413 | | if ( !$q['suppress_filters'] ) |
| 2414 | | $this->request = apply_filters_ref_array('posts_request', array( $this->request, &$this ) ); |
| | 2442 | if ( empty($limits) ) { |
| | 2443 | // do a direct query, as there is no benefit in fetching a huge load of IDs in an IN clause |
| | 2444 | $this->request = " SELECT $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby"; |
| | 2445 | $this->quick_request = " SELECT $quick_distinct $quick_fields FROM $wpdb->posts $quick_join WHERE 1=1 $quick_where $quick_groupby $orderby"; |
| 2416 | | $this->posts = $wpdb->get_results($this->request); |
| | 2447 | if ( !$q['suppress_filters'] ) { |
| | 2448 | $this->request = apply_filters('posts_request', $this->request, false); |
| | 2449 | $this->quick_request = apply_filters('posts_request', $this->quick_request, true); |
| | 2450 | } |
| | 2451 | |
| | 2452 | $this->posts = $wpdb->get_results($this->quick_request); |
| | 2453 | |
| | 2454 | $this->found_posts = count($this->posts); |
| | 2455 | $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); |
| | 2456 | $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); |
| | 2457 | } else { |
| | 2458 | $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; |
| | 2459 | if ( !$q['suppress_filters'] ) |
| | 2460 | $this->request = apply_filters_ref_array('posts_request', array( $this->request, &$this ) ); |
| | 2461 | |
| | 2462 | $post_ids = $wpdb->get_col($this->request); |
| | 2463 | |
| | 2464 | if ( !$post_ids ) { |
| | 2465 | $this->found_posts = 0; |
| | 2466 | $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); |
| | 2467 | $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); |
| | 2468 | |
| | 2469 | $this->quick_request = " SELECT $quick_distinct $quick_fields FROM $wpdb->posts $quick_join WHERE 1=1 $quick_where $quick_groupby $orderby"; |
| | 2470 | if ( !$q['suppress_filters'] ) |
| | 2471 | $this->quick_request = apply_filters('posts_request', $this->quick_request, true); |
| | 2472 | $this->posts = array(); // no point in querying, since there are no posts |
| | 2473 | } else { |
| | 2474 | $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' ); |
| | 2475 | $this->found_posts = $wpdb->get_var( $found_posts_query ); |
| | 2476 | $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); |
| | 2477 | $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); |
| | 2478 | |
| | 2479 | $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) . ") "; |
| | 2480 | |
| | 2481 | if ( !$q['suppress_filters'] ) |
| | 2482 | $this->quick_request = apply_filters('posts_request', $this->quick_request, true); |
| | 2483 | |
| | 2484 | $this->posts = $wpdb->get_results($this->quick_request); |
| | 2485 | } |
| | 2486 | } |
| | 2487 | |