ShortPixel Image Optimizer - Version 3.0.6

Version Description

  • Optimized bulk processor behaviour when navigating from one admin page to another.
  • Improved some explanatory texts.
Download this release

Release Info

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

Code changes from version 3.0.5 to 3.0.6

css/short-pixel.css CHANGED
@@ -42,6 +42,10 @@ li.shortpixel-hide {
42
  .bulk-progress.bulk-stats > div.label{
43
  width: 320px;
44
  }
 
 
 
 
45
  .progress {
46
  background-color: #ecedee;
47
  height: 30px;
@@ -82,7 +86,7 @@ li.shortpixel-hide {
82
  vertical-align: top;
83
  display: inline-block;
84
  }
85
- .wp-core-ui .button-secondary.bulk-cancel {
86
  float: right;
87
  height: 30px;
88
  }
42
  .bulk-progress.bulk-stats > div.label{
43
  width: 320px;
44
  }
45
+ .bulk-progress.bulk-stats > div.stat-value{
46
+ width: 80px;
47
+ text-align: right;
48
+ }
49
  .progress {
50
  background-color: #ecedee;
51
  height: 30px;
86
  vertical-align: top;
87
  display: inline-block;
88
  }
89
+ .wp-core-ui .button-primary.bulk-cancel {
90
  float: right;
91
  height: 30px;
92
  }
js/short-pixel.js CHANGED
@@ -8,11 +8,18 @@ jQuery(document).ready(function($){
8
  //register a bulk action
9
  jQuery('select[name^="action"] option:last-child').before('<option value="short-pixel-bulk">Optimize with ShortPixel</option>');
10
  }
 
 
 
 
 
 
11
  //check if bulk processing
12
  checkQuotaExceededAlert();
13
  checkBulkProgress();
14
  });
15
 
 
16
  var ShortPixel = function() {
17
 
18
  function setOptions(options) {
@@ -163,6 +170,7 @@ function setCellMessage(id, message){
163
  function manualOptimization(id) {
164
  setCellMessage(id, "<img src='" + ShortPixel.WP_PLUGIN_URL + "/shortpixel-image-optimiser/img/loading.gif'>Image waiting to be processed");
165
  jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");
 
166
  var data = { action : 'shortpixel_manual_optimization',
167
  image_id: id};
168
  jQuery.get(ajaxurl, data, function(response) {
@@ -231,10 +239,10 @@ function sliderUpdate(id, thumb, bkThumb, percent){
231
  oldSlide.css("z-index", 1000);
232
  jQuery(".bulk-img-opt", newSlide).attr("src", thumb);
233
  if(bkThumb.length > 0) {
234
- jQuery(".img-original", newSlide).show();
235
  jQuery(".bulk-img-orig", newSlide).attr("src", bkThumb);
236
  } else {
237
- jQuery(".img-original", newSlide).hide();
238
  }
239
  jQuery(".bulk-opt-percent", newSlide).text(percent + "%");
240
 
8
  //register a bulk action
9
  jQuery('select[name^="action"] option:last-child').before('<option value="short-pixel-bulk">Optimize with ShortPixel</option>');
10
  }
11
+ //
12
+ jQuery(window).unload(function(){
13
+ if(ShortPixel.bulkProcessor == true) {
14
+ clearBulkProcessor();
15
+ }
16
+ });
17
  //check if bulk processing
18
  checkQuotaExceededAlert();
19
  checkBulkProgress();
20
  });
21
 
22
+
23
  var ShortPixel = function() {
24
 
25
  function setOptions(options) {
170
  function manualOptimization(id) {
171
  setCellMessage(id, "<img src='" + ShortPixel.WP_PLUGIN_URL + "/shortpixel-image-optimiser/img/loading.gif'>Image waiting to be processed");
172
  jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");
173
+ jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");
174
  var data = { action : 'shortpixel_manual_optimization',
175
  image_id: id};
176
  jQuery.get(ajaxurl, data, function(response) {
239
  oldSlide.css("z-index", 1000);
240
  jQuery(".bulk-img-opt", newSlide).attr("src", thumb);
241
  if(bkThumb.length > 0) {
242
+ jQuery(".img-original", newSlide).css("display", "inline-block");
243
  jQuery(".bulk-img-orig", newSlide).attr("src", bkThumb);
244
  } else {
245
+ jQuery(".img-original", newSlide).css("display", "none");
246
  }
247
  jQuery(".bulk-opt-percent", newSlide).text(percent + "%");
248
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: picture, optimization, image editor, pngout, upload speed, shortpixel, co
5
 
6
  Requires at least: 3.0.1
7
  Tested up to: 4.2
8
- Stable tag: 3.0.5
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -119,6 +119,11 @@ The ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Co
119
 
120
  == Changelog ==
121
 
 
 
 
 
 
122
  = 3.0.5 =
123
 
124
  * different bug fixes
5
 
6
  Requires at least: 3.0.1
7
  Tested up to: 4.2
8
+ Stable tag: 3.0.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
119
 
120
  == Changelog ==
121
 
122
+ = 3.0.6 =
123
+
124
+ * Optimized bulk processor behaviour when navigating from one admin page to another.
125
+ * Improved some explanatory texts.
126
+
127
  = 3.0.5 =
128
 
129
  * different bug fixes
shortpixel_api.php CHANGED
@@ -170,9 +170,9 @@ class ShortPixelAPI {
170
  if ( !file_exists($PATHs[0]) )
171
  return array("Status" => self::STATUS_NOT_FOUND, "Message" => "File not found on disk.");
172
  elseif ( isset($APIresponse[0]->Status->Message) )
173
- return array("Status" => self::STATUS_FAIL, "Message" => "There was an error and your request was not processed.");
174
 
175
- return "Unknown error";
176
  break;
177
  }
178
  }
@@ -229,8 +229,8 @@ class ShortPixelAPI {
229
  }
230
  //check response so that download is OK
231
  elseif( filesize($tempFiles[$counter]) != $correctFileSize) {
232
- @unlink($tempFiles[$counter]);
233
  $size = filesize($tempFiles[$counter]);
 
234
  $returnMessage = array("Status" => self::STATUS_ERROR, "Message" => "Error downloading file - incorrect file size (downloaded: {$size}, correct: {$correctFileSize} )");
235
  }
236
  elseif (!file_exists($tempFiles[$counter])) {
170
  if ( !file_exists($PATHs[0]) )
171
  return array("Status" => self::STATUS_NOT_FOUND, "Message" => "File not found on disk.");
172
  elseif ( isset($APIresponse[0]->Status->Message) )
173
+ return array("Status" => self::STATUS_FAIL, "Message" => "There was an error and your request was not processed (" . $APIresponse[0]->Status->Message . ").");
174
 
175
+ return array("Status" => self::STATUS_FAIL, "Message" => "There was an error and your request was not processed");
176
  break;
177
  }
178
  }
229
  }
230
  //check response so that download is OK
231
  elseif( filesize($tempFiles[$counter]) != $correctFileSize) {
 
232
  $size = filesize($tempFiles[$counter]);
233
+ @unlink($tempFiles[$counter]);
234
  $returnMessage = array("Status" => self::STATUS_ERROR, "Message" => "Error downloading file - incorrect file size (downloaded: {$size}, correct: {$correctFileSize} )");
235
  }
236
  elseif (!file_exists($tempFiles[$counter])) {
shortpixel_queue.php CHANGED
@@ -246,7 +246,7 @@ class ShortPixelQueue {
246
  WPShortPixel::log("QUEUE - BulkPrevPercent: " . $this->bulkPreviousPercent . " BulkCurrentlyProcessing: "
247
  . $this->bulkCurrentlyProcessed . " out of " . $this->getBulkToProcess());
248
 
249
- if($this->getBulkToProcess() <= 0) return 100;
250
  // return maximum 99%
251
  $percent = $this->bulkPreviousPercent + round($this->bulkCurrentlyProcessed / $this->getBulkToProcess()
252
  * (100 - $this->bulkPreviousPercent));
246
  WPShortPixel::log("QUEUE - BulkPrevPercent: " . $this->bulkPreviousPercent . " BulkCurrentlyProcessing: "
247
  . $this->bulkCurrentlyProcessed . " out of " . $this->getBulkToProcess());
248
 
249
+ if($this->getBulkToProcess() <= 0) return ($this->processing () ? 99: 100);
250
  // return maximum 99%
251
  $percent = $this->bulkPreviousPercent + round($this->bulkCurrentlyProcessed / $this->getBulkToProcess()
252
  * (100 - $this->bulkPreviousPercent));
shortpixel_view.php CHANGED
@@ -16,17 +16,12 @@ class ShortPixelView {
16
  public function displayQuotaExceededAlert($quotaData)
17
  { ?>
18
  <br/>
19
- <div style="background-color: #fff; border-left: 4px solid #ff0000; box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1); padding: 1px 12px;">
20
  <h3>Quota Exceeded</h3>
21
- <p>
22
- The plugin has optimized <?=number_format($quotaData['APICallsMadeNumeric'] + $quotaData['APICallsMadeOneTimeNumeric'])?> images and stopped because it reached the available quota limit.
23
- </p>
24
- <p>
25
- It’s simple to upgrade, just click here to <a href='https://shortpixel.com/login/<?=$this->ctrl->getApiKey()?>' target='_blank'>log into your account</a> and see the options in the billing page.
26
- </p>
27
- <p>
28
- You can immediately start processing 5,000 images/month for &#36;4,99, choose another plan that suits you or <a href='https://shortpixel.com/contact' target='_blank'>contact us</a> for larger compression needs.
29
- </p>
30
  </div> <?php
31
  }
32
 
@@ -60,21 +55,20 @@ class ShortPixelView {
60
  <?php
61
  } elseif($percent) // bulk is paused
62
  { ?>
63
- <p>Bulk processing is paused. You can continue optimizing your Media Gallery from where you left, by clicking the button below. Already optimized images will not be reprocessed.</p>
64
  <?=$this->displayBulkProgressBar(false, $percent, "")?>
65
  <p>Please see below the optimization status so far:</p>
66
  <?=$this->displayBulkStats($filesOptimized, $thumbsProcessedCount, $under5PercentCount, $averageCompression, $savedSpace)?>
 
67
  <?php
68
  } else { ?>
69
  <p>Congratulations, your media library has been successfully optimized!</p>
70
- <p>Go to the ShortPixel <a href='" . get_admin_url() . "options-general.php?page=wp-shortpixel#facts'>Stats</a> and see all your websites' optimized stats.
71
-
72
  <?=$this->displayBulkStats($filesOptimized, $thumbsProcessedCount, $under5PercentCount, $averageCompression, $savedSpace)?>
73
- <p>Download your detailed <a href="https://api.shortpixel.com/v2/report.php?key=<?=$this->ctrl->getApiKey()?>">Optimization Report</a> to check your image optimization statistics for the last 40 days</p>
74
- <?php if(false && $imgProcessedCount['totalFiles'] < $imageCount['totalFiles']) { ?>
75
- <p>However, <?=number_format($imageCount['mainFiles'] - $imgProcessedCount['mainFiles'])?> images and <?=number_format(($imageCount['totalFiles'] - $imageCount['mainFiles']) - ($imgProcessedCount['totalFiles'] - $imgProcessedCount['mainFiles']))?> thumbnails are not yet optimized by ShorPixel.</p>
76
  <?php } ?>
77
- <p>Restart the optimization process for new images added to your library:
78
  <form action='' method='POST' >
79
  <input type='checkbox' name='thumbnails' <?=$this->ctrl->processThumbnails() ? "checked":""?>> Include thumbnails<br><br>
80
  <input type='submit' name='bulkProcess' id='bulkProcess' class='button button-primary' value='Restart Optimizing'>
@@ -88,7 +82,9 @@ class ShortPixelView {
88
  ?>
89
  <div class="wrap short-pixel-bulk-page">
90
  <h1>Bulk Image Optimization by ShortPixel</h1>
91
- <p>Bulk optimization has started. This process will take some time, depending on the number of images in your library. In the meantime, you can continue using the admin as usual. However, if you close the WordPress admin, the bulk processing will pause until you open it again. </p>
 
 
92
  <?=$this->displayBulkProgressBar(true, $percent, $message)?>
93
  <div class="bulk-progress bulk-slider-container">
94
  <div style="margin-bottom: 10px;"><span class="short-pixel-block-title">Just optimized:</span></div>
@@ -133,7 +129,7 @@ class ShortPixelView {
133
  &nbsp;<?=$message?>
134
  </div>
135
  <form action='' method='POST' style="display:inline;">
136
- <input type="submit" class="button button-secondary bulk-cancel" onclick="clearBulkProcessor();"
137
  name="<?=$running ? "bulkProcessPause" : "bulkProcessResume"?>" value="<?=$running ? "Pause" : "Resume Processing"?>"/>
138
  </form>
139
  </div>
@@ -143,13 +139,14 @@ class ShortPixelView {
143
  public function displayBulkStats($filesOptimized, $thumbsProcessedCount, $under5PercentCount, $averageCompression, $savedSpace) {
144
  ?>
145
  <div class="bulk-progress bulk-stats">
146
- <div class="label">Images/PDFs processed with ShortPixel:</div><div><?=number_format($filesOptimized - $thumbsProcessedCount)?></div><br>
147
- <div class="label">Thumbnails processed with ShortPixel:</div><div><?=number_format($thumbsProcessedCount)?></div><br>
148
- <div class="label totals">Total:</div><div><?=number_format($filesOptimized)?></div><br>
149
- <div class="label totals">Images & thumbs with less than 5% optimization (free):</div><div>-<?=number_format($under5PercentCount)?></div><br>
150
- <div class="label totals">Used quota:</div><div><?=number_format($filesOptimized - $under5PercentCount)?></div><br>
151
- <div class="label">Average optimization:</div><div><?=$averageCompression?>%</div><br>
152
- <div class="label">Saved space:</div><div><?=$savedSpace?></div>
 
153
  </div>
154
  <?php
155
  }
16
  public function displayQuotaExceededAlert($quotaData)
17
  { ?>
18
  <br/>
19
+ <div class="wrap" style="background-color: #fff; border-left: 4px solid #ff0000; box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1); padding: 1px 12px;">
20
  <h3>Quota Exceeded</h3>
21
+ <p>The plugin has optimized <?=number_format($quotaData['APICallsMadeNumeric'] + $quotaData['APICallsMadeOneTimeNumeric'])?> images and stopped because it reached the available quota limit.</p>
22
+ <p>It’s simple to upgrade, just <a href='https://shortpixel.com/login/<?=$this->ctrl->getApiKey()?>' target='_blank'>log into your account</a> and see the available options.</p>
23
+ <p>You can immediately start processing 5,000 images/month for &#36;4,99, choose another plan that suits you or <a href='https://shortpixel.com/contact' target='_blank'>contact us</a> for larger compression needs.</p>
24
+ <input type='button' name='checkQuota' class='button button-primary' value='Confirm New Quota' onclick="javascript:window.location.reload();" style="margin-bottom:12px;">
 
 
 
 
 
25
  </div> <?php
26
  }
27
 
55
  <?php
56
  } elseif($percent) // bulk is paused
57
  { ?>
58
+ <p>Bulk processing is paused until you resume the optimization process.</p>
59
  <?=$this->displayBulkProgressBar(false, $percent, "")?>
60
  <p>Please see below the optimization status so far:</p>
61
  <?=$this->displayBulkStats($filesOptimized, $thumbsProcessedCount, $under5PercentCount, $averageCompression, $savedSpace)?>
62
+ <p>You can continue optimizing your Media Gallery from where you left, by clicking the Resume processing button. Already optimized images will not be reprocessed.</p>
63
  <?php
64
  } else { ?>
65
  <p>Congratulations, your media library has been successfully optimized!</p>
 
 
66
  <?=$this->displayBulkStats($filesOptimized, $thumbsProcessedCount, $under5PercentCount, $averageCompression, $savedSpace)?>
67
+ <p>Go to the ShortPixel <a href='<?=get_admin_url()?>options-general.php?page=wp-shortpixel#facts'>Stats</a> and see all your websites' optimized stats. Download your detailed <a href="https://api.shortpixel.com/v2/report.php?key=<?=$this->ctrl->getApiKey()?>">Optimization Report</a> to check your image optimization statistics for the last 40 days</p>
68
+ <?php if($imgProcessedCount['totalFiles'] < $imageCount['totalFiles']) { ?>
69
+ <p><?=number_format($imageCount['mainFiles'] - $imgProcessedCount['mainFiles'])?> images and <?=number_format(($imageCount['totalFiles'] - $imageCount['mainFiles']) - ($imgProcessedCount['totalFiles'] - $imgProcessedCount['mainFiles']))?> thumbnails are not yet optimized by ShortPixel.</p>
70
  <?php } ?>
71
+ <p>Restart the optimization process for new images added to your library by clicking the button below. Already optimized images will not be reprocessed.
72
  <form action='' method='POST' >
73
  <input type='checkbox' name='thumbnails' <?=$this->ctrl->processThumbnails() ? "checked":""?>> Include thumbnails<br><br>
74
  <input type='submit' name='bulkProcess' id='bulkProcess' class='button button-primary' value='Restart Optimizing'>
82
  ?>
83
  <div class="wrap short-pixel-bulk-page">
84
  <h1>Bulk Image Optimization by ShortPixel</h1>
85
+ <p>Bulk optimization has started.<br>
86
+ This process will take some time, depending on the number of images in your library. In the meantime, you can continue using the admin as usual.<br>
87
+ However, <strong>if you close the WordPress admin, the bulk processing will pause</strong> until you open the admin again. </p>
88
  <?=$this->displayBulkProgressBar(true, $percent, $message)?>
89
  <div class="bulk-progress bulk-slider-container">
90
  <div style="margin-bottom: 10px;"><span class="short-pixel-block-title">Just optimized:</span></div>
129
  &nbsp;<?=$message?>
130
  </div>
131
  <form action='' method='POST' style="display:inline;">
132
+ <input type="submit" class="button button-primary bulk-cancel" onclick="clearBulkProcessor();"
133
  name="<?=$running ? "bulkProcessPause" : "bulkProcessResume"?>" value="<?=$running ? "Pause" : "Resume Processing"?>"/>
134
  </form>
135
  </div>
139
  public function displayBulkStats($filesOptimized, $thumbsProcessedCount, $under5PercentCount, $averageCompression, $savedSpace) {
140
  ?>
141
  <div class="bulk-progress bulk-stats">
142
+ <div class="label">Processed Images and PDFs:</div><div class="stat-value"><?=number_format($filesOptimized - $thumbsProcessedCount)?></div><br>
143
+ <div class="label">Processed Thumbnails:</div><div class="stat-value"><?=number_format($thumbsProcessedCount)?></div><br>
144
+ <div class="label totals">Total files processed:</div><div class="stat-value"><?=number_format($filesOptimized)?></div><br>
145
+ <div class="label totals">Files with <5% optimization (free):</div><div class="stat-value">-<?=number_format($under5PercentCount)?></div><br><br>
146
+ <div class="label totals">Used quota:</div><div class="stat-value"><?=number_format($filesOptimized - $under5PercentCount)?></div><br>
147
+ <br>
148
+ <div class="label">Average optimization:</div><div class="stat-value"><?=$averageCompression?>%</div><br>
149
+ <div class="label">Saved space:</div><div class="stat-value"><?=$savedSpace?></div>
150
  </div>
151
  <?php
152
  }
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: 3.0.5
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  */
@@ -19,7 +19,7 @@ if ( !is_plugin_active( 'wpmandrill/wpmandrill.php' ) ) {
19
 
20
  define('SP_RESET_ON_ACTIVATE', false);
21
 
22
- define('PLUGIN_VERSION', "3.0.5");
23
  define('SP_MAX_TIMEOUT', 10);
24
  define('SP_BACKUP', 'ShortpixelBackups');
25
  define('SP_BACKUP_FOLDER', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . SP_BACKUP);
@@ -52,8 +52,12 @@ class WPShortPixel {
52
  }
53
 
54
  public function __construct() {
55
- session_start();
56
-
 
 
 
 
57
  $this->populateOptions();
58
 
59
  $this->_apiInterface = new ShortPixelAPI($this->_apiKey, $this->_compressionType, $this->_CMYKtoRGBconversion);
@@ -189,9 +193,6 @@ class WPShortPixel {
189
  }
190
 
191
  function toolbar_shortpixel_processing( $wp_admin_bar ) {
192
- if ( !is_admin()) {
193
- return;
194
- }
195
  wp_enqueue_script('short-pixel.js', plugins_url('/js/short-pixel.js',__FILE__) );
196
 
197
  $extraClasses = " shortpixel-hide";
@@ -381,7 +382,7 @@ class WPShortPixel {
381
  //0: check key
382
  if( $this->_verifiedKey == false) {
383
  echo "Missing API Key";
384
- die();
385
  }
386
 
387
  self::log("HIP: 0 Priority Queue: ".json_encode($this->prioQ->get()));
@@ -454,7 +455,7 @@ class WPShortPixel {
454
  $uploadsUrl = content_url() . "/uploads/";
455
  $urlPath = implode("/", array_slice($filePath, 0, count($filePath) - 1));
456
  $thumb = (isset($meta["sizes"]["medium"]) ? $meta["sizes"]["medium"]["file"] : (isset($meta["sizes"]["thumbnail"]) ? $meta["sizes"]["thumbnail"]["file"]: ""));
457
- if(strlen($thumb) && get_option('wp-short-backup_images')) {
458
  $bkThumb = $uploadsUrl . SP_BACKUP . "/" . $urlPath . "/" . $thumb;
459
  }
460
  if(strlen($thumb)) {
@@ -494,6 +495,7 @@ class WPShortPixel {
494
  } else {
495
  die(var_dump($pathParts));
496
  }
 
497
  die(json_encode($ret));
498
 
499
  $urlList[] = wp_get_attachment_url($attachmentID);
@@ -765,7 +767,11 @@ class WPShortPixel {
765
  <a href="https://wordpress.org/plugins/shortpixel-image-optimiser/installation/" target="_blank">Installation </a> |
766
  <a href="https://shortpixel.com/contact" target="_blank">Support </a>
767
  </p>';
768
- echo '<p>New images uploaded to the Media Library will be optimized automatically.<br/>If you have existing images you would like to optimize, you can use the <a href="' . get_admin_url() . 'upload.php?page=wp-short-pixel-bulk">Bulk Optimization Tool</a>.</p>';
 
 
 
 
769
 
770
  $noticeHTML = "<br/><div style=\"background-color: #fff; border-left: 4px solid %s; box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1); padding: 1px 12px;\"><p>%s</p></div>";
771
 
@@ -786,7 +792,7 @@ class WPShortPixel {
786
  $KeyLength = strlen($_POST['key']);
787
 
788
  printf($noticeHTML, '#ff0000', "The key you provided has " . $KeyLength . " characters. The API key should have 20 characters, letters and numbers only.<BR> <b>Please check that the API key is the same as the one you received in your confirmation email.</b><BR>
789
- If this problem persists, please contact us at <a href='mailto:support@shortpixel.com?Subject=API Key issues' target='_top'>support@shortpixel.com</a> or <a href='https://shortpixel.com/contact' target='_blank'>here</a>.");
790
  }
791
  else
792
  {
@@ -1457,18 +1463,15 @@ HTML;
1457
  {
1458
  $filesList= $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "postmeta
1459
  WHERE ( post_id <= $maxId AND post_id > $minId )
1460
- AND ( meta_key = '_wp_attached_file' OR meta_key = '_wp_attachment_metadata' )
1461
  LIMIT $pointer,$limit");
1462
  if ( empty($filesList) ) {//we parsed all the results
1463
  break;
1464
  }
1465
  foreach ( $filesList as $file )
1466
  {
1467
- if ( $file->meta_key == "_wp_attached_file" ) {
1468
- continue;
1469
- }
1470
  $attachment = unserialize($file->meta_value);
1471
- if ( isset($attachment['ShortPixelImprovement']) && $attachment['ShortPixelImprovement'] > 0 ) {
1472
  $processedMainFiles++;
1473
  $processedTotalFiles++;
1474
  if ( isset($attachment['sizes']) ) {
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: 3.0.6
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  */
19
 
20
  define('SP_RESET_ON_ACTIVATE', false);
21
 
22
+ define('PLUGIN_VERSION', "3.0.6");
23
  define('SP_MAX_TIMEOUT', 10);
24
  define('SP_BACKUP', 'ShortpixelBackups');
25
  define('SP_BACKUP_FOLDER', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . SP_BACKUP);
52
  }
53
 
54
  public function __construct() {
55
+ if(!is_admin()) {
56
+ return;
57
+ }
58
+ if (!session_id()) {
59
+ session_start();
60
+ }
61
  $this->populateOptions();
62
 
63
  $this->_apiInterface = new ShortPixelAPI($this->_apiKey, $this->_compressionType, $this->_CMYKtoRGBconversion);
193
  }
194
 
195
  function toolbar_shortpixel_processing( $wp_admin_bar ) {
 
 
 
196
  wp_enqueue_script('short-pixel.js', plugins_url('/js/short-pixel.js',__FILE__) );
197
 
198
  $extraClasses = " shortpixel-hide";
382
  //0: check key
383
  if( $this->_verifiedKey == false) {
384
  echo "Missing API Key";
385
+ die("Missing API Key");
386
  }
387
 
388
  self::log("HIP: 0 Priority Queue: ".json_encode($this->prioQ->get()));
455
  $uploadsUrl = content_url() . "/uploads/";
456
  $urlPath = implode("/", array_slice($filePath, 0, count($filePath) - 1));
457
  $thumb = (isset($meta["sizes"]["medium"]) ? $meta["sizes"]["medium"]["file"] : (isset($meta["sizes"]["thumbnail"]) ? $meta["sizes"]["thumbnail"]["file"]: ""));
458
+ if(strlen($thumb) && get_option('wp-short-backup_images') && $this->_processThumbnails) {
459
  $bkThumb = $uploadsUrl . SP_BACKUP . "/" . $urlPath . "/" . $thumb;
460
  }
461
  if(strlen($thumb)) {
495
  } else {
496
  die(var_dump($pathParts));
497
  }
498
+ //TODO curata functia asta
499
  die(json_encode($ret));
500
 
501
  $urlList[] = wp_get_attachment_url($attachmentID);
767
  <a href="https://wordpress.org/plugins/shortpixel-image-optimiser/installation/" target="_blank">Installation </a> |
768
  <a href="https://shortpixel.com/contact" target="_blank">Support </a>
769
  </p>';
770
+ if($this->_verifiedKey) {
771
+ echo '<p>New images uploaded to the Media Library will be optimized automatically.<br/>If you have existing images you would like to optimize, you can use the <a href="' . get_admin_url() . 'upload.php?page=wp-short-pixel-bulk">Bulk Optimization Tool</a>.</p>';
772
+ } else {
773
+ echo '<p>Please enter here the API Key provided by ShortPixel:</p>';
774
+ }
775
 
776
  $noticeHTML = "<br/><div style=\"background-color: #fff; border-left: 4px solid %s; box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1); padding: 1px 12px;\"><p>%s</p></div>";
777
 
792
  $KeyLength = strlen($_POST['key']);
793
 
794
  printf($noticeHTML, '#ff0000', "The key you provided has " . $KeyLength . " characters. The API key should have 20 characters, letters and numbers only.<BR> <b>Please check that the API key is the same as the one you received in your confirmation email.</b><BR>
795
+ If this problem persists, please contact us at <a href='mailto:help@shortpixel.com?Subject=API Key issues' target='_top'>help@shortpixel.com</a> or <a href='https://shortpixel.com/contact' target='_blank'>here</a>.");
796
  }
797
  else
798
  {
1463
  {
1464
  $filesList= $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "postmeta
1465
  WHERE ( post_id <= $maxId AND post_id > $minId )
1466
+ AND ( meta_key = '_wp_attachment_metadata' )
1467
  LIMIT $pointer,$limit");
1468
  if ( empty($filesList) ) {//we parsed all the results
1469
  break;
1470
  }
1471
  foreach ( $filesList as $file )
1472
  {
 
 
 
1473
  $attachment = unserialize($file->meta_value);
1474
+ if ( isset($attachment['ShortPixelImprovement']) && ($attachment['ShortPixelImprovement'] > 0 || $attachment['ShortPixelImprovement'] === 0.0)) {
1475
  $processedMainFiles++;
1476
  $processedTotalFiles++;
1477
  if ( isset($attachment['sizes']) ) {