Awesome Weather Widget - Version 1.2.6

Version Description

Improved error handling with API calls

Download this release

Release Info

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

Code changes from version 1.2.5 to 1.2.6

Files changed (2) hide show
  1. awesome-weather.php +20 -1
  2. readme.txt +6 -0
awesome-weather.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://halgatewood.com/awesome-weather
5
  Description: A weather widget that actually looks cool
6
  Author: Hal Gatewood
7
  Author URI: http://www.halgatewood.com
8
- Version: 1.2.5
9
 
10
 
11
  FILTERS AVAILABLE:
@@ -79,6 +79,13 @@ function awesome_weather_logic( $atts )
79
  {
80
  $city_ping = "http://api.openweathermap.org/data/2.1/find/name?q=" . $city_name_slug;
81
  $city_ping_get = wp_remote_get( $city_ping );
 
 
 
 
 
 
 
82
  $data = json_decode( $city_ping_get['body'] );
83
 
84
  if( isset($data->message) AND $data->message == "not found" )
@@ -111,6 +118,12 @@ function awesome_weather_logic( $atts )
111
  if(!isset($weather_data['today']))
112
  {
113
  $today_get = wp_remote_get("http://api.openweathermap.org/data/2.1/weather/city/" . $city_id . "?units=" . $units);
 
 
 
 
 
 
114
  $weather_data['today'] = json_decode( $today_get['body'] );
115
  set_transient( $weather_transient_name, $weather_data, apply_filters( 'awesome_weather_cache', 3600 ) ); // CACHE FOR AN HOUR
116
  }
@@ -118,6 +131,12 @@ function awesome_weather_logic( $atts )
118
  if(!isset($weather_data['forecast']) AND $days_to_show != "hide")
119
  {
120
  $forecast_get = wp_remote_get("http://api.openweathermap.org/data/2.1/forecast/city/" . $city_id . "?mode=daily_compact&units=" . $units);
 
 
 
 
 
 
121
  $weather_data['forecast'] = json_decode( $forecast_get['body'] );
122
  set_transient( $weather_transient_name, $weather_data, apply_filters( 'awesome_weather_cache', 3600 ) ); // CACHE FOR AN HOUR
123
  }
5
  Description: A weather widget that actually looks cool
6
  Author: Hal Gatewood
7
  Author URI: http://www.halgatewood.com
8
+ Version: 1.2.6
9
 
10
 
11
  FILTERS AVAILABLE:
79
  {
80
  $city_ping = "http://api.openweathermap.org/data/2.1/find/name?q=" . $city_name_slug;
81
  $city_ping_get = wp_remote_get( $city_ping );
82
+
83
+ if( is_wp_error( $city_ping_get ) )
84
+ {
85
+ return awesome_weather_error( $city_ping_get->get_error_message() );
86
+ }
87
+
88
+
89
  $data = json_decode( $city_ping_get['body'] );
90
 
91
  if( isset($data->message) AND $data->message == "not found" )
118
  if(!isset($weather_data['today']))
119
  {
120
  $today_get = wp_remote_get("http://api.openweathermap.org/data/2.1/weather/city/" . $city_id . "?units=" . $units);
121
+
122
+ if( is_wp_error( $today_get ) )
123
+ {
124
+ return awesome_weather_error( $today_get->get_error_message() );
125
+ }
126
+
127
  $weather_data['today'] = json_decode( $today_get['body'] );
128
  set_transient( $weather_transient_name, $weather_data, apply_filters( 'awesome_weather_cache', 3600 ) ); // CACHE FOR AN HOUR
129
  }
131
  if(!isset($weather_data['forecast']) AND $days_to_show != "hide")
132
  {
133
  $forecast_get = wp_remote_get("http://api.openweathermap.org/data/2.1/forecast/city/" . $city_id . "?mode=daily_compact&units=" . $units);
134
+
135
+ if( is_wp_error( $forecast_get ) )
136
+ {
137
+ return awesome_weather_error( $forecast_get->get_error_message() );
138
+ }
139
+
140
  $weather_data['forecast'] = json_decode( $forecast_get['body'] );
141
  set_transient( $weather_transient_name, $weather_data, apply_filters( 'awesome_weather_cache', 3600 ) ); // CACHE FOR AN HOUR
142
  }
readme.txt CHANGED
@@ -48,6 +48,9 @@ All weather data is provided by http://openweathermap.org and is cached for one
48
 
49
  == Upgrade Notice ==
50
 
 
 
 
51
  = 1.2.5 =
52
  Widget with custom background CSS issue.
53
 
@@ -74,6 +77,9 @@ Changed API endpoints. Might not find weather without update.
74
 
75
  == Changelog ==
76
 
 
 
 
77
  = 1.2.5 =
78
  * Widget with custom background CSS issue.
79
 
48
 
49
  == Upgrade Notice ==
50
 
51
+ = 1.2.6 =
52
+ Improved error handling with API calls
53
+
54
  = 1.2.5 =
55
  Widget with custom background CSS issue.
56
 
77
 
78
  == Changelog ==
79
 
80
+ = 1.2.6 =
81
+ * Improved error handling with API calls
82
+
83
  = 1.2.5 =
84
  * Widget with custom background CSS issue.
85