add_option_whitelist()
云策文档标注
概述
add_option_whitelist() 是一个已弃用的 WordPress 函数,用于将选项数组添加到允许选项列表中。自 WordPress 5.5.0 起,建议使用 add_allowed_options() 替代。
关键要点
- 函数 add_option_whitelist() 已弃用,自版本 5.5.0 起应改用 add_allowed_options()。
- 参数包括必需的 $new_options 数组和可选的 $options 字符串或数组,返回数组。
- 相关函数包括 add_allowed_options() 和 _deprecated_function(),用于处理允许选项和弃用通知。
注意事项
在开发插件或主题时,避免使用此弃用函数,以保持代码兼容性和遵循 WordPress 最佳实践。
原文内容
Adds an array of options to the list of allowed options.
Parameters
$new_optionsarrayrequired$optionsstring|arrayrequired
Source
function add_option_whitelist( $new_options, $options = '' ) {
_deprecated_function( __FUNCTION__, '5.5.0', 'add_allowed_options()' );
return add_allowed_options( $new_options, $options );
}
Changelog
| Version | Description |
|---|---|
| 5.5.0 | Deprecated. Use add_allowed_options() instead. Please consider writing more inclusive code. |
| 2.7.0 | Introduced. |
Skip to note 2 content
David Brumbaugh
Here’s a nice little tutorial that uses add_option_wp_whitelist: http://wpmututorials.com/how-to/writing-plugins/