The problem is on lines 144 and 145 of functions/enqueue.php. Need to pass an array as the third parameter.
Me too – problem I have is I’m developing for a client and it doesn’t look good for that to be showing right before we were due to go live. Besides hiding the error message by turning off debugging – do we have any additional ideas for fixing it? As mentioned it appears to be due to the wrong variable type being passed in the new version 5.7 just released.
maybe a check inside this function – https://developer.ww.wp.xz.cn/reference/functions/wp_localize_script/
To handle older versions of the handler?
I guess I can add something to my own includes/function.php but rather not mess with core files when it will just get overwritten in the next release.
Thanks!
Hey everyone, I’m really sorry for the delay in getting back to you!
I’ll be working on this very soon and will address this issue and others all together.
Thanks for your patience!
any update.. i am facing this issues from more than 4 months. there is no resolution from support team either.
Thanks in advance.
Hey everyone, I’m looking into this now (finally, sorry for the delay – I’m just one person and life has been outta hand), but I can’t reproduce this so far.
I have installed a fresh nightly build of WordPress with PHP8 and will continue to try and reproduce.
I’ll make any changes I can asap.
Thanks for your patience!
Hi Benbodhi, this notice is triggered if in function bodhi_svgs_inline() the value $bodhi_svgs_options['force_inline_svg'] is empty and the else branch ist executed.
WP function wp_localize_script() requires an array as third parameter but the values assigned in the else branch are strings.
I’ve added an excerpt of the stack trace of the PHP notice for the call in line 144:
at 10 /usr/www/users/stagih/wp-includes/class.wp-scripts.php#496 -> _doing_it_wrong(WP_Scripts::localize,Der Parameter <code>$l10n</code> muss ein Array sein. Um beliebige Daten an Skripte zu übergeben, verwende stattdessen die Funktion <code>wp_add_inline_script()</code>.,5.7.0)
at 11 /usr/www/users/stagih/wp-includes/functions.wp-scripts.php#221 -> localize(bodhi_svg_inline,cssTarget,img.style-svg)
at 12 /usr/www/users/stagih/wp-content/plugins/svg-support/functions/enqueue.php#144 -> wp_localize_script(bodhi_svg_inline,cssTarget,img.style-svg)
at 13 /usr/www/users/stagih/wp-includes/class-wp-hook.php#292 -> bodhi_svgs_inline()
SVG Support version 2.3.18
Here’s how to fix it:
In file svg-support/functions/enqueue.php replace lines 144 and 145 with this:
wp_add_inline_script( 'bodhi_svg_inline', "var cssTarget = \"$css_target_array\"; var ForceInlineSVGActive = \"$force_inline_svg_active\";" );
As long as the variables are properly escaped it should work.
wp_localize_script() should no longer be used for injecting non-localization related javascript since WordPress 4.5 introduction of the wp_add_inline_script() function.
Sorry for the delay in updates everyone!
I have been hoping to roll in some new features with this fix, but they’re taking longer than expected.
So I’m looking at pushing out an update this week to address this issue at least.
Thanks for your patience!
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.