Tagged: API, google maps, warning
-
AuthorPosts
-
April 14, 2014 at 3:10 pm #251101
Hi Guys,
I am using the WP Store Locator plugin and part of it is not working. The plugin author told me it’s a js error. I deactivated all other plugins and the problem still remained, so I think it must be a conflict between Enfold and the plugin. There are no errors reported on the frontend but the backend, using firebug, reports the following error:
Warning: you have included the Google Maps API multiple times on this page. This may cause unexpected errors. (main.js:54)
I am not using google maps anywhere else on the site and as I said, all other plugins were deactivated and I still had the same problems. I tried adding the various codes to my child theme functions.php, that you guys have provided in other threads, for similar errors e.g.:
add_filter( 'avia_google_maps_widget_load_api', 'avia_remove_widget_script', 10, 2); function avia_remove_widget_script($load, $config) { $content = apply_filters('avia_builder_precompile', get_post_meta(get_the_ID(), '_aviaLayoutBuilderCleanData', true)); if(strpos($content, 'avia-google-maps')) return false; return true; }
But none of them worked and the Google Maps API warning still showed up. Any other ideas? I’ve contacted the author of the plugin to see if he can test it against Enfold but not sure he’ll be able to help. The plugin works fine with other themes, so although it’s not really your responsibility, I was hoping you may be able to shed light on where else the api is being called or used?
Thanks,
Matt
April 14, 2014 at 3:21 pm #251108Hi meanster99!
Thank you for using the theme!
Please post the website url here. We would like to check the website but, unfortunately, we can’t promise that we will be able to help with the issue because it is related with a third party plugin. Regretfully, we cannot provide support for third party plugins or scripts as stated on the support policy due to the fact that there is simply no way to account for all of the potential variables at play when using another developer’s plugin or script. Because of this, any questions you have regarding setup, integration, or troubleshooting any piece of functionality that is not included with the theme package should be directed to the plugin author.
Thank you for understanding.
Cheers!
IsmaelApril 14, 2014 at 3:49 pm #251140Hi Ismael,
Thanks and I appreciate you can’t support 3rd party plugins, so I am grateful. However, I’ve just tested a clean install of Enfold with just this WP Store Locator plugin installed and I am still getting the Google Maps API warning. I’ve changed themes to twentyfourteen and it works fine with that, so it must be Enfold is using the Google Maps API somewhere, even though I haven’t put any google maps on the test site (clean install)??
I’ve set-up a temporary test site with only Enfold and WP Store Locator installed and have given a login to the plugin author, so hopefully he’ll try and find a fix – I reminded him how popular Enfold was and that it would be beneficial to have his theme working with such a top seller, so hopefully he’ll help!
However, if you did want to just test it yourself with Enfold and WP Store Locator, please feel free and let me know if you work anything out! Or if you can point out where the other instance of Google Maps API is being included?
Many thanks,
Matt
- This reply was modified 10 years, 6 months ago by MM.
April 15, 2014 at 6:57 am #251450Hey!
You can also try this code:
add_action('after_setup_theme','avia_deactivate_google_api',10); function avia_deactivate_google_api() { global $avia_config; $avia_config['g_maps_widget_active'] = 1; }
Best regards,
PeterApril 15, 2014 at 8:13 am #251481Hi Peter,
Unfortunately, that doesn’t work either. The google maps api warning is still there (I’d emptied all caches). Looks like the plugin author is not going to get back to me either. Any other ideas?
Many thanks,
Matt
April 15, 2014 at 1:10 pm #251567Hi guys,
Maybe you can help me now I’ve worked out where the other instances of maps.google.com, that affect the WP Store Locator plugin, are located:
file affected: wp-content/themes/enfold/framework/php/class-framework-widgets.php
function I commented out (line 1133 onwards):function helper_print_google_maps_scripts() { $prefix = is_ssl() ? "https" : "http"; wp_register_script( 'avia-google-maps-api', $prefix.'://maps.google.com/maps/api/js?sensor=false', array('jquery'), '3', true); wp_enqueue_script( 'avia-google-maps-api' ); $is_widget_edit_page = in_array(basename($_SERVER['PHP_SELF']), array('widgets.php')); if($is_widget_edit_page) { wp_register_script( 'avia-google-maps-widget', AVIA_JS_URL.'conditional_load/avia_google_maps_widget.js', array( 'jquery','media-upload','media-views' ), '1.0.0', true); wp_enqueue_script( 'avia-google-maps-widget' ); $args = array( 'toomanyrequests' => __("Too many requests at once, please refresh the page to complete geocoding",'avia_framework'), 'latitude' => __("Latitude and longitude for",'avia_framework'), 'notfound' => __("couldn't be found by Google, please add them manually",'avia_framework'), 'insertaddress' => __("Please insert a valid address in the fields above",'avia_framework') ); wp_localize_script( 'avia-google-maps-api', 'AviaMapTranslation', $args ); } }
File affected: wp-content/themes/enfold/config-templatebuilder/avia-shortcodes/google_maps.php
Function I commented out (line: 31 onwards):function extra_assets() { if(is_admin()) { $prefix = is_ssl() ? "https" : "http"; wp_register_script( 'avia-google-maps-api', $prefix.'://maps.google.com/maps/api/js?sensor=false', array('jquery'), '3', true); wp_enqueue_script( 'avia-google-maps-api' ); $args = array( 'toomanyrequests' => __("Too many requests at once, please wait a few seconds before requesting coordinates again",'avia_framework'), 'notfound' => __("Address couldn't be found by Google, please add it manually",'avia_framework'), 'insertaddress' => __("Please insert a valid address in the fields above",'avia_framework') ); wp_localize_script( 'avia-google-maps-api', 'avia_gmaps_L10n', $args ); } }
After commented out these 2 functions the WP Store Locator plugin now works as it should, but obviously this is a temp fix as I will need to repeat the process after every update. Therefore, now you can see which functions are affected, would it be possible to provide me with some code I can add to my child theme’s functions.php? I know it’s a big ask (or not – not sure how easy it is for you guys!), but this would be a massive help if it’s not too much trouble for one of you php gurus?
Many thanks
Matt
April 16, 2014 at 9:31 am #251991Hi!
I’ll ask Kriesi to add a filter to the next theme update which will allow you to deactivate the map api. At the moment you must comment it out in the parent theme files.
Regards,
PeterApril 16, 2014 at 9:38 am #251997Hi!
Ok, with the next update you can use this code in your child theme functions.php file:
add_filter('avia-google-maps-api', '__return_false', 10, 2);
to deactivate the api scripts.
Cheers!
PeterApril 16, 2014 at 2:18 pm #252104Hi Peter,
That is great news. Yet again you guys deliver. So do I need to wait for 2.6.4 or will it work for 2.6.3, which was an update today, so I’m not sure whether it was before or after your post!
Huge thanks again.
Matt
April 18, 2014 at 8:16 am #253032Hey!
Tbh I’m not sure if it will work with 2.6.4. Personally I merge my code/patches with the developer version of Enfold which is v2.7. We’ll release the new version (with major enhancements) next week. However maybe Kriesi already included my patch into the (minor) v2.6.4 update. I really don’t know it though. If this: https://kriesi.at/support/topic/google-maps-api-multiple-times-on-the-page/#post-251997 code doesn’t work yet please wait for the 2.7 update – then it will work for sure.
Cheers!
PeterJune 23, 2014 at 4:28 pm #282539Hi,
I am encountering the same problem using WP GeoDirectory Plugin. I am using Enfold 2.7.1 and tried the given code:
`add_filter(‘avia-google-maps-api’, ‘__return_false’, 10, 2);
in my child themes functions.php but no luck,
Am I missing something ?
Thanks, Achim
June 23, 2014 at 4:34 pm #282544Hi!
Please update Enfold to the latest version 2.8.1 via FTP – http://vimeo.com/67209750
Best regards,
YigitJune 23, 2014 at 6:13 pm #282600Hi Yigit,
thanks for your response. I updated to 2.8.1 but still no luck.
Google Maps API are still activited multiple times
Regards, Achim
-
AuthorPosts
- The topic ‘Google Maps API multiple times on the page’ is closed to new replies.