Skip to content

Instantly share code, notes, and snippets.

@chikaibeneme
Created August 4, 2021 04:21
Show Gist options
  • Select an option

  • Save chikaibeneme/e12edb21b57f1b903d89a8271ad56f78 to your computer and use it in GitHub Desktop.

Select an option

Save chikaibeneme/e12edb21b57f1b903d89a8271ad56f78 to your computer and use it in GitHub Desktop.
functions.php
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( 'tribe_events_google_maps_api' );
wp_dequeue_script( 'tribe_events_embedded_map' );
wp_dequeue_script( 'tribe-gmaps' ); //(tribe-events-pro-geoloc loads this as a dependency)
wp_dequeue_script( 'tribe-events-pro-geoloc' ); //(may only be used when PRO gets the coordinates based on a Venue’s address so might not want to dequeue)
}
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