ShortPixel Image Optimizer - Version 1.6.3

Version Description

  • fallback to http if plugin activation fails for https
  • added error mesage API Key validation fail
Download this release

Release Info

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

Code changes from version 1.6.2 to 1.6.3

Files changed (2) hide show
  1. readme.txt +6 -1
  2. wp-shortpixel.php +24 -6
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
5
  Requires at least: 3.0.0 or higher
6
  Tested up to: 4.0
7
- Stable tag: 1.6.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -107,6 +107,11 @@ The ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Co
107
 
108
  == Changelog ==
109
 
 
 
 
 
 
110
  = 1.6.2 =
111
 
112
  * extra check for images that return 3xx/4xx codes to be ignored
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
5
  Requires at least: 3.0.0 or higher
6
  Tested up to: 4.0
7
+ Stable tag: 1.6.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
107
 
108
  == Changelog ==
109
 
110
+ = 1.6.3 =
111
+
112
+ * fallback to http if plugin activation fails for https
113
+ * added error mesage API Key validation fail
114
+
115
  = 1.6.2 =
116
 
117
  * extra check for images that return 3xx/4xx codes to be ignored
wp-shortpixel.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: ShortPixel Image Optimiser
4
  * Plugin URI: https://shortpixel.com/
5
  * Description: ShortPixel is an image compression tool that helps improve your website performance. The plugin optimises 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: 1.6.2
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  */
@@ -44,7 +44,6 @@ class WPShortPixel {
44
  //add settings page
45
  add_action( 'admin_menu', array( &$this, 'registerSettingsPage' ) );
46
  add_action( 'admin_menu', array( &$this, 'registerAdminPage' ) );
47
- add_action( 'admin_notices', array( &$this, 'displayNotice' ) );
48
  add_action( 'delete_attachment', array( &$this, 'handleDeleteAttachmentInBackup' ) );
49
 
50
  //automatic optimization
@@ -373,7 +372,6 @@ class WPShortPixel {
373
  }
374
 
375
  if($_POST["bulkProcess"]) {
376
- $imageLog = array();
377
  //remove all ShortPixel data from metadata
378
  foreach($attachments as $attachment) {
379
  if(exif_imagetype(get_attached_file($attachment->ID)) == false) continue;
@@ -381,6 +379,24 @@ class WPShortPixel {
381
  $meta['ShortPixel']['BulkProcessing'] = true;
382
  wp_update_attachment_metadata($attachment->ID, $meta);
383
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
  update_option('bulkProcessingStatus', 'running');
385
  }
386
 
@@ -653,8 +669,6 @@ Currently, you have {$imageCount} images in your library. </br>
653
  HTML;
654
  }
655
 
656
- public function displayNotice() {
657
- }
658
 
659
  public function getQuotaInformation($apiKey = null, $appendUserAgent = false) {
660
 
@@ -669,9 +683,13 @@ HTML;
669
  $args = array('timeout'=> SP_MAX_TIMEOUT, 'sslverify' => false);
670
  $response = wp_remote_get($requestURL, $args);
671
 
 
 
 
 
672
  $defaultData = array(
673
  "APIKeyValid" => false,
674
- "Message" => '',
675
  "APICallsMade" => 'Information unavailable. Please check your API key.',
676
  "APICallsQuota" => 'Information unavailable. Please check your API key.');
677
 
3
  * Plugin Name: ShortPixel Image Optimiser
4
  * Plugin URI: https://shortpixel.com/
5
  * Description: ShortPixel is an image compression tool that helps improve your website performance. The plugin optimises 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: 1.6.3
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  */
44
  //add settings page
45
  add_action( 'admin_menu', array( &$this, 'registerSettingsPage' ) );
46
  add_action( 'admin_menu', array( &$this, 'registerAdminPage' ) );
 
47
  add_action( 'delete_attachment', array( &$this, 'handleDeleteAttachmentInBackup' ) );
48
 
49
  //automatic optimization
372
  }
373
 
374
  if($_POST["bulkProcess"]) {
 
375
  //remove all ShortPixel data from metadata
376
  foreach($attachments as $attachment) {
377
  if(exif_imagetype(get_attached_file($attachment->ID)) == false) continue;
379
  $meta['ShortPixel']['BulkProcessing'] = true;
380
  wp_update_attachment_metadata($attachment->ID, $meta);
381
  }
382
+
383
+ //break this in separate foreach in order to easily comment it out if performance issues
384
+ // foreach($attachments as $attachment) {
385
+ // if(exif_imagetype(get_attached_file($attachment->ID)) == false) continue;
386
+ // $meta = wp_get_attachment_metadata($attachment->ID);
387
+ // $url = wp_get_attachment_url($attachment->ID);
388
+ // $path = get_attached_file($attachment->ID);
389
+ // $this->_apiInterface->doRequests($url, $path, $attachment->ID);
390
+ //
391
+ // if($this->_processThumbnails && !empty($meta['sizes'])) {
392
+ // foreach($meta['sizes'] as $thumbnailInfo) {
393
+ // $thumbURL = str_replace(basename($url), $thumbnailInfo['file'], $url);
394
+ // $thumbPath = str_replace(basename($path), $thumbnailInfo['file'], $path);
395
+ // $this->_apiInterface->doRequests($thumbURL, $thumbPath);
396
+ // }
397
+ // }
398
+ // }
399
+
400
  update_option('bulkProcessingStatus', 'running');
401
  }
402
 
669
  HTML;
670
  }
671
 
 
 
672
 
673
  public function getQuotaInformation($apiKey = null, $appendUserAgent = false) {
674
 
683
  $args = array('timeout'=> SP_MAX_TIMEOUT, 'sslverify' => false);
684
  $response = wp_remote_get($requestURL, $args);
685
 
686
+ if(is_wp_error( $response )) {
687
+ $response = wp_remote_get(str_replace('https://', 'http://', $requestURL), $args);
688
+ }
689
+
690
  $defaultData = array(
691
  "APIKeyValid" => false,
692
+ "Message" => 'API Key could not be validated. Could not connect Shortpixel service.',
693
  "APICallsMade" => 'Information unavailable. Please check your API key.',
694
  "APICallsQuota" => 'Information unavailable. Please check your API key.');
695