Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Last active December 15, 2017 07:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cliffordp/ca3baf77c9be8b72f37db10c7c91783b to your computer and use it in GitHub Desktop.
Save cliffordp/ca3baf77c9be8b72f37db10c7c91783b to your computer and use it in GitHub Desktop.
Do not load https://optimizerwp.com/optimizer-pro/ theme's Google Maps script on The Events Calendar (TEC) pages, except for Post Tags, then do not load TEC's
<?php
/**
* Do not load https://optimizerwp.com/optimizer-pro/ theme's Google Maps script on The Events Calendar (TEC) pages, except for Post Tags, then do not load TEC's
*
* From https://gist.github.com/cliffordp/ca3baf77c9be8b72f37db10c7c91783b
*
* For https://theeventscalendar.com/support/forums/topic/errors-you-have-included-the-google-maps-api-multiple-times-on-this-page/
*/
function tec_1163154_dequeue_gmaps_script() {
if ( ! class_exists( 'Tribe__Events__Main' ) ) {
return false;
}
$tecmain = Tribe__Events__Main::instance();
if (
// https://developer.wordpress.org/reference/functions/is_post_type_archive/
is_post_type_archive( $tecmain::POSTTYPE )
|| is_post_type_archive( $tecmain::VENUE_POST_TYPE )
|| is_post_type_archive( $tecmain::ORGANIZER_POST_TYPE )
// https://developer.wordpress.org/reference/functions/is_singular/
|| is_singular( $tecmain::POSTTYPE )
|| is_singular( $tecmain::VENUE_POST_TYPE )
|| is_singular( $tecmain::ORGANIZER_POST_TYPE )
// https://developer.wordpress.org/reference/functions/is_tax/
|| is_tax( $tecmain::TAXONOMY )
) {
wp_dequeue_script( 'optimizer_googlemaps' );
// Maybe also do this next one too? If yes, uncomment it.
// wp_dequeue_script( 'optimizer_map' );
}
if (
// https://developer.wordpress.org/reference/functions/is_tag/
is_tag()
) {
wp_dequeue_script( 'tribe_events_google_maps_api' );
}
}
add_action( 'wp_print_scripts', 'tec_1163154_dequeue_gmaps_script', 100 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment