Filter reference

Category:

References

Topic:

APIs

Maps

mmp_map_settings

Filters the map settings


Parameters

$settings
(array) Multidimensional array of map settings

Changelog

Version Description
4.6 Introduced

Examples

Add a prefix to the map name

add_filter('mmp_map_settings', 'mmp_add_map_name_prefix');

function mmp_add_map_name_prefix($settings) {
    $settings['name'] = 'This map is called: ' . $settings['name'];

    return $settings;
}

mmp_map_{$id}_settings

Filters the map settings for a specific map


Parameters

$settings
(array) Multidimensional array of map settings

Changelog

Version Description
4.6 Introduced

Examples

Turn the name for the map with ID 1 into a link

add_filter('mmp_map_1_settings', 'mmp_add_link_to_map_1_name');

function mmp_add_link_to_map_1_name($settings) {
    $settings['name'] = '<a href="https://www.example.com">' . $settings['name'] . '</a>';

    return $settings;
}

mmp_map_markers

Filters the map markers


Parameters

$markers
(array) Multidimensional array of map markers

Changelog

Version Description
4.11 Introduced

Examples

Hide the edit links for logged-in users

add_filter('mmp_map_markers', 'mmp_hide_marker_edit_links');

function mmp_hide_marker_edit_links($markers) {
    foreach ($markers as $key => $marker) {
        $markers[$key]['edit'] = false;
    }

    return $markers;
}

mmp_map_{$id}_markers

Filters the map markers for a specific map


Parameters

$markers
(array) Multidimensional array of map markers

Changelog

Version Description
4.11 Introduced

Examples

Remove popups on the map with ID 1

add_filter('mmp_map_1_markers', 'mmp_remove_popups_on_map_1');

function mmp_remove_popups_on_map_1($markers) {
    foreach ($markers as $key => $marker) {
        $markers[$key]['popup'] = false;
    }

    return $markers;
}

Markers

mmp_popup

Filters the popup content


Parameters

$popup
(string) Popup content
$marker
(object) Marker object

Changelog

Version Description
4.0 Introduced
4.18 $marker parameter added

Examples

Replace placeholders in format {{placeholder}} with dynamic content

add_filter('mmp_popup', 'mmp_replace_popup_placeholders');

function mmp_replace_popup_placeholders($popup) {
    $popup = str_replace('{{weekday}}', date('l'), $popup);
    $popup = str_replace('{{time}}', date('g:i a'), $popup);

    return $popup;
}

This would turn a popup with content Today is {{weekday}} and it is {{time}} into something like Today is Monday and it is 5:16 pm


Dynamically add marker data to the popup

add_filter('mmp_popup', 'mmp_add_marker_data_to_popup', 10, 2);

function mmp_add_marker_data_to_popup($popup, $marker) {
    $popup .= "<p>The coordinates for {$marker->name} are {$marker->lat}, {$marker->lng}</p>";

    return $popup;
}

This would add something like The coordinates for Central Park are 40.782222, -73.965278 to the end of the popup

mmp_marker_settings

Filters the marker settings (currently only used when adding or editing a marker)


Parameters

$settings
(array) Multidimensional array of marker settings

Changelog

Version Description
4.11 Introduced

mmp_marker_{$id}_settings

Filters the marker settings for a specific marker (currently only used when adding or editing a marker)


Parameters

$settings
(array) Multidimensional array of marker settings

Changelog

Version Description
4.11 Introduced

L10n

mmp_l10n_map_strings

Filters the map strings


Parameters

$map_strings
(array) Multidimensional array of map strings

Changelog

Version Description
4.26 Introduced

Examples

Change the placeholder text for the search in the list of markers

add_filter('mmp_l10n_map_strings', 'mmp_change_search_placeholder');

function mmp_change_search_placeholder($map_strings) {
    $map_strings['list']['search'] = 'Search stores';

    return $map_strings;
}

Updated on 23 October 2023