This hook allows developers to add a custom CSS class to the listing container in the WP Maps Pro plugin. It is triggered when the listing container is being generated, enabling runtime customization.
Usage
Developers can implement this hook in their theme’s functions.php
file or a custom plugin. It is useful for dynamically altering the appearance of map listings by injecting specific CSS classes based on certain conditions or preferences.
Example 1
Add a custom class to all map listings to apply uniform styling.
add_filter('wpgmp_listing_css_class', function($class, $map) { $class .= ' custom-map-listing-class'; return $class; }, 10, 2);
Example 2
Apply a different CSS class based on a specific map ID.
add_filter('wpgmp_listing_css_class', function($class, $map) { if($map->ID == 123) { $class .= ' special-map-class'; } return $class; }, 10, 2);
Example 3
Append multiple classes conditionally to enhance styling flexibility.
add_filter('wpgmp_listing_css_class', function($class, $map) { $class .= ' base-class'; if($map->type == 'satellite') { $class .= ' satellite-view'; } if($map->zoom > 10) { $class .= ' high-zoom'; } return $class; }, 10, 2);
Always ensure that the added class names are unique and do not conflict with existing styles to maintain consistent display and avoid unintended results.