Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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
You can’t perform that action at this time.