Forked from jesseeproductions/tribe-google-map-region
Last active
August 29, 2018 15:18
-
-
Save cliffordp/c7c2713e9f61166e9aef746823be6bfa to your computer and use it in GitHub Desktop.
The Events Calendar and/or PRO: Set Region and Language biasing for Google Maps (Australia in this example)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The Events Calendar and/or PRO: Set Region and Language biasing for Google Maps. | |
* | |
* @link https://gist.github.com/cliffordp/c7c2713e9f61166e9aef746823be6bfa This snippet. | |
* @link https://developers.google.com/maps/faq#languagesupport Language Codes. | |
* @link https://developers.google.com/maps/documentation/javascript/geocoding#GeocodingRegionCodes Region codes. | |
* | |
* @param string $api_url The Google Maps API URL. | |
* | |
* @return string | |
*/ | |
function tribe_add_google_map_region( $api_url ) { | |
if ( ! empty( $api_url ) ) { | |
// !!! TODO: change these as required for your language and location. This is set to Australia!!! | |
$api_url = add_query_arg( [ | |
'language' => 'en-Au', // English (Australian) | |
'region' => 'AU', // Australia | |
], $api_url ); | |
} | |
return $api_url; | |
} | |
// Google Maps for The Events Calendar (such as Single Event page's venue location map) | |
add_filter( 'tribe_events_google_maps_api', 'tribe_add_google_map_region' ); | |
// Google Maps for Events Calendar PRO's (such as geolocation and Map View) | |
add_filter( 'tribe_events_pro_google_maps_api', 'tribe_add_google_map_region' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment