ShortPixel Image Optimizer - Version 3.1.8

Version Description

  • fix reloading bulk page on quota used up
Download this release

Release Info

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

Code changes from version 3.1.7 to 3.1.8

css/short-pixel.css CHANGED
@@ -28,6 +28,12 @@ li.shortpixel-toolbar-processing.shortpixel-alert > a.ab-item > div,
28
  #wpadminbar li.shortpixel-toolbar-processing.shortpixel-alert > a.ab-item > div{
29
  background-image: none;
30
  }
 
 
 
 
 
 
31
  li.shortpixel-hide {
32
  display:none;
33
  }
28
  #wpadminbar li.shortpixel-toolbar-processing.shortpixel-alert > a.ab-item > div{
29
  background-image: none;
30
  }
31
+ .sp-quota-exceeded-alert {
32
+ background-color: #fff;
33
+ border-left: 4px solid #ff0000;
34
+ box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
35
+ padding: 1px 12px;
36
+ }
37
  li.shortpixel-hide {
38
  display:none;
39
  }
js/short-pixel.js CHANGED
@@ -53,15 +53,18 @@ function showToolBarAlert($status, $message) {
53
  var robo = jQuery("li.shortpixel-toolbar-processing");
54
  switch($status) {
55
  case ShortPixel.STATUS_QUOTA_EXCEEDED:
56
- if(window.location.href.search("wp-short-pixel-bulk") > 0) { //if we're in bulk reload to see all options
 
57
  location.reload();
58
  return;
59
  }
60
  robo.addClass("shortpixel-alert");
61
  robo.addClass("shortpixel-quota-exceeded");
62
- jQuery("a", robo).attr("href", "http://shortpixel.com/login/" + ShortPixel.API_KEY);
63
- jQuery("a", robo).attr("target", "_blank");
64
- jQuery("a div", robo).attr("title", "ShortPixel quota exceeded. Click to top-up");
 
 
65
  break;
66
  case ShortPixel.STATUS_FAIL:
67
  robo.addClass("shortpixel-alert shortpixel-processing");
53
  var robo = jQuery("li.shortpixel-toolbar-processing");
54
  switch($status) {
55
  case ShortPixel.STATUS_QUOTA_EXCEEDED:
56
+ if( window.location.href.search("wp-short-pixel-bulk") > 0
57
+ && jQuery(".sp-quota-exceeded-alert").length == 0) { //if we're in bulk and the alert is not displayed reload to see all options
58
  location.reload();
59
  return;
60
  }
61
  robo.addClass("shortpixel-alert");
62
  robo.addClass("shortpixel-quota-exceeded");
63
+ //jQuery("a", robo).attr("href", "http://shortpixel.com/login/" + ShortPixel.API_KEY);
64
+ jQuery("a", robo).attr("href", "options-general.php?page=wp-shortpixel");
65
+ //jQuery("a", robo).attr("target", "_blank");
66
+ //jQuery("a div", robo).attr("title", "ShortPixel quota exceeded. Click to top-up");
67
+ jQuery("a div", robo).attr("title", "ShortPixel quota exceeded. Click for details.");
68
  break;
69
  case ShortPixel.STATUS_FAIL:
70
  robo.addClass("shortpixel-alert shortpixel-processing");
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.4
8
- Stable tag: 3.1.7
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -168,6 +168,10 @@ The ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Co
168
 
169
  == Changelog ==
170
 
 
 
 
 
171
  = 3.1.7 =
172
 
173
  * bugfixes
5
 
6
  Requires at least: 3.0.1
7
  Tested up to: 4.4
8
+ Stable tag: 3.1.8
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
168
 
169
  == Changelog ==
170
 
171
+ = 3.1.8 =
172
+
173
+ * fix reloading bulk page on quota used up
174
+
175
  = 3.1.7 =
176
 
177
  * bugfixes
shortpixel_view.php CHANGED
@@ -16,7 +16,7 @@ class ShortPixelView {
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 <strong><?=number_format($quotaData['APICallsMadeNumeric'] + $quotaData['APICallsMadeOneTimeNumeric'])?> images</strong> and stopped because it reached the available quota limit.
22
  <?php if($quotaData['totalProcessedFiles'] < $quotaData['totalFiles']) { ?>
16
  public function displayQuotaExceededAlert($quotaData)
17
  { ?>
18
  <br/>
19
+ <div class="wrap sp-quota-exceeded-alert">
20
  <h3>Quota Exceeded</h3>
21
  <p>The plugin has optimized <strong><?=number_format($quotaData['APICallsMadeNumeric'] + $quotaData['APICallsMadeOneTimeNumeric'])?> images</strong> and stopped because it reached the available quota limit.
22
  <?php if($quotaData['totalProcessedFiles'] < $quotaData['totalFiles']) { ?>
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.1.7
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  */
@@ -21,7 +21,7 @@ define('SP_RESET_ON_ACTIVATE', false); //if true TODO set false
21
 
22
  define('SP_AFFILIATE_CODE', '');
23
 
24
- define('PLUGIN_VERSION', "3.1.7");
25
  define('SP_MAX_TIMEOUT', 10);
26
  define('SP_VALIDATE_MAX_TIMEOUT', 60);
27
  define('SP_BACKUP', 'ShortpixelBackups');
@@ -76,7 +76,9 @@ class WPShortPixel {
76
  $this->prioQ = new ShortPixelQueue($this);
77
  $this->view = new ShortPixelView($this);
78
 
79
- define('QUOTA_EXCEEDED', "Quota Exceeded. <a class='button button-smaller button-primary' href='https://shortpixel.com/login/".$this->_apiKey."' target='_blank'>Extend Quota</a>");
 
 
80
 
81
  $this->setDefaultViewModeList();//set default mode as list. only @ first run
82
 
@@ -102,6 +104,8 @@ class WPShortPixel {
102
  add_action( 'wp_ajax_shortpixel_dismiss_notice', array(&$this, 'dismissAdminNotice'));
103
  //backup restore
104
  add_action('admin_action_shortpixel_restore_backup', array(&$this, 'handleRestoreBackup'));
 
 
105
 
106
  //This adds the constants used in PHP to be available also in JS
107
  add_action( 'admin_footer', array( &$this, 'shortPixelJS') );
@@ -272,9 +276,10 @@ class WPShortPixel {
272
  self::log("TOOLBAR: Quota exceeded: " . self::getOpt( 'wp-short-pixel-quota-exceeded', 0));
273
  if(self::getOpt( 'wp-short-pixel-quota-exceeded', 0)) {
274
  $extraClasses = " shortpixel-alert shortpixel-quota-exceeded";
275
- $tooltip = "ShortPixel quota exceeded. Click to top-up";
276
- $link = "http://shortpixel.com/login/" . $this->_apiKey;
277
- $blank = '_blank';
 
278
  //$icon = "shortpixel-alert.png";
279
  }
280
  $lastStatus = self::getOpt( 'wp-short-pixel-bulk-last-status', array('Status' => ShortPixelAPI::STATUS_SUCCESS));
@@ -537,9 +542,10 @@ class WPShortPixel {
537
  $filePath = explode("/", $meta["file"]);
538
  $uploadsUrl = content_url() . "/uploads/";
539
  $urlPath = implode("/", array_slice($filePath, 0, count($filePath) - 1));
 
540
  $thumb = (isset($meta["sizes"]["medium"]) ? $meta["sizes"]["medium"]["file"] : (isset($meta["sizes"]["thumbnail"]) ? $meta["sizes"]["thumbnail"]["file"]: ""));
541
  if(strlen($thumb) && get_option('wp-short-backup_images') && $this->_processThumbnails) {
542
- $bkThumb = $uploadsUrl . SP_BACKUP . "/" . $urlPath . "/" . $thumb;
543
  }
544
  if(strlen($thumb)) {
545
  $thumb = $uploadsUrl . $urlPath . "/" . $thumb;
@@ -643,7 +649,17 @@ class WPShortPixel {
643
  wp_redirect($sendback);
644
  // we are done
645
  }
646
-
 
 
 
 
 
 
 
 
 
 
647
 
648
  public function handleDeleteAttachmentInBackup($ID) {
649
  $file = get_attached_file($ID);
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.1.8
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  */
21
 
22
  define('SP_AFFILIATE_CODE', '');
23
 
24
+ define('PLUGIN_VERSION', "3.1.8");
25
  define('SP_MAX_TIMEOUT', 10);
26
  define('SP_VALIDATE_MAX_TIMEOUT', 60);
27
  define('SP_BACKUP', 'ShortpixelBackups');
76
  $this->prioQ = new ShortPixelQueue($this);
77
  $this->view = new ShortPixelView($this);
78
 
79
+ define('QUOTA_EXCEEDED', "Quota Exceeded. <a class='button button-smaller button-primary' href='https://shortpixel.com/login/"
80
+ .$this->_apiKey."' target='_blank'>Extend Quota</a>"
81
+ ."<a class='button button-smaller' href='admin.php?action=shortpixel_check_quota' target='_blank'>Check&nbsp;&nbsp;Quota</a>");
82
 
83
  $this->setDefaultViewModeList();//set default mode as list. only @ first run
84
 
104
  add_action( 'wp_ajax_shortpixel_dismiss_notice', array(&$this, 'dismissAdminNotice'));
105
  //backup restore
106
  add_action('admin_action_shortpixel_restore_backup', array(&$this, 'handleRestoreBackup'));
107
+ //backup restore
108
+ add_action('admin_action_shortpixel_check_quota', array(&$this, 'handleCheckQuota'));
109
 
110
  //This adds the constants used in PHP to be available also in JS
111
  add_action( 'admin_footer', array( &$this, 'shortPixelJS') );
276
  self::log("TOOLBAR: Quota exceeded: " . self::getOpt( 'wp-short-pixel-quota-exceeded', 0));
277
  if(self::getOpt( 'wp-short-pixel-quota-exceeded', 0)) {
278
  $extraClasses = " shortpixel-alert shortpixel-quota-exceeded";
279
+ $tooltip = "ShortPixel quota exceeded. Click for details.";
280
+ //$link = "http://shortpixel.com/login/" . $this->_apiKey;
281
+ $link = "options-general.php?page=wp-shortpixel";
282
+ //$blank = '_blank';
283
  //$icon = "shortpixel-alert.png";
284
  }
285
  $lastStatus = self::getOpt( 'wp-short-pixel-bulk-last-status', array('Status' => ShortPixelAPI::STATUS_SUCCESS));
542
  $filePath = explode("/", $meta["file"]);
543
  $uploadsUrl = content_url() . "/uploads/";
544
  $urlPath = implode("/", array_slice($filePath, 0, count($filePath) - 1));
545
+ $urlBkPath = $this->_apiInterface->returnSubDir(get_attached_file($ID));
546
  $thumb = (isset($meta["sizes"]["medium"]) ? $meta["sizes"]["medium"]["file"] : (isset($meta["sizes"]["thumbnail"]) ? $meta["sizes"]["thumbnail"]["file"]: ""));
547
  if(strlen($thumb) && get_option('wp-short-backup_images') && $this->_processThumbnails) {
548
+ $bkThumb = $uploadsUrl . SP_BACKUP . "/" . $urlBkPath . "/" . $thumb;
549
  }
550
  if(strlen($thumb)) {
551
  $thumb = $uploadsUrl . $urlPath . "/" . $thumb;
649
  wp_redirect($sendback);
650
  // we are done
651
  }
652
+
653
+ public function handleCheckQuota() {
654
+ $this->getQuotaInformation();
655
+ // store the referring webpage location
656
+ $sendback = wp_get_referer();
657
+ // sanitize the referring webpage location
658
+ $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
659
+ // send the user back where they came from
660
+ wp_redirect($sendback);
661
+ // we are done
662
+ }
663
 
664
  public function handleDeleteAttachmentInBackup($ID) {
665
  $file = get_attached_file($ID);