sayontan/suffusion

PHP error in functions.php

Closed this issue · 1 comments

Warning: A non-numeric value encountered in /var/www/html/wp-content/themes/suffusion/functions.php on line 148

That code:

$header_args['width'] = $options['suf_main_col_width'] + $options['suf_sb_1_width'] + $options['suf_sb_2_width'];

The error comes about if the Default Sidebar Layout settings have empty string in for those values. This is unexpected, because the field descriptions state:

Enter the number of pixels here (don't enter 'px'). Non-integers will be ignored. Incompatible values will be treated as [number]

So despite this message, the defaults are not taken into account when left empty, and errors occur.

Good news: the workaround is to simply put the default value into the settings instead of leaving empty.

$header_args['width'] = $options['suf_main_col_width'] + $options['suf_sb_1_width'] + $options['suf_sb_2_width'];

mmm, maybe it needs something like

$options = array_filter($options , fn($value) => (!is_null($value) && $value !== ''));

before

$options = wp_parse_args((array)$options, $defaults);

to remove the empty values and take over the defaults