wpgmp_before_container - WP Maps Pro

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

wpgmp_before_container

This hook allows developers to inject custom HTML or functionality directly before the map container in the WP Maps Pro plugin. It is triggered just before the map container is rendered, enabling customization of the map’s surrounding HTML.

Usage

Developers can implement this hook in their theme’s functions.php file or in a custom plugin. It is useful for adding annotations, custom styles, or additional controls above the map. Make sure to use this hook responsibly to maintain the integrity and performance of the map display.

Example 1

Adding a custom header above the map for branding purposes.

add_action('wpgmp_before_container', function($map) {
    echo '<div class="custom-map-header">Welcome to Our Custom Map!</div>';
}, 10, 1);

Example 2

Injecting a custom style block to modify the appearance of elements around the map.

add_action('wpgmp_before_container', function($map) {
    echo '<style>.map-container { border: 2px solid #333; }</style>';
}, 10, 1);

Example 3

Displaying dynamic content, such as a data-driven message or status based on map settings.

add_action('wpgmp_before_container', function($map) {
    if ($map->settings['show_status']) {
        echo '<div class="map-status">Map is currently set to display all markers.</div>';
    }
}, 10, 1);

Tip: Always validate and sanitize any data output through this hook to prevent security vulnerabilities such as XSS (Cross-Site Scripting). Use WordPress functions like esc_html() or esc_attr() where appropriate.

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.