WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

wp_count_sites() WP 5.3.0

Count number of sites grouped by site status.

Хуков нет.

Возвращает

Число[]. Numbers of sites grouped by site status.

  • all(число)
    The total number of sites.

  • public(число)
    The number of public sites.

  • archived(число)
    The number of archived sites.

  • mature(число)
    The number of mature sites.

  • spam(число)
    The number of spam sites.

  • deleted(число)
    The number of deleted sites.

Использование

wp_count_sites( $network_id );
$network_id(число)
The network to get counts for.
По умолчанию: current network ID

Список изменений

С версии 5.3.0 Введена.

Код wp_count_sites() WP 5.5.1

wp-includes/ms-blogs.php
<?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;
}