Skip to content

Instantly share code, notes, and snippets.

@webaware
Last active July 14, 2017 05:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webaware/a030ffad554d536a907b to your computer and use it in GitHub Desktop.
Save webaware/a030ffad554d536a907b to your computer and use it in GitHub Desktop.
<?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