pre_load_script_translations
云策文档标注
概述
pre_load_script_translations 是一个 WordPress 过滤器钩子,用于在加载脚本翻译数据前进行预处理。开发者可以通过此钩子覆盖默认的翻译加载逻辑,实现自定义翻译数据注入。
关键要点
- 钩子名称:pre_load_script_translations
- 作用:预过滤脚本翻译数据,允许返回非空值以短路默认加载过程
- 参数:$translations(翻译数据,默认 null)、$file(翻译文件路径)、$handle(脚本句柄)、$domain(文本域)
- 相关函数:与 load_script_translations() 配合使用,用于加载脚本翻译
- 版本:自 WordPress 5.0.2 引入
原文内容
Pre-filters script translations for the given file, script handle and text domain.
Description
Returning a non-null value allows to override the default logic, effectively short-circuiting the function.
Parameters
$translationsstring|false|null-
JSON-encoded translation data. Default null.
$filestring|false-
Path to the translation file to load. False if there isn’t one.
$handlestring-
Name of the script to register a translation domain to.
$domainstring-
The text domain.
Source
$translations = apply_filters( 'pre_load_script_translations', null, $file, $handle, $domain );
Changelog
| Version | Description |
|---|---|
| 5.0.2 | Introduced. |