Invalid Argument
-
Hi,
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 isNULL
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.
- The topic ‘Invalid Argument’ is closed to new replies.