Notice: The function WP_Scripts::localize was called incorrectly. The parameter $l10n must be an array. To pass arbitrary data to scripts, use the wp_add_inline_script() function instead.
More information: Debugging in WordPress. (This message was added in version 5.7.0.) in /home/customer/www/XXX/public_html/XXX_stagi/wp-includes/functions.php on line 6085.
What can I do to solve the problem? Thanks
Notice: WP_Scripts :: localize Invalidly called. The $ l10n parameter should be an array. To pass random data into scripts, use wp_add_inline_script () instead. Please see WordPress Debugging for more information. (This message was added in version 5.7.0.) In /home1/nawwarst/public_html/wp-includes/functions.php on line 5313
]]>Here is the screenshot: https://prnt.sc/10hx431
]]>I’ve been attempting to determine the script handles produced by the plugin.
From what I can deduce from the plugin code, the script handle for a footer script for example would be footer-[data] with data being a string of letters and numbers.
When printing out the $wp_scripts variable, scripts loaded by the plugin were not there. Hopefully they are and I have something wrong.
It’d be great if I could access the scripts via their handles, could you assist?
Thanks in advance,
John
]]>[FATAL ERROR]
Fatal error: Call to undefined function wp_scripts() in /home/…../public_html/wp-content/plugins/wp-script-optimizer/classes/list.class.php on line 317
The above error appeared after clicking refresh the list.
Use the versions of WordPress 4.1 and WP Scripts & Styles Optimizer 0.3.0
https://www.ads-software.com/plugins/wp-script-optimizer/
]]>add_action('wp_enqueue_scripts', function(){
$system_jquery = $GLOBALS['wp_scripts']->registered['jquery'];
wp_deregister_script('jquery');
});
i’ve tried adding a priority value for the add_action.
]]>My website started outputting this error at the top of every page for users who are not logged in:
Warning: Invalid argument supplied for foreach() in /home/{site}/public_html/wordpress/wp-content/plugins/google-maps-builder/public/class-wordpress-google-maps.php on line 537
WordPress v4.1, Google Maps Builder v1.0.3.
The erroneous line is the following (function check_for_multiple_google_maps_api_calls()
):
//loop through registered scripts
foreach ( $wp_scripts->registered as $registered_script ) {
// Loop code...
}
When logged in (as an administrator, not sure if that part matters), the error does not occur. If I do a var_dump($wp_scripts)
just before the loop, it is NULL
for a guest.
I propose the following patch to prevent the error, inserted just before the loop in question. I haven’t dug further to see why the global is NULL
in the guest state, but this works as defensive programming anyways.
if(is_null($wp_scripts) || is_null($wp_scripts->registered)){
return $multiple_google_maps_api;
}
Thank you for your consideration.
https://www.ads-software.com/plugins/google-maps-builder/
]]>This doesn’t work, and I’m wondering why and how to fix it (for purely academic reasons):
function js_to_footer() {
global $wp_scripts;
set_footer_true( $wp_scripts->queue );
}
function set_footer_true( $scripts ) {
global $wp_scripts;
foreach( $scripts as $handle ) {
$wp_scripts->add_data( $handle, 'group', 1 );
set_footer_true( $wp_scripts->registered[$handle]->deps );
// looking at the registered scripts confirms their grouping changed
// var_dump( $wp_scripts->registered[$handle] );
}
}
add_action( 'wp_enqueue_scripts', 'js_to_footer', 11 );
I really don’t understand why. Setting a lower priority leaves jQuery in the head, but they don’t get loaded at all if a higher priority is set.
The code below is from Scripts to Footer plugin. It works, and I wonder why does simply removing these actions from the head get everything printed out in the footer?
function custom_clean_head() {
remove_action('wp_head', 'wp_print_scripts');
remove_action('wp_head', 'wp_print_head_scripts', 9);
remove_action('wp_head', 'wp_enqueue_scripts', 1);
}
add_action( 'wp_enqueue_scripts', 'custom_clean_head' );
Cheers,
Greg
Theres a way to get the registered scripts(wp_register_scripts())? I want to get them to load with head.js.
I gave a look at Wp_Scripts class, but I doesn’t found anything about:
https://core.trac.www.ads-software.com/browser/tags/3.4.2/wp-includes/class.wp-scripts.php
Thanks
]]>