ShortPixel Image Optimizer - Version 2.1.8

Version Description

  • improved texts/explanations for different sections
  • added extra option to convert CMYK to RGB for further size reduction
  • display credits for one time payments as well
  • API Key can also be configured in wp-config.php like this: define('SHORTPIXEL_API_KEY', 'YOUR_API_KEY'); Useful for multisite installations
Download this release

Release Info

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

Code changes from version 2.1.7 to 2.1.8

Files changed (3) hide show
  1. readme.txt +16 -4
  2. shortpixel_api.php +7 -2
  3. wp-shortpixel.php +83 -28
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.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -72,10 +72,13 @@ To get your API key, you must <a href="https://shortpixel.com/wp-apikey">Sign up
72
 
73
  You use the API key in the ShortPixel plugin Settings (don’t forget to click Save Settings). The same API key can be used on multiple websites/blogs.
74
 
75
- = How do I activate the API key on a multisite? =
76
 
77
- You have to activate the plugin in the network admin and then activate it manually via the plugins page on each individual site in the multisite.
78
- Once you have done that, the Settings menu appears and you can add the API key for each individual site.
 
 
 
79
 
80
  = How does Bulk Optimization work? =
81
 
@@ -115,9 +118,18 @@ The ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Co
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
 
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.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
72
 
73
  You use the API key in the ShortPixel plugin Settings (don’t forget to click Save Settings). The same API key can be used on multiple websites/blogs.
74
 
75
+ = How do I activate the API key on a multisite? =
76
 
77
+ You have to activate the plugin in the network admin and then activate it manually on each individual site in the multisite. Once you have done that, the Settings menu appears and you can add the API key for each individual site.
78
+
79
+ As an alternative, you can edit wp-config.php and add this line
80
+ define('SHORTPIXEL_API_KEY', 'APIKEY')
81
+ where 'APIKEY' is the API Key received upon sign up.
82
 
83
  = How does Bulk Optimization work? =
84
 
118
 
119
  == Changelog ==
120
 
121
+ = 2.1.8 =
122
+
123
+ * improved texts/explanations for different sections
124
+ * added extra option to convert CMYK to RGB for further size reduction
125
+ * display credits for one time payments as well
126
+ * API Key can also be configured in wp-config.php like this: define('SHORTPIXEL_API_KEY', 'YOUR_API_KEY'); Useful for multisite installations
127
+
128
+
129
  = 2.1.7 =
130
  * improved checking and reporting of firewall restriction on client side
131
  * optimized files are saved in the right location when dealing with WP Multisite
132
+ * updated screenshots
133
 
134
  = 2.1.6 =
135
 
shortpixel_api.php CHANGED
@@ -7,6 +7,7 @@ class shortpixel_api {
7
 
8
  private $_apiKey = '';
9
  private $_compressionType = '';
 
10
  private $_maxAttempts = 10;
11
  private $_apiEndPoint = 'https://api.shortpixel.com/v2/reducer.php';
12
 
@@ -14,6 +15,9 @@ class shortpixel_api {
14
  $this->_compressionType = $compressionType;
15
  }
16
 
 
 
 
17
  public function getCompressionType() {
18
  return $this->_compressionType;
19
  }
@@ -26,10 +30,10 @@ class shortpixel_api {
26
  return $this->_apiKey;
27
  }
28
 
29
- public function __construct($apiKey, $compressionType) {
30
  $this->_apiKey = $apiKey;
31
  $this->setCompressionType($compressionType);
32
-
33
  add_action('processImageAction', array(&$this, 'processImageAction'), 10, 4);
34
  }
35
 
@@ -60,6 +64,7 @@ class shortpixel_api {
60
  'plugin_version' => PLUGIN_VERSION,
61
  'key' => $this->_apiKey,
62
  'lossy' => $this->_compressionType,
 
63
  'urllist' => $imageList
64
  );
65
 
7
 
8
  private $_apiKey = '';
9
  private $_compressionType = '';
10
+ private $_CMYKtoRGBconversion = '';
11
  private $_maxAttempts = 10;
12
  private $_apiEndPoint = 'https://api.shortpixel.com/v2/reducer.php';
13
 
15
  $this->_compressionType = $compressionType;
16
  }
17
 
18
+ public function setCMYKtoRGB($CMYK2RGB) {
19
+ $this->_CMYKtoRGBconversion = $CMYK2RGB;
20
+ }
21
  public function getCompressionType() {
22
  return $this->_compressionType;
23
  }
30
  return $this->_apiKey;
31
  }
32
 
33
+ public function __construct($apiKey, $compressionType, $CMYK2RGB) {
34
  $this->_apiKey = $apiKey;
35
  $this->setCompressionType($compressionType);
36
+ $this->setCMYKtoRGB($CMYK2RGB);
37
  add_action('processImageAction', array(&$this, 'processImageAction'), 10, 4);
38
  }
39
 
64
  'plugin_version' => PLUGIN_VERSION,
65
  'key' => $this->_apiKey,
66
  'lossy' => $this->_compressionType,
67
+ 'cmyk2rgb' => $this->_CMYKtoRGBconversion,
68
  'urllist' => $imageList
69
  );
70
 
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.7
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.7");
19
  define('SP_DEBUG', false);
20
  define('SP_LOG', false);
21
  define('SP_MAX_TIMEOUT', 10);
@@ -35,6 +35,7 @@ class WPShortPixel {
35
  private $_apiKey = '';
36
  private $_compressionType = 1;
37
  private $_processThumbnails = 1;
 
38
  private $_backupImages = 1;
39
  private $_verifiedKey = false;
40
 
@@ -45,7 +46,7 @@ class WPShortPixel {
45
 
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 );
@@ -101,6 +102,12 @@ class WPShortPixel {
101
  add_option('wp-short-process_thumbnails', $this->_processThumbnails, '', 'yes' );
102
  }
103
 
 
 
 
 
 
 
104
  if(get_option('wp-short-backup_images') !== false) {
105
  $this->_backupImages = get_option('wp-short-backup_images');
106
  } else {
@@ -690,7 +697,14 @@ class WPShortPixel {
690
  }
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
 
@@ -808,6 +822,13 @@ class WPShortPixel {
808
 
809
  $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>";
810
 
 
 
 
 
 
 
 
811
  if(isset($_POST['submit']) || isset($_POST['validate'])) {
812
 
813
  //handle API Key - common for submit and validate
@@ -816,7 +837,7 @@ class WPShortPixel {
816
  if ( strlen($_POST['key']) <> 20 )
817
  {
818
  $KeyLength = strlen($_POST['key']);
819
-
820
  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>
821
  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>.");
822
  }
@@ -857,8 +878,10 @@ class WPShortPixel {
857
  $this->_apiInterface->setCompressionType($this->_compressionType);
858
  if(isset($_POST['thumbnails'])) { $this->_processThumbnails = 1; } else { $this->_processThumbnails = 0; }
859
  if(isset($_POST['backupImages'])) { $this->_backupImages = 1; } else { $this->_backupImages = 0; }
 
860
  update_option('wp-short-process_thumbnails', $this->_processThumbnails);
861
  update_option('wp-short-backup_images', $this->_backupImages);
 
862
  }
863
  }
864
 
@@ -896,6 +919,10 @@ class WPShortPixel {
896
 
897
  $checkedBackupImages = '';
898
  if($this->_backupImages) { $checkedBackupImages = 'checked'; }
 
 
 
 
899
 
900
  $formHTML = <<< HTML
901
  <form name='wp_shortpixel_options' action='' method='post' id='wp_shortpixel_options'>
@@ -909,6 +936,7 @@ class WPShortPixel {
909
  HTML;
910
 
911
  if(!$this->_verifiedKey) {
 
912
  //if invalid key we display the link to the API Key
913
  $formHTML .= '<tr><td style="padding-left: 0px;" colspan="2">Don’t have an API Key? <a href="https://shortpixel.com/wp-apikey" target="_blank">Sign up, it’s free.</a></td></tr>';
914
  $formHTML .= '</form>';
@@ -950,6 +978,12 @@ clip art and comics.
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">
@@ -979,22 +1013,23 @@ HTML;
979
  $fileCount = number_format(get_option('wp-short-pixel-fileCount'));
980
  $savedSpace = self::formatBytes(get_option('wp-short-pixel-savedSpace'),2);
981
  $averageCompression = round(get_option('wp-short-pixel-averageCompression'),2);
982
- $savedBandwidth = self::formatBytes(get_option('wp-short-pixel-savedSpace') * 1000,2);
983
  $quotaData = $this->getQuotaInformation();
984
  if (is_numeric($quotaData['APICallsQuota'])) {
985
  $quotaData['APICallsQuota'] .= "/month";
986
  }
987
  $backupFolderSize = self::formatBytes(self::folderSize(SP_BACKUP_FOLDER));
988
- $remainingImages = (int)str_replace(',', '', $quotaData['APICallsQuota']) - (int)str_replace(',', '', $quotaData['APICallsMade']);
989
- $remainingImages = number_format($remainingImages);
990
-
991
  $statHTML = <<< HTML
992
  <a id="facts"></a>
993
  <h3>Your ShortPixel Stats</h3>
994
  <table class="form-table">
995
- <tbody><tr>
996
- <th scope="row"><label for="totalFiles">Total number of processed files:</label></th>
997
- <td>{$fileCount}</td>
 
998
  </tr>
999
  <tr>
1000
  <th scope="row"><label for="savedSpace">Saved disk space by ShortPixel</label></th>
@@ -1006,24 +1041,40 @@ HTML;
1006
  </tr>
1007
  </tbody></table>
1008
 
1009
- <p style="padding-top: 0px; color: #818181;" >* Saved bandwidth is calculated at 100,000 impressions/image</p>
 
 
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>
1017
- <td>{$quotaData['APICallsMade']}</td>
1018
  </tr>
1019
  <tr>
1020
- <th scope="row"><label for="remainingImages">Remaining images in your plan: </label></th>
1021
  <td>{$remainingImages} images</td>
1022
  </tr>
 
 
 
 
 
 
1023
  <tr>
1024
- <th scope="row"><label for="averagCompression">Average compression of your files:</label></th>
1025
- <td>$averageCompression%</td>
1026
  </tr>
 
 
 
1027
  HTML;
1028
  if($this->_backupImages) {
1029
  $statHTML .= <<< HTML
@@ -1042,7 +1093,6 @@ HTML;
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
 
@@ -1079,17 +1129,18 @@ HTML;
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' >";
1087
  if ( $this->_processThumbnails )
1088
  $message .= "<input type='checkbox' name='thumbnails' checked> Include thumbnails";
1089
  else
1090
  $message .= "<input type='checkbox' name='thumbnails'> Include thumbnails";
 
 
1091
 
1092
- $message .= "<BR><BR><input type='submit' name='bulkProcess' id='bulkProcess' class='button button-primary' value='Compress all your images'>";
1093
 
1094
  }
1095
 
@@ -1155,17 +1206,21 @@ HTML;
1155
  return $defaultData;
1156
  }
1157
 
1158
- if ( $data->APICallsMade < $data->APICallsQuota ) //reset quota exceeded flag -> user is allowed to process more images.
1159
  update_option('wp-short-pixel-quota-exceeded',0);
1160
  else
1161
  update_option('wp-short-pixel-quota-exceeded',1);//activate quota limiting
1162
-
1163
  return array(
1164
  "APIKeyValid" => true,
1165
  "APICallsMade" => number_format($data->APICallsMade) . ' images',
1166
  "APICallsQuota" => number_format($data->APICallsQuota) . ' images',
 
 
1167
  "APICallsMadeNumeric" => $data->APICallsMade,
1168
- "APICallsQuotaNumeric" => $data->APICallsQuota
 
 
1169
  );
1170
 
1171
 
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.8
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.8");
19
  define('SP_DEBUG', false);
20
  define('SP_LOG', false);
21
  define('SP_MAX_TIMEOUT', 10);
35
  private $_apiKey = '';
36
  private $_compressionType = 1;
37
  private $_processThumbnails = 1;
38
+ private $_CMYKtoRGBconversion = 1;
39
  private $_backupImages = 1;
40
  private $_verifiedKey = false;
41
 
46
 
47
  $this->setDefaultViewModeList();//set default mode as list. only @ first run
48
 
49
+ $this->_apiInterface = new shortpixel_api($this->_apiKey, $this->_compressionType, $this->_CMYKtoRGBconversion);
50
 
51
  //add hook for image upload processing
52
  add_filter( 'wp_generate_attachment_metadata', array( &$this, 'handleImageUpload' ), 10, 2 );
102
  add_option('wp-short-process_thumbnails', $this->_processThumbnails, '', 'yes' );
103
  }
104
 
105
+ if(get_option('wp-short-pixel_cmyk2rgb') !== false) {
106
+ $this->_CMYKtoRGBconversion = get_option('wp-short-pixel_cmyk2rgb');
107
+ } else {
108
+ add_option('wp-short-pixel_cmyk2rgb', $this->_CMYKtoRGBconversion, '', 'yes' );
109
+ }
110
+
111
  if(get_option('wp-short-backup_images') !== false) {
112
  $this->_backupImages = get_option('wp-short-backup_images');
113
  } else {
697
  }
698
  else
699
  {
700
+ printf($noticeHTML, '#ff0000', "<h3>Quota Exceeded</h3>
701
+ <p>
702
+ The plugin has optimized " . number_format($quotaData['APICallsMadeNumeric']) . " images and stopped because it reached the monthly limit.</p>
703
+ <p>
704
+ It’s simple to upgrade, just <a href='https://shortpixel.com/login/".$this->_apiKey."' target='_blank'>log into your account</a> and see the options in the billing page.</p>
705
+ <p>
706
+ You can immediately start processing 5,000 images/month for &#36;4,99 or <a href='https://shortpixel.com/contact' target='_blank'>contact us</a> for larger compression needs.
707
+ </p>" );
708
 
709
  return;
710
 
822
 
823
  $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>";
824
 
825
+ //by default we try to fetch the API Key from wp-config.php (if defined)
826
+ if ( !isset($_POST['submit']) && !get_option('wp-short-pixel-verifiedKey') && strlen(SHORTPIXEL_API_KEY) == 20 )
827
+ {
828
+ $_POST['validate'] = "validate";
829
+ $_POST['key'] = SHORTPIXEL_API_KEY;
830
+ }
831
+
832
  if(isset($_POST['submit']) || isset($_POST['validate'])) {
833
 
834
  //handle API Key - common for submit and validate
837
  if ( strlen($_POST['key']) <> 20 )
838
  {
839
  $KeyLength = strlen($_POST['key']);
840
+
841
  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>
842
  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>.");
843
  }
878
  $this->_apiInterface->setCompressionType($this->_compressionType);
879
  if(isset($_POST['thumbnails'])) { $this->_processThumbnails = 1; } else { $this->_processThumbnails = 0; }
880
  if(isset($_POST['backupImages'])) { $this->_backupImages = 1; } else { $this->_backupImages = 0; }
881
+ if(isset($_POST['cmyk2rgb'])) { $this->_CMYKtoRGBconversion = 1; } else { $this->_CMYKtoRGBconversion = 0; }
882
  update_option('wp-short-process_thumbnails', $this->_processThumbnails);
883
  update_option('wp-short-backup_images', $this->_backupImages);
884
+ update_option('wp-short-pixel_cmyk2rgb', $this->_CMYKtoRGBconversion);
885
  }
886
  }
887
 
919
 
920
  $checkedBackupImages = '';
921
  if($this->_backupImages) { $checkedBackupImages = 'checked'; }
922
+
923
+ $cmyk2rgb = '';
924
+ if($this->_CMYKtoRGBconversion) { $cmyk2rgb = 'checked'; }
925
+
926
 
927
  $formHTML = <<< HTML
928
  <form name='wp_shortpixel_options' action='' method='post' id='wp_shortpixel_options'>
936
  HTML;
937
 
938
  if(!$this->_verifiedKey) {
939
+
940
  //if invalid key we display the link to the API Key
941
  $formHTML .= '<tr><td style="padding-left: 0px;" colspan="2">Don’t have an API Key? <a href="https://shortpixel.com/wp-apikey" target="_blank">Sign up, it’s free.</a></td></tr>';
942
  $formHTML .= '</form>';
978
  <input name="backupImages" type="checkbox" id="backupImages" {$checkedBackupImages}> Save and keep a backup of your original images in a separate folder.
979
  </td>
980
  </tr>
981
+ <tr>
982
+ <th scope="row"><label for="backupImages">CMYK to RGB conversion</label></th>
983
+ <td>
984
+ <input name="cmyk2rgb" type="checkbox" id="cmyk2rgb" {$cmyk2rgb}>Adjust your images for computer and mobile screen display.
985
+ </td>
986
+ </tr>
987
  </tr>
988
  </tbody></table>
989
  <p class="submit">
1013
  $fileCount = number_format(get_option('wp-short-pixel-fileCount'));
1014
  $savedSpace = self::formatBytes(get_option('wp-short-pixel-savedSpace'),2);
1015
  $averageCompression = round(get_option('wp-short-pixel-averageCompression'),2);
1016
+ $savedBandwidth = self::formatBytes(get_option('wp-short-pixel-savedSpace') * 10000,2);
1017
  $quotaData = $this->getQuotaInformation();
1018
  if (is_numeric($quotaData['APICallsQuota'])) {
1019
  $quotaData['APICallsQuota'] .= "/month";
1020
  }
1021
  $backupFolderSize = self::formatBytes(self::folderSize(SP_BACKUP_FOLDER));
1022
+ $remainingImages = number_format($quotaData['APICallsQuotaNumeric'] + $quotaData['APICallsQuotaOneTimeNumeric'] - $quotaData['APICallsMadeNumeric'] - $quotaData['APICallsMadeOneTimeNumeric'] );
1023
+ $totalCallsMade = number_format($quotaData['APICallsMadeNumeric'] + $quotaData['APICallsMadeOneTimeNumeric']);
1024
+
1025
  $statHTML = <<< HTML
1026
  <a id="facts"></a>
1027
  <h3>Your ShortPixel Stats</h3>
1028
  <table class="form-table">
1029
+ <tbody>
1030
+ <tr>
1031
+ <th scope="row"><label for="averagCompression">Average compression of your files:</label></th>
1032
+ <td>$averageCompression%</td>
1033
  </tr>
1034
  <tr>
1035
  <th scope="row"><label for="savedSpace">Saved disk space by ShortPixel</label></th>
1041
  </tr>
1042
  </tbody></table>
1043
 
1044
+ <p style="padding-top: 0px; color: #818181;" >* Saved bandwidth is calculated at 10,000 impressions/image</p>
1045
+
1046
+ <h3>Your ShortPixel Plan</h3>
1047
  <table class="form-table">
1048
+ <tbody>
1049
+ <tr>
1050
+ <th scope="row" bgcolor="#ffffff"><label for="apiQuota">Your ShortPixel plan</label></th>
1051
+ <td bgcolor="#ffffff">{$quotaData['APICallsQuota']}/month ( <a href="https://shortpixel.com/login/{$this->_apiKey}" target="_blank">Need More? See the options available</a> )
1052
+ </tr>
1053
+ <tr>
1054
+ <th scope="row"><label for="usedQUota">One time credits:</label></th>
1055
+ <td>{$quotaData['APICallsQuotaOneTimeNumeric']}</td>
1056
  </tr>
1057
  <tr>
1058
  <th scope="row"><label for="usedQUota">Number of images processed this month:</label></th>
1059
+ <td>{$totalCallsMade}</td>
1060
  </tr>
1061
  <tr>
1062
+ <th scope="row"><label for="remainingImages">Remaining** images in your plan: </label></th>
1063
  <td>{$remainingImages} images</td>
1064
  </tr>
1065
+ </tbody></table>
1066
+
1067
+ <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>
1068
+
1069
+ <table class="form-table">
1070
+ <tbody>
1071
  <tr>
1072
+ <th scope="row"><label for="totalFiles">Total number of processed files:</label></th>
1073
+ <td>{$fileCount}</td>
1074
  </tr>
1075
+
1076
+
1077
+
1078
  HTML;
1079
  if($this->_backupImages) {
1080
  $statHTML .= <<< HTML
1093
  $statHTML .= <<< HTML
1094
  </tbody></table>
1095
  HTML;
 
1096
 
1097
  echo $statHTML;
1098
 
1129
  else
1130
  {
1131
  $message = "<BR>
1132
+ <p>You have ".number_format($imageCount['mainFiles'])." images in your Media Library and ".number_format($imageOnlyThumbs)." smaller thumbnails, associated to these images.</p>
1133
+ <p>Unless you uncheck the box below, <b>ShortPixel will process a total of ".number_format($imageCount['totalFiles'])." images.</b></p>";
 
1134
 
1135
  $message .= "<form action='' method='POST' >";
1136
  if ( $this->_processThumbnails )
1137
  $message .= "<input type='checkbox' name='thumbnails' checked> Include thumbnails";
1138
  else
1139
  $message .= "<input type='checkbox' name='thumbnails'> Include thumbnails";
1140
+
1141
+ $message .= "<BR><BR>Optimizing thumbnails is important for your overall website speed. However, if you don't want to optimize thumbs, please uncheck the box above.";
1142
 
1143
+ $message .= "<BR><BR><input type='submit' name='bulkProcess' id='bulkProcess' class='button button-primary' value='Start Compression'>";
1144
 
1145
  }
1146
 
1206
  return $defaultData;
1207
  }
1208
 
1209
+ if ( ( $data->APICallsMade + $data->APICallsMadeOneTime ) < ( $data->APICallsQuota + $data->APICallsQuotaOneTime ) ) //reset quota exceeded flag -> user is allowed to process more images.
1210
  update_option('wp-short-pixel-quota-exceeded',0);
1211
  else
1212
  update_option('wp-short-pixel-quota-exceeded',1);//activate quota limiting
1213
+
1214
  return array(
1215
  "APIKeyValid" => true,
1216
  "APICallsMade" => number_format($data->APICallsMade) . ' images',
1217
  "APICallsQuota" => number_format($data->APICallsQuota) . ' images',
1218
+ "APICallsMadeOneTime" => number_format($data->APICallsMadeOneTime) . ' images',
1219
+ "APICallsQuotaOneTime" => number_format($data->APICallsQuotaOneTime) . ' images',
1220
  "APICallsMadeNumeric" => $data->APICallsMade,
1221
+ "APICallsQuotaNumeric" => $data->APICallsQuota,
1222
+ "APICallsMadeOneTimeNumeric" => $data->APICallsMadeOneTime,
1223
+ "APICallsQuotaOneTimeNumeric" => $data->APICallsQuotaOneTime
1224
  );
1225
 
1226