equal
deleted
inserted
replaced
261 * Sets up the WordPress query for retrieving sites. |
261 * Sets up the WordPress query for retrieving sites. |
262 * |
262 * |
263 * @since 4.6.0 |
263 * @since 4.6.0 |
264 * |
264 * |
265 * @param string|array $query Array or URL query string of parameters. |
265 * @param string|array $query Array or URL query string of parameters. |
266 * @return array|int List of WP_Site objects, a list of site IDs when 'fields' is set to 'ids', |
266 * @return WP_Site[]|int[]|int List of WP_Site objects, a list of site IDs when 'fields' is set to 'ids', |
267 * or the number of sites when 'count' is passed as a query var. |
267 * or the number of sites when 'count' is passed as a query var. |
268 */ |
268 */ |
269 public function query( $query ) { |
269 public function query( $query ) { |
270 $this->query_vars = wp_parse_args( $query ); |
270 $this->query_vars = wp_parse_args( $query ); |
271 |
271 |
272 return $this->get_sites(); |
272 return $this->get_sites(); |
277 * |
277 * |
278 * @since 4.6.0 |
278 * @since 4.6.0 |
279 * |
279 * |
280 * @global wpdb $wpdb WordPress database abstraction object. |
280 * @global wpdb $wpdb WordPress database abstraction object. |
281 * |
281 * |
282 * @return array|int List of WP_Site objects, a list of site IDs when 'fields' is set to 'ids', |
282 * @return WP_Site[]|int[]|int List of WP_Site objects, a list of site IDs when 'fields' is set to 'ids', |
283 * or the number of sites when 'count' is passed as a query var. |
283 * or the number of sites when 'count' is passed as a query var. |
284 */ |
284 */ |
285 public function get_sites() { |
285 public function get_sites() { |
286 global $wpdb; |
286 global $wpdb; |
287 |
287 |
288 $this->parse_query(); |
288 $this->parse_query(); |
331 * |
331 * |
332 * @since 5.2.0 |
332 * @since 5.2.0 |
333 * @since 5.6.0 The returned array of site data is assigned to the `sites` property |
333 * @since 5.6.0 The returned array of site data is assigned to the `sites` property |
334 * of the current WP_Site_Query instance. |
334 * of the current WP_Site_Query instance. |
335 * |
335 * |
336 * @param array|int|null $site_data Return an array of site data to short-circuit WP's site query, |
336 * @param WP_Site[]|int[]|int|null $site_data Return an array of site data to short-circuit WP's site query, |
337 * the site count as an integer if `$this->query_vars['count']` is set, |
337 * the site count as an integer if `$this->query_vars['count']` is set, |
338 * or null to run the normal queries. |
338 * or null to run the normal queries. |
339 * @param WP_Site_Query $query The WP_Site_Query instance, passed by reference. |
339 * @param WP_Site_Query $query The WP_Site_Query instance, passed by reference. |
340 */ |
340 */ |
341 $site_data = apply_filters_ref_array( 'sites_pre_query', array( $site_data, &$this ) ); |
341 $site_data = apply_filters_ref_array( 'sites_pre_query', array( $site_data, &$this ) ); |
342 |
342 |
343 if ( null !== $site_data ) { |
343 if ( null !== $site_data ) { |
344 if ( is_array( $site_data ) && ! $this->query_vars['count'] ) { |
344 if ( is_array( $site_data ) && ! $this->query_vars['count'] ) { |