wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_count_sites › WordPress Function
Since5.3.0
Deprecatedn/a
› wp_count_sites ( $network_id = null )
Parameters: |
|
Returns: |
|
Defined at: |
|
Codex: |
Counts number of sites grouped by site status.
Source
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;
}