This hook in the WP Maps Pro plugin allows developers to customize the settings of the “Nearby Places” tab. It is triggered when the nearby tab’s settings are being configured, enabling developers to modify various attributes like the title, amenities, and visual properties of the nearby circle.
Usage
Developers can implement this hook in their theme’s functions.php file or a custom plugin. It’s a powerful way to tailor the user experience by altering the default settings of the nearby tab according to specific requirements.
Example 1
Change the title of the nearby tab to a custom text.
add_filter('wpgmp_nearby_tab', 'custom_nearby_tab_title', 10, 2); function custom_nearby_tab_title($nearby_tab, $map) { $nearby_tab['nearby_tab_title'] = 'Local Attractions'; return $nearby_tab; }
Example 2
Modify the amenities shown in the nearby tab to include only certain types of places.
add_filter('wpgmp_nearby_tab', 'custom_nearby_amenities', 10, 2); function custom_nearby_amenities($nearby_tab, $map) { $nearby_tab['nearby_amenities'] = array( 'restaurant' => 'restaurant', 'hotel' => 'hotel' ); return $nearby_tab; }
Example 3
Adjust the visual settings of the nearby circle to have different stroke color and weight.
add_filter('wpgmp_nearby_tab', 'custom_nearby_circle_style', 10, 2); function custom_nearby_circle_style($nearby_tab, $map) { $nearby_tab['nearby_circle_strokecolor'] = '#FF5733'; $nearby_tab['nearby_circle_strokeweight'] = 2; return $nearby_tab; }
Always ensure you validate and sanitize inputs when modifying settings to maintain the security and stability of your WordPress site.