Changeset 46100 for trunk/src/wp-includes/class-wp-site-query.php
- Timestamp:
- 09/12/2019 10:16:08 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-site-query.php
r46087 r46100 289 289 } 290 290 291 $site_ ids= null;291 $site_data = null; 292 292 293 293 /** 294 * Filter the site s array before thequery takes place.294 * Filter the site data before the get_sites query takes place. 295 295 * 296 296 * Return a non-null value to bypass WordPress's default site queries. 297 297 * 298 * The expected return type from this filter depends on the value passed in the request query_vars: 299 * When `$this->query_vars['count']` is set, the filter should return the site count as an int. 300 * When `'ids' == $this->query_vars['fields']`, the filter should return an array of site ids. 301 * Otherwise the filter should return an array of WP_Site objects. 302 * 298 303 * @since 5.2.0 299 304 * 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_Site_Query $this The WP_Site_Query instance, passed by reference. 305 * @param array|int|null $site_data Return an array of site data to short-circuit WP's site query, 306 * the site count as an integer if `$this->query_vars['count']` is set, 307 * or null to run the normal queries. 308 * @param WP_Site_Query $this The WP_Site_Query instance, passed by reference. 303 309 */ 304 $site_ids = apply_filters_ref_array( 'sites_pre_query', array( $site_ids, &$this ) ); 305 306 if ( null === $site_ids ) { 307 308 // $args can include anything. Only use the args defined in the query_var_defaults to compute the key. 309 $_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ); 310 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']; 310 $site_data = apply_filters_ref_array( 'sites_pre_query', array( $site_data, &$this ) ); 311 312 if ( null !== $site_data ) { 313 return $site_data; 314 } 315 316 // $args can include anything. Only use the args defined in the query_var_defaults to compute the key. 317 $_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ); 318 319 // Ignore the $fields argument as the queried result will be the same regardless. 320 unset( $_args['fields'] ); 321 322 $key = md5( serialize( $_args ) ); 323 $last_changed = wp_cache_get_last_changed( 'sites' ); 324 325 $cache_key = "get_sites:$key:$last_changed"; 326 $cache_value = wp_cache_get( $cache_key, 'sites' ); 327 328 if ( false === $cache_value ) { 329 $site_ids = $this->get_site_ids(); 330 if ( $site_ids ) { 331 $this->set_found_sites(); 334 332 } 333 334 $cache_value = array( 335 'site_ids' => $site_ids, 336 'found_sites' => $this->found_sites, 337 ); 338 wp_cache_add( $cache_key, $cache_value, 'sites' ); 339 } else { 340 $site_ids = $cache_value['site_ids']; 341 $this->found_sites = $cache_value['found_sites']; 335 342 } 336 343
Note: See TracChangeset
for help on using the changeset viewer.