Description
This filter allows you modify the info window template that is used on individual store pages.
Usage
In this example the data from a custom field called “my_textinput” is added after the address details:
add_filter( 'wpsl_cpt_info_window_template', 'custom_cpt_info_window_template' );
function custom_cpt_info_window_template() {
$cpt_info_window_template = '<div class="wpsl-info-window">' . "\r\n";
$cpt_info_window_template .= "\t\t" . '<p class="wpsl-no-margin">' . "\r\n";
$cpt_info_window_template .= "\t\t\t" . '<strong><%= store %></strong>' . "\r\n";
$cpt_info_window_template .= "\t\t\t" . '<span><%= address %></span>' . "\r\n";
$cpt_info_window_template .= "\t\t\t" . '<% if ( address2 ) { %>' . "\r\n";
$cpt_info_window_template .= "\t\t\t" . '<span><%= address2 %></span>' . "\r\n";
$cpt_info_window_template .= "\t\t\t" . '<% } %>' . "\r\n";
$cpt_info_window_template .= "\t\t\t" . '<span>' . wpsl_address_format_placeholders() . '</span>' . "\r\n";
$cpt_info_window_template .= "\t\t\t" . '<span class="wpsl-country"><%= country %></span>' . "\r\n";
$cpt_info_window_template .= "\t\t" . '</p>' . "\r\n";
/**
* Include the data from a custom field called 'my_textinput'.
*
* Before you can access the 'my_textinput' data, you first
* need to add it to the meta fields through the
* 'wpsl_cpt_info_window_meta_fields' filter.
*/
$cpt_info_window_template .= "\t\t" . '<% if ( my_textinput ) { %>' . "\r\n";
$cpt_info_window_template .= "\t\t" . '<p><%= my_textinput %></p>' . "\r\n";
$cpt_info_window_template .= "\t\t" . '<% } %>' . "\r\n";
$cpt_info_window_template .= "\t" . '</div>' . "\r\n";
return $cpt_info_window_template;
}
The <% ... %> and <%= ... %> code is used by the
Underscore library to execute JS code, and to print the correct JSON data when the HTML template is rendered.
Source File This filter is located in /frontend/underscore-functions.php.
Placement The code needs to be placed in the functions.php file inside your active theme folder.