• Resolved askpivot

    (@askpivot)


    Hi, upon updating to WordPress 5.7, we received this notice on multiple websites:

    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 /home/customer/public_html/wp-includes/functions.php on line 5313

    I traced this problem to the Post SMTP plugin, in
    wp-content/plugins/post-smtp/Postman/PostmanViewController.php.
    The wp_localize_script calls on line 173 are throwing a notice because they are passing a string, not an array, from what I can tell.

    • This topic was modified 3 years, 8 months ago by askpivot. Reason: Removed private path info
Viewing 15 replies - 1 through 15 (of 18 total)
  • It has happened to me in 3 of my 4 sites that I have with this plugin. I had to change plugin. Any solution?

    Thread Starter askpivot

    (@askpivot)

    We also have Post SMTP installed on many sites. This notice displays in any instance in which PHP notices are displayed in the wp admin and have WP 5.7+ installed, for instance if you have WP_DEBUG set to true. We are waiting on a hopeful fix from the plugin author here.

    I have the same problem with PostSMTP with WordPress 5.7

    Notice: WP_Scripts::localize werd verkeerd aangeroepen. De parameter $l10n moet een array zijn. Gebruik in plaats daarvan de functie wp_add_inline_script() om willekeurige gegevens aan scripts door te geven. Lees Foutopsporing in WordPress voor meer informatie. (Dit bericht is toegevoegd in versie 5.7.0.) in C:\ClientSites\tele-pc.nl\wpcode.tele-pc.nl\wordpress\wp-includes\functions.php on line 5313

    Hi All,

    I also have same issue all of my sites (3) where this plugin used.

    After deactivating this plugin, notice / warning messages gone.

    Regards,
    Jozsef

    Hi all!

    Escalating to the developer @yehudah for comment, unfortunately I am not sure on this one.

    Kind Regards,
    Tim

    Thank you, @askpivot. Changing the code in the Post SMTP plugin, in
    wp-content/plugins/post-smtp/Postman/PostmanViewController.php, lines 173-178 to send array rather than a string resolves the issue. For example:

    wp_localize_script( ‘jquery_steps_script’, ‘steps_current_step’, array(‘steps_current_step’) );

    For reference, please see WordPress Code reference for
    WP_Scripts::localize( string $handle, string $object_name, array $l10n )
    https://developer.www.ads-software.com/reference/classes/wp_scripts/localize/

    HOWEVER, this really needs to be fixed by the developer ( @yehudah ) and released in next version.

    Joe N

    • This reply was modified 3 years, 7 months ago by Joe Nasevich.

    Thanks Joe, that stops the debug message.

    Just released a version.

    Hello @yehudah!

    I confirm, that issues resolved on my sites.

    Thank you!

    Regards,
    Jozsef

    @drseo

    Thank you for the update.

    I am also receiving this error message, I’ve freshly installed this on a new site…

    @ehlanafoley – please start a new thread and link to this one.

    Your Post SMTP diagnostics log would also be helpful.

    Kind Regards,
    Tim

    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 /home/askjohnsnow/public_html/wp-includes/functions.php on line 5313

    I am seeing this on clean install… with WP Mail SMTP

    appears to be affecting more than one Mail Plugin

    This is a new warning appearing in WordPress 5.7. If you don’t want to see it, and still want to have WP_DEBUG set to true, it is possible to disable the message by adding the following for example in your theme’s functions.php:

    add_filter('doing_it_wrong_trigger_error', function () {return false;}, 10, 0);

    Thanks @kamranmayo! ??

    Kind Regards,
    Tim

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘WP 5.7 – Notice: WP_Scripts::localize was called incorrectly.’ is closed to new replies.