This hook allows developers to customize the HTML output of a marker image in the WP Maps Pro plugin. It is triggered when the marker image is being rendered, enabling modifications to its HTML structure before display.
Usage
Developers can implement this hook in their theme’s functions.php file or via a custom plugin to alter the marker image HTML dynamically. This is particularly useful for adding custom attributes or wrappers around the marker image.
Example 1
Modify the marker image HTML to include a custom CSS class for styling purposes.
add_filter(‘wpgmp_marker_image_markup’, function($marker_image, $location, $map_id) {
return ‘
‘;
}, 10, 3);
Example 2
Change the marker image HTML to include a data attribute with the location ID for JavaScript interactions.
add_filter(‘wpgmp_marker_image_markup’, function($marker_image, $location, $map_id) {
return ‘‘;
}, 10, 3);
Example 3
Wrap the marker image in a link that points to a specific URL derived from the location data.
add_filter(‘wpgmp_marker_image_markup’, function($marker_image, $location, $map_id) {
$url = ‘https://example.com/location/’ . $location[‘slug’];
return ‘‘ . $marker_image . ‘‘;
}, 10, 3);
Tip: Always sanitize and validate any data being output to ensure security and prevent XSS vulnerabilities.