Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Last active May 30, 2018 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cliffordp/9d6c25feb389f98e8ae09a41273a3488 to your computer and use it in GitHub Desktop.
Save cliffordp/9d6c25feb389f98e8ae09a41273a3488 to your computer and use it in GitHub Desktop.
Override Google Maps API call URI and add Google Maps API Key
<?php
/**
* The Events Calendar: Override Google Maps API call URI, such as to include
* additional libraries (e.g. drawing, geometry, places, visualization).
*
* @link https://gist.github.com/cliffordp/9d6c25feb389f98e8ae09a41273a3488
* @link https://developers.google.com/maps/documentation/javascript/libraries
*
* @see add_query_arg()
* @see esc_url_raw()
**/
add_filter( 'tribe_events_google_maps_api', 'cliff_tec_modify_google_maps_uri' );
add_filter( 'tribe_events_pro_google_maps_api', 'cliff_tec_modify_google_maps_uri' );
function cliff_tec_modify_google_maps_uri( $api_url ) {
$api_url = add_query_arg( 'libraries', 'drawing,geometry,places,visualization', $api_url );
// esc_url() will break it so esc_url_raw() or don't escape at all
return esc_url_raw( $api_url );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment