wp_is_large_network

函式
wp_is_large_network ( $using = 'sites', $network_id = null )
引數
  • (string) $using 'sites or 'users'. Default is 'sites'.
    Required:
    Default: 'sites'
  • (int|null) $network_id ID of the network. Default is the current network.
    Required:
    Default: null
返回值
  • (bool) True if the network meets the criteria for large. False otherwise.
定義位置
相關方法
wp_get_networkis_main_networkwp_image_editorpopulate_networkwp_is_large_user_count
引入
3.3.0
棄用
-

wp_is_large_network: 這個函式用來檢查WordPress的網路是否被認為是大的。如果網路有超過10,000個站點,它將返回true。

確定我們是否有一個大型網路。

大型網路的預設標準是超過10,000個使用者或超過10,000個站點。外掛可以使用{@see ‘wp_is_large_network’}過濾器改變這個標準。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 );
$is_large_network = wp_is_large_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', $is_large_network, '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 );
}
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 ); $is_large_network = wp_is_large_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', $is_large_network, '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 ); }
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 );

		$is_large_network = wp_is_large_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', $is_large_network, '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 );
}

常見問題

FAQs
檢視更多 >