264 | | wp_cache_add( $cache_key, $site_ids, 'sites' ); |
| 263 | if ( $site_ids ) { |
| 264 | $this->set_found_sites(); |
| 265 | } |
| 266 | $cache_value = array( |
| 267 | 'site_ids' => $site_ids, |
| 268 | 'found_sites' => $this->found_sites, |
| 269 | 'max_num_pages' => $this->max_num_pages |
| 270 | ); |
| 271 | wp_cache_add( $cache_key, $cache_value, 'sites' ); |
| 272 | } else { |
| 273 | $site_ids = $cache_value['site_ids']; |
| 274 | $this->found_sites = $cache_value['found_sites']; |
| 275 | $this->max_num_pages = $cache_value['max_num_pages']; |
277 | | if ( $site_ids && $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) { |
278 | | /** |
279 | | * Filters the query used to retrieve found site count. |
280 | | * |
281 | | * @since 4.6.0 |
282 | | * |
283 | | * @param string $found_sites_query SQL query. Default 'SELECT FOUND_ROWS()'. |
284 | | * @param WP_Site_Query $site_query The `WP_Site_Query` instance. |
285 | | */ |
286 | | $found_sites_query = apply_filters( 'found_sites_query', 'SELECT FOUND_ROWS()', $this ); |
287 | | |
288 | | $this->found_sites = (int) $wpdb->get_var( $found_sites_query ); |
289 | | $this->max_num_pages = ceil( $this->found_sites / $this->query_vars['number'] ); |
290 | | } |
291 | | |
| 571 | * Set up the amount of found sites and the number of pages (if limit clause was used) |
| 572 | * for the current query. |
| 573 | * |
| 574 | * @since 4.6.0 |
| 575 | * @access private |
| 576 | * |
| 577 | * @global wpdb $wpdb WordPress database abstraction object. |
| 578 | * |
| 579 | */ |
| 580 | private function set_found_sites() { |
| 581 | global $wpdb; |
| 582 | |
| 583 | if ( $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) { |
| 584 | /** |
| 585 | * Filters the query used to retrieve found site count. |
| 586 | * |
| 587 | * @since 4.6.0 |
| 588 | * |
| 589 | * @param string $found_sites_query SQL query. Default 'SELECT FOUND_ROWS()'. |
| 590 | * @param WP_Site_Query $site_query The `WP_Site_Query` instance (passed by reference). |
| 591 | */ |
| 592 | $found_sites_query = apply_filters_ref_array( 'found_sites_query', array( 'SELECT FOUND_ROWS()', &$this ) ); |
| 593 | |
| 594 | $this->found_sites = (int) $wpdb->get_var( $found_sites_query ); |
| 595 | $this->max_num_pages = ceil( $this->found_sites / $this->query_vars['number'] ); |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | /** |