Smush Image Compression and Optimization - Version 2.1.1

Version Description

  • Fixed: Workaround for terrible bug in W3TC file based object caching
Download this release

Release Info

Developer uglyrobot
Plugin Icon 128x128 Smush Image Compression and Optimization
Version 2.1.1
Comparing to
See all releases

Code changes from version 2.1 to 2.1.1

Files changed (3) hide show
  1. lib/class-wp-smush.php +10 -8
  2. readme.txt +5 -2
  3. wp-smush.php +2 -2
lib/class-wp-smush.php CHANGED
@@ -602,8 +602,10 @@ if ( ! class_exists( 'WpSmush' ) ) {
602
  return false;
603
  }
604
 
 
605
  $key = "wp-smush-premium-" . substr( $api_key, - 5, 5 ); //add last 5 chars of apikey to transient key in case it changes
606
- if ( false === ( $valid = get_site_transient( $key ) ) ) {
 
607
  // call api
608
  $url = $this->api_server . '&key=' . urlencode( $api_key );
609
 
@@ -616,21 +618,21 @@ if ( ! class_exists( 'WpSmush' ) ) {
616
  if ( ! is_wp_error( $request ) && '200' == wp_remote_retrieve_response_code( $request ) ) {
617
  $result = json_decode( wp_remote_retrieve_body( $request ) );
618
  if ( $result && $result->success ) {
619
- $valid = true;
620
- set_site_transient( $key, 1, 12 * HOUR_IN_SECONDS );
621
  } else {
622
- $valid = false;
623
- set_site_transient( $key, 0, 24 * HOUR_IN_SECONDS ); //cache failure much shorter
624
  }
625
 
626
  } else {
627
- $valid = false;
628
- set_site_transient( $key, 0, 30 * MINUTE_IN_SECONDS ); //cache network failure even shorter, we don't want a request every pageload
629
  }
630
 
631
  }
632
 
633
- $this->is_pro = (bool) $valid;
634
 
635
  return $this->is_pro;
636
  }
602
  return false;
603
  }
604
 
605
+ //W3TC disk cache is buggy and always converts 0 to false, so we have to store as string
606
  $key = "wp-smush-premium-" . substr( $api_key, - 5, 5 ); //add last 5 chars of apikey to transient key in case it changes
607
+ $valid = get_site_transient( $key );
608
+ if ( empty( $valid ) ) {
609
  // call api
610
  $url = $this->api_server . '&key=' . urlencode( $api_key );
611
 
618
  if ( ! is_wp_error( $request ) && '200' == wp_remote_retrieve_response_code( $request ) ) {
619
  $result = json_decode( wp_remote_retrieve_body( $request ) );
620
  if ( $result && $result->success ) {
621
+ $valid = 'true';
622
+ set_site_transient( $key, 'true', 12 * HOUR_IN_SECONDS );
623
  } else {
624
+ $valid = 'false';
625
+ set_site_transient( $key, 'false', DAY_IN_SECONDS );
626
  }
627
 
628
  } else {
629
+ $valid = 'false';
630
+ set_site_transient( $key, 'false', 5 * MINUTE_IN_SECONDS ); //cache network failure even shorter, we don't want a request every pageload
631
  }
632
 
633
  }
634
 
635
+ $this->is_pro = ( 'true' == $valid );
636
 
637
  return $this->is_pro;
638
  }
readme.txt CHANGED
@@ -1,13 +1,13 @@
1
  === WP Smush ===
2
  Plugin Name: WP Smush
3
- Version: 2.1-beta1
4
  Author: WPMU DEV
5
  Author URI: http://premium.wpmudev.org/
6
  Contributors: WPMUDEV, alexdunae
7
  Tags: Attachment,Attachments,Compress,Compress Image File,Compress Image Size,Compress JPG,Compressed JPG, Compression Image,Image,Images,JPG,Optimise,Optimize,Photo,Photos,Pictures,PNG,Reduce Image Size,Smush,Smush.it,Upload,WordPress Compression,WordPress Image Tool,Yahoo, Yahoo Smush.it
8
  Requires at least: 3.5
9
  Tested up to: 4.3.1
10
- Stable tag: 2.1
11
  License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
12
 
13
  Reduce image file sizes, improve performance and boost your SEO using the free <a href="https://premium.wpmudev.org/">WPMU DEV</a> WordPress Smush API.
@@ -81,6 +81,9 @@ Yahoo's Smush.it API is gone forever. So WPMU DEV built our own free API that is
81
 
82
  == Changelog ==
83
 
 
 
 
84
  = 2.1 =
85
  * Fixed: Untranslatable strings in settings
86
  * Fixed: Increased is_pro() API timeouts
1
  === WP Smush ===
2
  Plugin Name: WP Smush
3
+ Version: 2.1.1
4
  Author: WPMU DEV
5
  Author URI: http://premium.wpmudev.org/
6
  Contributors: WPMUDEV, alexdunae
7
  Tags: Attachment,Attachments,Compress,Compress Image File,Compress Image Size,Compress JPG,Compressed JPG, Compression Image,Image,Images,JPG,Optimise,Optimize,Photo,Photos,Pictures,PNG,Reduce Image Size,Smush,Smush.it,Upload,WordPress Compression,WordPress Image Tool,Yahoo, Yahoo Smush.it
8
  Requires at least: 3.5
9
  Tested up to: 4.3.1
10
+ Stable tag: 2.1.1
11
  License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
12
 
13
  Reduce image file sizes, improve performance and boost your SEO using the free <a href="https://premium.wpmudev.org/">WPMU DEV</a> WordPress Smush API.
81
 
82
  == Changelog ==
83
 
84
+ = 2.1.1 =
85
+ * Fixed: Workaround for terrible bug in W3TC file based object caching
86
+
87
  = 2.1 =
88
  * Fixed: Untranslatable strings in settings
89
  * Fixed: Increased is_pro() API timeouts
wp-smush.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WP Smush
4
  Plugin URI: http://wordpress.org/extend/plugins/wp-smushit/
5
  Description: Reduce image file sizes, improve performance and boost your SEO using the free <a href="https://premium.wpmudev.org/">WPMU DEV</a> WordPress Smush API.
6
  Author: WPMU DEV
7
- Version: 2.1
8
  Author URI: http://premium.wpmudev.org/
9
  Textdomain: wp-smushit
10
  */
@@ -35,7 +35,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35
  * Constants
36
  */
37
  $prefix = 'WP_SMUSH_';
38
- $version = '2.1';
39
 
40
  /**
41
  * Set the default timeout for API request and AJAX timeout
4
  Plugin URI: http://wordpress.org/extend/plugins/wp-smushit/
5
  Description: Reduce image file sizes, improve performance and boost your SEO using the free <a href="https://premium.wpmudev.org/">WPMU DEV</a> WordPress Smush API.
6
  Author: WPMU DEV
7
+ Version: 2.1.1
8
  Author URI: http://premium.wpmudev.org/
9
  Textdomain: wp-smushit
10
  */
35
  * Constants
36
  */
37
  $prefix = 'WP_SMUSH_';
38
+ $version = '2.1.1';
39
 
40
  /**
41
  * Set the default timeout for API request and AJAX timeout