Last active
May 3, 2019 11:30
-
-
Save Pebblo/cb7bf925f3ed528bf3bc61a90fdfd7dc to your computer and use it in GitHub Desktop.
Copy of the espresso_google_map_link() which uses HTTPS, place this in a custom functions plugin to override the default function.
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 //Please do not include the opening PHP tag if you already have one | |
function espresso_google_map_link($atts) { | |
global $org_options; | |
extract($atts); | |
$address = "{$address}"; | |
$city = "{$city}"; | |
$state = "{$state}"; | |
$zip = "{$zip}"; | |
$country = "{$country}"; | |
$text = isset($text) ? "{$text}" : ""; | |
$type = isset($type) ? "{$type}" : ""; | |
$map_w = isset($map_w) ? "{$map_w}" : 400; | |
$map_h = isset($map_h) ? "{$map_h}" : 400; | |
$map_image_class = isset($map_image_class) ? "{$map_image_class}" : ''; | |
$gaddress = ($address != '' ? $address : '') . ($city != '' ? ',' . $city : '') . ($state != '' ? ',' . $state : '') . ($zip != '' ? ',' . $zip : '') . ($country != '' ? ',' . $country : ''); | |
$api_key = ! empty( $org_options['google_maps_api_key'] ) ? $org_options['google_maps_api_key'] : ''; | |
$api_key = apply_filters( 'filter_hook_espresso_google_map_api_key', $api_key ); | |
$google_map = htmlentities2('https://maps.google.com/maps?q=' . urlencode($gaddress)); | |
switch ($type) { | |
case 'text': | |
default: | |
$text = $text == '' ? __('Map and Directions', 'event_espresso') : $text; | |
break; | |
case 'url': | |
$text = $google_map; | |
break; | |
case 'map': | |
$google_map_link = '<a href="' . $google_map . '" target="_blank">' . '<img id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2('https://maps.googleapis.com/maps/api/staticmap?center=' . urlencode($gaddress) . '&zoom=14&size=' . $map_w . 'x' . $map_h . '&markers=color:green|label:|' . urlencode($gaddress) . '&sensor=false&key=' . $api_key ) . '" /></a>'; | |
return $google_map_link; | |
} | |
$google_map_link = '<a href="' . $google_map . '" target="_blank">' . $text . '</a>'; | |
return $google_map_link; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment