This hook in the WP Maps Pro plugin allows developers to customize the output of the map, listing, and filter HTML sections. It is triggered during the runtime, specifically when the map output is being generated, enabling changes to the layout or styling of these sections.
Usage
Developers can implement this hook in their theme’s functions.php
file or within a custom plugin. By using this hook, you can manipulate the HTML output of the map, filter, and listing sections, allowing for dynamic customization based on specific requirements.
Example 1
This example demonstrates how to prepend a custom message above the map output.
add_filter('wpgmp_map_output', 'custom_map_message', 10, 5); function custom_map_message($output, $map_div, $filters_div, $listing_div, $map_id) { $custom_message = '<div class="custom-message">Welcome to our custom map!</div>'; return $custom_message . $output; }
Example 2
In this example, we modify the map’s HTML to include a custom CSS class for additional styling.
add_filter('wpgmp_map_output', 'add_custom_class_to_map', 10, 5); function add_custom_class_to_map($output, $map_div, $filters_div, $listing_div, $map_id) { $map_div = str_replace('class="wpgmp_map"', 'class="wpgmp_map custom-map-class"', $map_div); return $map_div . $filters_div . $listing_div; }
Example 3
This example illustrates how to conditionally remove the filter section based on the map ID.
add_filter('wpgmp_map_output', 'conditionally_remove_filters', 10, 5); function conditionally_remove_filters($output, $map_div, $filters_div, $listing_div, $map_id) { if ($map_id == 1) { // Remove filters for map ID 1 $filters_div = ''; } return $map_div . $filters_div . $listing_div; }
Tip: Always ensure you sanitize and validate any data before outputting it to prevent security vulnerabilities such as XSS attacks.