Now Reading
WordPress Plugin Developers – Please Stop Auto Enabling Google Maps Api’s
Bright Idea
0

WordPress Plugin Developers – Please Stop Auto Enabling Google Maps Api’s

by Simon ParkerSeptember 4, 2019

I have wasted another day finding a hidden setting in another plugin that includes the Google Maps Api js without a key.

At Coffee Black we have a sort of rolling default setup for new WordPress websites.

It includes all of the plugins we always use and some tweaks and other nice to haves which make our lives so much simpler and makes us more efficient when creating a new site.

We use WP Bakery Page builder on all of our client sites and several addons for this.

Over the past 6 months, I have now spent an inordinate amount of time troubleshooting Google Maps API errors.

That seems like a simple thing to do right?

Here lies the issue. When you get an issue in WordPress the first port of call is generally to open console and see whats up.

But with a Google maps API error it only shows you the remote scripts and not the js file or PHP file that is calling the script.

Without the offending file being shown we can naturally assume that the component/plugin on the current page is what is causing the issue.

In my case this was LocatorAid a nice store locator plugin we have used on a few sites to show stockists or offices.

I raise a support ticket as the API key works fine in the back end of the site, they usefully load a google map on the api key config page so you can confirm it is working correctly, but on the front end I get the dreaded “Do you own this website” error

Now over the past six months we have had around 4 or 5 occasions when we have had odd API key issues, it turns out that the reason we were getting the API key issue is that another plugin is trying to load the maps API before the one we are troubleshooting.

Plugin Developers are including maps functionality into their plugins and activating the script includes by default.

Now until perhaps a year ago this wasn’t too big an issue as API keys were not mandatory for the maps API.

They are now……

So, In order, we have to do the following on every website for the following plugins

Massive Addons

Great set of additional elements for WP-Bakery page builder. But if you have all of their shortcodes active it will load the Google Maps JS library on every page.

You can either,

  1. Disable the map shortcode by going to the Massive Panel dashboard and disabling it there
  2. Add in the google maps api key in here.

Custom Page Templates – ACF, Advanced Custom Fields.

Another great plugin. this allows you to design page templates and override the defaults in a really simple way. Their dynamic values functionality opened up a lot of new options for us when creating pages.

When you install Custom Page Templates it automatically installs Advanced Custom Fields Pro as it relies on it to work.

And in the CPT Settings panel you will find another tickbox which needs to be unticked to stop it from loading the google maps API JS on every page.

again you can add your maps API key here if you are going to use the maps custom field. But they do at least provide a simple tick box to say do not include this script.

Ultimate Addons

Similar setup to Massive addons and another great selection of elements for WP-Bakery.

to stop them from including the google maps API you need to add the following “define(‘DISABLE_ULTIMATE_GOOGLE_MAP_API’, true);” into your wp-config.php file.

They do say they only load it on pages that use the element but it can cause conflicts with other plugins that load it everywhere.

And now,

My very favourite of the bunch so far.

UberMenu

Yep, that’s right. This is a Mega Menu plugin that by default includes the Google Maps API script.

As per the other plugins, I do very highly recommend the UberMenu plugin and we use it on every website as it provides a massive range of possible layouts for your menus and the documentation is very good as is the integration with the WordPress menu system.

The UberMenu options will appear in the header of the site. Hover on this and click onto the UberMenu Control Panel.

In here you will click onto the second tab for General Settings.

In the left hand menu you then click assets and scroll down to the Google Maps Section. Untick the Load Google Maps API box and save.

 

I don’t know what the real solution is here, perhaps someone can put together a centralised Google Maps Script Include that every other plugin can access via an API?

What I do know is including a script by default which requires API keys so will never work unless configured, and is used so widely by other plugins, is a daft idea and I want everyone to just stop it now.

Please

For the sake of my sanity and business.

 

What's your reaction?
Love It
100%
Interested
0%
Meh...
0%
What?
0%
Hate It
0%
Sad
0%
About The Author
Simon Parker

Leave a Response