update_themes_{$hostname}
云策文档标注
概述
update_themes_{$hostname} 是一个动态过滤器钩子,用于过滤特定主题主机名的更新响应。它允许开发者自定义主题更新数据,基于 Update URI 头字段中指定的主机名。
关键要点
- 这是一个动态钩子,$hostname 部分对应 Update URI 头字段中的主机名。
- 主要参数包括 $update(主题更新数据)、$theme_data(主题头信息)、$theme_stylesheet(主题样式表)和 $locales(已安装语言环境)。
- 可用于修改主题更新细节,如版本、URL、包地址、自动更新设置和翻译更新。
- 在 WordPress 6.1.0 版本中引入。
代码示例
$update = apply_filters( "update_themes_{$hostname}", false, $theme_data, $theme_stylesheet, $locales );注意事项
- 确保 $hostname 与主题的 Update URI 头字段匹配,否则钩子可能不会触发。
- 参数 $update 默认为 false,需返回更新数组或 false 以控制更新流程。
- 翻译更新部分包括语言、版本、时间戳和包地址,需注意版本字段指主题版本而非语言文件版本。
原文内容
Filters the update response for a given theme hostname.
Description
The dynamic portion of the hook name, $hostname, refers to the hostname of the URI specified in the Update URI header field.
Parameters
$updatearray|false- The theme update data with the latest details. Default false.
idstringOptional. ID of the theme for update purposes, should be a URI specified in theUpdate URIheader field.themestringDirectory name of the theme.versionstringThe version of the theme.urlstringThe URL for details of the theme.packagestringOptional. The update ZIP for the theme.testedstringOptional. The version of WordPress the theme is tested against.requires_phpstringOptional. The version of PHP which the theme requires.autoupdateboolOptional. Whether the theme should automatically update.translationsarrayOptional. List of translation updates for the theme.languagestringThe language the translation update is for.versionstringThe version of the theme this translation is for.
This is not the version of the language file.updatedstringThe update timestamp of the translation file.
Should be a date in theYYYY-MM-DD HH:MM:SSformat.packagestringThe ZIP location containing the translation update.autoupdatestringWhether the translation should be automatically installed.
$theme_dataarrayTheme headers.$theme_stylesheetstringTheme stylesheet.$localesstring[]Installed locales to look up translations for.Source
$update = apply_filters( "update_themes_{$hostname}", false, $theme_data, $theme_stylesheet, $locales );Changelog
Version Description 6.1.0 Introduced.
User Contributed Notes
You must log in before being able to contribute a note or feedback.