| 1 |
<?php |
| 2 |
/** This file is part of the wp-forecast plugin for WordPress |
| 3 |
* |
| 4 |
* Copyright 2021 Hans Matzen (email : webmaster at tuxlog dot de) |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation; either version 2 of the License, or |
| 9 |
* (at your option) any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 |
* |
| 20 |
* @package wp-forecast |
| 21 |
*/ |
| 22 |
|
| 23 |
if ( ! function_exists( 'openweathermap_get_weather' ) ) { |
| 24 |
/** |
| 25 |
* Get the data from OpenWeatherMap. |
| 26 |
* |
| 27 |
* @param strin $baseuri the Base URI for OWM. |
| 28 |
* @param string $apikey the apikey from OWM. |
| 29 |
* @param string $lat the latitude of the location. |
| 30 |
* @param string $lon the longitude of the location. |
| 31 |
* @param string $metric the units to us. |
| 32 |
*/ |
| 33 |
function openweathermap_get_weather( $baseuri, $apikey, $lat, $lon, $metric ) { |
| 34 |
$data = array(); |
| 35 |
|
| 36 |
if ( '1' == $metric ) { |
| 37 |
$metric = 'metric'; |
| 38 |
} else { |
| 39 |
$metric = 'imperial'; |
| 40 |
} |
| 41 |
|
| 42 |
// check parms. |
| 43 |
if ( trim( $apikey ) == '' || trim( $lat ) == '' || trim( $lon ) == '' ) { |
| 44 |
return array(); |
| 45 |
} |
| 46 |
$url1 = $baseuri . 'lat=' . $lat . '&lon=' . $lon . '&appid=' . $apikey . '&exclude=minutely,hourly&units=' . $metric . '&lang=en'; |
| 47 |
|
| 48 |
// Open the file and decode it. |
| 49 |
$file1 = wp_remote_get( $url1 ); |
| 50 |
if ( ! is_wp_error( $file1 ) ) { |
| 51 |
$data = json_decode( $file1['body'], true ); |
| 52 |
} |
| 53 |
|
| 54 |
return $data; |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
if ( ! function_exists( 'openweathermap_get_data' ) ) { |
| 60 |
/** |
| 61 |
* Extract the weather data from json object returned from OWM. |
| 62 |
* |
| 63 |
* @param array $weather_array the array to store the weather. |
| 64 |
* @param array $wpf_vars the parameters of the weather widget. |
| 65 |
*/ |
| 66 |
function openweathermap_get_data( $weather_array, $wpf_vars ) { |
| 67 |
$w = array(); |
| 68 |
|
| 69 |
if ( '1' == $wpf_vars['metric'] ) { |
| 70 |
$w['un_temp'] = 'C'; |
| 71 |
$w['un_dist'] = 'km'; |
| 72 |
$w['un_speed'] = 'm/s'; |
| 73 |
$w['un_pres'] = 'mb'; |
| 74 |
$w['un_prec'] = 'mm'; |
| 75 |
} else { |
| 76 |
$w['un_temp'] = 'F'; |
| 77 |
$w['un_dist'] = 'mi'; |
| 78 |
$w['un_speed'] = 'mph'; |
| 79 |
$w['un_pres'] = 'mb'; |
| 80 |
$w['un_prec'] = 'in'; |
| 81 |
} |
| 82 |
|
| 83 |
if ( ! isset( $weather_array['current'] ) || ! isset( $weather_array['daily'] ) ) { |
| 84 |
$w['failure'] = 'No OpenWeathermap data available. '; |
| 85 |
if ( isset( $weather_array['message'] ) ) { |
| 86 |
$w['failure'] .= $weather_array['message']; |
| 87 |
} |
| 88 |
return $w; |
| 89 |
} |
| 90 |
|
| 91 |
$w['lat'] = $weather_array['lat']; |
| 92 |
$w['lon'] = $weather_array['lon']; |
| 93 |
$w['time'] = $weather_array['current']['dt']; |
| 94 |
$w['timezone'] = $weather_array['timezone']; |
| 95 |
$mtz = new DateTimeZone( $w['timezone'] ); |
| 96 |
|
| 97 |
// current conditions. |
| 98 |
$w['pressure'] = $weather_array['current']['pressure']; |
| 99 |
$w['temperature'] = round( $weather_array['current']['temp'], 0 ); |
| 100 |
$w['realfeel'] = round( $weather_array['current']['feels_like'], 0 ); |
| 101 |
$w['humidity'] = $weather_array['current']['humidity']; |
| 102 |
$w['weathertext'] = $weather_array['current']['weather'][0]['description']; |
| 103 |
$w['weathericon'] = $weather_array['current']['weather'][0]['icon']; |
| 104 |
$w['weatherid'] = $weather_array['current']['weather'][0]['id']; |
| 105 |
$w['wgusts'] = $weather_array['daily'][0]['wind_gust']; |
| 106 |
$w['windspeed'] = $weather_array['current']['wind_speed']; |
| 107 |
$w['winddirection'] = $weather_array['current']['wind_deg']; |
| 108 |
$w['uvindex'] = $weather_array['current']['uvi']; |
| 109 |
|
| 110 |
// map precipitation values. |
| 111 |
// init vars. |
| 112 |
$w['precipProbability'] = 0; |
| 113 |
$w['precipIntensity'] = 0; |
| 114 |
$w['precipType'] = ''; |
| 115 |
// if it rains add rain volume and set precipitation type to rain. |
| 116 |
if ( isset( $weather_array['current']['rain'] ) ) { |
| 117 |
$w['precipIntensity'] += $weather_array['current']['rain']['1h']; |
| 118 |
$w['precipType'] = 'Rain'; |
| 119 |
} |
| 120 |
// if it snows add snow volume and set precipitation type to snow. |
| 121 |
if ( isset( $weather_array['current']['snow'] ) ) { |
| 122 |
$w['precipIntensity'] += $weather_array['current']['snow']['1h']; |
| 123 |
$w['precipType'] = 'Snow'; |
| 124 |
} |
| 125 |
// convert mm to inches for compatibility reasons with accuweather. |
| 126 |
$w['precipIntensity'] = $w['precipIntensity'] / 2.54 / 10; |
| 127 |
|
| 128 |
if ( $w['precipIntensity'] > 0 ) { |
| 129 |
$w['precipProbability'] = 100; |
| 130 |
} |
| 131 |
|
| 132 |
// sunset sunrise. |
| 133 |
$sr = new DateTime(); |
| 134 |
$sr->setTimezone( $mtz ); |
| 135 |
$sr->setTimestamp( $weather_array['daily']['0']['sunrise'] ); |
| 136 |
$w['sunrise'] = $sr->format( get_option( 'time_format' ) ); |
| 137 |
|
| 138 |
$ss = new DateTime(); |
| 139 |
$ss->setTimezone( $mtz ); |
| 140 |
$ss->setTimestamp( $weather_array['daily']['0']['sunset'] ); |
| 141 |
$w['sunset'] = $ss->format( get_option( 'time_format' ) ); |
| 142 |
|
| 143 |
// forecast. |
| 144 |
for ( $i = 0;$i <= 7;$i++ ) { |
| 145 |
|
| 146 |
$j = $i + 1; |
| 147 |
$odt = new DateTime(); |
| 148 |
$odt->setTimezone( $mtz ); |
| 149 |
|
| 150 |
$w[ 'fc_obsdate_' . $j ] = $weather_array['daily'][ $i ]['dt'] + $odt->getOffset(); |
| 151 |
$w[ 'fc_dt_short_' . $j ] = $weather_array['daily'][ $i ]['weather'][0]['description']; |
| 152 |
$w[ 'fc_dt_icon_' . $j ] = $weather_array['daily'][ $i ]['weather'][0]['icon']; |
| 153 |
$w[ 'fc_dt_id_' . $j ] = $weather_array['daily'][ $i ]['weather'][0]['id']; |
| 154 |
$w[ 'fc_dt_htemp_' . $j ] = round( $weather_array['daily'][ $i ]['temp']['day'], 0 ); |
| 155 |
$w[ 'fc_dt_ltemp_' . $j ] = round( $weather_array['daily'][ $i ]['temp']['day'], 0 ); |
| 156 |
$w[ 'fc_dt_windspeed_' . $j ] = $weather_array['daily'][ $i ]['wind_speed']; |
| 157 |
$w[ 'fc_dt_winddir_' . $j ] = $weather_array['daily'][ $i ]['wind_deg']; |
| 158 |
$w[ 'fc_dt_wgusts_' . $j ] = $weather_array['daily'][ $i ]['wind_gust']; |
| 159 |
$w[ 'fc_dt_maxuv_' . $j ] = $weather_array['daily'][ $i ]['uvi']; |
| 160 |
$w[ 'fc_nt_icon_' . $j ] = $weather_array['daily'][ $i ]['weather'][0]['icon']; |
| 161 |
$w[ 'fc_nt_id_' . $j ] = $weather_array['daily'][ $i ]['weather'][0]['id']; |
| 162 |
$w[ 'fc_nt_htemp_' . $j ] = round( $weather_array['daily'][ $i ]['temp']['night'], 0 ); |
| 163 |
$w[ 'fc_nt_ltemp_' . $j ] = round( $weather_array['daily'][ $i ]['temp']['night'], 0 ); |
| 164 |
$w[ 'fc_nt_windspeed_' . $j ] = $weather_array['daily'][ $i ]['wind_speed']; |
| 165 |
$w[ 'fc_nt_winddir_' . $j ] = $weather_array['daily'][ $i ]['wind_deg']; |
| 166 |
$w[ 'fc_nt_wgusts_' . $j ] = $weather_array['daily'][ $i ]['wind_gust']; |
| 167 |
$w[ 'fc_nt_maxuv_' . $j ] = $weather_array['daily'][ $i ]['uvi']; |
| 168 |
|
| 169 |
// map precipitation values. |
| 170 |
// init vars. |
| 171 |
$w[ 'fc_dt_precipProbability' . $j ] = $weather_array['daily'][ $i ]['pop'] * 100; |
| 172 |
$w[ 'fc_dt_precipIntensity' . $j ] = 0; |
| 173 |
$w[ 'fc_dt_precipType' . $j ] = ''; |
| 174 |
// if it rains add rain volume and set precipitation type to rain. |
| 175 |
if ( isset( $weather_array['daily'][ $i ]['rain'] ) ) { |
| 176 |
$w[ 'fc_dt_precipIntensity' . $j ] += $weather_array['daily'][ $i ]['rain']; |
| 177 |
$w[ 'fc_dt_precipType' . $j ] = 'Rain'; |
| 178 |
} |
| 179 |
// if it snows add snow volume and set precipitation type to snow. |
| 180 |
if ( isset( $weather_array['daily'][ $i ]['snow'] ) ) { |
| 181 |
$w[ 'fc_dt_precipIntensity' . $j ] += $weather_array['daily'][ $i ]['snow']; |
| 182 |
$w[ 'fc_dt_precipType' . $j ] = 'Snow'; |
| 183 |
} |
| 184 |
|
| 185 |
// convert mm to inches for compatibility reasons with accuweather. |
| 186 |
$w[ 'fc_dt_precipIntensity' . $j ] = $w[ 'fc_dt_precipIntensity' . $j ] / 2.54 / 10; |
| 187 |
} |
| 188 |
|
| 189 |
// fill failure anyway. |
| 190 |
$w['failure'] = ( isset( $w['failure'] ) ? $w['failure'] : '' ); |
| 191 |
|
| 192 |
return $w; |
| 193 |
} |
| 194 |
} |
| 195 |
|
| 196 |
if ( ! function_exists( 'openweathermap_forecast_data' ) ) { |
| 197 |
/** |
| 198 |
* Return the weather data for the cache from OWM |
| 199 |
* |
| 200 |
* @param string $wpfcid the Widget ID. |
| 201 |
* @param string $language_override the iso code of the language to use. |
| 202 |
*/ |
| 203 |
function openweathermap_forecast_data( $wpfcid = 'A', $language_override = null ) { |
| 204 |
|
| 205 |
$wpf_vars = get_wpf_opts( $wpfcid ); |
| 206 |
if ( ! empty( $language_override ) ) { |
| 207 |
$wpf_vars['wpf_language'] = $language_override; |
| 208 |
} |
| 209 |
|
| 210 |
$w = maybe_unserialize( wpf_get_option( 'wp-forecast-cache' . $wpfcid ) ); |
| 211 |
|
| 212 |
// get translations. |
| 213 |
global $wpf_lang_dict; |
| 214 |
$wpf_lang = array(); |
| 215 |
$langfile = WP_PLUGIN_DIR . '/wp-forecast/widgetlang/wp-forecast-' . strtolower( str_replace( '_', '-', $wpf_vars['wpf_language'] ) ) . '.php'; |
| 216 |
if ( file_exists( $langfile ) ) { |
| 217 |
include $langfile; |
| 218 |
} |
| 219 |
$wpf_lang_dict[ $wpf_vars['wpf_language'] ] = $wpf_lang; |
| 220 |
|
| 221 |
// -------------------------------------------------------------- |
| 222 |
// calc values for current conditions. |
| 223 |
if ( isset( $w['failure'] ) && '' != $w['failure'] ) { |
| 224 |
return array( 'failure' => $w['failure'] ); |
| 225 |
} |
| 226 |
|
| 227 |
$w['servicelink'] = 'https://openweathermap.org/weathermap?basemap=map&cities=true&layer=temperature&lat=' . $w['lat'] . '&lon=' . $w['lon'] . '&zoom=5'; |
| 228 |
$w['copyright'] = '<a href="https://openweathermap.org">© ' . gmdate( 'Y' ) . ' Powered by OpenWeather</a>'; |
| 229 |
|
| 230 |
// next line is for compatibility. |
| 231 |
$w['acculink'] = $w['servicelink']; |
| 232 |
$w['location'] = $wpf_vars['locname']; |
| 233 |
$w['locname'] = $w['location']; |
| 234 |
|
| 235 |
// handle empty timezone setting. |
| 236 |
if ( ! isset( $w['timezone'] ) ) { |
| 237 |
$w['timezone'] = get_option( 'timezone_string' ); |
| 238 |
} |
| 239 |
|
| 240 |
$tz = new DateTimeZone( $w['timezone'] ); |
| 241 |
$w['gmtdiff'] = $tz->getOffset( new DateTime() ); |
| 242 |
|
| 243 |
$ct = current_time( 'U' ); |
| 244 |
$ct = $ct + $wpf_vars['timeoffset'] * 60; // add or subtract time offset. |
| 245 |
|
| 246 |
$w['blogdate'] = date_i18n( $wpf_vars['fc_date_format'], $ct ); |
| 247 |
$w['blogtime'] = date_i18n( $wpf_vars['fc_time_format'], $ct ); |
| 248 |
|
| 249 |
// get date/time from openweathermap. |
| 250 |
$ct = $w['time'] + $w['gmtdiff']; |
| 251 |
$w['accudate'] = date_i18n( $wpf_vars['fc_date_format'], $ct ); |
| 252 |
$w['accutime'] = date_i18n( $wpf_vars['fc_time_format'], $ct ); |
| 253 |
|
| 254 |
$ico = openweathermap_map_icon( $w['weatherid'], false ); |
| 255 |
$iconfile = find_icon( $ico ); |
| 256 |
$w['icon'] = 'icons/' . $iconfile; |
| 257 |
$w['iconcode'] = $ico; |
| 258 |
$w['shorttext'] = wpf__( openweathermap_wcode2text( $w['weatherid'] ), $wpf_vars['wpf_language'] ); |
| 259 |
|
| 260 |
$w['temperature'] = $w['temperature'] . '°' . $w['un_temp']; |
| 261 |
$w['realfeel'] = $w['realfeel'] . '°' . $w['un_temp']; |
| 262 |
$w['humidity'] = round( $w['humidity'], 0 ); |
| 263 |
|
| 264 |
// workaround different pressure values returned by accuweather. |
| 265 |
$press = round( $w['pressure'], 0 ); |
| 266 |
if ( strlen( $press ) == 3 && substr( $press, 0, 1 ) == '1' ) { |
| 267 |
$press = $press * 10; |
| 268 |
} |
| 269 |
$w['pressure'] = $press . ' ' . $w['un_pres']; |
| 270 |
$w['humidity'] = round( $w['humidity'], 0 ); |
| 271 |
$w['windspeed'] = windstr( $wpf_vars['metric'], $w['windspeed'], $wpf_vars['windunit'] ); |
| 272 |
$w['winddir'] = translate_winddir_degree( $w['winddirection'], $wpf_vars['wpf_language'] ); |
| 273 |
$w['winddir_orig'] = str_replace( 'O', 'E', $w['winddir'] ); |
| 274 |
$w['windgusts'] = windstr( $wpf_vars['metric'], $w['wgusts'], $wpf_vars['windunit'] ); |
| 275 |
|
| 276 |
// calc values for forecast. |
| 277 |
for ( $i = 1; $i < 8; $i++ ) { |
| 278 |
// daytime forecast. |
| 279 |
$w[ 'fc_obsdate_' . $i ] = date_i18n( $wpf_vars['fc_date_format'], $w[ 'fc_obsdate_' . $i ] ); |
| 280 |
|
| 281 |
$ico = openweathermap_map_icon( $w[ 'fc_dt_id_' . $i ], false ); |
| 282 |
$iconfile = find_icon( $ico ); |
| 283 |
$w[ 'fc_dt_icon_' . $i ] = 'icons/' . $iconfile; |
| 284 |
$w[ 'fc_dt_iconcode_' . $i ] = $ico; |
| 285 |
$w[ 'fc_dt_desc_' . $i ] = wpf__( openweathermap_wcode2text( $w[ 'fc_dt_id_' . $i ] ), $wpf_vars['wpf_language'] ); |
| 286 |
$w[ 'fc_dt_htemp_' . $i ] = $w[ 'fc_dt_htemp_' . $i ] . '°' . $w['un_temp']; |
| 287 |
$wstr = windstr( $wpf_vars['metric'], $w[ 'fc_dt_windspeed_' . $i ], $wpf_vars['windunit'] ); |
| 288 |
$w[ 'fc_dt_windspeed_' . $i ] = $wstr; |
| 289 |
$w[ 'fc_dt_winddir_' . $i ] = translate_winddir_degree( $w[ 'fc_dt_winddir_' . $i ], $wpf_vars['wpf_language'] ); |
| 290 |
$w[ 'fc_dt_winddir_orig_' . $i ] = str_replace( 'O', 'E', $w[ 'fc_dt_winddir_' . $i ] ); |
| 291 |
$w[ 'fc_dt_wgusts_' . $i ] = windstr( $wpf_vars['metric'], $w[ 'fc_dt_wgusts_' . $i ], $wpf_vars['windunit'] ); |
| 292 |
$w[ 'fc_dt_maxuv_' . $i ] = $w[ 'fc_dt_maxuv_' . $i ]; |
| 293 |
|
| 294 |
// nighttime forecast. |
| 295 |
$ico = openweathermap_map_icon( $w[ 'fc_nt_id_' . $i ], true ); |
| 296 |
$iconfile = find_icon( $ico ); |
| 297 |
$w[ 'fc_nt_icon_' . $i ] = 'icons/' . $iconfile; |
| 298 |
$w[ 'fc_nt_iconcode_' . $i ] = $ico; |
| 299 |
$w[ 'fc_nt_desc_' . $i ] = wpf__( openweathermap_wcode2text( $w[ 'fc_nt_id_' . $i ] ), $wpf_vars['wpf_language'] ); |
| 300 |
$w[ 'fc_nt_ltemp_' . $i ] = $w[ 'fc_nt_ltemp_' . $i ] . '°' . $w['un_temp']; |
| 301 |
$wstr = windstr( $wpf_vars['metric'], $w[ 'fc_nt_windspeed_' . $i ], $wpf_vars['windunit'] ); |
| 302 |
$w[ 'fc_nt_windspeed_' . $i ] = $wstr; |
| 303 |
$w[ 'fc_nt_winddir_' . $i ] = translate_winddir_degree( $w[ 'fc_nt_winddir_' . $i ], $wpf_vars['wpf_language'] ); |
| 304 |
$w[ 'fc_nt_winddir_orig_' . $i ] = str_replace( 'O', 'E', $w[ 'fc_nt_winddir_' . $i ] ); |
| 305 |
$w[ 'fc_nt_wgusts_' . $i ] = windstr( $wpf_vars['metric'], $w[ 'fc_nt_wgusts_' . $i ], $wpf_vars['windunit'] ); |
| 306 |
$w[ 'fc_nt_maxuv_' . $i ] = $w[ 'fc_nt_maxuv_' . $i ]; |
| 307 |
} |
| 308 |
|
| 309 |
// add hook for possible individual changes. |
| 310 |
$w = apply_filters( 'wp-forecast-openweathermap-data', $w ); |
| 311 |
|
| 312 |
return $w; |
| 313 |
} |
| 314 |
} |
| 315 |
|
| 316 |
if ( ! function_exists( 'openweathermap_map_icon' ) ) { |
| 317 |
/** |
| 318 |
* Function to map the weather code to a weather icon |
| 319 |
* |
| 320 |
* @param string $weatherid the id of the weather condition. |
| 321 |
* @param bool $night the parameter to say if it is night or not. |
| 322 |
* @param bool $icomode if true map to weathericon font, if false map to gif images. |
| 323 |
*/ |
| 324 |
function openweathermap_map_icon( $weatherid, $night = false, $icomode = false ) { |
| 325 |
/* |
| 326 |
Icon mapping from OWM |
| 327 |
*/ |
| 328 |
|
| 329 |
/* |
| 330 |
$ico_arr = array( |
| 331 |
'clear-day' => '01', |
| 332 |
'clear-night' => '33', |
| 333 |
'rain' => '12', |
| 334 |
'snow' => '22', |
| 335 |
'sleet' => '29', |
| 336 |
'wind' => '32', |
| 337 |
'fog' => '11', |
| 338 |
'cloudy' => '06', |
| 339 |
'partly-cloudy-day' => '04', |
| 340 |
'partly-cloudy-night' => '38', |
| 341 |
'hail' => '25', |
| 342 |
'thunderstorm' => '15', |
| 343 |
'tornado' => '32', |
| 344 |
); |
| 345 |
*/ |
| 346 |
|
| 347 |
$icon = '01'; |
| 348 |
|
| 349 |
/* thunderstorm */ |
| 350 |
if ( $weatherid >= 200 && $weatherid <= 232 ) { |
| 351 |
$icon = '15'; |
| 352 |
} |
| 353 |
/* rain */ |
| 354 |
if ( $weatherid >= 500 && $weatherid <= 531 ) { |
| 355 |
$icon = '12'; |
| 356 |
} |
| 357 |
if ( $weatherid >= 300 && $weatherid <= 321 ) { |
| 358 |
$icon = '12'; |
| 359 |
} |
| 360 |
/* snow , sleet*/ |
| 361 |
if ( $weatherid >= 600 && $weatherid <= 622 ) { |
| 362 |
$icon = '22'; |
| 363 |
} |
| 364 |
if ( 611 == $weatherid ) { |
| 365 |
$icon = '29'; |
| 366 |
} |
| 367 |
/* tornado */ |
| 368 |
if ( 781 == $weatherid ) { |
| 369 |
$icon = '32'; |
| 370 |
} |
| 371 |
/* fog */ |
| 372 |
if ( 741 == $weatherid ) { |
| 373 |
$icon = '11'; |
| 374 |
} |
| 375 |
/* clear sky */ |
| 376 |
if ( 800 == $weatherid && false === $night ) { |
| 377 |
$icon = '01'; |
| 378 |
} |
| 379 |
if ( 800 == $weatherid && true === $night ) { |
| 380 |
$icon = '33'; |
| 381 |
} |
| 382 |
|
| 383 |
/* partl cloudy */ |
| 384 |
if ( $weatherid >= 801 && $weatherid <= 803 && false === $night ) { |
| 385 |
$icon = '04'; |
| 386 |
} |
| 387 |
if ( $weatherid >= 801 && $weatherid <= 803 && true === $night ) { |
| 388 |
$icon = '38'; |
| 389 |
} |
| 390 |
if ( 804 == $weatherid ) { |
| 391 |
$icon = '06'; |
| 392 |
} |
| 393 |
|
| 394 |
// mapping for weathfont icons. |
| 395 |
if ( false != $icomode ) { |
| 396 |
if ( 200 == $weatherid ) { |
| 397 |
$icon = 'wi-thunderstorm'; } |
| 398 |
if ( 201 == $weatherid ) { |
| 399 |
$icon = 'wi-thunderstorm'; } |
| 400 |
if ( 202 == $weatherid ) { |
| 401 |
$icon = 'wi-thunderstorm'; } |
| 402 |
if ( 210 == $weatherid ) { |
| 403 |
$icon = 'wi-lightning'; } |
| 404 |
if ( 211 == $weatherid ) { |
| 405 |
$icon = 'wi-lightning'; } |
| 406 |
if ( 212 == $weatherid ) { |
| 407 |
$icon = 'wi-lightning'; } |
| 408 |
if ( 221 == $weatherid ) { |
| 409 |
$icon = 'wi-lightning'; } |
| 410 |
if ( 230 == $weatherid ) { |
| 411 |
$icon = 'wi-thunderstorm'; } |
| 412 |
if ( 231 == $weatherid ) { |
| 413 |
$icon = 'wi-thunderstorm'; } |
| 414 |
if ( 232 == $weatherid ) { |
| 415 |
$icon = 'wi-thunderstorm'; } |
| 416 |
if ( 300 == $weatherid ) { |
| 417 |
$icon = 'wi-sprinkle'; } |
| 418 |
if ( 301 == $weatherid ) { |
| 419 |
$icon = 'wi-sprinkle'; } |
| 420 |
if ( 302 == $weatherid ) { |
| 421 |
$icon = 'wi-rain'; } |
| 422 |
if ( 310 == $weatherid ) { |
| 423 |
$icon = 'wi-rain-mix'; } |
| 424 |
if ( 311 == $weatherid ) { |
| 425 |
$icon = 'wi-rain'; } |
| 426 |
if ( 312 == $weatherid ) { |
| 427 |
$icon = 'wi-rain'; } |
| 428 |
if ( 313 == $weatherid ) { |
| 429 |
$icon = 'wi-showers'; } |
| 430 |
if ( 314 == $weatherid ) { |
| 431 |
$icon = 'wi-rain'; } |
| 432 |
if ( 321 == $weatherid ) { |
| 433 |
$icon = 'wi-sprinkle'; } |
| 434 |
if ( 500 == $weatherid ) { |
| 435 |
$icon = 'wi-sprinkle'; } |
| 436 |
if ( 501 == $weatherid ) { |
| 437 |
$icon = 'wi-rain'; } |
| 438 |
if ( 502 == $weatherid ) { |
| 439 |
$icon = 'wi-rain'; } |
| 440 |
if ( 503 == $weatherid ) { |
| 441 |
$icon = 'wi-rain'; } |
| 442 |
if ( 504 == $weatherid ) { |
| 443 |
$icon = 'wi-rain'; } |
| 444 |
if ( 511 == $weatherid ) { |
| 445 |
$icon = 'wi-rain-mix'; } |
| 446 |
if ( 520 == $weatherid ) { |
| 447 |
$icon = 'wi-showers'; } |
| 448 |
if ( 521 == $weatherid ) { |
| 449 |
$icon = 'wi-showers'; } |
| 450 |
if ( 522 == $weatherid ) { |
| 451 |
$icon = 'wi-showers'; } |
| 452 |
if ( 531 == $weatherid ) { |
| 453 |
$icon = 'wi-storm-showers'; } |
| 454 |
if ( 600 == $weatherid ) { |
| 455 |
$icon = 'wi-snow'; } |
| 456 |
if ( 601 == $weatherid ) { |
| 457 |
$icon = 'wi-snow'; } |
| 458 |
if ( 602 == $weatherid ) { |
| 459 |
$icon = 'wi-sleet'; } |
| 460 |
if ( 611 == $weatherid ) { |
| 461 |
$icon = 'wi-rain-mix'; } |
| 462 |
if ( 612 == $weatherid ) { |
| 463 |
$icon = 'wi-rain-mix'; } |
| 464 |
if ( 615 == $weatherid ) { |
| 465 |
$icon = 'wi-rain-mix'; } |
| 466 |
if ( 616 == $weatherid ) { |
| 467 |
$icon = 'wi-rain-mix'; } |
| 468 |
if ( 620 == $weatherid ) { |
| 469 |
$icon = 'wi-rain-mix'; } |
| 470 |
if ( 621 == $weatherid ) { |
| 471 |
$icon = 'wi-snow'; } |
| 472 |
if ( 622 == $weatherid ) { |
| 473 |
$icon = 'wi-snow'; } |
| 474 |
if ( 701 == $weatherid ) { |
| 475 |
$icon = 'wi-fog'; } |
| 476 |
if ( 711 == $weatherid ) { |
| 477 |
$icon = 'wi-smoke'; } |
| 478 |
if ( 721 == $weatherid ) { |
| 479 |
$icon = 'wi-day-haze'; } |
| 480 |
if ( 731 == $weatherid ) { |
| 481 |
$icon = 'wi-dust'; } |
| 482 |
if ( 741 == $weatherid ) { |
| 483 |
$icon = 'wi-fog'; } |
| 484 |
if ( 761 == $weatherid ) { |
| 485 |
$icon = 'wi-dust'; } |
| 486 |
if ( 762 == $weatherid ) { |
| 487 |
$icon = 'wi-dust'; } |
| 488 |
if ( 771 == $weatherid ) { |
| 489 |
$icon = 'wi-cloudy-gusts'; } |
| 490 |
if ( 781 == $weatherid ) { |
| 491 |
$icon = 'wi-tornado'; } |
| 492 |
if ( 800 == $weatherid ) { |
| 493 |
$icon = 'wi-day-sunny'; } |
| 494 |
if ( 801 == $weatherid ) { |
| 495 |
$icon = 'wi-cloud'; } |
| 496 |
if ( 802 == $weatherid ) { |
| 497 |
$icon = 'wi-cloud'; } |
| 498 |
if ( 803 == $weatherid ) { |
| 499 |
$icon = 'wi-cloudy'; } |
| 500 |
if ( 804 == $weatherid ) { |
| 501 |
$icon = 'wi-cloudy'; } |
| 502 |
if ( 900 == $weatherid ) { |
| 503 |
$icon = 'wi-tornado'; } |
| 504 |
if ( 901 == $weatherid ) { |
| 505 |
$icon = 'wi-storm-showers'; } |
| 506 |
if ( 902 == $weatherid ) { |
| 507 |
$icon = 'wi-hurricane'; } |
| 508 |
if ( 903 == $weatherid ) { |
| 509 |
$icon = 'wi-snowflake-cold'; } |
| 510 |
if ( 904 == $weatherid ) { |
| 511 |
$icon = 'wi-hot'; } |
| 512 |
if ( 905 == $weatherid ) { |
| 513 |
$icon = 'wi-windy'; } |
| 514 |
if ( 906 == $weatherid ) { |
| 515 |
$icon = 'wi-hail'; } |
| 516 |
if ( 957 == $weatherid ) { |
| 517 |
$icon = 'wi-strong-wind'; } |
| 518 |
// Day. |
| 519 |
if ( 200 == $weatherid ) { |
| 520 |
$icon = 'wi-day-thunderstorm'; } |
| 521 |
if ( 201 == $weatherid ) { |
| 522 |
$icon = 'wi-day-thunderstorm'; } |
| 523 |
if ( 202 == $weatherid ) { |
| 524 |
$icon = 'wi-day-thunderstorm'; } |
| 525 |
if ( 210 == $weatherid ) { |
| 526 |
$icon = 'wi-day-lightning'; } |
| 527 |
if ( 211 == $weatherid ) { |
| 528 |
$icon = 'wi-day-lightning'; } |
| 529 |
if ( 212 == $weatherid ) { |
| 530 |
$icon = 'wi-day-lightning'; } |
| 531 |
if ( 221 == $weatherid ) { |
| 532 |
$icon = 'wi-day-lightning'; } |
| 533 |
if ( 230 == $weatherid ) { |
| 534 |
$icon = 'wi-day-thunderstorm'; } |
| 535 |
if ( 231 == $weatherid ) { |
| 536 |
$icon = 'wi-day-thunderstorm'; } |
| 537 |
if ( 232 == $weatherid ) { |
| 538 |
$icon = 'wi-day-thunderstorm'; } |
| 539 |
if ( 300 == $weatherid ) { |
| 540 |
$icon = 'wi-day-sprinkle'; } |
| 541 |
if ( 301 == $weatherid ) { |
| 542 |
$icon = 'wi-day-sprinkle'; } |
| 543 |
if ( 302 == $weatherid ) { |
| 544 |
$icon = 'wi-day-rain'; } |
| 545 |
if ( 310 == $weatherid ) { |
| 546 |
$icon = 'wi-day-rain'; } |
| 547 |
if ( 311 == $weatherid ) { |
| 548 |
$icon = 'wi-day-rain'; } |
| 549 |
if ( 312 == $weatherid ) { |
| 550 |
$icon = 'wi-day-rain'; } |
| 551 |
if ( 313 == $weatherid ) { |
| 552 |
$icon = 'wi-day-rain'; } |
| 553 |
if ( 314 == $weatherid ) { |
| 554 |
$icon = 'wi-day-rain'; } |
| 555 |
if ( 321 == $weatherid ) { |
| 556 |
$icon = 'wi-day-sprinkle'; } |
| 557 |
if ( 500 == $weatherid ) { |
| 558 |
$icon = 'wi-day-sprinkle'; } |
| 559 |
if ( 501 == $weatherid ) { |
| 560 |
$icon = 'wi-day-rain'; } |
| 561 |
if ( 502 == $weatherid ) { |
| 562 |
$icon = 'wi-day-rain'; } |
| 563 |
if ( 503 == $weatherid ) { |
| 564 |
$icon = 'wi-day-rain'; } |
| 565 |
if ( 504 == $weatherid ) { |
| 566 |
$icon = 'wi-day-rain'; } |
| 567 |
if ( 511 == $weatherid ) { |
| 568 |
$icon = 'wi-day-rain-mix'; } |
| 569 |
if ( 520 == $weatherid ) { |
| 570 |
$icon = 'wi-day-showers'; } |
| 571 |
if ( 521 == $weatherid ) { |
| 572 |
$icon = 'wi-day-showers'; } |
| 573 |
if ( 522 == $weatherid ) { |
| 574 |
$icon = 'wi-day-showers'; } |
| 575 |
if ( 531 == $weatherid ) { |
| 576 |
$icon = 'wi-day-storm-showers'; } |
| 577 |
if ( 600 == $weatherid ) { |
| 578 |
$icon = 'wi-day-snow'; } |
| 579 |
if ( 601 == $weatherid ) { |
| 580 |
$icon = 'wi-day-sleet'; } |
| 581 |
if ( 602 == $weatherid ) { |
| 582 |
$icon = 'wi-day-snow'; } |
| 583 |
if ( 611 == $weatherid ) { |
| 584 |
$icon = 'wi-day-rain-mix'; } |
| 585 |
if ( 612 == $weatherid ) { |
| 586 |
$icon = 'wi-day-rain-mix'; } |
| 587 |
if ( 615 == $weatherid ) { |
| 588 |
$icon = 'wi-day-rain-mix'; } |
| 589 |
if ( 616 == $weatherid ) { |
| 590 |
$icon = 'wi-day-rain-mix'; } |
| 591 |
if ( 620 == $weatherid ) { |
| 592 |
$icon = 'wi-day-rain-mix'; } |
| 593 |
if ( 621 == $weatherid ) { |
| 594 |
$icon = 'wi-day-snow'; } |
| 595 |
if ( 622 == $weatherid ) { |
| 596 |
$icon = 'wi-day-snow'; } |
| 597 |
if ( 701 == $weatherid ) { |
| 598 |
$icon = 'wi-day-fog'; } |
| 599 |
if ( 711 == $weatherid ) { |
| 600 |
$icon = 'wi-smoke'; } |
| 601 |
if ( 721 == $weatherid ) { |
| 602 |
$icon = 'wi-day-haze'; } |
| 603 |
if ( 731 == $weatherid ) { |
| 604 |
$icon = 'wi-dust'; } |
| 605 |
if ( 741 == $weatherid ) { |
| 606 |
$icon = 'wi-day-fog'; } |
| 607 |
if ( 761 == $weatherid ) { |
| 608 |
$icon = 'wi-dust'; } |
| 609 |
if ( 762 == $weatherid ) { |
| 610 |
$icon = 'wi-dust'; } |
| 611 |
if ( 781 == $weatherid ) { |
| 612 |
$icon = 'wi-tornado'; } |
| 613 |
if ( 800 == $weatherid ) { |
| 614 |
$icon = 'wi-day-sunny'; } |
| 615 |
if ( 801 == $weatherid ) { |
| 616 |
$icon = 'wi-day-cloudy'; } |
| 617 |
if ( 802 == $weatherid ) { |
| 618 |
$icon = 'wi-day-cloudy'; } |
| 619 |
if ( 803 == $weatherid ) { |
| 620 |
$icon = 'wi-cloudy'; } |
| 621 |
if ( 804 == $weatherid ) { |
| 622 |
$icon = 'wi-cloudy'; } |
| 623 |
if ( 900 == $weatherid ) { |
| 624 |
$icon = 'wi-tornado'; } |
| 625 |
if ( 902 == $weatherid ) { |
| 626 |
$icon = 'wi-hurricane'; } |
| 627 |
if ( 903 == $weatherid ) { |
| 628 |
$icon = 'wi-snowflake-cold'; } |
| 629 |
if ( 904 == $weatherid ) { |
| 630 |
$icon = 'wi-hot'; } |
| 631 |
if ( 906 == $weatherid ) { |
| 632 |
$icon = 'wi-day-hail'; } |
| 633 |
if ( 957 == $weatherid ) { |
| 634 |
$icon = 'wi-strong-wind'; } |
| 635 |
// Night. |
| 636 |
if ( 200 == $weatherid ) { |
| 637 |
$icon = 'wi-night-alt-thunderstorm'; } |
| 638 |
if ( 201 == $weatherid ) { |
| 639 |
$icon = 'wi-night-alt-thunderstorm'; } |
| 640 |
if ( 202 == $weatherid ) { |
| 641 |
$icon = 'wi-night-alt-thunderstorm'; } |
| 642 |
if ( 210 == $weatherid ) { |
| 643 |
$icon = 'wi-night-alt-lightning'; } |
| 644 |
if ( 211 == $weatherid ) { |
| 645 |
$icon = 'wi-night-alt-lightning'; } |
| 646 |
if ( 212 == $weatherid ) { |
| 647 |
$icon = 'wi-night-alt-lightning'; } |
| 648 |
if ( 221 == $weatherid ) { |
| 649 |
$icon = 'wi-night-alt-lightning'; } |
| 650 |
if ( 230 == $weatherid ) { |
| 651 |
$icon = 'wi-night-alt-thunderstorm'; } |
| 652 |
if ( 231 == $weatherid ) { |
| 653 |
$icon = 'wi-night-alt-thunderstorm'; } |
| 654 |
if ( 232 == $weatherid ) { |
| 655 |
$icon = 'wi-night-alt-thunderstorm'; } |
| 656 |
if ( 300 == $weatherid ) { |
| 657 |
$icon = 'wi-night-alt-sprinkle'; } |
| 658 |
if ( 301 == $weatherid ) { |
| 659 |
$icon = 'wi-night-alt-sprinkle'; } |
| 660 |
if ( 302 == $weatherid ) { |
| 661 |
$icon = 'wi-night-alt-rain'; } |
| 662 |
if ( 310 == $weatherid ) { |
| 663 |
$icon = 'wi-night-alt-rain'; } |
| 664 |
if ( 311 == $weatherid ) { |
| 665 |
$icon = 'wi-night-alt-rain'; } |
| 666 |
if ( 312 == $weatherid ) { |
| 667 |
$icon = 'wi-night-alt-rain'; } |
| 668 |
if ( 313 == $weatherid ) { |
| 669 |
$icon = 'wi-night-alt-rain'; } |
| 670 |
if ( 314 == $weatherid ) { |
| 671 |
$icon = 'wi-night-alt-rain'; } |
| 672 |
if ( 321 == $weatherid ) { |
| 673 |
$icon = 'wi-night-alt-sprinkle'; } |
| 674 |
if ( 500 == $weatherid ) { |
| 675 |
$icon = 'wi-night-alt-sprinkle'; } |
| 676 |
if ( 501 == $weatherid ) { |
| 677 |
$icon = 'wi-night-alt-rain'; } |
| 678 |
if ( 502 == $weatherid ) { |
| 679 |
$icon = 'wi-night-alt-rain'; } |
| 680 |
if ( 503 == $weatherid ) { |
| 681 |
$icon = 'wi-night-alt-rain'; } |
| 682 |
if ( 504 == $weatherid ) { |
| 683 |
$icon = 'wi-night-alt-rain'; } |
| 684 |
if ( 511 == $weatherid ) { |
| 685 |
$icon = 'wi-night-alt-rain-mix'; } |
| 686 |
if ( 520 == $weatherid ) { |
| 687 |
$icon = 'wi-night-alt-showers'; } |
| 688 |
if ( 521 == $weatherid ) { |
| 689 |
$icon = 'wi-night-alt-showers'; } |
| 690 |
if ( 522 == $weatherid ) { |
| 691 |
$icon = 'wi-night-alt-showers'; } |
| 692 |
if ( 531 == $weatherid ) { |
| 693 |
$icon = 'wi-night-alt-storm-showers'; } |
| 694 |
if ( 600 == $weatherid ) { |
| 695 |
$icon = 'wi-night-alt-snow'; } |
| 696 |
if ( 601 == $weatherid ) { |
| 697 |
$icon = 'wi-night-alt-sleet'; } |
| 698 |
if ( 602 == $weatherid ) { |
| 699 |
$icon = 'wi-night-alt-snow'; } |
| 700 |
if ( 611 == $weatherid ) { |
| 701 |
$icon = 'wi-night-alt-rain-mix'; } |
| 702 |
if ( 612 == $weatherid ) { |
| 703 |
$icon = 'wi-night-alt-rain-mix'; } |
| 704 |
if ( 615 == $weatherid ) { |
| 705 |
$icon = 'wi-night-alt-rain-mix'; } |
| 706 |
if ( 616 == $weatherid ) { |
| 707 |
$icon = 'wi-night-alt-rain-mix'; } |
| 708 |
if ( 620 == $weatherid ) { |
| 709 |
$icon = 'wi-night-alt-rain-mix'; } |
| 710 |
if ( 621 == $weatherid ) { |
| 711 |
$icon = 'wi-night-alt-snow'; } |
| 712 |
if ( 622 == $weatherid ) { |
| 713 |
$icon = 'wi-night-alt-snow'; } |
| 714 |
if ( 701 == $weatherid ) { |
| 715 |
$icon = 'wi-night-fog'; } |
| 716 |
if ( 711 == $weatherid ) { |
| 717 |
$icon = 'wi-smoke'; } |
| 718 |
if ( 721 == $weatherid ) { |
| 719 |
$icon = 'wi-day-haze'; } |
| 720 |
if ( 731 == $weatherid ) { |
| 721 |
$icon = 'wi-dust'; } |
| 722 |
if ( 741 == $weatherid ) { |
| 723 |
$icon = 'wi-night-fog'; } |
| 724 |
if ( 761 == $weatherid ) { |
| 725 |
$icon = 'wi-dust'; } |
| 726 |
if ( 762 == $weatherid ) { |
| 727 |
$icon = 'wi-dust'; } |
| 728 |
if ( 781 == $weatherid ) { |
| 729 |
$icon = 'wi-tornado'; } |
| 730 |
if ( 800 == $weatherid ) { |
| 731 |
$icon = 'wi-night-clear'; } |
| 732 |
if ( 801 == $weatherid ) { |
| 733 |
$icon = 'wi-night-alt-partly-cloudy'; } |
| 734 |
if ( 802 == $weatherid ) { |
| 735 |
$icon = 'wi-night-alt-cloudy'; } |
| 736 |
if ( 803 == $weatherid ) { |
| 737 |
$icon = 'wi-cloudy'; } |
| 738 |
if ( 804 == $weatherid ) { |
| 739 |
$icon = 'wi-cloudy'; } |
| 740 |
if ( 900 == $weatherid ) { |
| 741 |
$icon = 'wi-tornado'; } |
| 742 |
if ( 902 == $weatherid ) { |
| 743 |
$icon = 'wi-hurricane'; } |
| 744 |
if ( 903 == $weatherid ) { |
| 745 |
$icon = 'wi-snowflake-cold'; } |
| 746 |
if ( 904 == $weatherid ) { |
| 747 |
$icon = 'wi-hot'; } |
| 748 |
if ( 906 == $weatherid ) { |
| 749 |
$icon = 'wi-night-alt-hail'; } |
| 750 |
if ( 957 == $weatherid ) { |
| 751 |
$icon = 'wi-strong-wind'; } |
| 752 |
} |
| 753 |
|
| 754 |
return $icon; |
| 755 |
} |
| 756 |
} |
| 757 |
|
| 758 |
if ( ! function_exists( 'openweathermap_wcode2text' ) ) { |
| 759 |
/** |
| 760 |
* Return the weather data for the cache from OWM |
| 761 |
* |
| 762 |
* @param string $wcode the OWM code for the weather condition. |
| 763 |
*/ |
| 764 |
function openweathermap_wcode2text( $wcode ) { |
| 765 |
|
| 766 |
/** |
| 767 |
* OpenWEatherMap condition codes |
| 768 |
* |
| 769 |
* Group 2xx: Thunderstorm |
| 770 |
* ID Main Description Icon |
| 771 |
* 200 Thunderstorm thunderstorm with light rain 11d |
| 772 |
* 201 Thunderstorm thunderstorm with rain 11d |
| 773 |
* 202 Thunderstorm thunderstorm with heavy rain 11d |
| 774 |
* 210 Thunderstorm light thunderstorm 11d |
| 775 |
* 211 Thunderstorm thunderstorm 11d |
| 776 |
* 212 Thunderstorm heavy thunderstorm 11d |
| 777 |
* 221 Thunderstorm ragged thunderstorm 11d |
| 778 |
* 230 Thunderstorm thunderstorm with light drizzle 11d |
| 779 |
* 231 Thunderstorm thunderstorm with drizzle 11d |
| 780 |
* 232 Thunderstorm thunderstorm with heavy drizzle 11d |
| 781 |
* |
| 782 |
* Group 3xx: Drizzle |
| 783 |
* ID Main Description Icon |
| 784 |
* 300 Drizzle light intensity drizzle 09d |
| 785 |
* 301 Drizzle drizzle 09d |
| 786 |
* 302 Drizzle heavy intensity drizzle 09d |
| 787 |
* 310 Drizzle light intensity drizzle rain 09d |
| 788 |
* 311 Drizzle drizzle rain 09d |
| 789 |
* 312 Drizzle heavy intensity drizzle rain 09d |
| 790 |
* 313 Drizzle shower rain and drizzle 09d |
| 791 |
* 314 Drizzle heavy shower rain and drizzle 09d |
| 792 |
* 321 Drizzle shower drizzle 09d |
| 793 |
* |
| 794 |
* Group 5xx: Rain |
| 795 |
* ID Main Description Icon |
| 796 |
* 500 Rain light rain 10d |
| 797 |
* 501 Rain moderate rain 10d |
| 798 |
* 502 Rain heavy intensity rain 10d |
| 799 |
* 503 Rain very heavy rain 10d |
| 800 |
* 504 Rain extreme rain 10d |
| 801 |
* 511 Rain freezing rain 13d |
| 802 |
* 520 Rain light intensity shower rain 09d |
| 803 |
* 521 Rain shower rain 09d |
| 804 |
* 522 Rain heavy intensity shower rain 09d |
| 805 |
* 531 Rain ragged shower rain 09d |
| 806 |
* |
| 807 |
* Group 6xx: Snow |
| 808 |
* ID Main Description Icon |
| 809 |
* 600 Snow light snow 13d |
| 810 |
* 601 Snow snow 13d |
| 811 |
* 602 Snow heavy snow 13d |
| 812 |
* 611 Snow sleet 13d |
| 813 |
* 612 Snow light shower sleet 13d |
| 814 |
* 613 Snow shower sleet 13d |
| 815 |
* 615 Snow light rain and snow 13d |
| 816 |
* 616 Snow rain and snow 13d |
| 817 |
* 620 Snow light shower snow 13d |
| 818 |
* 621 Snow shower snow 13d |
| 819 |
* 622 Snow heavy shower snow 13d |
| 820 |
* |
| 821 |
* Group 7xx: Atmosphere |
| 822 |
* ID Main Description Icon |
| 823 |
* 701 Mist mist 50d |
| 824 |
* 711 Smoke smoke 50d |
| 825 |
* 721 Haze haze 50d |
| 826 |
* 731 Dust sand/dust whirls 50d |
| 827 |
* 741 Fog fog 50d |
| 828 |
* 751 Sand sand 50d |
| 829 |
* 761 Dust dust 50d |
| 830 |
* 762 Ash volcanic ash 50d |
| 831 |
* 771 Squall squalls 50d |
| 832 |
* 781 Tornado tornado 50d |
| 833 |
* |
| 834 |
* Group 800: Clear |
| 835 |
* ID Main Description Icon |
| 836 |
* 800 Clear clear sky 01d / 01n |
| 837 |
* |
| 838 |
* Group 80x: Clouds |
| 839 |
* ID Main Description Icon |
| 840 |
* 801 Clouds few clouds: 11-25% 02d / 02n |
| 841 |
* 802 Clouds scattered clouds: 25-50% 03d / 03n |
| 842 |
* 803 Clouds broken clouds: 51-84% 04d / 04n |
| 843 |
* 804 Clouds overcast clouds: 85-100% 04d / 04n |
| 844 |
*/ |
| 845 |
|
| 846 |
$c = __( 'clear sky', 'wp-forecast' ); // the short description for the weather condition. |
| 847 |
|
| 848 |
if ( $wcode >= 200 && $wcode < 300 ) { |
| 849 |
switch ( $wcode ) { |
| 850 |
case 200: |
| 851 |
$c = __( 'Thunderstorm with light rain', 'xxxdummy' ); |
| 852 |
break; |
| 853 |
case 201: |
| 854 |
$c = __( 'Thunderstorm with rain', 'xxxdummy' ); |
| 855 |
break; |
| 856 |
case 202: |
| 857 |
$c = __( 'Thunderstorm with heavy rain', 'xxxdummy' ); |
| 858 |
break; |
| 859 |
case 210: |
| 860 |
$c = __( 'Light thunderstorm', 'xxxdummy' ); |
| 861 |
break; |
| 862 |
case 211: |
| 863 |
$c = __( 'Thunderstorm', 'xxxdummy' ); |
| 864 |
break; |
| 865 |
case 212: |
| 866 |
$c = __( 'Heavy thunderstorm', 'xxxdummy' ); |
| 867 |
break; |
| 868 |
case 221: |
| 869 |
$c = __( 'Ragged thunderstorm', 'xxxdummy' ); |
| 870 |
break; |
| 871 |
case 230: |
| 872 |
$c = __( 'Thunderstorm with light drizzle', 'xxxdummy' ); |
| 873 |
break; |
| 874 |
case 231: |
| 875 |
$c = __( 'Thunderstorm with drizzle', 'xxxdummy' ); |
| 876 |
break; |
| 877 |
case 232: |
| 878 |
$c = __( 'Thunderstorm with heavy drizzle', 'xxxdummy' ); |
| 879 |
break; |
| 880 |
} |
| 881 |
} |
| 882 |
|
| 883 |
if ( $wcode >= 300 && $wcode < 400 ) { |
| 884 |
switch ( $wcode ) { |
| 885 |
case 300: |
| 886 |
$c = __( 'Light drizzle', 'xxxdummy' ); |
| 887 |
break; |
| 888 |
case 301: |
| 889 |
$c = __( 'Drizzle', 'xxxdummy' ); |
| 890 |
break; |
| 891 |
case 302: |
| 892 |
$c = __( 'Heavy drizzle', 'xxxdummy' ); |
| 893 |
break; |
| 894 |
case 310: |
| 895 |
$c = __( 'Light drizzle rain', 'xxxdummy' ); |
| 896 |
break; |
| 897 |
case 311: |
| 898 |
$c = __( 'Drizzle rain', 'xxxdummy' ); |
| 899 |
break; |
| 900 |
case 312: |
| 901 |
$c = __( 'Heavy drizzle rain', 'xxxdummy' ); |
| 902 |
break; |
| 903 |
case 313: |
| 904 |
$c = __( 'Shower rain and drizzle', 'xxxdummy' ); |
| 905 |
break; |
| 906 |
case 314: |
| 907 |
$c = __( 'Heavy shower rain and drizzle', 'xxxdummy' ); |
| 908 |
break; |
| 909 |
case 321: |
| 910 |
$c = __( 'Shower drizzle', 'xxxdummy' ); |
| 911 |
break; |
| 912 |
} |
| 913 |
} |
| 914 |
|
| 915 |
if ( $wcode >= 500 && $wcode < 600 ) { |
| 916 |
switch ( $wcode ) { |
| 917 |
case 500: |
| 918 |
$c = __( 'Light rain', 'xxxdummy' ); |
| 919 |
break; |
| 920 |
case 501: |
| 921 |
$c = __( 'Moderate rain', 'xxxdummy' ); |
| 922 |
break; |
| 923 |
case 502: |
| 924 |
$c = __( 'Heavy rain', 'xxxdummy' ); |
| 925 |
break; |
| 926 |
case 503: |
| 927 |
$c = __( 'Very heavy rain', 'xxxdummy' ); |
| 928 |
break; |
| 929 |
case 504: |
| 930 |
$c = __( 'Extreme rain', 'xxxdummy' ); |
| 931 |
break; |
| 932 |
case 511: |
| 933 |
$c = __( 'Freezing rain', 'xxxdummy' ); |
| 934 |
break; |
| 935 |
case 520: |
| 936 |
$c = __( 'Light shower rain', 'xxxdummy' ); |
| 937 |
break; |
| 938 |
case 521: |
| 939 |
$c = __( 'Shower rain', 'xxxdummy' ); |
| 940 |
break; |
| 941 |
case 522: |
| 942 |
$c = __( 'Heavy shower rain', 'xxxdummy' ); |
| 943 |
break; |
| 944 |
case 531: |
| 945 |
$c = __( 'Ragged shower rain', 'xxxdummy' ); |
| 946 |
break; |
| 947 |
} |
| 948 |
} |
| 949 |
|
| 950 |
if ( $wcode >= 600 && $wcode < 700 ) { |
| 951 |
switch ( $wcode ) { |
| 952 |
case 600: |
| 953 |
$c = __( 'Light snow', 'xxxdummy' ); |
| 954 |
break; |
| 955 |
case 601: |
| 956 |
$c = __( 'Snow', 'xxxdummy' ); |
| 957 |
break; |
| 958 |
case 602: |
| 959 |
$c = __( 'Heavy snow', 'xxxdummy' ); |
| 960 |
break; |
| 961 |
case 611: |
| 962 |
$c = __( 'Sleet', 'xxxdummy' ); |
| 963 |
break; |
| 964 |
case 612: |
| 965 |
$c = __( 'Light shower sleet', 'xxxdummy' ); |
| 966 |
break; |
| 967 |
case 613: |
| 968 |
$c = __( 'Shower sleet', 'xxxdummy' ); |
| 969 |
break; |
| 970 |
case 615: |
| 971 |
$c = __( 'Light rain and snow', 'xxxdummy' ); |
| 972 |
break; |
| 973 |
case 616: |
| 974 |
$c = __( 'Rain and snow', 'xxxdummy' ); |
| 975 |
break; |
| 976 |
case 620: |
| 977 |
$c = __( 'Light shower snow', 'xxxdummy' ); |
| 978 |
break; |
| 979 |
case 621: |
| 980 |
$c = __( 'Shower snow', 'xxxdummy' ); |
| 981 |
break; |
| 982 |
case 622: |
| 983 |
$c = __( 'Heavy shower snow', 'xxxdummy' ); |
| 984 |
break; |
| 985 |
} |
| 986 |
} |
| 987 |
|
| 988 |
if ( $wcode >= 700 && $wcode < 800 ) { |
| 989 |
switch ( $wcode ) { |
| 990 |
case 701: |
| 991 |
$c = __( 'Mist', 'xxxdummy' ); |
| 992 |
break; |
| 993 |
case 711: |
| 994 |
$c = __( 'Smoke', 'xxxdummy' ); |
| 995 |
break; |
| 996 |
case 721: |
| 997 |
$c = __( 'Haze', 'xxxdummy' ); |
| 998 |
break; |
| 999 |
case 731: |
| 1000 |
$c = __( 'Dust', 'xxxdummy' ); |
| 1001 |
break; |
| 1002 |
case 741: |
| 1003 |
$c = __( 'Fog', 'xxxdummy' ); |
| 1004 |
break; |
| 1005 |
case 751: |
| 1006 |
$c = __( 'Sand', 'xxxdummy' ); |
| 1007 |
break; |
| 1008 |
case 761: |
| 1009 |
$c = __( 'Dust', 'xxxdummy' ); |
| 1010 |
break; |
| 1011 |
case 762: |
| 1012 |
$c = __( 'Ash', 'xxxdummy' ); |
| 1013 |
break; |
| 1014 |
case 771: |
| 1015 |
$c = __( 'Squalls', 'xxxdummy' ); |
| 1016 |
break; |
| 1017 |
case 781: |
| 1018 |
$c = __( 'Tornado', 'xxxdummy' ); |
| 1019 |
break; |
| 1020 |
} |
| 1021 |
} |
| 1022 |
|
| 1023 |
if ( $wcode >= 800 && $wcode < 900 ) { |
| 1024 |
switch ( $wcode ) { |
| 1025 |
case 800: |
| 1026 |
$c = __( 'Clear sky', 'xxxdummy' ); |
| 1027 |
break; |
| 1028 |
case 801: |
| 1029 |
$c = __( 'Few clouds', 'xxxdummy' ); |
| 1030 |
break; |
| 1031 |
case 802: |
| 1032 |
$c = __( 'Scattered clouds', 'xxxdummy' ); |
| 1033 |
break; |
| 1034 |
case 803: |
| 1035 |
$c = __( 'Broken clouds', 'xxxdummy' ); |
| 1036 |
break; |
| 1037 |
case 804: |
| 1038 |
$c = __( 'Overcast clouds', 'xxxdummy' ); |
| 1039 |
break; |
| 1040 |
} |
| 1041 |
} |
| 1042 |
|
| 1043 |
return $c; |
| 1044 |
} // end of function. |
| 1045 |
} // end of function wrapper. |
| 1046 |
|