wp_using_themes()
云策文档标注
概述
wp_using_themes() 函数用于判断当前请求是否应使用主题,返回布尔值。它基于 WP_USE_THEMES 常量定义,并可通过 'wp_using_themes' 过滤器进行自定义。
关键要点
- 函数返回 true 表示应使用主题,false 表示不应使用主题。
- 核心逻辑检查 WP_USE_THEMES 常量是否已定义且为 true。
- 提供 'wp_using_themes' 过滤器钩子,允许开发者动态修改返回值。
- 自 WordPress 5.1.0 版本引入。
代码示例
function wp_using_themes() {
/**
* Filters whether the current request should use themes.
*
* @since 5.1.0
*
* @param bool $wp_using_themes Whether the current request should use themes.
*/
return apply_filters( 'wp_using_themes', defined( 'WP_USE_THEMES' ) && WP_USE_THEMES );
}
原文内容
Determines whether the current request should use themes.
Source
function wp_using_themes() {
/**
* Filters whether the current request should use themes.
*
* @since 5.1.0
*
* @param bool $wp_using_themes Whether the current request should use themes.
*/
return apply_filters( 'wp_using_themes', defined( 'WP_USE_THEMES' ) && WP_USE_THEMES );
}
Hooks
- apply_filters( ‘wp_using_themes’, bool $wp_using_themes )
-
Filters whether the current request should use themes.
Changelog
| Version | Description |
|---|---|
| 5.1.0 | Introduced. |