ShortPixel Image Optimizer - Version 4.12.4

Version Description

Release date: 27th December 2018

  • Fixed: shortpixel-thumbnails-regenerated action when not all the thumbnails were regenerated
Download this release

Release Info

Developer ShortPixel
Plugin Icon 128x128 ShortPixel Image Optimizer
Version 4.12.4
Comparing to
See all releases

Code changes from version 4.12.3 to 4.12.4

class/db/shortpixel-meta-facade.php CHANGED
@@ -86,10 +86,16 @@ class ShortPixelMetaFacade {
86
  }
87
  }
88
 
89
- function sanitizeMeta($rawMeta){
90
  if(!is_array($rawMeta)) {
91
  if($rawMeta == '') { return array('ShortPixel' => array()); }
92
- else { return array("previous_meta" => $rawMeta, 'ShortPixel' => array()); }
 
 
 
 
 
 
93
  }
94
  return $rawMeta;
95
  }
@@ -194,7 +200,12 @@ class ShortPixelMetaFacade {
194
 
195
  update_post_meta($_ID, '_wp_attachment_metadata', $rawMeta);
196
  //wp_update_attachment_metadata($_ID, $rawMeta);
197
- update_post_meta($_ID, '_shortpixel_status', $this->meta->getStatus());
 
 
 
 
 
198
 
199
  if($_ID == $this->ID) {
200
  $this->rawMeta = $rawMeta;
86
  }
87
  }
88
 
89
+ static function sanitizeMeta($rawMeta){
90
  if(!is_array($rawMeta)) {
91
  if($rawMeta == '') { return array('ShortPixel' => array()); }
92
+ else {
93
+ $meta = @unserialize($rawMeta);
94
+ if(is_array($meta)) {
95
+ return $meta;
96
+ }
97
+ return array("previous_meta" => $rawMeta, 'ShortPixel' => array());
98
+ }
99
  }
100
  return $rawMeta;
101
  }
200
 
201
  update_post_meta($_ID, '_wp_attachment_metadata', $rawMeta);
202
  //wp_update_attachment_metadata($_ID, $rawMeta);
203
+ //status and optimization percent in the same time, for sorting purposes :)
204
+ $status = $this->meta->getStatus();
205
+ if($status == 2) {
206
+ $status += 0.01 * $rawMeta['ShortPixelImprovement'];
207
+ }
208
+ update_post_meta($_ID, '_shortpixel_status', number_format($status, 4));
209
 
210
  if($_ID == $this->ID) {
211
  $this->rawMeta = $rawMeta;
class/wp-short-pixel.php CHANGED
@@ -1559,13 +1559,15 @@ class WPShortPixel {
1559
  $shortPixelMeta["thumbsOptList"] = array();
1560
  $shortPixelMeta["retinasOpt"] = 0;
1561
  } else {
 
1562
  foreach($regeneratedSizes as $size) {
1563
- if(isset($shortPixelMeta["thumbsOptList"][$size])) {
1564
- unset($shortPixelMeta["thumbsOptList"][$size]);
1565
  $shortPixelMeta["thumbsOpt"] = max(0, $shortPixelMeta["thumbsOpt"] - 1);
1566
  $shortPixelMeta["retinasOpt"] = max(0, $shortPixelMeta["retinasOpt"] - 1);
1567
  }
1568
  }
 
1569
  }
1570
  $meta = wp_get_attachment_metadata($postId);
1571
  $meta["ShortPixel"] = $shortPixelMeta;
@@ -1784,7 +1786,9 @@ class WPShortPixel {
1784
 
1785
  $duplicates = ShortPixelMetaFacade::getWPMLDuplicates($attachmentID);
1786
  foreach($duplicates as $ID) {
1787
- $crtMeta = $attachmentID == $ID ? $rawMeta : wp_get_attachment_metadata($ID);
 
 
1788
  if( isset($crtMeta["ShortPixelImprovement"]) && is_numeric($crtMeta["ShortPixelImprovement"])
1789
  && 0 + $crtMeta["ShortPixelImprovement"] < 5 && $this->_settings->under5Percent > 0) {
1790
  $this->_settings->under5Percent = $this->_settings->under5Percent - 1; // - (isset($crtMeta["ShortPixel"]["thumbsOpt"]) ? $crtMeta["ShortPixel"]["thumbsOpt"] : 0);
1559
  $shortPixelMeta["thumbsOptList"] = array();
1560
  $shortPixelMeta["retinasOpt"] = 0;
1561
  } else {
1562
+ $regeneratedThumbs = array();
1563
  foreach($regeneratedSizes as $size) {
1564
+ if(isset($size['file']) && in_array($size['file'], $shortPixelMeta["thumbsOptList"] )) {
1565
+ $regeneratedThumbs[] = $size['file'];
1566
  $shortPixelMeta["thumbsOpt"] = max(0, $shortPixelMeta["thumbsOpt"] - 1);
1567
  $shortPixelMeta["retinasOpt"] = max(0, $shortPixelMeta["retinasOpt"] - 1);
1568
  }
1569
  }
1570
+ $shortPixelMeta["thumbsOptList"] = array_diff($shortPixelMeta["thumbsOptList"], $regeneratedThumbs);
1571
  }
1572
  $meta = wp_get_attachment_metadata($postId);
1573
  $meta["ShortPixel"] = $shortPixelMeta;
1786
 
1787
  $duplicates = ShortPixelMetaFacade::getWPMLDuplicates($attachmentID);
1788
  foreach($duplicates as $ID) {
1789
+ //Added sanitizeMeta (improved with @unserialize) as per https://secure.helpscout.net/conversation/725053586/11656?folderId=1117588
1790
+ $crtMeta = $attachmentID == $ID ? $rawMeta : ShortPixelMetaFacade::sanitizeMeta(wp_get_attachment_metadata($ID));
1791
+ if(isset($crtMeta['previous_meta'])) continue;
1792
  if( isset($crtMeta["ShortPixelImprovement"]) && is_numeric($crtMeta["ShortPixelImprovement"])
1793
  && 0 + $crtMeta["ShortPixelImprovement"] < 5 && $this->_settings->under5Percent > 0) {
1794
  $this->_settings->under5Percent = $this->_settings->under5Percent - 1; // - (isset($crtMeta["ShortPixel"]["thumbsOpt"]) ? $crtMeta["ShortPixel"]["thumbsOpt"] : 0);
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: compressor, image, compression, optimize, image optimizer, image optimiser
4
  Requires at least: 3.2.0
5
  Tested up to: 5.0
6
  Requires PHP: 5.2
7
- Stable tag: 4.12.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -241,6 +241,12 @@ The ShortPixel Image Optimiser plugin calls the following actions and filters:
241
 
242
  == Changelog ==
243
 
 
 
 
 
 
 
244
  = 4.12.3 =
245
 
246
  Release date: 19th December 2018
4
  Requires at least: 3.2.0
5
  Tested up to: 5.0
6
  Requires PHP: 5.2
7
+ Stable tag: 4.12.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
241
 
242
  == Changelog ==
243
 
244
+ = 4.12.4 =
245
+
246
+ Release date: 27th December 2018
247
+
248
+ * Fixed: shortpixel-thumbnails-regenerated action when not all the thumbnails were regenerated
249
+
250
  = 4.12.3 =
251
 
252
  Release date: 19th December 2018
wp-shortpixel.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: ShortPixel Image Optimizer
4
  * Plugin URI: https://shortpixel.com/
5
  * Description: ShortPixel optimizes images automatically, while guarding the quality of your images. Check your <a href="options-general.php?page=wp-shortpixel" target="_blank">Settings &gt; ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
6
- * Version: 4.12.3
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  * Text Domain: shortpixel-image-optimiser
@@ -18,7 +18,7 @@ define('SHORTPIXEL_PLUGIN_FILE', __FILE__);
18
 
19
  //define('SHORTPIXEL_AFFILIATE_CODE', '');
20
 
21
- define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.12.3");
22
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
23
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
24
  define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');
3
  * Plugin Name: ShortPixel Image Optimizer
4
  * Plugin URI: https://shortpixel.com/
5
  * Description: ShortPixel optimizes images automatically, while guarding the quality of your images. Check your <a href="options-general.php?page=wp-shortpixel" target="_blank">Settings &gt; ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
6
+ * Version: 4.12.4
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  * Text Domain: shortpixel-image-optimiser
18
 
19
  //define('SHORTPIXEL_AFFILIATE_CODE', '');
20
 
21
+ define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.12.4");
22
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
23
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
24
  define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');