我在wordpress中有一个插件的自定义选项,它可以正常工作直到我进行升级,我使用的是一个在github中找到的自定义类
class RationalOptionPages {
/* ==========================================================================
Vars
========================================================================== */
protected $attributes = array(
'input' => array(
'autocomplete' => false,
'autofocus' => false,
'disabled' => false,
'list' => false,
'max' => false,
'maxlength' => false,
'min' => false,
'pattern' => false,
'readonly' => false,
'required' => true,
'size' => false,
'step' => false,
), 我为这些选项又画了一页
'section-three' => array(
'title' => __( 'Block', 'sample-domain' ),
'fields' => array(
'radio' => array(
'uid' => 'asp_typing_option',
'title' => __( 'Typing Block Option', 'sample-domain' ),
'type' => 'radio',
'value' => 'option-one',
'choices' => array(
'option-one' => __( 'Active', 'sample-domain' ),
'option-two' => __( 'Deactivate', 'sample-domain' ),
),
),
),
), 当我重设网站,然后输出错误时,就会出现问题。
Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\wordpress\wp-content\plugins\redux-framework\init.php on line 3 theerror is for all the options, then i save and the error disappear我用这种方式调用这些选项
$opt_sectionas = get_option('sample-page')['asp_section_option'];
$opt_carousel = get_option('sample-page')['asp_carousel_option'];
$opt_animate = get_option('sample-page')['asp_animate_aos_option'];
$opt_columns = get_option('sample-page')['asp_advance_columns_option'];发布于 2022-07-23 03:01:22
我解决了这个问题,在“看涨选项”部分的旁边添加了一个旧版本。
$opt_sectionas = get_option('sample-page')['asp_section_option'];
$opt_carousel = get_option('sample-page')['asp_carousel_option'];这是新版本
$opt_sectionas = get_option('sample-page')['asp_section_option'] ?? '';
$opt_carousel = get_option('sample-page')['asp_carousel_option'] ?? ''; https://stackoverflow.com/questions/73087497
复制相似问题