wp_is_site_protected_by_basic_auth
云策文档标注
概述
本文档介绍 WordPress 的 wp_is_site_protected_by_basic_auth 过滤器,用于控制站点是否受 HTTP Basic Auth 保护。开发者可以通过此过滤器基于不同上下文(如登录、管理或前端)动态调整保护状态。
关键要点
- 过滤器名称:wp_is_site_protected_by_basic_auth
- 参数:$is_protected(布尔值,表示站点是否受保护)和 $context(字符串,指定检查保护的上下文,可选 'login'、'admin' 或 'front')
- 用途:允许开发者过滤站点是否受 HTTP Basic Auth 保护,常用于自定义身份验证逻辑
- 相关函数:wp_is_site_protected_by_basic_auth(),位于 wp-includes/load.php,用于检查站点保护状态
- 版本历史:从 WordPress 5.6.1 版本引入
原文内容
Filters whether a site is protected by HTTP Basic Auth.
Parameters
$is_protectedbool-
Whether the site is protected by Basic Auth.
$contextstring-
The context to check for protection. One of
'login','admin', or'front'.
Source
return apply_filters( 'wp_is_site_protected_by_basic_auth', $is_protected, $context );
Changelog
| Version | Description |
|---|---|
| 5.6.1 | Introduced. |