This hook allows developers to modify the message displayed to users when map functionality requires cookies acceptance in the WP Maps Pro plugin. It is triggered when the plugin checks if cookies acceptance is mandatory.
Usage
Developers can implement this hook in their theme’s functions.php file or in a custom plugin. It enables modification of the no-map notice text, allowing you to provide a custom message to users. Ensure to use this custom hook to enhance user experience without compromising functionality.
Example 1
Customize the no-map notice to provide a more detailed explanation to users.
add_filter( 'wpgmp_nomap_notice', 'custom_no_map_notice', 10, 2 ); function custom_no_map_notice( $no_map_notice, $map_id ) { return 'To view the map, please accept cookies. This is important for loading map functionalities.'; }
Example 2
Change the message based on the map ID, providing specific instructions for different maps.
add_filter( 'wpgmp_nomap_notice', 'map_specific_notice', 10, 2 ); function map_specific_notice( $no_map_notice, $map_id ) { if ( $map_id == 42 ) { return 'Map 42 requires cookies to show local attractions. Please accept cookies.'; } return $no_map_notice; }
Example 3
Append a link to a cookie policy page in the no-map notice for user guidance.
add_filter( 'wpgmp_nomap_notice', 'notice_with_policy_link', 10, 2 ); function notice_with_policy_link( $no_map_notice, $map_id ) { $policy_url = site_url('/cookie-policy/'); return $no_map_notice . ' <a href="' . $policy_url . '">Learn more about our cookie policy.</a>'; }
Tip: Always test your changes in a staging environment first to avoid disrupting the user experience on your live site. Ensure that your custom messages comply with legal standards and clearly communicate the necessity of accepting cookies.