current_theme_supports-{$feature}
云策文档标注
概述
本文档介绍了 WordPress 中的 current_theme_supports-{$feature} 过滤器钩子,用于动态过滤当前活动主题是否支持特定功能。该钩子名称中的 $feature 部分是可变的,对应具体的主题功能。
关键要点
- current_theme_supports-{$feature} 是一个过滤器钩子,用于检查或修改活动主题对指定功能的支持状态。
- 钩子名称中的 $feature 是动态部分,可替换为 add_theme_support() 中定义的主题功能值。
- 该钩子接受三个参数:$supports(布尔值,表示是否支持,默认 true)、$args(数组,功能参数)和 $feature(字符串,主题功能)。
- 相关函数 current_theme_supports() 用于检查主题支持,位于 wp-includes/theme.php 文件中。
- 此钩子自 WordPress 3.4.0 版本引入。
原文内容
Filters whether the active theme supports a specific feature.
Description
The dynamic portion of the hook name, $feature, refers to the specific theme feature. See add_theme_support() for the list of possible values.
Parameters
$supportsbool-
Whether the active theme supports the given feature. Default true.
$argsarray-
Array of arguments for the feature.
$featurestring-
The theme feature.
Source
return apply_filters( "current_theme_supports-{$feature}", true, $args, $_wp_theme_features[ $feature ] ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
Changelog
| Version | Description |
|---|---|
| 3.4.0 | Introduced. |