我们是否拥有庞大的网络。

原型

wp_is_large_network( string $using = 'sites', int|null $network_id = null )

描述

大型网络的默认条件是超过10,000个用户或超过10,000个站点。插件可以使用’wp_is_large_network’过滤器更改此条件。

参数

$using (string) (Optional) ‘网站或’用户’。默认为“网站”。

$network_id (int|null) (Optional) 网络ID。默认是当前网络。

返回值

(bool)  如果网络符合大型标准,则为True。否则就错了。

源文件

路径:wp-includes/ms-functions.php

<?php
...
function wp_is_large_network( $using = 'sites', $network_id = null ) {
	$network_id = (int) $network_id;
	if ( ! $network_id ) {
		$network_id = get_current_network_id();
	}
	if ( 'users' == $using ) {
		$count = get_user_count( $network_id );
		/**
		 * Filters whether the network is considered large.
		 *
		 * @since 3.3.0
		 * @since 4.8.0 The $network_id parameter has been added.
		 *
		 * @param bool   $is_large_network Whether the network has more than 10000 users or sites.
		 * @param string $component        The component to count. Accepts 'users', or 'sites'.
		 * @param int    $count            The count of items for the component.
		 * @param int    $network_id       The ID of the network being checked.
		 */
		return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count, $network_id );
	}
	$count = get_blog_count( $network_id );
	/** This filter is documented in wp-includes/ms-functions.php */
	return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count, $network_id );
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/wp_is_large_network/