| 294 | | // Ignore the $fields argument as the queried result will be the same regardless. |
| 295 | | unset( $_args['fields'] ); |
| | 292 | /** |
| | 293 | * Filters the sites array before the query takes place. |
| | 294 | * |
| | 295 | * Return a non-null value to bypass WordPress's default site queries. |
| | 296 | * |
| | 297 | * |
| | 298 | * @since 5.1.0 |
| | 299 | * |
| | 300 | * @param array|null $site_ids Return an array of site data to short-circuit WP's site query, |
| | 301 | * or null to allow WP to run its normal queries. |
| | 302 | * @param WP_Query $this The WP_Site_Query instance, passed by reference. |
| | 303 | */ |
| | 304 | $site_ids = apply_filters_ref_array( 'sites_pre_query', array( null, &$this ) ); |
| 303 | | if ( false === $cache_value ) { |
| 304 | | $site_ids = $this->get_site_ids(); |
| 305 | | if ( $site_ids ) { |
| 306 | | $this->set_found_sites(); |
| | 311 | // Ignore the $fields argument as the queried result will be the same regardless. |
| | 312 | unset( $_args['fields'] ); |
| | 313 | |
| | 314 | $key = md5( serialize( $_args ) ); |
| | 315 | $last_changed = wp_cache_get_last_changed( 'sites' ); |
| | 316 | |
| | 317 | $cache_key = "get_sites:$key:$last_changed"; |
| | 318 | $cache_value = wp_cache_get( $cache_key, 'sites' ); |
| | 319 | |
| | 320 | if ( false === $cache_value ) { |
| | 321 | $site_ids = $this->get_site_ids(); |
| | 322 | if ( $site_ids ) { |
| | 323 | $this->set_found_sites(); |
| | 324 | } |
| | 325 | |
| | 326 | $cache_value = array( |
| | 327 | 'site_ids' => $site_ids, |
| | 328 | 'found_sites' => $this->found_sites, |
| | 329 | ); |
| | 330 | wp_cache_add( $cache_key, $cache_value, 'sites' ); |
| | 331 | } else { |
| | 332 | $site_ids = $cache_value['site_ids']; |
| | 333 | $this->found_sites = $cache_value['found_sites']; |