customize_changeset_save_data
云策文档标注
概述
customize_changeset_save_data 是一个 WordPress 过滤器,用于在保存定制器更改集时过滤设置数据。它允许插件修改或添加额外数据到更改集中。
关键要点
- 过滤器名称:customize_changeset_save_data
- 主要用途:过滤即将持久化到更改集中的设置数据,支持插件添加元数据等额外信息
- 参数:$data(更新的更改集数据数组,映射设置ID到包含$value和其他元数据的数组),$context(过滤上下文数组)
- 上下文参数包括:uuid(更改集UUID)、title(请求的标题)、status(请求的状态)、date_gmt(GMT时间戳)、post_id(更改集文章ID)、previous_data(先前数据)、manager(WP_Customize_Manager实例)
- 引入版本:WordPress 4.7.0
- 相关函数:在 WP_Customize_Manager::save_changeset_post() 中使用
代码示例
$data = apply_filters( 'customize_changeset_save_data', $data, $filter_context );
原文内容
Filters the settings’ data that will be persisted into the changeset.
Description
Plugins may amend additional data (such as additional meta for settings) into the changeset with this filter.
Parameters
$dataarray-
Updated changeset data, mapping setting IDs to arrays containing a $value item and optionally other metadata.
$contextarray-
Filter context.
uuidstringChangeset UUID.titlestringRequested title for the changeset post.statusstringRequested status for the changeset post.date_gmtstringRequested date for the changeset post in MySQL format and GMT timezone.post_idint|falsePost ID for the changeset, or false if it doesn’t exist yet.previous_dataarrayPrevious data contained in the changeset.managerWP_Customize_ManagerManager instance.
Source
$data = apply_filters( 'customize_changeset_save_data', $data, $filter_context );
Changelog
| Version | Description |
|---|---|
| 4.7.0 | Introduced. |