wp_maybe_update_network_site_counts

函式
wp_maybe_update_network_site_counts ( $network_id = null )
引數
  • (int|null) $network_id ID of the network. Default is the current network.
    Required:
    Default: null
定義位置
相關方法
wp_maybe_update_network_user_countswp_update_network_site_countswp_maybe_update_network_site_counts_on_updatewp_update_network_user_countswp_update_network_counts
引入
3.7.0
棄用
-

wp_maybe_update_network_site_counts: 這個函式用於更新網路中的網站數量。它檢查計數是否是最新的,如果不是,它就更新計數。

更新當前網路的站點數量。

如果通過{@see ‘enable_network_counts’}過濾器啟用,當一個站點被建立或其狀態被更新時,更新網路上的站點數量。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_maybe_update_network_site_counts( $network_id = null ) {
$is_small_network = ! wp_is_large_network( 'sites', $network_id );
/**
* Filters whether to update network site or user counts when a new site is created.
*
* @since 3.7.0
*
* @see wp_is_large_network()
*
* @param bool $small_network Whether the network is considered small.
* @param string $context Context. Either 'users' or 'sites'.
*/
if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) ) {
return;
}
wp_update_network_site_counts( $network_id );
}
function wp_maybe_update_network_site_counts( $network_id = null ) { $is_small_network = ! wp_is_large_network( 'sites', $network_id ); /** * Filters whether to update network site or user counts when a new site is created. * * @since 3.7.0 * * @see wp_is_large_network() * * @param bool $small_network Whether the network is considered small. * @param string $context Context. Either 'users' or 'sites'. */ if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) ) { return; } wp_update_network_site_counts( $network_id ); }
function wp_maybe_update_network_site_counts( $network_id = null ) {
	$is_small_network = ! wp_is_large_network( 'sites', $network_id );

	/**
	 * Filters whether to update network site or user counts when a new site is created.
	 *
	 * @since 3.7.0
	 *
	 * @see wp_is_large_network()
	 *
	 * @param bool   $small_network Whether the network is considered small.
	 * @param string $context       Context. Either 'users' or 'sites'.
	 */
	if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) ) {
		return;
	}

	wp_update_network_site_counts( $network_id );
}

常見問題

FAQs
檢視更多 >