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