diff --git a/wp-includes/class-wp-network-query.php b/wp-includes/class-wp-network-query.php index 1e0cb54733..f12bc5c54f 100644 --- a/wp-includes/class-wp-network-query.php +++ b/wp-includes/class-wp-network-query.php @@ -212,7 +212,17 @@ class WP_Network_Query { * an array of network IDs. * - Otherwise the filter should return an array of WP_Network objects. * + * Note that if the filter returns an array of network data, it will be assigned + * to the `networks` property of the current WP_Network_Query instance. + * + * Filtering functions that require pagination information are encouraged to set + * the `found_networks` and `max_num_pages` properties of the WP_Network_Query object, + * passed to the filter by reference. If WP_Network_Query does not perform a database + * query, it will not have enough information to generate these values itself. + * * @since 5.2.0 + * @since 5.6.0 The returned array of network data is assigned to the `networks` property + * of the current WP_Network_Query instance. * * @param array|int|null $network_data Return an array of network data to short-circuit WP's network query, * the network count as an integer if `$this->query_vars['count']` is set, @@ -222,6 +232,10 @@ class WP_Network_Query { $network_data = apply_filters_ref_array( 'networks_pre_query', array( $network_data, &$this ) ); if ( null !== $network_data ) { + if ( is_array( $network_data ) && ! $this->query_vars['count'] ) { + $this->networks = $network_data; + } + return $network_data; } diff --git a/wp-includes/class-wp-site-query.php b/wp-includes/class-wp-site-query.php index e19a84c749..fb98fd9daa 100644 --- a/wp-includes/class-wp-site-query.php +++ b/wp-includes/class-wp-site-query.php @@ -303,7 +303,17 @@ class WP_Site_Query { * an array of site IDs. * - Otherwise the filter should return an array of WP_Site objects. * + * Note that if the filter returns an array of site data, it will be assigned + * to the `sites` property of the current WP_Site_Query instance. + * + * Filtering functions that require pagination information are encouraged to set + * the `found_sites` and `max_num_pages` properties of the WP_Site_Query object, + * passed to the filter by reference. If WP_Site_Query does not perform a database + * query, it will not have enough information to generate these values itself. + * * @since 5.2.0 + * @since 5.6.0 The returned array of site data is assigned to the `sites` property + * of the current WP_Site_Query instance. * * @param array|int|null $site_data Return an array of site data to short-circuit WP's site query, * the site count as an integer if `$this->query_vars['count']` is set, @@ -313,6 +323,10 @@ class WP_Site_Query { $site_data = apply_filters_ref_array( 'sites_pre_query', array( $site_data, &$this ) ); if ( null !== $site_data ) { + if ( is_array( $site_data ) && ! $this->query_vars['count'] ) { + $this->sites = $site_data; + } + return $site_data; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 8a3a8d781a..23e044fc87 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-beta3-49537'; +$wp_version = '5.6-beta3-49538'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.