settings Archives - WP Maps Pro

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

Hook Category: settings

This hook in the WP Maps Pro plugin allows developers to customize text strings and settings used in JavaScript files. It is triggered during the runtime to modify the localized script data using wp_localize_script.

Usage

Developers can implement this hook to modify the default text strings and settings used by the WP Maps Pro plugin. It is particularly useful for changing labels, messages, and other strings that appear in the plugin’s frontend components. This customization can be done in the theme’s functions.php file or a custom plugin.

Example 1

Change the “Find Locations” button text to “Search Locations”.

add_filter('wpgmp_text_settings', 'customize_wpgmp_text_settings');
function customize_wpgmp_text_settings($wpgmp_local) {
    $wpgmp_local['find_location'] = 'Search Locations';
    return $wpgmp_local;
}

Example 2

Modify the placeholder text for the search input field.

add_filter('wpgmp_text_settings', 'modify_search_placeholder');
function modify_search_placeholder($wpgmp_local) {
    $wpgmp_local['search_placeholder'] = 'Search for a location...';
    return $wpgmp_local;
}

Example 3

Change the “No results found” message to a custom message.

add_filter('wpgmp_text_settings', 'custom_no_results_message');
function custom_no_results_message($wpgmp_local) {
    $wpgmp_local['wpgmp_location_no_results'] = 'Sorry, we couldn\'t find any locations matching your search.';
    return $wpgmp_local;
}

Tip: Always ensure that the modifications do not interfere with the core functionality of the plugin and test changes thoroughly in a staging environment before applying them to a live site.

This hook in the WP Maps Pro plugin allows developers to customize functionality at runtime by adding or removing extra fields when saving plugin settings. It is particularly useful for modifying the data fields available in the plugin.

Usage

Developers can implement this hook within their theme’s functions.php file or a custom plugin. It’s triggered during the process of saving plugin settings, and it provides an opportunity to dynamically modify the extra fields associated with the plugin.

Example 1

This example demonstrates how to add a new custom field, “Fax No”, to the existing extra fields.

add_filter('wpgmp_plugin_extra_fields', function($extra_fields) {
    $extra_fields[] = 'Fax No';
    return $extra_fields;
});

Example 2

In this example, we remove the “Website” field from the extra fields array.

add_filter('wpgmp_plugin_extra_fields', function($extra_fields) {
    $key = array_search('Website', $extra_fields);
    if ($key !== false) {
        unset($extra_fields[$key]);
    }
    return $extra_fields;
});

Example 3

This example shows how to replace the “Email” field with a “Contact Email” field.

add_filter('wpgmp_plugin_extra_fields', function($extra_fields) {
    $key = array_search('Email', $extra_fields);
    if ($key !== false) {
        $extra_fields[$key] = 'Contact Email';
    }
    return $extra_fields;
});

Tip: Always ensure the integrity of your data by validating and sanitizing inputs to avoid potential security vulnerabilities.

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.