| @@ -2,14 +2,16 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Weather support |
| 4 | 4 | * |
| 5 | 5 | * @package event-post |
| 6 | - * @version 5.10.4 | |
| 6 | + * @version 6.1.2 | |
| 7 | 7 | * @since 4.3.0 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | namespace EventPost; |
| 11 | 11 | |
| 12 | +if ( ! defined( 'ABSPATH' ) ) exit; | |
| 13 | + | |
| 12 | 14 | $EventPostWeather = new Weather(); |
| 13 | 15 | |
| 14 | 16 | /** |
| 15 | 17 | * Provides weather support thanks to OpenWeatherMap |
| @@ -101,23 +103,23 @@ | ||
| 101 | 103 | * @param type $ep_settings |
| 102 | 104 | */ |
| 103 | 105 | function settings_form($ep_settings) { |
| 104 | 106 | ?> |
| 105 | - <h2><?php _e('Weather', 'event-post'); ?></h2> | |
| 107 | + <h2><?php esc_html_e('Weather', 'event-post'); ?></h2> | |
| 106 | 108 | <?php // Translators: %s is a link to openweathermap.org ?> |
| 107 | - <p class="description"><?php printf(__('Provided thanks to %s', 'event-post'), '<a href="http://openweathermap.org" target="_blank">openweathermap.org</a>'); ?></p> | |
| 109 | + <p class="description"><?php printf(esc_html(__('Provided thanks to %s', 'event-post')), '<a href="http://openweathermap.org" target="_blank">openweathermap.org</a>'); ?></p> | |
| 108 | 110 | <table class="form-table" id="eventpost-settings-table-weather"> |
| 109 | 111 | <tbody> |
| 110 | 112 | <tr> |
| 111 | 113 | <th> |
| 112 | - <?php _e('Enable weather', 'event-post') ?> | |
| 114 | + <?php esc_html_e('Enable weather', 'event-post') ?> | |
| 113 | 115 | </th> |
| 114 | 116 | <td> |
| 115 | 117 | <label for="weather_enabled"> |
| 116 | 118 | <input type="checkbox" name="ep_settings[weather_enabled]" id="weather_enabled" <?php if ($ep_settings['weather_enabled'] == '1') { |
| 117 | - echo'checked'; | |
| 119 | + echo esc_attr('checked'); | |
| 118 | 120 | } ?> value="1"> |
| 119 | - <?php _e('Enable weather feature', 'event-post') ?> | |
| 121 | + <?php esc_html_e('Enable weather feature', 'event-post') ?> | |
| 120 | 122 | </label> |
| 121 | 123 | </td> |
| 122 | 124 | </tr> |
| 123 | 125 | <tr> |
| @@ -122,32 +124,33 @@ | ||
| 122 | 124 | </tr> |
| 123 | 125 | <tr> |
| 124 | 126 | <th> |
| 125 | 127 | <label for="weather_api_key"> |
| 126 | - <?php _e('API key', 'event-post') ?> | |
| 128 | + <?php esc_html_e('API key', 'event-post') ?> | |
| 127 | 129 | </label> |
| 128 | 130 | </th> |
| 129 | 131 | <td> |
| 130 | - <input type="text" name="ep_settings[weather_api_key]" id="weather_api_key" value="<?php echo $ep_settings['weather_api_key']; ?>" size="40"> | |
| 131 | - <p class="description"><?php printf(__('Get a free API key at: %s', 'event-post'), '<a href="http://openweathermap.org/appid#get" target="_blank">openweathermap.org/appid#get</a>'); ?></p> | |
| 132 | + <input type="text" name="ep_settings[weather_api_key]" id="weather_api_key" value="<?php echo esc_attr($ep_settings['weather_api_key']); ?>" size="40"> | |
| 133 | + <?php // Translators: %s is a link to openweathermap.org/appid#get ?> | |
| 134 | + <p class="description"><?php printf(esc_html(__('Get a free API key at: %s', 'event-post')), '<a href="http://openweathermap.org/appid#get" target="_blank">openweathermap.org/appid#get</a>'); ?></p> | |
| 132 | 135 | </td> |
| 133 | 136 | </tr> |
| 134 | 137 | <tr> |
| 135 | 138 | <th> |
| 136 | 139 | <label for="weather_units"> |
| 137 | - <?php _e('Units', 'event-post') ?> | |
| 140 | + <?php esc_html_e('Units', 'event-post') ?> | |
| 138 | 141 | </label> |
| 139 | 142 | </th> |
| 140 | 143 | <td> |
| 141 | 144 | <select name="ep_settings[weather_units]" id="weather_units"> |
| 142 | 145 | <option value="standard" <?php selected($ep_settings['weather_units'], 'standard', true);?>> |
| 143 | - <?php _e('Standard (Fahrenheit)', 'event-post') ?> | |
| 146 | + <?php esc_html_e('Standard (Fahrenheit)', 'event-post') ?> | |
| 144 | 147 | </option> |
| 145 | 148 | <option value="metric" <?php selected($ep_settings['weather_units'], 'metric', true);?>> |
| 146 | - <?php _e('Metric (Celsius)', 'event-post') ?> | |
| 149 | + <?php esc_html_e('Metric (Celsius)', 'event-post') ?> | |
| 147 | 150 | </option> |
| 148 | 151 | <option value="imperial" <?php selected($ep_settings['weather_units'], 'imperial', true);?>> |
| 149 | - <?php _e('Imperial (Kelvin)', 'event-post') ?> | |
| 152 | + <?php esc_html_e('Imperial (Kelvin)', 'event-post') ?> | |
| 150 | 153 | </option> |
| 151 | 154 | </select> |
| 152 | 155 | </td> |
| 153 | 156 | </tr> |
| @@ -259,11 +262,12 @@ | ||
| 259 | 262 | |
| 260 | 263 | function get_weather_icons($weather){ |
| 261 | 264 | $string = ''; |
| 262 | 265 | foreach((array) $weather as $item){ |
| 263 | - $text = ucfirst(__(strtolower($item->description), 'event-post')); | |
| 266 | + $text = ucfirst(__(strtolower($item->description), 'event-post')); // phpcs:ignore WordPress.WP.I18n | |
| 264 | 267 | $string.='<span class="eventpost-weather-'.str_replace('-', '', strtolower($item->description)).' eventpost-weather-'.$item->icon.'">' |
| 265 | - . '<img src="'. plugins_url('../img/weather/'.$this->theme.'/'.$item->icon.'.png', __FILE__).'" alt="'.sprintf('%s icon', $text).'">' | |
| 268 | + // Translators: %s is the weather description | |
| 269 | + . '<img src="'. plugins_url('../img/weather/'.$this->theme.'/'.$item->icon.'.png', __FILE__).'" alt="'.sprintf('%s icon', $text).'">' | |
| 266 | 270 | . '<em class="eventpost-weather-text">'.$text.'</em>' |
| 267 | 271 | . '</span>'; |
| 268 | 272 | } |
| 269 | 273 | return $string; |
| @@ -329,9 +333,9 @@ | ||
| 329 | 333 | } |
| 330 | 334 | break; |
| 331 | 335 | } |
| 332 | 336 | if($echo){ |
| 333 | - echo $string; | |
| 337 | + echo wp_kses($string, EventPost()->kses_tags); | |
| 334 | 338 | } |
| 335 | 339 | return $string; |
| 336 | 340 | } |
| 337 | 341 | |