ShortPixel Image Optimizer - Version 2.1.7

Version Description

  • improved checking and reporting of firewall restriction on client side
  • optimized files are saved in the right location when dealing with WP Multisite
Download this release

Release Info

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

Code changes from version 2.1.6 to 2.1.7

Files changed (3) hide show
  1. readme.txt +9 -2
  2. shortpixel_api.php +26 -2
  3. wp-shortpixel.php +41 -37
readme.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: AlexSP
4
  Tags: picture, optimization, image editor, pngout, upload speed, shortpixel, compression, jpegmini, webp, lossless, cwebp, media, tinypng, jpegtran,image, image optimisation, shrink, picture, photo, optimize photos, compress, performance, tinypng, crunch, pngquant, attachment, optimize, pictures,fast, images, image files, image quality, lossy, upload, kraken, resize, seo, smushit, optipng, kraken image optimizer, ewww, photo optimization, gifsicle, image optimizer, images, krakenio, png, gmagick, image optimize, pdf, pdf optimisation, pdf optimization, optimize pdf, optimise pdf, shrink pdf, jpg, jpeg, jpg optimisation, jpg optimization, optimize jpg, optimise jpg, shrink jpg, gif, animated gif, optimize gif, optimise gif
5
  Requires at least: 3.0.0 or higher
6
  Tested up to: 4.2
7
- Stable tag: 2.1.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -95,11 +95,14 @@ Your images are automatically stored in a backup folder, on your hosting server.
95
 
96
  For now, ShortPixel supports JPEG, PNG, PDF and GIF formats. Animated GIFs and thumbnails are also optimized. Additional formats are scheduled for optimization in the future.
97
 
 
 
 
 
98
  = I’m stuck. What do I do? =
99
 
100
  The ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Contact us</a>!
101
 
102
-
103
  == Screenshots ==
104
 
105
  1. Activate your API key in the plugin Settings. (Settings>ShortPixel)
@@ -112,6 +115,10 @@ The ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Co
112
 
113
  == Changelog ==
114
 
 
 
 
 
115
  = 2.1.6 =
116
 
117
  * improved login procedure upon quota is exceeded
4
  Tags: picture, optimization, image editor, pngout, upload speed, shortpixel, compression, jpegmini, webp, lossless, cwebp, media, tinypng, jpegtran,image, image optimisation, shrink, picture, photo, optimize photos, compress, performance, tinypng, crunch, pngquant, attachment, optimize, pictures,fast, images, image files, image quality, lossy, upload, kraken, resize, seo, smushit, optipng, kraken image optimizer, ewww, photo optimization, gifsicle, image optimizer, images, krakenio, png, gmagick, image optimize, pdf, pdf optimisation, pdf optimization, optimize pdf, optimise pdf, shrink pdf, jpg, jpeg, jpg optimisation, jpg optimization, optimize jpg, optimise jpg, shrink jpg, gif, animated gif, optimize gif, optimise gif
5
  Requires at least: 3.0.0 or higher
6
  Tested up to: 4.2
7
+ Stable tag: 2.1.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
95
 
96
  For now, ShortPixel supports JPEG, PNG, PDF and GIF formats. Animated GIFs and thumbnails are also optimized. Additional formats are scheduled for optimization in the future.
97
 
98
+ = Will ShortPixel work if my website is using CloudFare? =
99
+
100
+ Yes, the image processing happens without interfering with the CloudFare protection. The ShortPixel and CloudFare plugins are also compatible.
101
+
102
  = I’m stuck. What do I do? =
103
 
104
  The ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Contact us</a>!
105
 
 
106
  == Screenshots ==
107
 
108
  1. Activate your API key in the plugin Settings. (Settings>ShortPixel)
115
 
116
  == Changelog ==
117
 
118
+ = 2.1.7 =
119
+ * improved checking and reporting of firewall restriction on client side
120
+ * optimized files are saved in the right location when dealing with WP Multisite
121
+
122
  = 2.1.6 =
123
 
124
  * improved login procedure upon quota is exceeded
shortpixel_api.php CHANGED
@@ -8,7 +8,7 @@ class shortpixel_api {
8
  private $_apiKey = '';
9
  private $_compressionType = '';
10
  private $_maxAttempts = 10;
11
- private $_apiEndPoint = 'https://api.shortpixel.com/v2/reducer.php';//fai
12
 
13
  public function setCompressionType($compressionType) {
14
  $this->_compressionType = $compressionType;
@@ -356,14 +356,38 @@ class shortpixel_api {
356
 
357
  static public function returnSubDir($file)//return subdir for that particular attached file
358
  {
 
 
 
 
 
 
 
 
359
 
360
  $uploadDir = wp_upload_dir();
361
 
362
  if ( !isset($file) || strpos($file, "/") === false )
363
  $SubDir = "";
364
  else
365
- $SubDir = trim(substr($file,0,strrpos($file,"/")+1));
 
 
 
 
 
 
 
 
 
366
 
 
 
 
 
 
 
 
367
  //remove upload dir from the URL if needed
368
  $SubDir = str_ireplace($uploadDir['basedir'] . DIRECTORY_SEPARATOR ,"", $SubDir);
369
 
8
  private $_apiKey = '';
9
  private $_compressionType = '';
10
  private $_maxAttempts = 10;
11
+ private $_apiEndPoint = 'https://api.shortpixel.com/v2/reducer.php';
12
 
13
  public function setCompressionType($compressionType) {
14
  $this->_compressionType = $compressionType;
356
 
357
  static public function returnSubDir($file)//return subdir for that particular attached file
358
  {
359
+ $MultisiteExtraPath = "";
360
+
361
+ if ( function_exists('is_multisite') && function_exists('get_current_blog_id') )
362
+ {//for dealing with WP Multisites
363
+ $BlogID = get_current_blog_id();
364
+ if ( is_multisite() && $BlogID > 1 ) //is a WP Multisite
365
+ $MultisiteExtraPath = "sites" . DIRECTORY_SEPARATOR . $BlogID . DIRECTORY_SEPARATOR;
366
+ }
367
 
368
  $uploadDir = wp_upload_dir();
369
 
370
  if ( !isset($file) || strpos($file, "/") === false )
371
  $SubDir = "";
372
  else
373
+ $SubDir = $MultisiteExtraPath . trim(substr($file,0,strrpos($file,"/")+1));
374
+
375
+ //remove upload dir from the URL if needed
376
+ $SubDir = str_ireplace($uploadDir['basedir'] . DIRECTORY_SEPARATOR ,"", $SubDir);
377
+
378
+ return $SubDir;
379
+ }
380
+
381
+ static public function returnSubDirURL($file)//return subdir for that particular attached file
382
+ {
383
 
384
+ $uploadDir = wp_upload_dir();
385
+
386
+ if ( !isset($file) || strpos($file, "/") === false )
387
+ $SubDir = "";
388
+ else
389
+ $SubDir = trim(substr($file,0,strrpos($file,"/")+1));
390
+
391
  //remove upload dir from the URL if needed
392
  $SubDir = str_ireplace($uploadDir['basedir'] . DIRECTORY_SEPARATOR ,"", $SubDir);
393
 
wp-shortpixel.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: ShortPixel Image Optimizer
4
  * Plugin URI: https://shortpixel.com/
5
  * Description: ShortPixel is an image compression tool that helps improve your website performance. The plugin optimizes images automatically using both lossy and lossless compression. Resulting, smaller, images are no different in quality from the original. To install: 1) Click the "Activate" link to the left of this description. 2) <a href="https://shortpixel.com/wp-apikey" target="_blank">Free Sign up</a> for your unique API Key . 3) Check your email for your API key. 4) Use your API key to activate ShortPixel plugin in the 'Plugins' menu in WordPress. 5) Done!
6
- * Version: 2.1.6
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  */
@@ -15,7 +15,7 @@ if ( !is_plugin_active( 'wpmandrill/wpmandrill.php' ) ) {
15
  require_once( ABSPATH . 'wp-includes/pluggable.php' );//to avoid conflict with wpmandrill plugin
16
  }
17
 
18
- define('PLUGIN_VERSION', "2.1.6");
19
  define('SP_DEBUG', false);
20
  define('SP_LOG', false);
21
  define('SP_MAX_TIMEOUT', 10);
@@ -24,7 +24,7 @@ define('MUST_HAVE_KEY', true);
24
  define('MAX_API_RETRIES', 5);
25
  $MAX_EXECUTION_TIME = ini_get('max_execution_time');
26
  if ( is_numeric($MAX_EXECUTION_TIME) )
27
- define('MAX_EXECUTION_TIME', $MAX_EXECUTION_TIME - 3 ); //in seconds
28
  else
29
  define('MAX_EXECUTION_TIME', 25 );
30
  define("SP_MAX_RESULTS_QUERY", 6);
@@ -46,7 +46,7 @@ class WPShortPixel {
46
  $this->setDefaultViewModeList();//set default mode as list. only @ first run
47
 
48
  $this->_apiInterface = new shortpixel_api($this->_apiKey, $this->_compressionType);
49
-
50
  //add hook for image upload processing
51
  add_filter( 'wp_generate_attachment_metadata', array( &$this, 'handleImageUpload' ), 10, 2 );
52
  add_filter( 'manage_media_columns', array( &$this, 'columns' ) );//add media library column header
@@ -272,7 +272,7 @@ class WPShortPixel {
272
  }
273
  else
274
  {
275
- $meta['ShortPixelImprovement'] = 'Optimisation N/A';
276
  return $meta;
277
  }
278
  }
@@ -293,6 +293,7 @@ class WPShortPixel {
293
 
294
  if ( $startQueryID <= $endQueryID )
295
  {
 
296
  echo 'Empty queue ' . $startQueryID . '->' . $endQueryID;
297
  die;
298
  }
@@ -308,7 +309,7 @@ class WPShortPixel {
308
 
309
  $resultsPostMeta = $wpdb->get_results($queryPostMeta);
310
 
311
- if ( empty($resultsPostMeta) )
312
  {
313
  $this->getMaxShortPixelId();//fetch data for endQueryID and startQueryID
314
  update_option("wp-short-pixel-query-id-start", $startQueryID);//update max and min ID
@@ -328,11 +329,12 @@ class WPShortPixel {
328
  }
329
  else
330
  $meta = wp_get_attachment_metadata($itemMetaData->post_id);
 
331
  $meta['ShortPixelImprovement'] = ( isset($meta['ShortPixelImprovement']) ) ? $meta['ShortPixelImprovement'] : "";
332
  $filePath = get_attached_file($itemMetaData->post_id);
333
  $fileExtension = strtolower(substr($filePath,strrpos($filePath,".")+1));
334
 
335
- if ( ( $itemMetaData->meta_key == "_wp_attachment_metadata" && $meta['ShortPixelImprovement'] <> "Optimisation N/A" && !is_numeric($meta['ShortPixelImprovement']) ) || $fileExtension == "pdf" )//Optimisation N/A = is an unsupported file format
336
  {
337
  $idList[] = $itemMetaData;
338
  }
@@ -467,11 +469,17 @@ class WPShortPixel {
467
  $uploadDir = wp_upload_dir();
468
 
469
  if ( empty($meta['file']) )//file has no metadata attached (like PDF files uploaded before SP plugin)
470
- $SubDir = $this->_apiInterface->returnSubDir($imagePath);
 
 
 
471
  else
472
- $SubDir = $this->_apiInterface->returnSubDir($meta['file']);
 
 
 
473
 
474
- $imageURLs[] = $uploadDir['baseurl'] . DIRECTORY_SEPARATOR . $SubDir . basename($imagePath);//URL to PDF file
475
  $imagePaths[] = $uploadDir['basedir'] . DIRECTORY_SEPARATOR . $SubDir . basename($imagePath);
476
 
477
  $processThumbnails = get_option('wp-short-process_thumbnails');
@@ -625,17 +633,7 @@ class WPShortPixel {
625
  echo "<p>Don’t have an API Key yet? Get it now at <a href=\"https://shortpixel.com/wp-apikey\" target=\"_blank\">www.ShortPixel.com</a>, for free.</p>";
626
  return;
627
  }
628
-
629
-
630
- if ( isset($_POST['bulkProcess']) )
631
- {//set the thumbnails option
632
- if ( isset($_POST['thumbnails']) )
633
- update_option('wp-short-process_thumbnails', 1);
634
- else
635
- update_option('wp-short-process_thumbnails', 0);
636
- }
637
-
638
-
639
  if(isset($_GET['cancel']))
640
  {//cancel an ongoing bulk processing, it might be needed sometimes
641
  $this->cancelProcessing();
@@ -643,6 +641,12 @@ class WPShortPixel {
643
 
644
  if(isset($_POST["bulkProcess"]))
645
  {
 
 
 
 
 
 
646
  $this->getMaxShortPixelId();//fetch data for endQueryID and startQueryID
647
  update_option("wp-short-pixel-query-id-start", $startQueryID);//start downwards from the biggest item ID
648
  update_option("wp-short-pixel-query-id-stop", 0);
@@ -687,15 +691,9 @@ class WPShortPixel {
687
  else
688
  {
689
  printf($noticeHTML, '#ff0000', "The plugin has stopped because it reached the monthly limit. You can upgrade your ShortPixel plan by <a href='https://shortpixel.com/login/".$this->_apiKey."' target='_blank'>logging into your account</a> - see the <a href='https://shortpixel.com/pricing' target='_blank'>options available</a><BR>The plugin successfully optimized " . number_format($quotaData['APICallsMadeNumeric']) . " images, with a " . round(get_option('wp-short-pixel-averageCompression'),2) . "% average compression rate. See your own stats by <a href='https://shortpixel.com/login/".$this->_apiKey."' target='_blank'>checking your optimization reports</a>. <BR>" );
690
- //fai
691
-
692
 
693
- //~ see the . number_format($quotaData['APICallsMadeNumeric']) . " images and stopped because it reached the monthly limit which is " . number_format($quotaData['APICallsQuotaNumeric']) . ".<BR> See the other <a href='https://shortpixel.com/pricing' target='_blank'>options availbe</a> and <a href='https://shortpixel.com/login/".$this->_apiKey."' target='_blank'>log into your account</a> to change your type of subscription.");
694
- //~
695
  return;
696
 
697
- //The plugin has stopped because it reached the monthly limit. You can upgrade your ShortPixel plan by logging into your account - see the options available
698
- //fai stop bulk
699
  }
700
  }
701
 
@@ -728,7 +726,7 @@ class WPShortPixel {
728
 
729
  echo '
730
  <a class="button button-secondary" href="' . get_admin_url() . 'upload.php">Media Library</a>
731
- <a class="button button-secondary" href="' . get_admin_url() . 'upload.php?page=wp-short-pixel-bulk&cancel=1">Cancel Processing</a>
732
  ';
733
 
734
  } else
@@ -952,6 +950,7 @@ clip art and comics.
952
  <input name="backupImages" type="checkbox" id="backupImages" {$checkedBackupImages}> Save and keep a backup of your original images in a separate folder.
953
  </td>
954
  </tr>
 
955
  </tbody></table>
956
  <p class="submit">
957
  <input type="submit" name="submit" id="submit" class="button button-primary" title="Save Changes" value="Save Changes">
@@ -1011,7 +1010,7 @@ HTML;
1011
  <table class="form-table">
1012
  <tbody><tr>
1013
  <th scope="row"><label for="apiQuota">Your ShortPixel plan</label></th>
1014
- <td>{$quotaData['APICallsQuota']}</td>
1015
  </tr>
1016
  <tr>
1017
  <th scope="row"><label for="usedQUota">Number of images processed this month:</label></th>
@@ -1043,8 +1042,13 @@ HTML;
1043
  $statHTML .= <<< HTML
1044
  </tbody></table>
1045
  HTML;
 
 
1046
  echo $statHTML;
 
 
1047
  }
 
1048
  }
1049
 
1050
  public function getBulkProcessingForm() {
@@ -1075,8 +1079,8 @@ HTML;
1075
  else
1076
  {
1077
  $message = "<BR>
1078
- <p>Before you start the image processing, please take into consideration the extra thumbnails (for each image in your Media Library, Wordress automatically creates smaller images for different screen resolutions, mobile, etc).</p>
1079
- <p>You now have {$imageCount['mainFiles']} images in your Media Library and {$imageOnlyThumbs} smaller thumbnails. Unless you uncheck the box below, ShortPixel will process a total of {$imageCount['totalFiles']} images.</p>
1080
  <p>Optimizing thumbnails is important for your mobile website speed. However, if you don't want to optimize thumbs, please uncheck the box below</p>";
1081
 
1082
  $message .= "<form action='' method='POST' >";
@@ -1091,7 +1095,7 @@ HTML;
1091
 
1092
 
1093
  if ( get_option( 'wp-short-pixel-cancel-pointer') )//add also the resume bulk processing option
1094
- $message .= "&nbsp;&nbsp;&nbsp;<input type='submit' name='bulkProcessResume' id='bulkProcessResume' class='button button-primary' value='Resume cancelled process'>";
1095
 
1096
  $message .= "
1097
  </form>";
@@ -1123,14 +1127,14 @@ HTML;
1123
 
1124
  $defaultData = array(
1125
  "APIKeyValid" => false,
1126
- "Message" => 'API Key could not be validated due to a connectivity error.<BR>It is likely that your hosting provider doesn\'t allow connections to our servers via <i>wp_remote_post</i> command.<BR> If you need further assistance from us please <a href="https://shortpixel.com/contact" target="_blank">contact us</a>',
1127
  "APICallsMade" => 'Information unavailable. Please check your API key.',
1128
  "APICallsQuota" => 'Information unavailable. Please check your API key.');
1129
 
1130
  if(is_object($response) && get_class($response) == 'WP_Error') {
1131
 
1132
  $urlElements = parse_url($requestURL);
1133
- $portConnect = @fsockopen($urlElements['host'],81,$errno,$errstr,15);
1134
  if(!$portConnect)
1135
  $defaultData['Message'] .= "<BR>Debug info: <i>$errstr</i>";
1136
 
@@ -1180,7 +1184,7 @@ HTML;
1180
  if(!$this->_verifiedKey)
1181
  print 'Invalid API Key. <a href="options-general.php?page=wp-shortpixel">Check your Settings</a>';
1182
  else
1183
- print 'Optimisation N/A';
1184
  }
1185
  else
1186
  {
@@ -1228,7 +1232,7 @@ HTML;
1228
  print '%';
1229
  return;
1230
  }
1231
- elseif ( $data['ShortPixelImprovement'] <> "Optimisation N/A" )
1232
  {
1233
  if ( trim(strip_tags($data['ShortPixelImprovement'])) == "Quota exceeded" )
1234
  {
@@ -1246,7 +1250,7 @@ HTML;
1246
  }
1247
  else
1248
  {
1249
- print "Optimisation N/A";
1250
  return;
1251
  }
1252
 
3
  * Plugin Name: ShortPixel Image Optimizer
4
  * Plugin URI: https://shortpixel.com/
5
  * Description: ShortPixel is an image compression tool that helps improve your website performance. The plugin optimizes images automatically using both lossy and lossless compression. Resulting, smaller, images are no different in quality from the original. To install: 1) Click the "Activate" link to the left of this description. 2) <a href="https://shortpixel.com/wp-apikey" target="_blank">Free Sign up</a> for your unique API Key . 3) Check your email for your API key. 4) Use your API key to activate ShortPixel plugin in the 'Plugins' menu in WordPress. 5) Done!
6
+ * Version: 2.1.7
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  */
15
  require_once( ABSPATH . 'wp-includes/pluggable.php' );//to avoid conflict with wpmandrill plugin
16
  }
17
 
18
+ define('PLUGIN_VERSION', "2.1.7");
19
  define('SP_DEBUG', false);
20
  define('SP_LOG', false);
21
  define('SP_MAX_TIMEOUT', 10);
24
  define('MAX_API_RETRIES', 5);
25
  $MAX_EXECUTION_TIME = ini_get('max_execution_time');
26
  if ( is_numeric($MAX_EXECUTION_TIME) )
27
+ define('MAX_EXECUTION_TIME', $MAX_EXECUTION_TIME - 5 ); //in seconds
28
  else
29
  define('MAX_EXECUTION_TIME', 25 );
30
  define("SP_MAX_RESULTS_QUERY", 6);
46
  $this->setDefaultViewModeList();//set default mode as list. only @ first run
47
 
48
  $this->_apiInterface = new shortpixel_api($this->_apiKey, $this->_compressionType);
49
+
50
  //add hook for image upload processing
51
  add_filter( 'wp_generate_attachment_metadata', array( &$this, 'handleImageUpload' ), 10, 2 );
52
  add_filter( 'manage_media_columns', array( &$this, 'columns' ) );//add media library column header
272
  }
273
  else
274
  {
275
+ $meta['ShortPixelImprovement'] = 'Optimization N/A';
276
  return $meta;
277
  }
278
  }
293
 
294
  if ( $startQueryID <= $endQueryID )
295
  {
296
+ delete_option('bulkProcessingStatus');
297
  echo 'Empty queue ' . $startQueryID . '->' . $endQueryID;
298
  die;
299
  }
309
 
310
  $resultsPostMeta = $wpdb->get_results($queryPostMeta);
311
 
312
+ if ( empty($resultsPostMeta) )//no results
313
  {
314
  $this->getMaxShortPixelId();//fetch data for endQueryID and startQueryID
315
  update_option("wp-short-pixel-query-id-start", $startQueryID);//update max and min ID
329
  }
330
  else
331
  $meta = wp_get_attachment_metadata($itemMetaData->post_id);
332
+
333
  $meta['ShortPixelImprovement'] = ( isset($meta['ShortPixelImprovement']) ) ? $meta['ShortPixelImprovement'] : "";
334
  $filePath = get_attached_file($itemMetaData->post_id);
335
  $fileExtension = strtolower(substr($filePath,strrpos($filePath,".")+1));
336
 
337
+ if ( ( $itemMetaData->meta_key == "_wp_attachment_metadata" && $meta['ShortPixelImprovement'] <> "Optimization N/A" && !is_numeric($meta['ShortPixelImprovement']) ) || $fileExtension == "pdf" )//Optimization N/A = is an unsupported file format
338
  {
339
  $idList[] = $itemMetaData;
340
  }
469
  $uploadDir = wp_upload_dir();
470
 
471
  if ( empty($meta['file']) )//file has no metadata attached (like PDF files uploaded before SP plugin)
472
+ {
473
+ $SubDir = $this->_apiInterface->returnSubDir($imagePath);
474
+ $SubDirURL = $this->_apiInterface->returnSubDirURL($imagePath);
475
+ }
476
  else
477
+ {
478
+ $SubDir = $this->_apiInterface->returnSubDir($meta['file']);
479
+ $SubDirURL = $this->_apiInterface->returnSubDirURL($imagePath);
480
+ }
481
 
482
+ $imageURLs[] = $uploadDir['baseurl'] . DIRECTORY_SEPARATOR . $SubDirURL . basename($imagePath);//URL to PDF file
483
  $imagePaths[] = $uploadDir['basedir'] . DIRECTORY_SEPARATOR . $SubDir . basename($imagePath);
484
 
485
  $processThumbnails = get_option('wp-short-process_thumbnails');
633
  echo "<p>Don’t have an API Key yet? Get it now at <a href=\"https://shortpixel.com/wp-apikey\" target=\"_blank\">www.ShortPixel.com</a>, for free.</p>";
634
  return;
635
  }
636
+
 
 
 
 
 
 
 
 
 
 
637
  if(isset($_GET['cancel']))
638
  {//cancel an ongoing bulk processing, it might be needed sometimes
639
  $this->cancelProcessing();
641
 
642
  if(isset($_POST["bulkProcess"]))
643
  {
644
+ //set the thumbnails option
645
+ if ( isset($_POST['thumbnails']) )
646
+ update_option('wp-short-process_thumbnails', 1);
647
+ else
648
+ update_option('wp-short-process_thumbnails', 0);
649
+
650
  $this->getMaxShortPixelId();//fetch data for endQueryID and startQueryID
651
  update_option("wp-short-pixel-query-id-start", $startQueryID);//start downwards from the biggest item ID
652
  update_option("wp-short-pixel-query-id-stop", 0);
691
  else
692
  {
693
  printf($noticeHTML, '#ff0000', "The plugin has stopped because it reached the monthly limit. You can upgrade your ShortPixel plan by <a href='https://shortpixel.com/login/".$this->_apiKey."' target='_blank'>logging into your account</a> - see the <a href='https://shortpixel.com/pricing' target='_blank'>options available</a><BR>The plugin successfully optimized " . number_format($quotaData['APICallsMadeNumeric']) . " images, with a " . round(get_option('wp-short-pixel-averageCompression'),2) . "% average compression rate. See your own stats by <a href='https://shortpixel.com/login/".$this->_apiKey."' target='_blank'>checking your optimization reports</a>. <BR>" );
 
 
694
 
 
 
695
  return;
696
 
 
 
697
  }
698
  }
699
 
726
 
727
  echo '
728
  <a class="button button-secondary" href="' . get_admin_url() . 'upload.php">Media Library</a>
729
+ <a class="button button-secondary" href="' . get_admin_url() . 'upload.php?page=wp-short-pixel-bulk&cancel=1">Pause Processing</a>
730
  ';
731
 
732
  } else
950
  <input name="backupImages" type="checkbox" id="backupImages" {$checkedBackupImages}> Save and keep a backup of your original images in a separate folder.
951
  </td>
952
  </tr>
953
+ </tr>
954
  </tbody></table>
955
  <p class="submit">
956
  <input type="submit" name="submit" id="submit" class="button button-primary" title="Save Changes" value="Save Changes">
1010
  <table class="form-table">
1011
  <tbody><tr>
1012
  <th scope="row"><label for="apiQuota">Your ShortPixel plan</label></th>
1013
+ <td>{$quotaData['APICallsQuota']} ( <a href="https://shortpixel.com/login/{$this->_apiKey}" target="_blank">See more options</a> )
1014
  </tr>
1015
  <tr>
1016
  <th scope="row"><label for="usedQUota">Number of images processed this month:</label></th>
1042
  $statHTML .= <<< HTML
1043
  </tbody></table>
1044
  HTML;
1045
+ $statHTML .= '<p style="padding-top: 0px; color: #818181;" >Increase your image quota by <a href="https://shortpixel.com/login/'.$this->_apiKey.'" target="_blank">upgrading</a> your ShortPixel plan.</p>';
1046
+
1047
  echo $statHTML;
1048
+
1049
+
1050
  }
1051
+
1052
  }
1053
 
1054
  public function getBulkProcessingForm() {
1079
  else
1080
  {
1081
  $message = "<BR>
1082
+ <p>Before you start the image processing, please take into consideration the extra thumbnails (for each image in your Media Library, WordPress automatically creates smaller images for different screen resolutions, mobile, etc).</p>
1083
+ <p>You now have ".number_format($imageCount['mainFiles'])." images in your Media Library and ".number_format($imageOnlyThumbs)." smaller thumbnails. Unless you uncheck the box below, ShortPixel will process a total of ".number_format($imageCount['totalFiles'])." images.</p>
1084
  <p>Optimizing thumbnails is important for your mobile website speed. However, if you don't want to optimize thumbs, please uncheck the box below</p>";
1085
 
1086
  $message .= "<form action='' method='POST' >";
1095
 
1096
 
1097
  if ( get_option( 'wp-short-pixel-cancel-pointer') )//add also the resume bulk processing option
1098
+ $message .= "&nbsp;&nbsp;&nbsp;<input type='submit' name='bulkProcessResume' id='bulkProcessResume' class='button button-primary' value='Resume process'>";
1099
 
1100
  $message .= "
1101
  </form>";
1127
 
1128
  $defaultData = array(
1129
  "APIKeyValid" => false,
1130
+ "Message" => 'API Key could not be validated due to a connectivity error.<BR>Your firewall may be blocking us. Please contact your hosting provider and ask them to allow connections from your site to IP 176.9.106.46.<BR> If you still cannot validate your API Key after this, please <a href="https://shortpixel.com/contact" target="_blank">contact us</a> and we will try to help. ',
1131
  "APICallsMade" => 'Information unavailable. Please check your API key.',
1132
  "APICallsQuota" => 'Information unavailable. Please check your API key.');
1133
 
1134
  if(is_object($response) && get_class($response) == 'WP_Error') {
1135
 
1136
  $urlElements = parse_url($requestURL);
1137
+ $portConnect = @fsockopen($urlElements['host'],8,$errno,$errstr,15);
1138
  if(!$portConnect)
1139
  $defaultData['Message'] .= "<BR>Debug info: <i>$errstr</i>";
1140
 
1184
  if(!$this->_verifiedKey)
1185
  print 'Invalid API Key. <a href="options-general.php?page=wp-shortpixel">Check your Settings</a>';
1186
  else
1187
+ print 'Optimization N/A';
1188
  }
1189
  else
1190
  {
1232
  print '%';
1233
  return;
1234
  }
1235
+ elseif ( $data['ShortPixelImprovement'] <> "Optimization N/A" )
1236
  {
1237
  if ( trim(strip_tags($data['ShortPixelImprovement'])) == "Quota exceeded" )
1238
  {
1250
  }
1251
  else
1252
  {
1253
+ print "Optimization N/A";
1254
  return;
1255
  }
1256