Resolved
Resolved in: 3.1.8
Overview of the issue
- Full error notice: Notice: WP_Scripts::localize was called <strong>incorrectly</strong>. The <code>$l10n</code> parameter must be an array.
- We have a new notice appearing with WordPress version 5.7
- You will see this error ONLY if you have wp_debug enabled.
We are aware of this issue, we have a fix already, and we will release a version that will include the right fix after we finish testing it soon.
Workaround
A fix will be released soon for this issue.
Here’s a patch to prevent the notice:
Edit the file wp-content/plugins/wpml-string-translation/classes/menus/theme-plugin-localization-ui/class-wpml-st-theme-plugin-localization-resources.php on line 27 and replace:
get_option( WPML_ST_Themes_And_Plugins_Updates::WPML_ST_ITEMS_TO_SCAN )
By:
get_option( WPML_ST_Themes_And_Plugins_Updates::WPML_ST_ITEMS_TO_SCAN, [] )
The patch that you are proposing did not fix the issue for us. What we did was to put WP_DEBUG to off mode.
But even though the errors are not showing, we have an adverse effect where our top menu does not translate anymore.
Thanks and sorry! – We are looking into this
#SOLVED
The patch seems to work for me, the line is just few steps below, not 27 but 34.
31 wp_localize_script(
32 ‘wpml-theme-plugin-localization-scan’,
33 ‘wpml_groups_to_scan’,
34 get_option( WPML_ST_Themes_And_Plugins_Updates::WPML_ST_ITEMS_TO_SCAN, [] )
35 );
Thanks
We are glad that it worked and thank you for your report.
We are looking into this.
This is what I am getting in my WP dashboard “Notice: WP_Scripts::localize was called incorrectly. The $l10n parameter must be an array. To pass arbitrary data to scripts, use the wp_add_inline_script() function instead. Please see Debugging in WordPress for more information. (This message was added in version 5.7.0.)”.
Thank you for your report, could you please try the workaround provided?
Don’t mention it, thank you for all the energy you put in this fantastic system.
Thank you very much for your kind words. <3
It helps. Thank you.
Same issue as above, when is update available from you to fix? Thanks!
Thank you for your report, however we don’t have an ETA yet, could you please try the workaround provided in the meantime?
Just a quick update here – we already have a fix for this issue; it is being tested and will be released very soon.
Same problem here, solved with the workaround.
We are glad it worked, it should be solved with WPML String Translation 3.1.8 which was released yesterday.
This issue should be solved with today’s WPML release.
Hello, when the new release will be available as I’m encountering similar problem?
“Notice: WP_Scripts::localize was called incorrectly. The $l10n parameter must be an array. To pass arbitrary data to scripts, use the wp_add_inline_script() function instead. Please see Debugging in WordPress for more information. (This message was added in version 5.7.0.) in /var/www/wp-includes/functions.php on line 5313”
Hello there,
This issue should be solved with WPML String Translation 3.1.8 which was released yesterday.
Don’t hesitate to make a full backup of your site and update your WPML package.
Regards
Thanks for your answer but the issue persists even after update.
Thank you for your report. Could you please open a ticket in our support forum so we can take a look into your site?
https://wpml.org/forums/forum/english-support/
Hi, having same error, but the site does not have a folder wp-content/plugins/wpml-string-translation etc. How can it throw an error if it’s not even there?
I can hide the error message on front end by turning debug to false, but site has been going down quite a bit recently. Do you think the error is related to it going offline? (SSL errors, timeouts)
thanks
Nancy
Hello Nancy,
This error was associated to WPML String Translation, so that folder should be there unless you don’t have this extension installed. 🙂
Thus, if you don’t have this folder, I strongly recommend you to delete your WPML String Translation plugin and upload a new copy:
https://wpml.org/account/downloads/
If the issue persists after our latest update, please open a ticket in our support forum:
https://wpml.org/forums/forum/english-support/
Regards