Last active
July 14, 2017 05:42
-
-
Save webaware/a030ffad554d536a907b to your computer and use it in GitHub Desktop.
Events Manager locations map with directions -- see http://snippets.webaware.com.au/snippets/events-manager-locations-map-with-directions/
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 | |
/* | |
Plugin Name: Flxmap Events Manager | |
Plugin URI: https://gist.github.com/webaware/a030ffad554d536a907b | |
Description: Events Manager locations map with directions | |
Version: 2 | |
Author: WebAware | |
Author URI: http://snippets.webaware.com.au/snippets/events-manager-locations-map-with-directions/ | |
*/ | |
add_filter('em_location_output_placeholder', 'flxmap_events_manager_location', 10, 3); | |
/** | |
* add Events Manager location placeholder for map directions | |
* @param string $result | |
* @param EM_Location $location | |
* @param string $placeholder | |
* @return string | |
*/ | |
function flxmap_events_manager_location($result, $location, $placeholder) { | |
if ($placeholder === '#_LOCATIONMAPWITHDIR') { | |
if (function_exists('flexmap_show_map')) { | |
if ($location->location_latitude && $location->location_longitude) { | |
$result = flexmap_show_map(array( | |
'center' => $location->location_latitude . ',' . $location->location_longitude, | |
'title' => $location->location_name, | |
'directions' => 'true', | |
'width' => get_option('dbem_map_default_width'), | |
'height' => get_option('dbem_map_default_height'), | |
'region' => 'au', // hint which region searches apply to | |
'echo' => '0', // return as a string | |
)); | |
} | |
else { | |
$result = ''; | |
} | |
} | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment