Awesome Weather Widget - Version 1.5.13

Version Description

  • Another attempted fix to the forecast days
Download this release

Release Info

Developer halgatewood
Plugin Icon 128x128 Awesome Weather Widget
Version 1.5.13
Comparing to
See all releases

Code changes from version 1.5.12 to 1.5.13

Files changed (2) hide show
  1. awesome-weather.php +15 -2
  2. readme.txt +4 -1
awesome-weather.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://halgatewood.com/awesome-weather
5
  Description: A weather widget that actually looks cool
6
  Author: Hal Gatewood
7
  Author URI: https://www.halgatewood.com
8
- Version: 1.5.12
9
  Text Domain: awesome-weather
10
  Domain Path: /languages
11
 
@@ -205,7 +205,7 @@ function awesome_weather_logic( $atts )
205
 
206
 
207
  // FORECAST
208
- $forecast_ping = "http://api.openweathermap.org/data/2.5/forecast?" . $api_query . "&lang=" . $locale . "&units=" . $units ."&cnt=7" . $appid_string;
209
  $forecast_ping_get = wp_remote_get( $forecast_ping );
210
 
211
  if( is_wp_error( $forecast_ping_get ) )
@@ -425,6 +425,9 @@ function awesome_weather_logic( $atts )
425
  $rtn .= "<div class=\"awesome-weather-forecast awe_days_{$days_to_show} awecf\">";
426
  $c = 1;
427
  $forecast = $weather_data['forecast'];
 
 
 
428
  $days_to_show = (int) $days_to_show;
429
  $days_of_week = apply_filters( 'awesome_weather_days_of_week', array( __('Sun' ,'awesome-weather'), __('Mon' ,'awesome-weather'), __('Tue' ,'awesome-weather'), __('Wed' ,'awesome-weather'), __('Thu' ,'awesome-weather'), __('Fri' ,'awesome-weather'), __('Sat' ,'awesome-weather') ) );
430
 
@@ -432,7 +435,17 @@ function awesome_weather_logic( $atts )
432
 
433
  foreach( (array) $forecast->list as $forecast )
434
  {
 
 
 
 
 
 
 
 
435
  if( $dt_today >= date('Ymd', $forecast->dt)) continue;
 
 
436
  $forecast->temp = (int) $forecast->main->temp;
437
  $day_of_week = $days_of_week[ date('w', $forecast->dt) ];
438
  $rtn .= "
5
  Description: A weather widget that actually looks cool
6
  Author: Hal Gatewood
7
  Author URI: https://www.halgatewood.com
8
+ Version: 1.5.13
9
  Text Domain: awesome-weather
10
  Domain Path: /languages
11
 
205
 
206
 
207
  // FORECAST
208
+ $forecast_ping = "http://api.openweathermap.org/data/2.5/forecast?" . $api_query . "&lang=" . $locale . "&units=" . $units . $appid_string;
209
  $forecast_ping_get = wp_remote_get( $forecast_ping );
210
 
211
  if( is_wp_error( $forecast_ping_get ) )
425
  $rtn .= "<div class=\"awesome-weather-forecast awe_days_{$days_to_show} awecf\">";
426
  $c = 1;
427
  $forecast = $weather_data['forecast'];
428
+
429
+ $last_day_visible = 0;
430
+
431
  $days_to_show = (int) $days_to_show;
432
  $days_of_week = apply_filters( 'awesome_weather_days_of_week', array( __('Sun' ,'awesome-weather'), __('Mon' ,'awesome-weather'), __('Tue' ,'awesome-weather'), __('Wed' ,'awesome-weather'), __('Thu' ,'awesome-weather'), __('Fri' ,'awesome-weather'), __('Sat' ,'awesome-weather') ) );
433
 
435
 
436
  foreach( (array) $forecast->list as $forecast )
437
  {
438
+ // GET DAY OF WEEK NUMBER
439
+ $day_of_week_number = date('w', $forecast->dt);
440
+
441
+ // ONLY SHOW ONE FORCAST PER DAY
442
+ if( $day_of_week_number == $last_day_visible ) continue;
443
+ $last_day_visible = $day_of_week_number;
444
+
445
+ // IF TODAY IS GREATER THAN FORECAST DAY, SKIP
446
  if( $dt_today >= date('Ymd', $forecast->dt)) continue;
447
+
448
+
449
  $forecast->temp = (int) $forecast->main->temp;
450
  $day_of_week = $days_of_week[ date('w', $forecast->dt) ];
451
  $rtn .= "
readme.txt CHANGED
@@ -91,8 +91,11 @@ The easiest shortcode setting is just: `[awesome-weather location="Oklahoma City
91
 
92
  == Changelog ==
93
 
 
 
 
94
  = 1.5.12 =
95
- * Fix to API change made by OpenWeatherMap
96
 
97
  = 1.5.11 =
98
  * Get just the weather data with function: awesome_weather_data
91
 
92
  == Changelog ==
93
 
94
+ = 1.5.13 =
95
+ * Another attempted fix to the forecast days
96
+
97
  = 1.5.12 =
98
+ * Attempted fix to forecast days due to OpenWeatherMap API Change
99
 
100
  = 1.5.11 =
101
  * Get just the weather data with function: awesome_weather_data