Test Failed
Push — master ( 9f58db...1a3aaa )
by Devin
05:56
created
includes/admin/EDD_SL_Plugin_Updater.php 1 patch
Spacing   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Exit if accessed directly
4
-if ( ! defined( 'ABSPATH' ) ) {
4
+if ( ! defined('ABSPATH')) {
5 5
 	exit;
6 6
 }
7 7
 
@@ -33,21 +33,21 @@  discard block
 block discarded – undo
33 33
 	 * @param string $_plugin_file Path to the plugin file.
34 34
 	 * @param array  $_api_data    Optional data to send with API calls.
35 35
 	 */
36
-	public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
36
+	public function __construct($_api_url, $_plugin_file, $_api_data = null) {
37 37
 
38 38
 		global $edd_plugin_data, $edd_plugin_url_available;
39 39
 
40
-		$this->api_url = trailingslashit( $_api_url );
40
+		$this->api_url = trailingslashit($_api_url);
41 41
 
42 42
 		$this->api_data    = $_api_data;
43
-		$this->name        = plugin_basename( $_plugin_file );
44
-		$this->slug        = basename( $_plugin_file, '.php' );
43
+		$this->name        = plugin_basename($_plugin_file);
44
+		$this->slug        = basename($_plugin_file, '.php');
45 45
 		$this->version     = $_api_data['version'];
46
-		$this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
47
-		$this->beta        = ! empty( $this->api_data['beta'] ) ? true : false;
48
-		$this->cache_key   = 'edd_sl_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
46
+		$this->wp_override = isset($_api_data['wp_override']) ? (bool) $_api_data['wp_override'] : false;
47
+		$this->beta        = ! empty($this->api_data['beta']) ? true : false;
48
+		$this->cache_key   = 'edd_sl_'.md5(serialize($this->slug.$this->api_data['license'].$this->beta));
49 49
 
50
-		$edd_plugin_data[ $this->slug ] = $this->api_data;
50
+		$edd_plugin_data[$this->slug] = $this->api_data;
51 51
 
52 52
 		/**
53 53
 		 * Fires after the $edd_plugin_data is setup.
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		 *
57 57
 		 * @param array $edd_plugin_data Array of EDD SL plugin data.
58 58
 		 */
59
-		do_action( 'post_edd_sl_plugin_updater_setup', $edd_plugin_data );
59
+		do_action('post_edd_sl_plugin_updater_setup', $edd_plugin_data);
60 60
 
61 61
 		// Set up hooks.
62 62
 		$this->init();
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public function init() {
74 74
 
75
-		add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
76
-		add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
77
-		remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
78
-		add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
79
-		add_action( 'admin_init', array( $this, 'show_changelog' ) );
75
+		add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
76
+		add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3);
77
+		remove_action('after_plugin_row_'.$this->name, 'wp_plugin_update_row', 10);
78
+		add_action('after_plugin_row_'.$this->name, array($this, 'show_update_notification'), 10, 2);
79
+		add_action('admin_init', array($this, 'show_changelog'));
80 80
 
81 81
 	}
82 82
 
@@ -93,25 +93,25 @@  discard block
 block discarded – undo
93 93
 	 * @param array $_transient_data Update array build by WordPress.
94 94
 	 * @return array Modified update array with custom plugin data.
95 95
 	 */
96
-	public function check_update( $_transient_data ) {
96
+	public function check_update($_transient_data) {
97 97
 
98 98
 		global $pagenow;
99 99
 
100
-		if ( ! is_object( $_transient_data ) ) {
100
+		if ( ! is_object($_transient_data)) {
101 101
 			$_transient_data = new stdClass();
102 102
 		}
103 103
 
104
-		if ( 'plugins.php' == $pagenow && is_multisite() ) {
104
+		if ('plugins.php' == $pagenow && is_multisite()) {
105 105
 			return $_transient_data;
106 106
 		}
107 107
 
108
-		if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
108
+		if ( ! empty($_transient_data->response) && ! empty($_transient_data->response[$this->name]) && false === $this->wp_override) {
109 109
 			return $_transient_data;
110 110
 		}
111 111
 
112 112
 		$version_info = $this->get_cached_version_info();
113 113
 
114
-		if ( false === $version_info ) {
114
+		if (false === $version_info) {
115 115
 			$version_info = $this->api_request(
116 116
 				'plugin_latest_version', array(
117 117
 					'slug' => $this->slug,
@@ -119,20 +119,20 @@  discard block
 block discarded – undo
119 119
 				)
120 120
 			);
121 121
 
122
-			$this->set_version_info_cache( $version_info );
122
+			$this->set_version_info_cache($version_info);
123 123
 
124 124
 		}
125 125
 
126
-		if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
126
+		if (false !== $version_info && is_object($version_info) && isset($version_info->new_version)) {
127 127
 
128
-			if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
128
+			if (version_compare($this->version, $version_info->new_version, '<')) {
129 129
 
130
-				$_transient_data->response[ $this->name ] = $version_info;
130
+				$_transient_data->response[$this->name] = $version_info;
131 131
 
132 132
 			}
133 133
 
134 134
 			$_transient_data->last_checked           = time();
135
-			$_transient_data->checked[ $this->name ] = $this->version;
135
+			$_transient_data->checked[$this->name] = $this->version;
136 136
 
137 137
 		}
138 138
 
@@ -145,36 +145,36 @@  discard block
 block discarded – undo
145 145
 	 * @param string $file
146 146
 	 * @param array  $plugin
147 147
 	 */
148
-	public function show_update_notification( $file, $plugin ) {
148
+	public function show_update_notification($file, $plugin) {
149 149
 
150
-		if ( is_network_admin() ) {
150
+		if (is_network_admin()) {
151 151
 			return;
152 152
 		}
153 153
 
154
-		if ( ! current_user_can( 'update_plugins' ) ) {
154
+		if ( ! current_user_can('update_plugins')) {
155 155
 			return;
156 156
 		}
157 157
 
158
-		if ( ! is_multisite() ) {
158
+		if ( ! is_multisite()) {
159 159
 			return;
160 160
 		}
161 161
 
162
-		if ( $this->name != $file ) {
162
+		if ($this->name != $file) {
163 163
 			return;
164 164
 		}
165 165
 
166 166
 		// Remove our filter on the site transient
167
-		remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
167
+		remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10);
168 168
 
169
-		$update_cache = get_site_transient( 'update_plugins' );
169
+		$update_cache = get_site_transient('update_plugins');
170 170
 
171
-		$update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
171
+		$update_cache = is_object($update_cache) ? $update_cache : new stdClass();
172 172
 
173
-		if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
173
+		if (empty($update_cache->response) || empty($update_cache->response[$this->name])) {
174 174
 
175 175
 			$version_info = $this->get_cached_version_info();
176 176
 
177
-			if ( false === $version_info ) {
177
+			if (false === $version_info) {
178 178
 				$version_info = $this->api_request(
179 179
 					'plugin_latest_version', array(
180 180
 						'slug' => $this->slug,
@@ -182,65 +182,65 @@  discard block
 block discarded – undo
182 182
 					)
183 183
 				);
184 184
 
185
-				$this->set_version_info_cache( $version_info );
185
+				$this->set_version_info_cache($version_info);
186 186
 			}
187 187
 
188
-			if ( ! is_object( $version_info ) ) {
188
+			if ( ! is_object($version_info)) {
189 189
 				return;
190 190
 			}
191 191
 
192
-			if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
192
+			if (version_compare($this->version, $version_info->new_version, '<')) {
193 193
 
194
-				$update_cache->response[ $this->name ] = $version_info;
194
+				$update_cache->response[$this->name] = $version_info;
195 195
 
196 196
 			}
197 197
 
198 198
 			$update_cache->last_checked           = time();
199
-			$update_cache->checked[ $this->name ] = $this->version;
199
+			$update_cache->checked[$this->name] = $this->version;
200 200
 
201
-			set_site_transient( 'update_plugins', $update_cache );
201
+			set_site_transient('update_plugins', $update_cache);
202 202
 
203 203
 		} else {
204 204
 
205
-			$version_info = $update_cache->response[ $this->name ];
205
+			$version_info = $update_cache->response[$this->name];
206 206
 
207 207
 		}
208 208
 
209 209
 		// Restore our filter
210
-		add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
210
+		add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
211 211
 
212
-		if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
212
+		if ( ! empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<')) {
213 213
 
214 214
 			// build a plugin list row, with update notification
215
-			$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
215
+			$wp_list_table = _get_list_table('WP_Plugins_List_Table');
216 216
 			// <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
217
-			echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
217
+			echo '<tr class="plugin-update-tr" id="'.$this->slug.'-update" data-slug="'.$this->slug.'" data-plugin="'.$this->slug.'/'.$file.'">';
218 218
 			echo '<td colspan="3" class="plugin-update colspanchange">';
219 219
 			echo '<div class="update-message notice inline notice-warning notice-alt">';
220 220
 
221
-			$changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
221
+			$changelog_link = self_admin_url('index.php?edd_sl_action=view_plugin_changelog&plugin='.$this->name.'&slug='.$this->slug.'&TB_iframe=true&width=772&height=911');
222 222
 
223
-			if ( empty( $version_info->download_link ) ) {
223
+			if (empty($version_info->download_link)) {
224 224
 				printf(
225
-					__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'give' ),
226
-					esc_html( $version_info->name ),
227
-					'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
228
-					esc_html( $version_info->new_version ),
225
+					__('There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'give'),
226
+					esc_html($version_info->name),
227
+					'<a target="_blank" class="thickbox" href="'.esc_url($changelog_link).'">',
228
+					esc_html($version_info->new_version),
229 229
 					'</a>'
230 230
 				);
231 231
 			} else {
232 232
 				printf(
233
-					__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'give' ),
234
-					esc_html( $version_info->name ),
235
-					'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
236
-					esc_html( $version_info->new_version ),
233
+					__('There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'give'),
234
+					esc_html($version_info->name),
235
+					'<a target="_blank" class="thickbox" href="'.esc_url($changelog_link).'">',
236
+					esc_html($version_info->new_version),
237 237
 					'</a>',
238
-					'<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) . '">',
238
+					'<a href="'.esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$this->name, 'upgrade-plugin_'.$this->name)).'">',
239 239
 					'</a>'
240 240
 				);
241 241
 			}
242 242
 
243
-			do_action( "in_plugin_update_message-{$file}", $plugin, $version_info );
243
+			do_action("in_plugin_update_message-{$file}", $plugin, $version_info);
244 244
 
245 245
 			echo '</div></td></tr>';
246 246
 		}
@@ -256,15 +256,15 @@  discard block
 block discarded – undo
256 256
 	 * @param object $_args
257 257
 	 * @return object $_data
258 258
 	 */
259
-	public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
259
+	public function plugins_api_filter($_data, $_action = '', $_args = null) {
260 260
 
261
-		if ( $_action != 'plugin_information' ) {
261
+		if ($_action != 'plugin_information') {
262 262
 
263 263
 			return $_data;
264 264
 
265 265
 		}
266 266
 
267
-		if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
267
+		if ( ! isset($_args->slug) || ($_args->slug != $this->slug)) {
268 268
 
269 269
 			return $_data;
270 270
 
@@ -279,20 +279,20 @@  discard block
 block discarded – undo
279 279
 			),
280 280
 		);
281 281
 
282
-		$cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
282
+		$cache_key = 'edd_api_request_'.md5(serialize($this->slug.$this->api_data['license'].$this->beta));
283 283
 
284 284
 		// Get the transient where we store the api request for this plugin for 24 hours
285
-		$edd_api_request_transient = $this->get_cached_version_info( $cache_key );
285
+		$edd_api_request_transient = $this->get_cached_version_info($cache_key);
286 286
 
287 287
 		// If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
288
-		if ( empty( $edd_api_request_transient ) ) {
288
+		if (empty($edd_api_request_transient)) {
289 289
 
290
-			$api_response = $this->api_request( 'plugin_information', $to_send );
290
+			$api_response = $this->api_request('plugin_information', $to_send);
291 291
 
292 292
 			// Expires in 3 hours
293
-			$this->set_version_info_cache( $api_response, $cache_key );
293
+			$this->set_version_info_cache($api_response, $cache_key);
294 294
 
295
-			if ( false !== $api_response ) {
295
+			if (false !== $api_response) {
296 296
 				$_data = $api_response;
297 297
 			}
298 298
 		} else {
@@ -300,20 +300,20 @@  discard block
 block discarded – undo
300 300
 		}
301 301
 
302 302
 		// Convert sections into an associative array, since we're getting an object, but Core expects an array.
303
-		if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
303
+		if (isset($_data->sections) && ! is_array($_data->sections)) {
304 304
 			$new_sections = array();
305
-			foreach ( $_data->sections as $key => $value ) {
306
-				$new_sections[ $key ] = $value;
305
+			foreach ($_data->sections as $key => $value) {
306
+				$new_sections[$key] = $value;
307 307
 			}
308 308
 
309 309
 			$_data->sections = $new_sections;
310 310
 		}
311 311
 
312 312
 		// Convert banners into an associative array, since we're getting an object, but Core expects an array.
313
-		if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
313
+		if (isset($_data->banners) && ! is_array($_data->banners)) {
314 314
 			$new_banners = array();
315
-			foreach ( $_data->banners as $key => $value ) {
316
-				$new_banners[ $key ] = $value;
315
+			foreach ($_data->banners as $key => $value) {
316
+				$new_banners[$key] = $value;
317 317
 			}
318 318
 
319 319
 			$_data->banners = $new_banners;
@@ -329,10 +329,10 @@  discard block
 block discarded – undo
329 329
 	 * @param string $url
330 330
 	 * @return object $array
331 331
 	 */
332
-	public function http_request_args( $args, $url ) {
332
+	public function http_request_args($args, $url) {
333 333
 
334 334
 		$verify_ssl = $this->verify_ssl();
335
-		if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
335
+		if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download')) {
336 336
 			$args['sslverify'] = $verify_ssl;
337 337
 		}
338 338
 		return $args;
@@ -350,30 +350,30 @@  discard block
 block discarded – undo
350 350
 	 * @param array  $_data   Parameters for the API action.
351 351
 	 * @return false|object
352 352
 	 */
353
-	private function api_request( $_action, $_data ) {
353
+	private function api_request($_action, $_data) {
354 354
 
355 355
 		global $wp_version;
356 356
 
357
-		$data = array_merge( $this->api_data, $_data );
357
+		$data = array_merge($this->api_data, $_data);
358 358
 
359
-		if ( $data['slug'] != $this->slug ) {
359
+		if ($data['slug'] != $this->slug) {
360 360
 			return;
361 361
 		}
362 362
 
363
-		if ( $this->api_url == trailingslashit( home_url() ) ) {
363
+		if ($this->api_url == trailingslashit(home_url())) {
364 364
 			return false; // Don't allow a plugin to ping itself
365 365
 		}
366 366
 
367 367
 		$api_params = array(
368 368
 			'edd_action' => 'get_version',
369
-			'license'    => ! empty( $data['license'] ) ? $data['license'] : '',
370
-			'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
371
-			'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
372
-			'version'    => isset( $data['version'] ) ? $data['version'] : false,
369
+			'license'    => ! empty($data['license']) ? $data['license'] : '',
370
+			'item_name'  => isset($data['item_name']) ? $data['item_name'] : false,
371
+			'item_id'    => isset($data['item_id']) ? $data['item_id'] : false,
372
+			'version'    => isset($data['version']) ? $data['version'] : false,
373 373
 			'slug'       => $data['slug'],
374 374
 			'author'     => $data['author'],
375 375
 			'url'        => home_url(),
376
-			'beta'       => ! empty( $data['beta'] ),
376
+			'beta'       => ! empty($data['beta']),
377 377
 		);
378 378
 
379 379
 		$verify_ssl = $this->verify_ssl();
@@ -385,22 +385,22 @@  discard block
 block discarded – undo
385 385
 			)
386 386
 		);
387 387
 
388
-		if ( ! is_wp_error( $request ) ) {
389
-			$request = json_decode( wp_remote_retrieve_body( $request ) );
388
+		if ( ! is_wp_error($request)) {
389
+			$request = json_decode(wp_remote_retrieve_body($request));
390 390
 		}
391 391
 
392
-		if ( $request && isset( $request->sections ) ) {
393
-			$request->sections = maybe_unserialize( $request->sections );
392
+		if ($request && isset($request->sections)) {
393
+			$request->sections = maybe_unserialize($request->sections);
394 394
 		} else {
395 395
 			$request = false;
396 396
 		}
397 397
 
398
-		if ( $request && isset( $request->banners ) ) {
399
-			$request->banners = maybe_unserialize( $request->banners );
398
+		if ($request && isset($request->banners)) {
399
+			$request->banners = maybe_unserialize($request->banners);
400 400
 		}
401 401
 
402
-		if ( ! empty( $request->sections ) ) {
403
-			foreach ( $request->sections as $key => $section ) {
402
+		if ( ! empty($request->sections)) {
403
+			foreach ($request->sections as $key => $section) {
404 404
 				$request->$key = (array) $section;
405 405
 			}
406 406
 		}
@@ -412,37 +412,37 @@  discard block
 block discarded – undo
412 412
 
413 413
 		global $edd_plugin_data;
414 414
 
415
-		if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
415
+		if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action']) {
416 416
 			return;
417 417
 		}
418 418
 
419
-		if ( empty( $_REQUEST['plugin'] ) ) {
419
+		if (empty($_REQUEST['plugin'])) {
420 420
 			return;
421 421
 		}
422 422
 
423
-		if ( empty( $_REQUEST['slug'] ) ) {
423
+		if (empty($_REQUEST['slug'])) {
424 424
 			return;
425 425
 		}
426 426
 
427
-		if ( ! current_user_can( 'update_plugins' ) ) {
428
-			wp_die( __( 'You do not have permission to install plugin updates', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
427
+		if ( ! current_user_can('update_plugins')) {
428
+			wp_die(__('You do not have permission to install plugin updates', 'give'), __('Error', 'give'), array('response' => 403));
429 429
 		}
430 430
 
431
-		$data         = $edd_plugin_data[ $_REQUEST['slug'] ];
432
-		$beta         = ! empty( $data['beta'] ) ? true : false;
433
-		$cache_key    = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
434
-		$version_info = $this->get_cached_version_info( $cache_key );
431
+		$data         = $edd_plugin_data[$_REQUEST['slug']];
432
+		$beta         = ! empty($data['beta']) ? true : false;
433
+		$cache_key    = md5('edd_plugin_'.sanitize_key($_REQUEST['plugin']).'_'.$beta.'_version_info');
434
+		$version_info = $this->get_cached_version_info($cache_key);
435 435
 
436
-		if ( false === $version_info ) {
436
+		if (false === $version_info) {
437 437
 
438 438
 			$api_params = array(
439 439
 				'edd_action' => 'get_version',
440
-				'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
441
-				'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
440
+				'item_name'  => isset($data['item_name']) ? $data['item_name'] : false,
441
+				'item_id'    => isset($data['item_id']) ? $data['item_id'] : false,
442 442
 				'slug'       => $_REQUEST['slug'],
443 443
 				'author'     => $data['author'],
444 444
 				'url'        => home_url(),
445
-				'beta'       => ! empty( $data['beta'] ),
445
+				'beta'       => ! empty($data['beta']),
446 446
 			);
447 447
 
448 448
 			$verify_ssl = $this->verify_ssl();
@@ -454,61 +454,61 @@  discard block
 block discarded – undo
454 454
 				)
455 455
 			);
456 456
 
457
-			if ( ! is_wp_error( $request ) ) {
458
-				$version_info = json_decode( wp_remote_retrieve_body( $request ) );
457
+			if ( ! is_wp_error($request)) {
458
+				$version_info = json_decode(wp_remote_retrieve_body($request));
459 459
 			}
460 460
 
461
-			if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
462
-				$version_info->sections = maybe_unserialize( $version_info->sections );
461
+			if ( ! empty($version_info) && isset($version_info->sections)) {
462
+				$version_info->sections = maybe_unserialize($version_info->sections);
463 463
 			} else {
464 464
 				$version_info = false;
465 465
 			}
466 466
 
467
-			if ( ! empty( $version_info ) ) {
468
-				foreach ( $version_info->sections as $key => $section ) {
467
+			if ( ! empty($version_info)) {
468
+				foreach ($version_info->sections as $key => $section) {
469 469
 					$version_info->$key = (array) $section;
470 470
 				}
471 471
 			}
472 472
 
473
-			$this->set_version_info_cache( $version_info, $cache_key );
473
+			$this->set_version_info_cache($version_info, $cache_key);
474 474
 
475 475
 		}
476 476
 
477
-		if ( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
478
-			echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
477
+		if ( ! empty($version_info) && isset($version_info->sections['changelog'])) {
478
+			echo '<div style="background:#fff;padding:10px;">'.$version_info->sections['changelog'].'</div>';
479 479
 		}
480 480
 
481 481
 		exit;
482 482
 	}
483 483
 
484
-	public function get_cached_version_info( $cache_key = '' ) {
484
+	public function get_cached_version_info($cache_key = '') {
485 485
 
486
-		if ( empty( $cache_key ) ) {
486
+		if (empty($cache_key)) {
487 487
 			$cache_key = $this->cache_key;
488 488
 		}
489 489
 
490
-		$cache = get_option( $cache_key );
490
+		$cache = get_option($cache_key);
491 491
 
492
-		if ( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
492
+		if (empty($cache['timeout']) || time() > $cache['timeout']) {
493 493
 			return false; // Cache is expired
494 494
 		}
495 495
 
496
-		return json_decode( $cache['value'] );
496
+		return json_decode($cache['value']);
497 497
 
498 498
 	}
499 499
 
500
-	public function set_version_info_cache( $value = '', $cache_key = '' ) {
500
+	public function set_version_info_cache($value = '', $cache_key = '') {
501 501
 
502
-		if ( empty( $cache_key ) ) {
502
+		if (empty($cache_key)) {
503 503
 			$cache_key = $this->cache_key;
504 504
 		}
505 505
 
506 506
 		$data = array(
507
-			'timeout' => strtotime( '+3 hours', time() ),
508
-			'value'   => json_encode( $value ),
507
+			'timeout' => strtotime('+3 hours', time()),
508
+			'value'   => json_encode($value),
509 509
 		);
510 510
 
511
-		update_option( $cache_key, $data, 'no' );
511
+		update_option($cache_key, $data, 'no');
512 512
 
513 513
 	}
514 514
 
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 	 * @return bool
520 520
 	 */
521 521
 	private function verify_ssl() {
522
-		return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
522
+		return (bool) apply_filters('edd_sl_api_request_verify_ssl', true, $this);
523 523
 	}
524 524
 
525 525
 }
Please login to merge, or discard this patch.