WordPress.org

Ready to get started?Download WordPress

Forums

WP Find Your Nearest
Conflict with Hubspot plugin (4 posts)

  1. jpsingleton
    Member
    Posted 7 months ago #

    When I have the WP Find Your Nearest and Hubspot plugins active at the same time and try to search by ZIP code, the wheel spins and spins. In the console, I have this warning:

    "Warning: you have included the Google Maps API multiple times on this page. This may cause unexpected errors."

    The error refers to this file: http://maps.gstatic.com/intl/en_us/mapfiles/api-3/14/1/main.js

    When I disable the Hubspot plugin, it works fine. When I revert back to the old version of the FYN plugin, its performance is hit and miss between browser/OS configurations. (It usually works fine for me on Mac/Chrome, but in other cases throws the error "Postcode not found!undefined, US".)

    Unfortunately, my client requires the Hubspot plugin so removing it is not an option. I'm assuming the conflict has something to do with how the Google Maps API is being called. Do you have any idea why the new FYN version would be causing conflicts where the previous version was not?

    Thanks in advance!

    http://wordpress.org/plugins/wp-find-your-nearest/

  2. jpsingleton
    Member
    Posted 7 months ago #

    Alright, so a bit of clarification. I actually spun off my own version of the plugin a while back because I needed to be able to format the results differently (with an unordered list + list items). The point at which my code forked was 0.2.2.

    Just recently, it's been brought to my attention that some users in some browsers will occasionally get an error when they try to click onto the page containing the zip code search form: "Postcode not found!undefined, US" Hence, my looking to revert back to the main code base (or at least spin a version off of 0.2.5).

    I suspect it was the switch to support Google API V3 (in version 0.2.3) that created the conflicts with Hubspot.

    Somehow, between FYN and Hubspot, this script appears in the header twice:

    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&ver=3.5.2"></script>

    Is there a way to make sure the script only gets loaded once?

    Thanks.

  3. jpsingleton
    Member
    Posted 7 months ago #

    It's not ideal, but I found a workaround that won't require editing either of the plugins.

    This is how FYN includes the script:

    wp_register_script( 'googlemapapi', "http://maps.google.com/maps/api/js?sensor=false$key", FALSE );
    wp_enqueue_script( 'googlemapapi' );

    And this is how Hubspot includes the script:

    wp_enqueue_script('google-maps', 'http://maps.google.com/maps/api/js?sensor=false');

    In my functions.php file, I essentially removed Hubspot's script so only the FYN script will be included.

    add_action( 'wp_print_scripts', 'custom_deregister', 100 );
    
    function custom_deregister() {
    	if(!is_admin()) {
    		wp_deregister_script( 'google-maps' );
    	}
    }

    This will break if FYN is ever using a version of the API that is different from the one that Hubspot is wanting, but I don't know of a better solution right now. (I'm also not using FYN with an API key so that may or may not cause problems as well down the road, or in other situations.)

  4. TroyBlack
    Member
    Posted 3 months ago #

    I had the same issue and this solution worked for now.

Reply

You must log in to post.

About this Plugin

About this Topic