WP_Customize_Filter_Setting
云策文档标注
概述
WP_Customize_Filter_Setting 是 WordPress 自定义器中的一个设置类,用于过滤值但不保存结果。开发者需通过其他设置或回调来处理过滤后的值。
关键要点
- WP_Customize_Filter_Setting 继承自 WP_Customize_Setting,专门用于值过滤而非持久化存储。
- 过滤后的结果应由另一个设置或回调函数处理,以确保正确应用。
- 该类自 WordPress 3.4.0 版本引入,是自定义器 API 的一部分。
代码示例
class WP_Customize_Filter_Setting extends WP_Customize_Setting {
/**
* Saves the value of the setting, using the related API.
*
* @since 3.4.0
*
* @param mixed $value The value to update.
*/
public function update( $value ) {}
}注意事项
使用 WP_Customize_Filter_Setting 时,需注意其 update 方法不实际保存值,开发者应结合 WP_Customize_Setting 或其他机制来管理数据。
原文内容
A setting that is used to filter a value, but will not save the results.
Description
Results should be properly handled using another setting or callback.
See also
Methods
| Name | Description |
|---|---|
| WP_Customize_Filter_Setting::update | Saves the value of the setting, using the related API. |
Source
class WP_Customize_Filter_Setting extends WP_Customize_Setting {
/**
* Saves the value of the setting, using the related API.
*
* @since 3.4.0
*
* @param mixed $value The value to update.
*/
public function update( $value ) {}
}
Changelog
| Version | Description |
|---|---|
| 3.4.0 | Introduced. |