钩子文档

wp_is_large_user_count

💡 云策文档标注

概述

wp_is_large_user_count 是一个 WordPress 过滤器,用于基于用户数量判断站点是否被视为大型站点。它允许开发者自定义判断逻辑,默认阈值为超过10000个用户。

关键要点

  • 这是一个过滤器,钩子名为 'wp_is_large_user_count',用于修改站点是否被认定为大型用户数量的判断。
  • 接受三个参数:$is_large_user_count(布尔值,表示当前判断结果)、$count(整数,用户总数)和 $network_id(整数或 null,网络ID,null 表示当前网络)。
  • 默认实现中,如果用户数大于10000,则返回 true,否则返回 false。
  • 在 WordPress 6.0.0 版本中引入。

代码示例

return apply_filters( 'wp_is_large_user_count', $count > 10000, $count, $network_id );

注意事项

  • 此过滤器主要用于性能优化或功能限制场景,例如在处理大量用户时调整查询行为。
  • 开发者可以通过添加过滤器回调来覆盖默认阈值或添加自定义逻辑。

📄 原文内容

Filters whether the site is considered large, based on its number of users.

Parameters

$is_large_user_countbool
Whether the site has a large number of users.
$countint
The total number of users.
$network_idint|null
ID of the network. null represents the current network.

Source

return apply_filters( 'wp_is_large_user_count', $count > 10000, $count, $network_id );

Changelog

Version Description
6.0.0 Introduced.