This hook allows developers to customize the functionality of rendering shortcodes within the infowindow message in the WP Maps Pro plugin. It is triggered during the rendering process of these shortcodes, providing an opportunity to modify or extend the behavior.
Usage
Developers can implement this hook in their themes or plugins to alter how shortcodes are rendered in the infowindow message. This can be done by adding a filter to modify the boolean data based on the map instance provided. It is especially useful for adding custom logic or conditions when rendering shortcodes.
Example 1
Enable shortcode rendering only for a specific map ID.
add_filter('wpgmp_render_shortcode', 'custom_render_shortcode_logic', 10, 2); function custom_render_shortcode_logic($render, $map) { if ($map->id == 5) { // Check for map ID 5 return true; // Enable shortcode rendering } return $render; // Default behavior for other maps }
Example 2
Disable shortcode rendering based on a specific condition, such as checking user roles.
add_filter('wpgmp_render_shortcode', 'disable_shortcode_for_non_admins', 10, 2); function disable_shortcode_for_non_admins($render, $map) { if (!current_user_can('administrator')) { return false; // Disable shortcode rendering for non-admin users } return $render; }
Example 3
Modify the infowindow message content based on a custom field value.
add_filter('wpgmp_render_shortcode', 'custom_infowindow_content_logic', 10, 2); function custom_infowindow_content_logic($render, $map) { if (get_post_meta($map->post_id, 'custom_field_key', true) == 'special_value') { return true; // Render shortcodes if custom field matches } return $render; }
Tip: Always ensure that any conditions or modifications performed within the hook are secure and do not expose vulnerabilities to your WordPress site. Validate and sanitize any user input or data used in your hook implementations.