Title: Function WP_Scripts::localize was called incorrectly
Last modified: April 3, 2023

---

# Function WP_Scripts::localize was called incorrectly

 *  Resolved [ebai4](https://wordpress.org/support/users/ebai4/)
 * (@ebai4)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/function-wp_scriptslocalize-was-called-incorrectly-2/)
 * With the latest WP **6.2** I’m getting this notice:
 * plugins\**wpvr**\admin\class-wpvr-admin.php:243
 *     ```wp-block-code
       [03-Apr-2023 09:47:06 UTC] PHP Notice:  Function WP_Scripts::localize was called <strong>incorrectly</strong>. The <code>$l10n</code> parameter must be an array. To pass arbitrary data to scripts, use the <code>wp_add_inline_script()</code> function instead. Please see <a href="https://wordpress.org/documentation/article/debugging-in-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 5.7.0.) in xxxxxxxx\wp-includes\functions.php on line 5865
   
       [03-Apr-2023 09:47:06 UTC] PHP Stack trace:
   
       [03-Apr-2023 09:47:06 UTC] PHP   1. {main}() xxxxxxxx\wp-admin\admin.php:0
   
       [03-Apr-2023 09:47:06 UTC] PHP   2. require_once() xxxxxxxx\wp-admin\admin.php:239
   
       [03-Apr-2023 09:47:06 UTC] PHP   3. do_action() xxxxxxxx\wp-admin\admin-header.php:118
   
       [03-Apr-2023 09:47:06 UTC] PHP   4. WP_Hook->do_action() xxxxxxxx\wp-includes\plugin.php:517
   
       [03-Apr-2023 09:47:06 UTC] PHP   5. WP_Hook->apply_filters() xxxxxxxx\wp-includes\class-wp-hook.php:332
   
       [03-Apr-2023 09:47:06 UTC] PHP   6. Wpvr_Admin->enqueue_scripts() xxxxxxxx\wp-includes\class-wp-hook.php:308
   
       [03-Apr-2023 09:47:06 UTC] PHP   7. wp_localize_script() xxxxxxxx\wp-content\plugins\wpvr\admin\class-wpvr-admin.php:243
   
       [03-Apr-2023 09:47:06 UTC] PHP   8. WP_Scripts->localize() xxxxxxxx\wp-includes\functions.wp-scripts.php:221
   
       [03-Apr-2023 09:47:06 UTC] PHP   9. _doing_it_wrong() xxxxxxxx\wp-includes\class-wp-scripts.php:502
   
       [03-Apr-2023 09:47:06 UTC] PHP  10. trigger_error() xxxxxxxx\wp-includes\functions.php:5865
       ```
   

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Jahir Chowdhury](https://wordpress.org/support/users/jahirchowdhury/)
 * (@jahirchowdhury)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/function-wp_scriptslocalize-was-called-incorrectly-2/#post-16631429)
 * Hi [@ebai4](https://wordpress.org/support/users/ebai4/) ,
 * Thank you for informing us about it.
 * We’re forwarding this to our developers to have a look.
 * Thank you for your patience.
 * Regards,
 *  [Jahir Chowdhury](https://wordpress.org/support/users/jahirchowdhury/)
 * (@jahirchowdhury)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/function-wp_scriptslocalize-was-called-incorrectly-2/#post-16634919)
 * Hi [@ebai4](https://wordpress.org/support/users/ebai4/) ,
 * We tried it on multiple testing sites on our end but couldn’t replicate the issue.
 * Can you please make sure that WPVR is updated to the latest version?
 * And then run a plugin conflict test to see if it’s due to a conflict with any
   other plugin.
 * You can also contact us on our site.
 * Regards,
 *  [darkoth](https://wordpress.org/support/users/darkoth/)
 * (@darkoth)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/function-wp_scriptslocalize-was-called-incorrectly-2/#post-16680715)
 * I had the same error. Problem was in class-wpvr-admin.php
 * I have replaced this:
 *     ```wp-block-code
       wp_localize_script(
       	$this->plugin_name,
       	'admin_url',
       	admin_url()
       );
       ```
   
 * with this:
 *     ```wp-block-code
       wp_localize_script(
       	$this->plugin_name,
       	'admin_url',
       	array('admin_url()')
       );
       ```
   
 * And error message is gone. What do you think about this solution Jahir?
    -  This reply was modified 3 years, 1 month ago by [darkoth](https://wordpress.org/support/users/darkoth/).
    -  This reply was modified 3 years, 1 month ago by [darkoth](https://wordpress.org/support/users/darkoth/).
 *  [Jahir Chowdhury](https://wordpress.org/support/users/jahirchowdhury/)
 * (@jahirchowdhury)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/function-wp_scriptslocalize-was-called-incorrectly-2/#post-16687245)
 * Hi [@darkoth](https://wordpress.org/support/users/darkoth/) ,
 * Thank you so much for your input.
 * I’m forwarding it to our devs. I’ll let you know as soon as I hear something 
   from them.
 * Regards,
 *  [Jahir Chowdhury](https://wordpress.org/support/users/jahirchowdhury/)
 * (@jahirchowdhury)
 * [3 years ago](https://wordpress.org/support/topic/function-wp_scriptslocalize-was-called-incorrectly-2/#post-16732553)
 * Hi [@ebai4](https://wordpress.org/support/users/ebai4/) & [@darkoth](https://wordpress.org/support/users/darkoth/),
 * Thank you for your patience.
 * We’ve just released an update of the plugin with a fix to this issue.
 * Please update your plugin to the latest version and see if it’s resolved.
 * Let us know if the issue is still there.
 * Regards,

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Function WP_Scripts::localize was called incorrectly’ is closed to new
replies.

 * ![](https://ps.w.org/wpvr/assets/icon-256x256.gif?rev=2480604)
 * [WP VR - 360 Panorama and Free Virtual Tour Builder For WordPress](https://wordpress.org/plugins/wpvr/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpvr/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpvr/)
 * [Active Topics](https://wordpress.org/support/plugin/wpvr/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpvr/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpvr/reviews/)

## Tags

 * [wp_localize_script](https://wordpress.org/support/topic-tag/wp_localize_script/)

 * 5 replies
 * 3 participants
 * Last reply from: [Jahir Chowdhury](https://wordpress.org/support/users/jahirchowdhury/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/function-wp_scriptslocalize-was-called-incorrectly-2/#post-16732553)
 * Status: resolved