PHP通知:未定义的偏移量:/wordpress/wp-includes/plugin.php中的0和寄存器设置API更改

时间:2017-11-02 作者:here

WordPress v4上运行的插件遇到以下类型的错误。x并隔离到register\\u setting()调用。

[02-Nov-2017 00:55:35 UTC] PHP Notice:  Undefined offset: 0 in /wordpress/wp-includes/plugin.php on line 981
[02-Nov-2017 00:55:35 UTC] PHP Notice:  Undefined offset: 0 in /wordpress/wp-includes/plugin.php on line 999
有什么好处?

类似但不同的根本原因Plugin.php: PHP Notice: Undefined offset: 0 in

1 个回复
SO网友:here

https://make.wordpress.org/core/2016/10/26/registering-your-settings-in-wordpress-4-7/

这个register_setting() function 签名在v4中更改。7允许使用第三个选项的数组代替先前版本中的回调函数。将数组传递给WordPress v4中的register\\u setting()。6、x及更早版本将导致上述错误。

WordPress v4。6.8功能定义:https://github.com/WordPress/WordPress/blob/1aa173010736085a921beb10fd420d6d863419a5/wp-admin/includes/plugin.php#L1767-L1795

/**
 * Register a setting and its sanitization callback
 *
 * @since 2.7.0
 *
 * @global array $new_whitelist_options
 *
 * @param string $option_group A settings group name. Should correspond to a whitelisted option key name.
 *  Default whitelisted option key names include "general," "discussion," and "reading," among others.
 * @param string $option_name The name of an option to sanitize and save.
 * @param callable $sanitize_callback A callback function that sanitizes the option\'s value.
 */

结束

相关推荐