Dequeue Events Calendar Google Maps API

Home Forums Calendar Products Events Calendar PRO Dequeue Events Calendar Google Maps API

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1203088
    shokideagroup
    Participant

    Hey,

    I am overriding the single-event template and using my own Google maps API within the template. I would like to dequeue the Events Calendar’s Google maps API, so that I do not have two on the page.

    I saw this post (https://theeventscalendar.com/support/forums/topic/google-maps-in-footer-on-events-page-duplicate-gmaps-script-acf-problem/) and tried to dequeue the following scripts inside my functions file, but it had no effect.

    function remove_events_map_apis() {
        wp_dequeue_script( 'tribe_events_google_maps_api' );
        wp_dequeue_script( 'tribe_events_embedded_map' );
        wp_dequeue_script( 'tribe-gmaps' );
        wp_dequeue_script( 'tribe-events-pro-geoloc' );
    }
    add_action( 'wp_print_scripts', 'remove_events_map_apis' );

    Thanks in advance for the help!

    #1203636
    Cliff
    Member

    Hi. Thanks for your detailed question.

    What if you add a higher priority, like 100, to your add_action line, like in the code snippet in that other thread?

    And may I ask why dequeuing ours and using your own (or the one from another plugin or your theme)?

    Thanks.

    #1203807
    shokideagroup
    Participant

    Hey Cliff,

    Once you said something about priority it got me thinking that what I wanted to dequeue was in the footer. So I was able get it to work by replacing “wp_print_scripts” with “wp_footer”. I also only needed to dequeue two scripts, the following code is what worked for me in case anyone else needs to do the same thing.

    function tribe_events_map_apis() {
        wp_dequeue_script( 'tribe_events_google_maps_api' );
        wp_dequeue_script( 'tribe_events_embedded_map' );
    }
    add_action( 'wp_footer', 'tribe_events_map_apis' );

    I needed to dequeue your Google Maps API and use my own, because I needed to add “&callback=initMap” to the end of src.

    Thanks for your help!

    #1204218
    Cliff
    Member

    Thanks for sharing.

    What about just filtering the URL that gets used by our plugin. Maybe something along the lines of https://gist.github.com/cliffordp/9d6c25feb389f98e8ae09a41273a3488 or even using add_query_arg()

    #1212035
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Dequeue Events Calendar Google Maps API’ is closed to new replies.