ShortPixel Image Optimizer - Version 4.12.6

Version Description

Release date: 27th January 2019

  • Improvements to the .htaccess WebP method
  • Improve performance of backup deletion - get rid of unnecessary checks
  • Fixed: wrong calculation of remaining credits
  • Fixed: discrepancy between the description of the exclude size option and the behaviour for the exact size case.
Download this release

Release Info

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

Code changes from version 4.12.5 to 4.12.6

class/view/shortpixel_view.php CHANGED
@@ -1056,7 +1056,7 @@ class ShortPixelView {
1056
  if( $isNginx ){
1057
  $deliverWebpUnaltered = ''; // Uncheck
1058
  $deliverWebpUnalteredDisabled = 'disabled'; // Disable
1059
- $deliverWebpUnalteredLabel = __('It looks like you\'re running your site on an NginX server. This means that you can only achieve this functionality by directly configuring the server config files and .htaccess file. Please follow the following link for instructions on how to achieve this:','shortpixel-image-optimiser')." <a href=\"javascript:void(0)\" data-beacon-article=\"5bfeb9de2c7d3a31944e78ee\">Open article</a>";
1060
  } else {
1061
  if( !$htaccessWriteable ){
1062
  $deliverWebpUnalteredDisabled = 'disabled'; // Disable
@@ -1069,7 +1069,7 @@ class ShortPixelView {
1069
  } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false) {
1070
  // Show a message about the risks and caveats of serving WEBP images via .htaccess
1071
  $deliverWebpUnalteredLabel = '<span style="color: initial;">'.__('Based on testing your particular hosting configuration, we determined that your server','shortpixel-image-optimiser').
1072
- '<img src="'.str_replace("/class/view", "/res", plugins_url( 'img/test.jpg' , __FILE__ )).'">'.
1073
  __('serve the WEBP versions of the JPEG files seamlessly, via .htaccess.','shortpixel-image-optimiser').' <a href="javascript:void(0)" data-beacon-article="5c1d050e04286304a71d9ce4">Open article to read more about this.</a></span>';
1074
  }
1075
  }
@@ -1204,15 +1204,16 @@ class ShortPixelView {
1204
  <th scope="row"><?php _e('Convert PNG images to JPEG','shortpixel-image-optimiser');?></th>
1205
  <td>
1206
  <input name="png2jpg" type="checkbox" id="png2jpg" <?php echo( $convertPng2Jpg );?> <?php echo($gdInstalled ? '' : 'disabled') ?>>
1207
- <label for="png2jpg"><?php _e('Automatically convert the PNG images to JPEG if possible.','shortpixel-image-optimiser');?></label>
 
 
1208
  <p class="settings-info">
1209
  <?php _e('Converts all PNGs that don\'t have transparent pixels to JPEG. This can dramatically reduce the file size, especially if you have camera pictures that are saved in PNG format. The plugin will also search for references of the image in posts and will replace them.','shortpixel-image-optimiser');?>
 
1210
  </p><br>
1211
  <input name="png2jpgForce" type="checkbox" id="png2jpgForce" <?php echo( $convertPng2JpgForce );?> <?php echo($gdInstalled ? '' : 'disabled') ?>>
1212
  <label for="png2jpgForce">
1213
- <?php _e('Also force the conversion of images with transparency.','shortpixel-image-optimiser');
1214
- if(!$gdInstalled) {echo("&nbsp;<span style='color:red;'>" . __('You need PHP GD for this. Please ask your hosting to install it.','shortpixel-image-optimiser') . "</span>");}
1215
- ?>
1216
  </label>
1217
  </td>
1218
  </tr>
@@ -1463,7 +1464,6 @@ class ShortPixelView {
1463
  <?php }
1464
 
1465
  function displaySettingsStats($quotaData, $averageCompression, $savedSpace, $savedBandwidth,
1466
-
1467
  $remainingImages, $totalCallsMade, $fileCount, $backupFolderSize) { ?>
1468
  <div class="wp-shortpixel-tab-content">
1469
  <a id="facts"></a>
@@ -1539,9 +1539,9 @@ class ShortPixelView {
1539
  (defined("SHORTPIXEL_HIDE_API_KEY") ? '' : $this->ctrl->getApiKey()));?>
1540
  <br><br>
1541
  <?php _e('Consumed: ','shortpixel-image-optimiser'); ?>
1542
- <strong><?php echo( $totalCallsMade['plan'] ); ?></strong>
1543
  <?php _e('; Remaining: ','shortpixel-image-optimiser'); ?>
1544
- <strong><?php echo( $quotaData['APICallsQuota'] - $totalCallsMade['plan'] ); ?></strong>
1545
  </td>
1546
  </tr>
1547
  <tr>
@@ -1553,9 +1553,9 @@ class ShortPixelView {
1553
  <strong><?php echo( number_format($quotaData['APICallsQuotaOneTimeNumeric'])); ?></strong>
1554
  <br><br>
1555
  <?php _e('Consumed: ','shortpixel-image-optimiser'); ?>
1556
- <strong><?php echo( $totalCallsMade['oneTime'] ); ?></strong>
1557
  <?php _e('; Remaining: ','shortpixel-image-optimiser'); ?>
1558
- <strong><?php echo( $remainingImages ); ?></strong>**
1559
  </td>
1560
  </tr>
1561
  <tr>
1056
  if( $isNginx ){
1057
  $deliverWebpUnaltered = ''; // Uncheck
1058
  $deliverWebpUnalteredDisabled = 'disabled'; // Disable
1059
+ $deliverWebpUnalteredLabel = __('It looks like you\'re running your site on an NginX server. This means that you can only achieve this functionality by directly configuring the server config files. Please follow this link for instructions on how to achieve this:','shortpixel-image-optimiser')." <a href=\"javascript:void(0)\" data-beacon-article=\"5bfeb9de2c7d3a31944e78ee\">Open article</a>";
1060
  } else {
1061
  if( !$htaccessWriteable ){
1062
  $deliverWebpUnalteredDisabled = 'disabled'; // Disable
1069
  } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false) {
1070
  // Show a message about the risks and caveats of serving WEBP images via .htaccess
1071
  $deliverWebpUnalteredLabel = '<span style="color: initial;">'.__('Based on testing your particular hosting configuration, we determined that your server','shortpixel-image-optimiser').
1072
+ '&nbsp;<img src="'.str_replace("/class/view", "/res", plugins_url( 'img/test.jpg' , __FILE__ )).'">&nbsp;'.
1073
  __('serve the WEBP versions of the JPEG files seamlessly, via .htaccess.','shortpixel-image-optimiser').' <a href="javascript:void(0)" data-beacon-article="5c1d050e04286304a71d9ce4">Open article to read more about this.</a></span>';
1074
  }
1075
  }
1204
  <th scope="row"><?php _e('Convert PNG images to JPEG','shortpixel-image-optimiser');?></th>
1205
  <td>
1206
  <input name="png2jpg" type="checkbox" id="png2jpg" <?php echo( $convertPng2Jpg );?> <?php echo($gdInstalled ? '' : 'disabled') ?>>
1207
+ <label for="png2jpg"><?php _e('Automatically convert the PNG images to JPEG if possible.','shortpixel-image-optimiser');
1208
+ if(!$gdInstalled) {echo("&nbsp;<span style='color:red;'>" . __('You need PHP GD for this. Please ask your hosting to install it.','shortpixel-image-optimiser') . "</span>");}
1209
+ ?></label>
1210
  <p class="settings-info">
1211
  <?php _e('Converts all PNGs that don\'t have transparent pixels to JPEG. This can dramatically reduce the file size, especially if you have camera pictures that are saved in PNG format. The plugin will also search for references of the image in posts and will replace them.','shortpixel-image-optimiser');?>
1212
+ <strong><?php _e('The image will NOT be converted if the resulting JPEG is larger than the original PNG.','shortpixel-image-optimiser');?></strong>
1213
  </p><br>
1214
  <input name="png2jpgForce" type="checkbox" id="png2jpgForce" <?php echo( $convertPng2JpgForce );?> <?php echo($gdInstalled ? '' : 'disabled') ?>>
1215
  <label for="png2jpgForce">
1216
+ <?php _e('Also force the conversion of images with transparency.','shortpixel-image-optimiser'); ?>
 
 
1217
  </label>
1218
  </td>
1219
  </tr>
1464
  <?php }
1465
 
1466
  function displaySettingsStats($quotaData, $averageCompression, $savedSpace, $savedBandwidth,
 
1467
  $remainingImages, $totalCallsMade, $fileCount, $backupFolderSize) { ?>
1468
  <div class="wp-shortpixel-tab-content">
1469
  <a id="facts"></a>
1539
  (defined("SHORTPIXEL_HIDE_API_KEY") ? '' : $this->ctrl->getApiKey()));?>
1540
  <br><br>
1541
  <?php _e('Consumed: ','shortpixel-image-optimiser'); ?>
1542
+ <strong><?php echo( number_format( $totalCallsMade['plan'] ) ); ?></strong>
1543
  <?php _e('; Remaining: ','shortpixel-image-optimiser'); ?>
1544
+ <strong><?php echo( number_format( $quotaData['APICallsQuotaNumeric'] - $totalCallsMade['plan'] ) ); ?></strong>
1545
  </td>
1546
  </tr>
1547
  <tr>
1553
  <strong><?php echo( number_format($quotaData['APICallsQuotaOneTimeNumeric'])); ?></strong>
1554
  <br><br>
1555
  <?php _e('Consumed: ','shortpixel-image-optimiser'); ?>
1556
+ <strong><?php echo( number_format($totalCallsMade['oneTime']) ); ?></strong>
1557
  <?php _e('; Remaining: ','shortpixel-image-optimiser'); ?>
1558
+ <strong><?php echo( number_format( $quotaData['APICallsQuotaOneTimeNumeric'] - $totalCallsMade['oneTime'] ) ); ?></strong>**
1559
  </td>
1560
  </tr>
1561
  <tr>
class/wp-short-pixel.php CHANGED
@@ -2335,13 +2335,15 @@ class WPShortPixel {
2335
  if(file_exists(SHORTPIXEL_BACKUP_FOLDER)) {
2336
 
2337
  //extract all images from DB in an array. of course
 
 
2338
  $attachments = null;
2339
  $attachments = get_posts( array(
2340
  'numberposts' => -1,
2341
  'post_type' => 'attachment',
2342
  'post_mime_type' => 'image'
2343
  ));
2344
-
2345
 
2346
  //delete the actual files on disk
2347
  $this->deleteDir(SHORTPIXEL_BACKUP_FOLDER);//call a recursive function to empty files and sub-dirs in backup dir
@@ -2570,13 +2572,22 @@ class WPShortPixel {
2570
  insert_with_markers( get_home_path() . '.htaccess', 'ShortPixelWebp', '
2571
  <IfModule mod_rewrite.c>
2572
  RewriteEngine On
2573
- RewriteCond %{HTTP_ACCEPT} image/webp
2574
- RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
2575
- RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
 
 
 
 
 
 
 
 
 
2576
  </IfModule>
2577
-
2578
  <IfModule mod_headers.c>
2579
- Header append Vary Accept env=REDIRECT_accept
 
2580
  </IfModule>
2581
 
2582
  <IfModule mod_mime.c>
@@ -2884,7 +2895,7 @@ Header append Vary Accept env=REDIRECT_webp
2884
  }
2885
  $remainingImages = $quotaData['APICallsRemaining'];
2886
  $remainingImages = ( $remainingImages < 0 ) ? 0 : number_format($remainingImages);
2887
- $totalCallsMade = array( 'plan'=>number_format( $quotaData['APICallsMadeNumeric'] ), 'oneTime'=>number_format( $quotaData['APICallsMadeOneTimeNumeric'] ) );
2888
 
2889
  $resources = wp_remote_post($this->_settings->httpProto . "://shortpixel.com/resources-frag");
2890
  if(is_wp_error( $resources )) {
@@ -3111,7 +3122,13 @@ Header append Vary Accept env=REDIRECT_webp
3111
  $file = get_attached_file($id);
3112
  $data = ShortPixelMetaFacade::sanitizeMeta(wp_get_attachment_metadata($id));
3113
 
3114
- //if($extended) {var_dump(wp_get_attachment_url($id)); echo(json_encode(ShortPixelMetaFacade::getWPMLDuplicates($id))); echo('<br>BK: ' . apply_filters('shortpixel_get_backup', get_attached_file($id))); echo(json_encode($data));}
 
 
 
 
 
 
3115
  $fileExtension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
3116
  $invalidKey = !$this->_settings->verifiedKey;
3117
  $quotaExceeded = $this->_settings->quotaExceeded;
@@ -3470,12 +3487,12 @@ Header append Vary Accept env=REDIRECT_webp
3470
  static public function isProcessableSize($width, $height, $excludePattern) {
3471
  $ranges = preg_split("/(x|×)/",$excludePattern);
3472
  $widthBounds = explode("-", $ranges[0]);
 
3473
  $heightBounds = isset($ranges[1]) ? explode("-", $ranges[1]) : false;
3474
- if( $width >= 0 + $widthBounds[0]
3475
- && (!isset($widthBounds[1]) || isset($widthBounds[1]) && $width <= 0 + $widthBounds[1])
3476
  && ( $heightBounds === false
3477
- || ($height >= 0 + $heightBounds[0]
3478
- && (!isset($heightBounds[1]) || isset($heightBounds[1]) && $height <= 0 + $heightBounds[1])))) {
3479
  return false;
3480
  }
3481
  return true;
2335
  if(file_exists(SHORTPIXEL_BACKUP_FOLDER)) {
2336
 
2337
  //extract all images from DB in an array. of course
2338
+ // Simon: WHY?!!! commenting for now...
2339
+ /*
2340
  $attachments = null;
2341
  $attachments = get_posts( array(
2342
  'numberposts' => -1,
2343
  'post_type' => 'attachment',
2344
  'post_mime_type' => 'image'
2345
  ));
2346
+ */
2347
 
2348
  //delete the actual files on disk
2349
  $this->deleteDir(SHORTPIXEL_BACKUP_FOLDER);//call a recursive function to empty files and sub-dirs in backup dir
2572
  insert_with_markers( get_home_path() . '.htaccess', 'ShortPixelWebp', '
2573
  <IfModule mod_rewrite.c>
2574
  RewriteEngine On
2575
+ # Does browser explicitly support webp?
2576
+ RewriteCond %{HTTP_USER_AGENT} Chrome [OR]
2577
+ # OR Is request from Page Speed
2578
+ RewriteCond %{HTTP_USER_AGENT} "Google Page Speed Insights" [OR]
2579
+ # OR does this browser explicitly support webp
2580
+ RewriteCond %{HTTP_ACCEPT} image/webp [OR]
2581
+
2582
+ # AND does a webp image exist?
2583
+ RewriteCond %{DOCUMENT_ROOT}/$1\.webp -f
2584
+
2585
+ # THEN send the webp image and set the env var webp
2586
+ RewriteRule (.+)\.(?:jpe?g|png)$ $1.webp [NC,T=image/webp,E=webp,L]
2587
  </IfModule>
 
2588
  <IfModule mod_headers.c>
2589
+ # If REDIRECT_webp env var exists, append Accept to the Vary header
2590
+ Header append Vary Accept env=REDIRECT_webp
2591
  </IfModule>
2592
 
2593
  <IfModule mod_mime.c>
2895
  }
2896
  $remainingImages = $quotaData['APICallsRemaining'];
2897
  $remainingImages = ( $remainingImages < 0 ) ? 0 : number_format($remainingImages);
2898
+ $totalCallsMade = array( 'plan' => $quotaData['APICallsMadeNumeric'] , 'oneTime' => $quotaData['APICallsMadeOneTimeNumeric'] );
2899
 
2900
  $resources = wp_remote_post($this->_settings->httpProto . "://shortpixel.com/resources-frag");
2901
  if(is_wp_error( $resources )) {
3122
  $file = get_attached_file($id);
3123
  $data = ShortPixelMetaFacade::sanitizeMeta(wp_get_attachment_metadata($id));
3124
 
3125
+ if($extended && isset($_POST['SHORTPIXEL_DEBUG'])) {
3126
+ var_dump(wp_get_attachment_url($id));
3127
+ echo('<br><br>' . json_encode(ShortPixelMetaFacade::getWPMLDuplicates($id)));
3128
+ echo('<br><br>' . json_encode($data));
3129
+ echo('<br><br>');
3130
+ }
3131
+
3132
  $fileExtension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
3133
  $invalidKey = !$this->_settings->verifiedKey;
3134
  $quotaExceeded = $this->_settings->quotaExceeded;
3487
  static public function isProcessableSize($width, $height, $excludePattern) {
3488
  $ranges = preg_split("/(x|×)/",$excludePattern);
3489
  $widthBounds = explode("-", $ranges[0]);
3490
+ if(!isset($widthBounds[1])) $widthBounds[1] = $widthBounds[0];
3491
  $heightBounds = isset($ranges[1]) ? explode("-", $ranges[1]) : false;
3492
+ if(!isset($heightBounds[1])) $heightBounds[1] = $heightBounds[0];
3493
+ if( $width >= 0 + $widthBounds[0] && $width <= 0 + $widthBounds[1]
3494
  && ( $heightBounds === false
3495
+ || ($height >= 0 + $heightBounds[0] && $height <= 0 + $heightBounds[1]))) {
 
3496
  return false;
3497
  }
3498
  return true;
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.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -17,7 +17,7 @@ Speed up your website and boost your SEO by compressing old & new images and PDF
17
  Increase your website's SEO ranking, number of visitors and ultimately your sales by optimizing any image or PDF document on your website.
18
  ShortPixel is an easy to use, lightweight, install-and-forget-about-it <a href="https://shortpixel.com" target="_blank">image optimization</a> plugin that can compress all your past images and PDF documents with a single click. New images are automatically resized/rescaled and optimized on the fly, in the background.
19
 
20
- **Ready for a quick DEMO? Test it <a href="http://poopy.life/create?url=/wp-admin/admin.php?page=sandbox" target="_blank">here</a>.**
21
 
22
  Short Pixel uses minimal resources and works well with any shared, cloud, VPS or dedicated web hosting. It can optimize any image you have on your website even the images that aren't listed in Media Library like those in galleries like <a href="https://wordpress.org/plugins/nextgen-gallery/" target="_blank">NextGEN</a>, <a href="https://wordpress.org/plugins/modula-best-grid-gallery/" target="_blank">Modula</a> or added directly via FTP!
23
 
@@ -241,6 +241,15 @@ The ShortPixel Image Optimiser plugin calls the following actions and filters:
241
 
242
  == Changelog ==
243
 
 
 
 
 
 
 
 
 
 
244
  = 4.12.5 =
245
 
246
  Release date: 10th Ianuary 2019
@@ -399,4 +408,4 @@ Release date: 3rd July 2018
399
  * display the x close link for the bulk warning box.
400
 
401
  = EARLIER VERSIONS =
402
- * please refer to the changelog.txt file inside the plugin archive.
4
  Requires at least: 3.2.0
5
  Tested up to: 5.0
6
  Requires PHP: 5.2
7
+ Stable tag: 4.12.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
17
  Increase your website's SEO ranking, number of visitors and ultimately your sales by optimizing any image or PDF document on your website.
18
  ShortPixel is an easy to use, lightweight, install-and-forget-about-it <a href="https://shortpixel.com" target="_blank">image optimization</a> plugin that can compress all your past images and PDF documents with a single click. New images are automatically resized/rescaled and optimized on the fly, in the background.
19
 
20
+ **Ready for a quick DEMO? Test <a href="https://sandboxwordpress.com/?htmldata=https://shortpixel.com/sp.html&slug=shortpixel-image-optimiser&redirect=plugins.php&title=Test%20SHORTPIXEL%20Now!&ga=UA-55918546-1" target="_blank">here</a> or <a href="http://poopy.life/create?url=/wp-admin/admin.php?page=sandbox" target="_blank">here</a>.**
21
 
22
  Short Pixel uses minimal resources and works well with any shared, cloud, VPS or dedicated web hosting. It can optimize any image you have on your website even the images that aren't listed in Media Library like those in galleries like <a href="https://wordpress.org/plugins/nextgen-gallery/" target="_blank">NextGEN</a>, <a href="https://wordpress.org/plugins/modula-best-grid-gallery/" target="_blank">Modula</a> or added directly via FTP!
23
 
241
 
242
  == Changelog ==
243
 
244
+ = 4.12.6 =
245
+
246
+ Release date: 27th January 2019
247
+
248
+ * Improvements to the .htaccess WebP method
249
+ * Improve performance of backup deletion - get rid of unnecessary checks
250
+ * Fixed: wrong calculation of remaining credits
251
+ * Fixed: discrepancy between the description of the exclude size option and the behaviour for the exact size case.
252
+
253
  = 4.12.5 =
254
 
255
  Release date: 10th Ianuary 2019
408
  * display the x close link for the bulk warning box.
409
 
410
  = EARLIER VERSIONS =
411
+ * please refer to the changelog.txt file inside the plugin archive.
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.5
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.5-RC2");
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.6
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.6");
22
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
23
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
24
  define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');