Hi,
I’m getting multiple warning messages at the top of each page at the frontend regarding the following:
PHP Warning: Undefined array key 0 in /wp-content/plugins/cornerstone/includes/classes/Services/GlobalFonts.php on line 292.
These warnings are NOT suppressed by settings WP_DEBUG to false as suggested in this post from februari 2023: https://theme.co/forum/t/multiple-errors-warnings-and-others-when-upgrading-to-php-8-1-12/103053
PHP 8.2.11
WP 6.4.x
CS 7.4.x
Here’s a quick for you that didn’t take almost a year to come up with:
public function getClosestWeight( $current, $fallback, $options) {
$value = intval( empty( $current ) ? $fallback : $current);
$value = $value ? $value : $fallback;
$numeric = array_filter(array_map(function($item) {
return intval($item);
}, $options));
usort($numeric,function($a,$b) use ($value){
return abs($a - $value) - abs($b - $value);
});
// QUICK FIX
if ( !$numeric || !is_array( $numeric ) ) return $fallback;
return strval($numeric[0] ? $numeric[0] : $fallback);
}