wpgmp_map_class - WP Maps Pro

15000+ live websites are using this google maps wordpress plugin.

wpgmp_map_class

The wpgmp_map_class hook in WP Maps Pro allows developers to customize the CSS class of the map element div at runtime. This hook is useful for modifying the appearance or behavior of map elements by adding custom CSS classes.

Usage

Developers can implement this hook in their theme’s functions.php file or within a custom plugin. The hook is used to append or modify CSS classes on map div elements, enabling tailored styling or additional functionality.

Example 1

Description of the first use-case: Adding a unique CSS class to a map element for custom styling.

add_filter( 'wpgmp_map_class', 'add_custom_map_class', 10, 2 );

function add_custom_map_class( $classes, $map ) {
    $classes .= ' my-custom-class';
    return $classes;
}

Example 2

Description of the second use-case: Conditionally adding a CSS class based on map ID.

add_filter( 'wpgmp_map_class', 'conditional_map_class', 10, 2 );

function conditional_map_class( $classes, $map ) {
    if ( $map->ID == 5 ) {
        $classes .= ' special-map-class';
    }
    return $classes;
}

Example 3

Description of the third use-case: Removing an existing class and adding a new one.

add_filter( 'wpgmp_map_class', 'replace_map_class', 10, 2 );

function replace_map_class( $classes, $map ) {
    $classes = str_replace( 'old-class', '', $classes );
    $classes .= ' new-class';
    return $classes;
}

Tip: Always validate and sanitize inputs when modifying hooks to ensure security and prevent potential conflicts or errors in your WordPress site.

Install Plugin Now!

Buy this plugin exclusively on CodeCanyon! You’ll get free updates, full support, and if you’re not satisfied, we’ve got you covered with a 30-day money-back guarantee.