pre_prepare_themes_for_js
云策文档标注
概述
pre_prepare_themes_for_js 是一个 WordPress 过滤器,用于在主题数据被准备用于 JavaScript 之前进行过滤。如果传递非空数组,将导致 wp_prepare_themes_for_js() 函数提前返回该值。
关键要点
- 过滤器名称:pre_prepare_themes_for_js
- 作用:过滤主题数据,影响 wp_prepare_themes_for_js() 的输出
- 参数:$prepared_themes(关联数组,默认空数组)、$themes(WP_Theme[] 数组或 null)、$current_theme(字符串,活动主题 slug)
- 返回值:如果过滤器返回非空数组,wp_prepare_themes_for_js() 将直接返回该数组
- 引入版本:WordPress 4.2.0
代码示例
$prepared_themes = (array) apply_filters( 'pre_prepare_themes_for_js', array(), $themes, $current_theme );
原文内容
Filters theme data before it is prepared for JavaScript.
Description
Passing a non-empty array will result in wp_prepare_themes_for_js() returning early with that value instead.
Parameters
$prepared_themesarray-
An associative array of theme data. Default empty array.
$themesWP_Theme[]|null-
An array of theme objects to prepare, if any.
$current_themestring-
The active theme slug.
Source
$prepared_themes = (array) apply_filters( 'pre_prepare_themes_for_js', array(), $themes, $current_theme );
Changelog
| Version | Description |
|---|---|
| 4.2.0 | Introduced. |