wpgmp_filters - WP Maps Pro

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

wpgmp_filters

The wpgmp_filters hook in WP Maps Pro allows developers to customize marker filtering functionalities at runtime. It is triggered to add or remove custom filters for marker filterings.

Usage

Developers can implement this hook in their WordPress themes or plugins to modify the available filtering options for map markers. This is particularly useful for tailoring the map’s filtering functionality to fit specific requirements or user preferences.

Example 1

In this example, we add a new custom filter for filtering markers by “Region”.

add_filter('wpgmp_filters', 'add_region_filter', 10, 2);
function add_region_filter($all_filters, $map) {
    // Ensure base structure exists
    if (!isset($all_filters['filters'])) {
        $all_filters['filters'] = [];
    }

    if (!isset($all_filters['filters']['dropdown'])) {
        $all_filters['filters']['dropdown'] = [];
    }

    // Add the Region filter
    $all_filters['filters']['dropdown']['region'] = 'Region';

    return $all_filters;
}

Example 2

This example demonstrates how to remove the “Phone” filter from the list of available filters.

add_filter('wpgmp_filters', 'remove_phone_filter', 10, 2);
function remove_phone_filter($all_filters, $map) {
    if (isset($all_filters['filters']['dropdown']['phone'])) {
        unset($all_filters['filters']['dropdown']['phone']);
    }
    return $all_filters;
}

Example 3

Here, we replace a placeholder with an actual taxonomy slug for a custom taxonomy filter.

add_filter('wpgmp_filters', 'custom_taxonomy_filter', 10, 2);
function custom_taxonomy_filter($all_filters, $map) {
    // Ensure the filters and dropdown keys exist
    if (!isset($all_filters['filters'])) {
        $all_filters['filters'] = [];
    }

    if (!isset($all_filters['filters']['dropdown'])) {
        $all_filters['filters']['dropdown'] = [];
    }

    // Add your custom taxonomy filter
    $all_filters['filters']['dropdown']['custom_taxonomy_slug'] = 'Custom Taxonomy';

    return $all_filters;
}

Tip: Always validate and sanitize the data you work with to maintain the security and integrity of 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.