Uses
| Uses | Description |
|---|---|
| wp-includes/load.php: get_current_network_id() | Retrieves the current network ID. |
| wp-includes/class-wp-site-query.php: WP_Site_Query::__construct() | Sets up the site query, based on the query vars passed. |
Count number of sites grouped by site status.
(int) (Optional) The network to get counts for. Default is the current network ID.
Default value: null
(int[]) Numbers of sites grouped by site status.
File: wp-includes/ms-blogs.php
function wp_count_sites( $network_id = null ) {
if ( empty( $network_id ) ) {
$network_id = get_current_network_id();
}
$counts = array();
$args = array(
'network_id' => $network_id,
'number' => 1,
'fields' => 'ids',
'no_found_rows' => false,
);
$q = new WP_Site_Query( $args );
$counts['all'] = $q->found_sites;
$_args = $args;
$statuses = array( 'public', 'archived', 'mature', 'spam', 'deleted' );
foreach ( $statuses as $status ) {
$_args = $args;
$_args[ $status ] = 1;
$q = new WP_Site_Query( $_args );
$counts[ $status ] = $q->found_sites;
}
return $counts;
} | Version | Description |
|---|---|
| 5.3.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_count_sites