Skip Navigation

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, [] )

21 Responses to “Notice: WP_Scripts::localize was called with WP 5.7”

  1. 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.

  2. #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

  3. 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, however we don’t have an ETA yet, could you please try the workaround provided in the meantime?

  4. Just a quick update here – we already have a fix for this issue; it is being tested and will be released very soon.

  5. 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”

  6. 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