wp_is_large_network
云策文档标注
概述
wp_is_large_network 是一个 WordPress 过滤器,用于判断网络是否被视为大型网络,基于用户或站点的数量阈值。
关键要点
- 过滤器名称:wp_is_large_network,用于自定义网络大小的判断逻辑。
- 参数:包括 $is_large_network(布尔值,表示网络是否大型)、$component(字符串,指定计数组件,如 'users' 或 'sites')、$count(整数,组件计数)、$network_id(整数,网络 ID)。
- 默认阈值:网络有超过 10000 个用户或站点时被视为大型。
- 版本历史:从 3.3.0 版本引入,4.8.0 版本添加了 $network_id 参数。
代码示例
function custom_large_network( $is_large_network, $component, $count, $network_id ) {
return ( $count > 5000);
}
add_filter( 'wp_is_large_network', 'custom_large_network', 10, 4 );注意事项
开发者可以通过此过滤器调整阈值,例如将默认的 10000 改为 5000,以适应特定网络规模需求。
原文内容
Filters whether the network is considered large.
Parameters
$is_large_networkbool-
Whether the network has more than 10000 users or sites.
$componentstring-
The component to count. Accepts
'users', or'sites'. $countint-
The count of items for the component.
$network_idint-
The ID of the network being checked.
Source
return apply_filters( 'wp_is_large_network', $is_large_network, 'users', $count, $network_id );
Skip to note 2 content
Rami Yushuvaev
Whether the network has more than 5,000 users/sites instead of 10,000:
function custom_large_network( $is_large_network, $component, $count, $network_id ) { return ( $count > 5000); } add_filter( 'wp_is_large_network', 'custom_large_network', 10, 4 );Source: https://generatewp.com/snippet/9XaNVan/