ShortPixel Image Optimizer - Version 4.8.9

Version Description

  • On some multisites installed in a subdirectory, the get_home_path() doesn't return the subdirectory, fallback to ABSPATH
  • Sometimes images are not PNG even if they have .png extension. Don't try to convert them if imagecreatefrompng returns false.
  • Get an aproximate row count for InnoDB tables to optimize the speed, but fallback to normal count(*) for MyISAM
  • Fix several warnings ($thumbsMissing not an array, $found is not set, etc.)
  • Return error message when folder could not be found, when adding other media folders
  • More info to some API errors
Download this release

Release Info

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

Code changes from version 4.8.8 to 4.8.9

class/db/shortpixel-custom-meta-dao.php CHANGED
@@ -190,6 +190,9 @@ class ShortPixelCustomMetaDao {
190
  public function newFolderFromPath($path, $uploadPath, $rootPath) {
191
  WpShortPixelDb::checkCustomTables(); // check if custom tables are created, if not, create them
192
  $addedFolder = ShortPixelFolder::checkFolder($path, $uploadPath);
 
 
 
193
  $addedFolderReal = realpath($addedFolder);
194
  $addedFolder = wp_normalize_path($addedFolder); $addedFolderReal = wp_normalize_path($addedFolderReal); $rootPath = wp_normalize_path($rootPath);
195
  if(strpos($addedFolder, $rootPath) !== 0) {
190
  public function newFolderFromPath($path, $uploadPath, $rootPath) {
191
  WpShortPixelDb::checkCustomTables(); // check if custom tables are created, if not, create them
192
  $addedFolder = ShortPixelFolder::checkFolder($path, $uploadPath);
193
+ if(!$addedFolder) {
194
+ return __('Folder could not be found: ' . $uploadPath . $path ,'shortpixel-image-optimiser');
195
+ }
196
  $addedFolderReal = realpath($addedFolder);
197
  $addedFolder = wp_normalize_path($addedFolder); $addedFolderReal = wp_normalize_path($addedFolderReal); $rootPath = wp_normalize_path($rootPath);
198
  if(strpos($addedFolder, $rootPath) !== 0) {
class/db/shortpixel-meta-facade.php CHANGED
@@ -148,7 +148,7 @@ class ShortPixelMetaFacade {
148
  }
149
 
150
  $thumbsMissing = $this->meta->getThumbsMissing();
151
- if(count($thumbsMissing)) {
152
  $rawMeta['ShortPixel']['thumbsMissing'] = $this->meta->getThumbsMissing();
153
  } else {
154
  unset($rawMeta['ShortPixel']['thumbsMissing']);
148
  }
149
 
150
  $thumbsMissing = $this->meta->getThumbsMissing();
151
+ if(is_array($thumbsMissing) && count($thumbsMissing)) {
152
  $rawMeta['ShortPixel']['thumbsMissing'] = $this->meta->getThumbsMissing();
153
  } else {
154
  unset($rawMeta['ShortPixel']['thumbsMissing']);
class/db/wp-shortpixel-media-library-adapter.php CHANGED
@@ -276,10 +276,16 @@ class WpShortPixelMediaLbraryAdapter {
276
 
277
  protected static function getOptimalChunkSize() {
278
  global $wpdb;
279
- $cnt = $wpdb->get_results("SELECT count(*) posts FROM " . $wpdb->prefix . "posts");
 
 
 
 
 
 
280
  $posts = isset($cnt) && count($cnt) > 0 ? $cnt[0]->posts : 0;
281
  if($posts > 100000) {
282
- return 20000;
283
  } elseif ($posts > 50000) {
284
  return 5000;
285
  } elseif($posts > 10000) {
276
 
277
  protected static function getOptimalChunkSize() {
278
  global $wpdb;
279
+ //get an aproximate but fast row count.
280
+ $row = $wpdb->get_results("EXPLAIN SELECT count(*) from " . $wpdb->prefix . "posts");
281
+ if(isset($row['rows'])) {
282
+ $cnt = $row['rows'];
283
+ } else {
284
+ $cnt = $wpdb->get_results("SELECT count(*) posts FROM " . $wpdb->prefix . "posts");
285
+ }
286
  $posts = isset($cnt) && count($cnt) > 0 ? $cnt[0]->posts : 0;
287
  if($posts > 100000) {
288
+ return 10000;
289
  } elseif ($posts > 50000) {
290
  return 5000;
291
  } elseif($posts > 10000) {
class/shortpixel-png2jpg.php CHANGED
@@ -23,16 +23,20 @@ class ShortPixelPng2Jpg {
23
  }
24
  $transparent_pixel = $img = $bg = false;
25
  if (!$transparent) {
26
- $img = imagecreatefrompng($image);
27
- $w = imagesx($img); // Get the width of the image
28
- $h = imagesy($img); // Get the height of the image
29
- //run through pixels until transparent pixel is found:
30
- for ($i = 0; $i < $w; $i++) {
31
- for ($j = 0; $j < $h; $j++) {
32
- $rgba = imagecolorat($img, $i, $j);
33
- if (($rgba & 0x7F000000) >> 24) {
34
- $transparent_pixel = true;
35
- break;
 
 
 
 
36
  }
37
  }
38
  }
@@ -152,7 +156,7 @@ class ShortPixelPng2Jpg {
152
  */
153
  public function checkConvertMediaPng2Jpg($meta, $ID) {
154
 
155
- if(!$this->_settings->png2jpg || strtolower(substr($meta['file'], -4)) !== '.png') {
156
  return $meta;
157
  }
158
 
23
  }
24
  $transparent_pixel = $img = $bg = false;
25
  if (!$transparent) {
26
+ $img = @imagecreatefrompng($image);
27
+ if(!$img) {
28
+ $transparent = true; //it's not a PNG, can't convert it
29
+ } else {
30
+ $w = imagesx($img); // Get the width of the image
31
+ $h = imagesy($img); // Get the height of the image
32
+ //run through pixels until transparent pixel is found:
33
+ for ($i = 0; $i < $w; $i++) {
34
+ for ($j = 0; $j < $h; $j++) {
35
+ $rgba = imagecolorat($img, $i, $j);
36
+ if (($rgba & 0x7F000000) >> 24) {
37
+ $transparent_pixel = true;
38
+ break;
39
+ }
40
  }
41
  }
42
  }
156
  */
157
  public function checkConvertMediaPng2Jpg($meta, $ID) {
158
 
159
+ if(!$this->_settings->png2jpg || !isset($meta['file']) || strtolower(substr($meta['file'], -4)) !== '.png') {
160
  return $meta;
161
  }
162
 
class/shortpixel_queue.php CHANGED
@@ -188,6 +188,7 @@ class ShortPixelQueue {
188
  $items = self::parseQ($items);
189
  $items = is_array($items) ? $items : array();
190
  $newItems = array();
 
191
  foreach($items as $item) { // this instead of array_values(array_diff(.. because we need to know if we actually removed it
192
  if($item != $ID) {
193
  $newItems[] = $item;
188
  $items = self::parseQ($items);
189
  $items = is_array($items) ? $items : array();
190
  $newItems = array();
191
+ $found = false;
192
  foreach($items as $item) { // this instead of array_values(array_diff(.. because we need to know if we actually removed it
193
  if($item != $ID) {
194
  $newItems[] = $item;
class/view/shortpixel_view.php CHANGED
@@ -53,7 +53,7 @@ class ShortPixelView {
53
  title='<?php _e('Go to my account and select a plan','shortpixel-image-optimiser');?>' target='_blank' style="margin-right:10px;">
54
  <strong><?php _e('Upgrade','shortpixel-image-optimiser');?></strong>
55
  </a>
56
- <input type='button' name='checkQuota' class='button' value='<?php _e('Confirm New Quota','shortpixel-image-optimiser');?>'
57
  onclick="ShortPixel.recheckQuota()">
58
  </div>
59
  <p><?php _e('Get more image credits by referring ShortPixel to your friends!','shortpixel-image-optimiser');?>
@@ -148,7 +148,7 @@ class ShortPixelView {
148
  printf(__("You are adding an average of <strong>%d images and thumbnails every month</strong> to your Media Library and you have <strong>a plan of %d images/month</strong>."
149
  . " You might need to upgrade you plan in order to have all your images optimized.", 'shortpixel_image_optimiser'), $extra['monthAvg'], $extra['monthlyQuota']);
150
  } else {
151
- printf(__("You currently have <strong>%d images and thumbnails to optimize</strong> but you only you have <strong>%d images</strong> available in your current plan."
152
  . " You might need to upgrade you plan in order to have all your images optimized.", 'shortpixel_image_optimiser'), $extra['filesTodo'], $extra['quotaAvailable']);
153
  }?></p><?php
154
  self::includeProposeUpgradePopup();
@@ -187,6 +187,7 @@ class ShortPixelView {
187
 
188
  public function displayBulkProcessingForm($quotaData, $thumbsProcessedCount, $under5PercentCount, $bulkRan,
189
  $averageCompression, $filesOptimized, $savedSpace, $percent, $customCount) {
 
190
  ?>
191
  <div class="wrap short-pixel-bulk-page">
192
  <h1>Bulk Image Optimization by ShortPixel</h1>
@@ -227,7 +228,9 @@ class ShortPixelView {
227
  <?php if(max(0, $quotaData['totalMlFiles'] - $quotaData['totalProcessedMlFiles']) + $customCount > 0) { ?>
228
  <div class="bulk-play">
229
  <input type='hidden' name='bulkProcess' id='bulkProcess' value='Start Optimizing'/>
230
- <a href='javascript:void(0);' onclick="document.getElementById('startBulk').submit();" class='button'>
 
 
231
  <div style="width: 320px">
232
  <div class="bulk-btn-img" class="bulk-btn-img">
233
  <img src='<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/robo-slider.png' ));?>'
@@ -490,7 +493,8 @@ class ShortPixelView {
490
  <form action='' method='POST' >
491
  <input type='checkbox' id='bulk-thumbnails' name='thumbnails' <?php echo($this->ctrl->processThumbnails() ? "checked":"");?>
492
  onchange="ShortPixel.onBulkThumbsCheck(this)"> <?php _e('Include thumbnails','shortpixel-image-optimiser');?><br><br>
493
- <input type='submit' name='bulkProcess' id='bulkProcess' class='button button-primary' value='<?php _e('Restart Optimizing','shortpixel-image-optimiser');?>'>
 
494
  <input type='submit' name='bulkRestore' id='bulkRestore' class='button' value='<?php _e('Bulk Restore Media Library','shortpixel-image-optimiser');?>' onclick="ShortPixel.confirmBulkAction('Restore',event)" style="float: right;">
495
  <input type='submit' name='bulkCleanup' id='bulkCleanup' class='button' value='<?php _e('Bulk Delete Metadata','shortpixel-image-optimiser');?>' onclick="ShortPixel.confirmBulkAction('Cleanup',event)" style="float: right;margin-right:10px;">
496
  <input type='submit' name='bulkCleanupPending' id='bulkCleanupPending' class='button' value='<?php _e('Bulk Delete Pending Metadata','shortpixel-image-optimiser');?>' onclick="ShortPixel.confirmBulkAction('CleanupPending', event)" style="display:none">
@@ -589,10 +593,10 @@ class ShortPixelView {
589
  <?php } ?>
590
  <div class="bulk-progress-indicator">
591
  <div style="margin-bottom:5px"><?php _e('Average reduction','shortpixel-image-optimiser');?></div>
592
- <div id="sp-avg-optimization"><input type="text" id="sp-avg-optimization-dial" value="<?php echo("" . round($averageCompression))?>" class="dial"></div>
593
  <script>
594
  jQuery(function() {
595
- ShortPixel.percentDial("#sp-avg-optimization-dial", 60);
596
  });
597
  </script>
598
  </div>
53
  title='<?php _e('Go to my account and select a plan','shortpixel-image-optimiser');?>' target='_blank' style="margin-right:10px;">
54
  <strong><?php _e('Upgrade','shortpixel-image-optimiser');?></strong>
55
  </a>
56
+ <input type='button' name='checkQuota' class='button' value='<?php _e('Confirm New Credits','shortpixel-image-optimiser');?>'
57
  onclick="ShortPixel.recheckQuota()">
58
  </div>
59
  <p><?php _e('Get more image credits by referring ShortPixel to your friends!','shortpixel-image-optimiser');?>
148
  printf(__("You are adding an average of <strong>%d images and thumbnails every month</strong> to your Media Library and you have <strong>a plan of %d images/month</strong>."
149
  . " You might need to upgrade you plan in order to have all your images optimized.", 'shortpixel_image_optimiser'), $extra['monthAvg'], $extra['monthlyQuota']);
150
  } else {
151
+ printf(__("You currently have <strong>%d images and thumbnails to optimize</strong> but you only have <strong>%d images</strong> available in your current plan."
152
  . " You might need to upgrade you plan in order to have all your images optimized.", 'shortpixel_image_optimiser'), $extra['filesTodo'], $extra['quotaAvailable']);
153
  }?></p><?php
154
  self::includeProposeUpgradePopup();
187
 
188
  public function displayBulkProcessingForm($quotaData, $thumbsProcessedCount, $under5PercentCount, $bulkRan,
189
  $averageCompression, $filesOptimized, $savedSpace, $percent, $customCount) {
190
+ $settings = $this->ctrl->getSettings();
191
  ?>
192
  <div class="wrap short-pixel-bulk-page">
193
  <h1>Bulk Image Optimization by ShortPixel</h1>
228
  <?php if(max(0, $quotaData['totalMlFiles'] - $quotaData['totalProcessedMlFiles']) + $customCount > 0) { ?>
229
  <div class="bulk-play">
230
  <input type='hidden' name='bulkProcess' id='bulkProcess' value='Start Optimizing'/>
231
+ <a href='javascript:void(0);' <?php echo($settings->quotaExceeded
232
+ ? "disabled title=\"" . __("Top-up your account to optimize more images.",'shortpixel-image-optimiser')."\""
233
+ : "onclick=\"document.getElementById('startBulk').submit();\""); ?> class='button'>
234
  <div style="width: 320px">
235
  <div class="bulk-btn-img" class="bulk-btn-img">
236
  <img src='<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/robo-slider.png' ));?>'
493
  <form action='' method='POST' >
494
  <input type='checkbox' id='bulk-thumbnails' name='thumbnails' <?php echo($this->ctrl->processThumbnails() ? "checked":"");?>
495
  onchange="ShortPixel.onBulkThumbsCheck(this)"> <?php _e('Include thumbnails','shortpixel-image-optimiser');?><br><br>
496
+ <input type='submit' name='bulkProcess' id='bulkProcess' class='button button-primary' value='<?php _e('Restart Optimizing','shortpixel-image-optimiser');?>'
497
+ <?php echo($settings->quotaExceeded? "disabled title=\"" . __("Top-up your account to optimize more images.",'shortpixel-image-optimiser')."\"" : ""); ?>>
498
  <input type='submit' name='bulkRestore' id='bulkRestore' class='button' value='<?php _e('Bulk Restore Media Library','shortpixel-image-optimiser');?>' onclick="ShortPixel.confirmBulkAction('Restore',event)" style="float: right;">
499
  <input type='submit' name='bulkCleanup' id='bulkCleanup' class='button' value='<?php _e('Bulk Delete Metadata','shortpixel-image-optimiser');?>' onclick="ShortPixel.confirmBulkAction('Cleanup',event)" style="float: right;margin-right:10px;">
500
  <input type='submit' name='bulkCleanupPending' id='bulkCleanupPending' class='button' value='<?php _e('Bulk Delete Pending Metadata','shortpixel-image-optimiser');?>' onclick="ShortPixel.confirmBulkAction('CleanupPending', event)" style="display:none">
593
  <?php } ?>
594
  <div class="bulk-progress-indicator">
595
  <div style="margin-bottom:5px"><?php _e('Average reduction','shortpixel-image-optimiser');?></div>
596
+ <div id="sp-avg-optimization"><input type="text" id="sp-avg-optimization-dial-bulk" value="<?php echo("" . round($averageCompression))?>" class="dial"></div>
597
  <script>
598
  jQuery(function() {
599
+ ShortPixel.percentDial("#sp-avg-optimization-dial-bulk", 60);
600
  });
601
  </script>
602
  </div>
class/wp-short-pixel.php CHANGED
@@ -184,7 +184,7 @@ class WPShortPixel {
184
  'Zara 4 Image Compression' => 'zara-4/zara-4.php',
185
  'Prizm Image' => 'prizm-image/wp-prizmimage.php',
186
  'CW Image Optimizer' => 'cw-image-optimizer/cw-image-optimizer.php',
187
- 'Regenerate Thumbnails can cause thumbnails reoptimization' => 'regenerate-thumbnails/regenerate-thumbnails.php'
188
  );
189
  $found = array();
190
  foreach($conflictPlugins as $name => $path) {
@@ -232,7 +232,7 @@ class WPShortPixel {
232
  if(!is_array($currentStats) || isset($_GET['checkquota']) || isset($currentStats["quotaData"])) {
233
  $this->getQuotaInformation();
234
  }
235
- if($this->_settings->verifiedKey
236
  && (!isset($dismissed['upgmonth']) || !isset($dismissed['upgbulk'])) && isset($this->_settings->currentStats['optimizePdfs'])
237
  && $this->_settings->currentStats['optimizePdfs'] == $this->_settings->optimizePdfs ) {
238
  $screen = get_current_screen();
@@ -243,7 +243,7 @@ class WPShortPixel {
243
  if( !isset($dismissed['upgbulk']) && $screen && $screen->id == 'media_page_wp-short-pixel-bulk' && $this->bulkUpgradeNeeded($stats)) {
244
  //looks like the user hasn't got enough credits to bulk process all media library
245
  ShortPixelView::displayActivationNotice('upgbulk', array('filesTodo' => $stats['totalFiles'] - $stats['totalProcessedFiles'],
246
- 'quotaAvailable' => $quotaData['APICallsQuotaNumeric'] + $quotaData['APICallsQuotaOneTimeNumeric'] - $quotaData['APICallsMadeNumeric'] - $quotaData['APICallsMadeOneTimeNumeric']));
247
  }
248
  //consider the monthly plus 1/6 of the available one-time credits.
249
  elseif(!isset($dismissed['upgmonth']) && $this->monthlyUpgradeNeeded($stats)) {
@@ -1304,15 +1304,15 @@ class WPShortPixel {
1304
  }
1305
 
1306
  public function getBackupFolderAny($file, $thumbs) {
1307
- if(!file_exists($file)) {
1308
- //try with the thumbnails
1309
- if(isset($thumbs)) foreach($thumbs as $size) {
1310
- $backup = $this->getBackupFolder(trailingslashit(dirname($file)) . $size['file']);
1311
- if($backup) return $backup;
1312
- }
1313
- } else {
1314
- return $this->getBackupFolder($file);
1315
- }
1316
  }
1317
 
1318
  protected function setFilePerms($file) {
@@ -1625,9 +1625,12 @@ class WPShortPixel {
1625
  $customImageCount = $this->spMetaDao->countAllProcessableFiles();
1626
  foreach($customImageCount as $key => $val) {
1627
  $quotaData[$key] = isset($quotaData[$key])
1628
- ? (is_array($quotaData[$key]) ? array_merge($quotaData[$key], $val) : $quotaData[$key] + $val) //array
1629
- : (is_numeric($quotaData[$key]) ? $quotaData[$key] + $val //numeric
1630
- : $quotaData[$key] . ", " . $val); //string
 
 
 
1631
  }
1632
  }
1633
  $this->_settings->currentStats = $quotaData;
@@ -1731,9 +1734,9 @@ class WPShortPixel {
1731
  }
1732
 
1733
  $quotaData = $this->checkQuotaAndAlert(null, isset($_GET['checkquota']), 0);
1734
- if($this->_settings->quotaExceeded != 0) {
1735
- return;
1736
- }
1737
 
1738
  if(isset($_POST['bulkProcessPause']))
1739
  {//pause an ongoing bulk processing, it might be needed sometimes
@@ -1806,8 +1809,8 @@ class WPShortPixel {
1806
 
1807
  //check the custom bulk
1808
  $pendingMeta = $this->_settings->hasCustomFolders ? $this->spMetaDao->getPendingMetaCount() : 0;
1809
-
1810
- if ( ($filesLeft[0]->FilesLeftToBeProcessed > 0 && $this->prioQ->bulkRunning())
1811
  || (0 + $pendingMeta > 0 && !$this->_settings->customBulkPaused && $this->prioQ->bulkRan())//bulk processing was started
1812
  && (!$this->prioQ->bulkPaused() || $this->_settings->skipToCustom)) //bulk not paused or if paused, user pressed Process Custom button
1813
  {
@@ -2340,7 +2343,11 @@ class WPShortPixel {
2340
  //add the NextGen galleries to custom folders
2341
  $ngGalleries = ShortPixelNextGenAdapter::getGalleries();
2342
  foreach($ngGalleries as $gallery) {
2343
- $folderMsg = $this->spMetaDao->newFolderFromPath($gallery, get_home_path(), self::getCustomFolderBase());
 
 
 
 
2344
  $this->_settings->hasCustomFolders = time();
2345
  }
2346
  $customFolders = $this->spMetaDao->getFolders();
184
  'Zara 4 Image Compression' => 'zara-4/zara-4.php',
185
  'Prizm Image' => 'prizm-image/wp-prizmimage.php',
186
  'CW Image Optimizer' => 'cw-image-optimizer/cw-image-optimizer.php',
187
+ 'Regenerate Thumbnails: recreating image files may require re-optimization of the resulting thumbnails, even if they were previously optimized.' => 'regenerate-thumbnails/regenerate-thumbnails.php'
188
  );
189
  $found = array();
190
  foreach($conflictPlugins as $name => $path) {
232
  if(!is_array($currentStats) || isset($_GET['checkquota']) || isset($currentStats["quotaData"])) {
233
  $this->getQuotaInformation();
234
  }
235
+ if($this->_settings->verifiedKey && !$this->_settings->quotaExceeded
236
  && (!isset($dismissed['upgmonth']) || !isset($dismissed['upgbulk'])) && isset($this->_settings->currentStats['optimizePdfs'])
237
  && $this->_settings->currentStats['optimizePdfs'] == $this->_settings->optimizePdfs ) {
238
  $screen = get_current_screen();
243
  if( !isset($dismissed['upgbulk']) && $screen && $screen->id == 'media_page_wp-short-pixel-bulk' && $this->bulkUpgradeNeeded($stats)) {
244
  //looks like the user hasn't got enough credits to bulk process all media library
245
  ShortPixelView::displayActivationNotice('upgbulk', array('filesTodo' => $stats['totalFiles'] - $stats['totalProcessedFiles'],
246
+ 'quotaAvailable' => max(0, $quotaData['APICallsQuotaNumeric'] + $quotaData['APICallsQuotaOneTimeNumeric'] - $quotaData['APICallsMadeNumeric'] - $quotaData['APICallsMadeOneTimeNumeric'])));
247
  }
248
  //consider the monthly plus 1/6 of the available one-time credits.
249
  elseif(!isset($dismissed['upgmonth']) && $this->monthlyUpgradeNeeded($stats)) {
1304
  }
1305
 
1306
  public function getBackupFolderAny($file, $thumbs) {
1307
+ $ret = $this->getBackupFolder($file);
1308
+ if(!$ret && !file_exists($file) && isset($thumbs)) {
1309
+ //try with the thumbnails
1310
+ foreach($thumbs as $size) {
1311
+ $backup = $this->getBackupFolder(trailingslashit(dirname($file)) . $size['file']);
1312
+ if($backup) return $backup;
1313
+ }
1314
+ }
1315
+ return $ret;
1316
  }
1317
 
1318
  protected function setFilePerms($file) {
1625
  $customImageCount = $this->spMetaDao->countAllProcessableFiles();
1626
  foreach($customImageCount as $key => $val) {
1627
  $quotaData[$key] = isset($quotaData[$key])
1628
+ ? (is_array($quotaData[$key])
1629
+ ? array_merge($quotaData[$key], $val)
1630
+ : (is_numeric($quotaData[$key])
1631
+ ? $quotaData[$key] + $val
1632
+ : $quotaData[$key] . ", " . $val)) //array
1633
+ : $val; //string
1634
  }
1635
  }
1636
  $this->_settings->currentStats = $quotaData;
1734
  }
1735
 
1736
  $quotaData = $this->checkQuotaAndAlert(null, isset($_GET['checkquota']), 0);
1737
+ //if($this->_settings->quotaExceeded != 0) {
1738
+ //return;
1739
+ //}
1740
 
1741
  if(isset($_POST['bulkProcessPause']))
1742
  {//pause an ongoing bulk processing, it might be needed sometimes
1809
 
1810
  //check the custom bulk
1811
  $pendingMeta = $this->_settings->hasCustomFolders ? $this->spMetaDao->getPendingMetaCount() : 0;
1812
+
1813
+ if ( ($filesLeft[0]->FilesLeftToBeProcessed > 0 && $this->prioQ->bulkRunning())
1814
  || (0 + $pendingMeta > 0 && !$this->_settings->customBulkPaused && $this->prioQ->bulkRan())//bulk processing was started
1815
  && (!$this->prioQ->bulkPaused() || $this->_settings->skipToCustom)) //bulk not paused or if paused, user pressed Process Custom button
1816
  {
2343
  //add the NextGen galleries to custom folders
2344
  $ngGalleries = ShortPixelNextGenAdapter::getGalleries();
2345
  foreach($ngGalleries as $gallery) {
2346
+ $msg = $this->spMetaDao->newFolderFromPath($gallery, get_home_path(), self::getCustomFolderBase());
2347
+ if($msg) { //try again with ABSPATH as maybe WP is in a subdir
2348
+ $msg = $this->spMetaDao->newFolderFromPath($gallery, ABSPATH, self::getCustomFolderBase());
2349
+ }
2350
+ $folderMsg .= $msg;
2351
  $this->_settings->hasCustomFolders = time();
2352
  }
2353
  $customFolders = $this->spMetaDao->getFolders();
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: compress, image, compression, optimize, image optimizer, image optimiser,
4
  Requires at least: 3.2.0
5
  Tested up to: 4.9
6
  Requires PHP: 5.2
7
- Stable tag: 4.8.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -19,7 +19,7 @@ ShortPixel is an easy to use, lightweight, install-and-forget-about-it <a rel="f
19
 
20
  **Ready for a quick DEMO? <a href="https://addendio.com/try-plugin/?slug=shortpixel-image-optimiser" target="_blank">Test here.</a>**
21
 
22
- This plugin 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 NextGEN or added directly via FTP!
23
 
24
  Both lossy and lossless image compression is available for the most common image types (JPG, PNG, GIF and WebP) plus PDF files.
25
  We also offer **glossy** JPEG compression which is a very high quality lossy optimization algorithm. Specially designed for photographers!
@@ -228,6 +228,15 @@ The ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Co
228
 
229
  == Changelog ==
230
 
 
 
 
 
 
 
 
 
 
231
  = 4.8.8 =
232
  * fix for trying to convert .png files that are not png actually
233
  * fix for installs which don't have PHP GD - deactivate the png 2 jpg conversion
4
  Requires at least: 3.2.0
5
  Tested up to: 4.9
6
  Requires PHP: 5.2
7
+ Stable tag: 4.8.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
19
 
20
  **Ready for a quick DEMO? <a href="https://addendio.com/try-plugin/?slug=shortpixel-image-optimiser" target="_blank">Test here.</a>**
21
 
22
+ This plugin 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
 
24
  Both lossy and lossless image compression is available for the most common image types (JPG, PNG, GIF and WebP) plus PDF files.
25
  We also offer **glossy** JPEG compression which is a very high quality lossy optimization algorithm. Specially designed for photographers!
228
 
229
  == Changelog ==
230
 
231
+ = 4.8.9 =
232
+ * On some multisites installed in a subdirectory, the get_home_path() doesn't return the subdirectory, fallback to ABSPATH
233
+ * Sometimes images are not PNG even if they have .png extension. Don't try to convert them if imagecreatefrompng returns false.
234
+ * Get an aproximate row count for InnoDB tables to optimize the speed, but fallback to normal count(*) for MyISAM
235
+ * Fix several warnings ($thumbsMissing not an array, $found is not set, etc.)
236
+ * Return error message when folder could not be found, when adding other media folders
237
+ * More info to some API errors
238
+
239
+
240
  = 4.8.8 =
241
  * fix for trying to convert .png files that are not png actually
242
  * fix for installs which don't have PHP GD - deactivate the png 2 jpg conversion
shortpixel_api.php CHANGED
@@ -193,9 +193,11 @@ class ShortPixelAPI {
193
 
194
  //die(var_dump($response));
195
 
196
- if($response['response']['code'] != 200)//response <> 200 -> there was an error apparently?
197
- return array("Status" => self::STATUS_FAIL, "Message" => __('There was an error and your request was not processed.','shortpixel-image-optimiser'));
198
-
 
 
199
  $APIresponse = $this->parseResponse($response);//get the actual response from API, its an array
200
 
201
  if ( isset($APIresponse[0]) ) //API returned image details
@@ -248,7 +250,8 @@ class ShortPixelAPI {
248
 
249
  if(!isset($APIresponse['Status'])) {
250
  WpShortPixel::log("API Response Status unfound : " . json_encode($APIresponse));
251
- return array("Status" => self::STATUS_FAIL, "Message" => __('Unrecognized API response. Please contact support. (SERVER RESPONSE: ' . $response . ')','shortpixel-image-optimiser'));
 
252
  } else {
253
  switch($APIresponse['Status']->Code)
254
  {
193
 
194
  //die(var_dump($response));
195
 
196
+ if($response['response']['code'] != 200) {//response <> 200 -> there was an error apparently?
197
+ return array("Status" => self::STATUS_FAIL, "Message" => __('There was an error and your request was not processed.', 'shortpixel-image-optimiser')
198
+ . (isset($response['response']['message']) ? ' (' . $response['response']['message'] . ')' : ''), "Code" => $response['response']['code']);
199
+ }
200
+
201
  $APIresponse = $this->parseResponse($response);//get the actual response from API, its an array
202
 
203
  if ( isset($APIresponse[0]) ) //API returned image details
250
 
251
  if(!isset($APIresponse['Status'])) {
252
  WpShortPixel::log("API Response Status unfound : " . json_encode($APIresponse));
253
+ return array("Status" => self::STATUS_FAIL, "Message" => __('Unrecognized API response. Please contact support.','shortpixel-image-optimiser'),
254
+ "Code" => self::ERR_UNKNOWN, "Debug" => ' (SERVER RESPONSE: ' . json_encode($response) . ')');
255
  } else {
256
  switch($APIresponse['Status']->Code)
257
  {
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.8.8
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.8.8");
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.8.9
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.8.9");
22
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
23
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
24
  define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');