Undefined array key
-
When customizing seperate accordions with colors, a PHP warning appears as of PHP 8.0 and above. It will turn in to an error in a future version of php.
Warning : Undefined array key "color" in /wp-content/plugins/advanced-accordion-block/advanced-accordion-block.php on line 146 Warning : Undefined array key "color" in /wp-content/plugins/advanced-accordion-block/advanced-accordion-block.php on line 148
I have done a quick and dirty patch that checks if the key is set, and if not, sets the custom css to an invalid property the browser will ignore.
/*line 140 in advanced-accordion-block/advanced-accordion-block.php*/ // separate accordion public function aagb_render_group_accordion($attributes, $content){ if(! is_admin( )){ $handle = 'aagb-'.$attributes['uniqueId']; $custom_css = ''; // container if(isset($attributes['activeAccordionBorder']['color'])){ $activeAccordionBorderColor = $attributes['activeAccordionBorder']['color']; } else { $activeAccordionBorderColor = 'no-val'; } if(isset($attributes['activeAccordionBorder']['width'])){ $activeAccordionBorderWidth = $attributes['activeAccordionBorder']['width']; } else { $activeAccordionBorderWidth = 'no-val'; } if(isset($attributes['activeAccordionBorder']['style'])){ $activeAccordionBorderStyle = $attributes['activeAccordionBorder']['style']; } else { $activeAccordionBorderStyle = 'no-val'; } $custom_css .= '.aagb_accordion_'.$attributes['uniqueId'].' .aagb__accordion_active{ border-color: '.$activeAccordionBorderColor.' !important; border-width: '.$activeAccordionBorderWidth.'!important; border-style: '.$activeAccordionBorderStyle.'!important; }'; // body $custom_css .= '.aagb_accordion_'.$attributes['uniqueId'].' .aagb__accordion_body--show{ border-top-color: '.$activeAccordionBorderColor.' !important; border-top-width: '.$activeAccordionBorderWidth.'!important; border-top-style: '.$activeAccordionBorderStyle.'!important; }'; $this->aagb_render_inline_css( $handle, $custom_css ); } return $content; }
- The topic ‘Undefined array key’ is closed to new replies.