Technical documentation for developers who want to extend or customize the plugin.
Post Meta Field Names
Coordinate Fields (Pro)
When using the plugin’s metabox, coordinates are stored as:
| Meta Key | Description | Format |
|---|---|---|
_lmfe_latitude |
Latitude coordinate (hidden field) | Float: -90 to 90 |
_lmfe_longitude |
Longitude coordinate (hidden field) | Float: -180 to 180 |
lmfe_pin_color |
Custom marker color (visible field) | Hex: #RRGGBB |
Retrieving Coordinates Programmatically
// Get coordinates for a post
$post_id = 123;
$lat = get_post_meta($post_id, '_lmfe_latitude', true);
$lng = get_post_meta($post_id, '_lmfe_longitude', true);
$pin_color = get_post_meta($post_id, 'lmfe_pin_color', true);
if ($lat && $lng) {
echo "Location: {$lat}, {$lng}";
echo "Pin Color: {$pin_color}";
}
Setting Coordinates Programmatically
// Set coordinates for a post
$post_id = 123;
update_post_meta($post_id, '_lmfe_latitude', 51.5074);
update_post_meta($post_id, '_lmfe_longitude', -0.1278);
update_post_meta($post_id, 'lmfe_pin_color', '#3498db');
Custom Field Integration
Using with ACF (Advanced Custom Fields)
The plugin automatically detects ACF fields. Create two number fields:
// ACF field group example
'fields' => [
[
'key' => 'field_lat',
'name' => 'my_custom_lat',
'type' => 'number',
],
[
'key' => 'field_lng',
'name' => 'my_custom_lng',
'type' => 'number',
],
]
// In widget settings:
Latitude Field: my_custom_lat
Longitude Field: my_custom_lng
Using with Metabox.io
Similar to ACF, create custom fields and reference them by name:
// Metabox.io field registration
'fields' => [
[
'id' => 'store_latitude',
'name' => 'Latitude',
'type' => 'number',
],
[
'id' => 'store_longitude',
'name' => 'Longitude',
'type' => 'number',
],
]
// In widget settings:
Latitude Field: store_latitude
Longitude Field: store_longitude
Filters and Actions
Available Filters
Modify Query Arguments
/**
* Filter location query arguments
*
* @param array $args WP_Query arguments
* @param array $settings Widget settings
*/
add_filter('lmfe_location_query_args', function($args, $settings) {
// Only show locations from last 30 days
$args['date_query'] = [
[
'after' => '30 days ago',
],
];
return $args;
}, 10, 2);
Modify Location Data
/**
* Filter location data before sending to map
*
* @param array $location Location data array
* @param int $post_id Post ID
*/
add_filter('lmfe_location_data', function($location, $post_id) {
// Add custom data to popup
$location['custom_field'] = get_post_meta($post_id, 'custom_field', true);
return $location;
}, 10, 2);
Customize Popup Content
/**
* Filter popup HTML content
*
* @param string $content Popup HTML
* @param int $post_id Post ID
*/
add_filter('lmfe_popup_content', function($content, $post_id) {
// Add custom button to popup
$content .= 'View Details';
return $content;
}, 10, 2);
Available Actions
Before Map Renders
/**
* Action before map renders
*
* @param array $settings Widget settings
*/
add_action('lmfe_before_map_render', function($settings) {
// Enqueue custom scripts or styles
wp_enqueue_script('my-custom-map-script');
});
After Location Meta Save
/**
* Action after coordinates are saved
*
* @param int $post_id Post ID
* @param float $lat Latitude
* @param float $lng Longitude
*/
add_action('lmfe_location_saved', function($post_id, $lat, $lng) {
// Trigger custom actions (e.g., geocode reverse lookup)
do_something_with_coordinates($lat, $lng);
}, 10, 3);
Creating Custom Map Widgets
Extend the Base Widget
namespace MyPlugin;
use LMFE\Widgets\Location_Map_Widget;
class Custom_Map_Widget extends Location_Map_Widget {
public function get_name() {
return 'my_custom_map';
}
public function get_title() {
return __('My Custom Map', 'my-plugin');
}
protected function register_controls() {
parent::register_controls();
// Add your custom controls here
$this->add_control(
'my_custom_setting',
[
'label' => __('Custom Setting', 'my-plugin'),
'type' => \Elementor\Controls_Manager::TEXT,
]
);
}
}
Database Schema
Options Table
| Option Name | Description | Type |
|---|---|---|
lmfe_registered_cpts |
Array of registered location CPTs | Serialized array |
lmfe_enabled_post_types |
Post types with metabox enabled | Serialized array |
Querying Locations Programmatically
// Get all posts with coordinates
$locations = new WP_Query([
'post_type' => 'any',
'posts_per_page' => -1,
'meta_query' => [
'relation' => 'AND',
[
'key' => '_lmfe_latitude',
'compare' => 'EXISTS',
],
[
'key' => '_lmfe_longitude',
'compare' => 'EXISTS',
],
],
]);
foreach ($locations->posts as $location) {
$lat = get_post_meta($location->ID, '_lmfe_latitude', true);
$lng = get_post_meta($location->ID, '_lmfe_longitude', true);
// Process location
}
REST API Integration
Exposing Coordinates via REST API
// Register coordinates in REST API
add_action('rest_api_init', function() {
register_rest_field('locations', 'coordinates', [
'get_callback' => function($post) {
return [
'lat' => get_post_meta($post['id'], '_lmfe_latitude', true),
'lng' => get_post_meta($post['id'], '_lmfe_longitude', true),
];
},
'schema' => [
'description' => 'Location coordinates',
'type' => 'object',
],
]);
});
floatval() for coordinates and validate ranges.


