I’ve had the exact same problem @lowegreg. I went into /plugins/svg-support/functions/enqueue.php and replaced those two lines with these lines, including a comment:
/* fix for wp_localize_script (third parameter) not being called with an array
* ref: https://stackoverflow.com/questions/66611705/getting-notice-is-wordpress-wp-scriptslocalize-was-called-incorrectly
*
* original code:
* wp_localize_script( 'bodhi_svg_inline', 'cssTarget', $css_target_array );
* wp_localize_script( 'bodhi_svg_inline', 'ForceInlineSVGActive', $force_inline_svg_active );
*/
wp_localize_script( 'bodhi_svg_inline', 'cssTarget', array($css_target_array) );
wp_localize_script( 'bodhi_svg_inline', 'ForceInlineSVGActive', array($force_inline_svg_active) );
While this fixes the fatal error I was getting on my website, I still get an error in my browser console that I haven’t been able to resolve:
Firefox:
Uncaught TypeError: i is undefined
bodhisvgsInlineSupport [site-domain]/wp-content/plugins/svg-support/js/min/svgs-inline-min.js?ver=1.0.0:1
Chrome:
Uncaught TypeError: Cannot read property 'endsWith' of undefined
at String.<anonymous> (svgs-inline-min.js?ver=1.0.0:1)
Please help, thanks!
Passing arrays to wp_localize_script() does remove the PHP notice (since wp_localize_script is expecting an array for the third argument), but then the passed data isn’t in the format the svgs-inline.js script expects.
The message in the error log suggested using the wp_add_inline_script() function instead. This worked for me to remove the errors (replaces lines 144 and 145 of svg-support/functions/enqueue.php):
wp_add_inline_script(
'bodhi_svg_inline',
sprintf(
'cssTarget=%s;ForceInlineSVGActive=%s;',
json_encode($css_target_array),
json_encode($force_inline_svg_active)
)
);
Thank you @jasontremblay!
I did find another solution on this support page:
https://wordpress.org/support/topic/svg-support-advanced-settings-trigger-wp-error-under-latest-wp-ver-php-8/
If you scroll to the bottom, @huntprod gives a solution that worked for me. His work is linked at https://gist.github.com/jhunt/61261891aed0c46d065604c6c67e3b10. It involves editing three files (svg-support/functions/enqueue.php, svg-support/js/svgs-inline.js, and svg-support/js/min/svgs-inline-min.js).
Your solution @jasontremblay is probably cleaner/simpler, so thank you for providing it!
Sorry for the delay everyone! I have fixed this issue, but was also trying to roll in some new features too… but they’re taking longer than expected. So I’ll be looking at pushing an update this week that addresses this issue at least!
Please fix this! This issue causes a lot of suffering.
I FINALLY pushed out an update with a fix for this in it. 2.3.19 should have it sorted.
But please do let me know if you come across any issues by opening a new thread.
I’ll mark this one as resolved now.
Thanks @jasontremblay I ended up using your code after trying about 10 different things after I finally got the warnings displaying in a few dev environments.