ShortPixel Image Optimizer - Version 4.16.3

Version Description

Release date: 9th March 2020 * Fix missing button to choose a plan when running out of credits. * Language 0 new strings added, 0 updated, 0 fuzzied, and 0 obsoleted

Download this release

Release Info

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

Code changes from version 4.16.2 to 4.16.3

build/shortpixel/notices/src/NoticeModel.php CHANGED
@@ -179,7 +179,7 @@ class NoticeModel //extends ShortPixelModel
179
 
180
  // $data_string = "{action:'$this->notice_action'}";
181
 
182
- $js = "jQuery(document).on('click','#$this->id button',
183
  function() {
184
  var data = $data;
185
  var url = $url;
179
 
180
  // $data_string = "{action:'$this->notice_action'}";
181
 
182
+ $js = "jQuery(document).on('click','#$this->id button .notice-dismiss',
183
  function() {
184
  var data = $data;
185
  var url = $url;
class/controller/adminnotices_controller.php CHANGED
@@ -77,8 +77,10 @@ class adminNoticesController extends ShortPixelController
77
  $this->doCompatNotices();
78
  $this->doUnlistedNotices();
79
  $this->doQuotaNotices();
 
80
  }
81
 
 
82
  /** Load the various messages about the lack of API-keys in the plugin */
83
  protected function doAPINotices()
84
  {
@@ -300,6 +302,7 @@ class adminNoticesController extends ShortPixelController
300
  {
301
  $message = '<p>' . sprintf(__("You currently have <strong>%d images and thumbnails to optimize</strong> but you only have <strong>%d images</strong> available in your current plan."
302
  . " You might need to upgrade your plan in order to have all your images optimized.", 'shortpixel-image-optimiser'), $extra['filesTodo'], $extra['quotaAvailable']) . '</p>';
 
303
  $message .= $this->proposeUpgradePopup();
304
  //self::includeProposeUpgradePopup();
305
  return $message;
@@ -309,6 +312,7 @@ class adminNoticesController extends ShortPixelController
309
  {
310
  $message = '<p>' . sprintf(__("You are adding an average of <strong>%d images and thumbnails every month</strong> to your Media Library and you have <strong>a plan of %d images/month</strong>."
311
  . " You might need to upgrade your plan in order to have all your images optimized.", 'shortpixel-image-optimiser'), $extra['monthAvg'], $extra['monthlyQuota']) . '</p>';
 
312
  $message .= $this->proposeUpgradePopup();
313
  return $message;
314
  }
77
  $this->doCompatNotices();
78
  $this->doUnlistedNotices();
79
  $this->doQuotaNotices();
80
+
81
  }
82
 
83
+
84
  /** Load the various messages about the lack of API-keys in the plugin */
85
  protected function doAPINotices()
86
  {
302
  {
303
  $message = '<p>' . sprintf(__("You currently have <strong>%d images and thumbnails to optimize</strong> but you only have <strong>%d images</strong> available in your current plan."
304
  . " You might need to upgrade your plan in order to have all your images optimized.", 'shortpixel-image-optimiser'), $extra['filesTodo'], $extra['quotaAvailable']) . '</p>';
305
+ $message .= ' <button class="button button-primary" id="shortpixel-upgrade-advice" onclick="ShortPixel.proposeUpgrade()" style="margin-right:10px;"><strong>' . __('Show me the best available options', 'shortpixel-image-optimiser') . '</strong></button>';
306
  $message .= $this->proposeUpgradePopup();
307
  //self::includeProposeUpgradePopup();
308
  return $message;
312
  {
313
  $message = '<p>' . sprintf(__("You are adding an average of <strong>%d images and thumbnails every month</strong> to your Media Library and you have <strong>a plan of %d images/month</strong>."
314
  . " You might need to upgrade your plan in order to have all your images optimized.", 'shortpixel-image-optimiser'), $extra['monthAvg'], $extra['monthlyQuota']) . '</p>';
315
+ $message .= ' <button class="button button-primary" id="shortpixel-upgrade-advice" onclick="ShortPixel.proposeUpgrade()" style="margin-right:10px;"><strong>' . __('Show me the best available options', 'shortpixel-image-optimiser') . '</strong></button>';
316
  $message .= $this->proposeUpgradePopup();
317
  return $message;
318
  }
class/view/settings/part-general.php CHANGED
@@ -6,7 +6,7 @@
6
 
7
  <div class="wp-shortpixel-options wp-shortpixel-tab-content" style="visibility: hidden">
8
 
9
- <p><?php printf(__('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="%supload.php?page=wp-short-pixel-bulk">Bulk Optimization Tool</a>.','shortpixel-image-optimiser'),get_admin_url());?></p>
10
  <table class="form-table">
11
  <tbody>
12
  <tr>
6
 
7
  <div class="wp-shortpixel-options wp-shortpixel-tab-content" style="visibility: hidden">
8
 
9
+
10
  <table class="form-table">
11
  <tbody>
12
  <tr>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: compressor, image, compression, optimize, image optimizer, image optimiser
4
  Requires at least: 3.2.0
5
  Tested up to: 5.3
6
  Requires PHP: 5.3
7
- Stable tag: 4.16.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -34,7 +34,7 @@ Make an instant <a href="http://shortpixel.com/image-compression-test" target="_
34
  * option to automatically convert PNG to JPG if that will result in smaller images. Ideal for large images in PNG format.
35
  * no file size limit
36
  * option to freely convert any JPEG, PNG or GIF (even animated ones!) to **WebP** for more Google love. <a href="http://blog.shortpixel.com/how-webp-images-can-speed-up-your-site/" target="_blank">How to enable WebP?</a>
37
- * option to include the generated WebP images into the front-end pages by using the &lt;picture&gt; tag instead of &lt;img&gt;
38
  * compatible with WP Retina 2x - all **retina images** are automatically compressed. <a href="http://blog.shortpixel.com/how-to-use-optimized-retina-images-on-your-wordpress-site-for-best-user-experience-on-apple-devices/" target="_blank">How to benefit from Retina displays?</a>
39
  * optimize thumbnails as well as featured images. You can also **select individual thumbnails to exclude** from optimization.
40
  * ability to optimize any image on your site including images in **NextGEN Gallery** and any other image galleries or sliders
@@ -91,7 +91,7 @@ Help us spread the word by recommending ShortPixel to your friends and collect *
91
  Let's get ShortPixel plugin running on your WordPress website:
92
 
93
 
94
- 1. Sign up using your email at https://shortpixel.com/wp-apikey
95
  2. You will receive your personal API key in a confirmation email, to the address you provided.
96
  3. Upload the ShortPixel plugin to the /wp-content/plugins/ directory
97
  4. Use your unique API key to activate ShortPixel plugin in the 'Plugins' menu in WordPress.
@@ -151,15 +151,17 @@ Let's get ShortPixel plugin running on your WordPress website:
151
 
152
  = How do I activate the API key on a multisite? =
153
  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.
154
- As an alternative, you can edit wp-config.php and add this line
155
- define(‘SHORTPIXEL_API_KEY’, ‘APIKEY’)
156
- where APIKEY’ is the API Key received upon sign up.
 
157
  If configured that way, the API key will be used for all the sites of the multisite but will only be visible on the main site’s Settings page, being hidden for the rest of the sites.
158
 
159
  = I am not the only one working in the WordPress Dashboard. How can I hide my API key? =
160
  There is a simple way to hide the API key, all you need to do is to add these two lines in your wp-config.php:
161
- define('SHORTPIXEL_API_KEY', '<<your api key here>>');
162
- define('SHORTPIXEL_HIDE_API_KEY', true);
 
163
 
164
  = How much is a credit? =
165
  A credit is used each time ShortPixel optimizes an image or thumbnail by at least 5%. If we're not able to optimize an image or thumbnail by at least 5% then no credit will be used :-)
@@ -213,34 +215,49 @@ The ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Co
213
  == Actions and Filters for Developers ==
214
 
215
  The ShortPixel Image Optimiser plugin calls the following actions and filters:
216
- > do_action( 'shortpixel_image_optimised', $post_id ); //upon successful optimization
217
 
218
- > do_action("shortpixel_before_restore_image", $post_id); //before restoring an image from backup
 
 
 
 
219
 
220
- > do_action("shortpixel_after_restore_image", $post_id); //after succesful restore
 
221
 
222
- > apply_filters("shortpixel_backup_folder", $backup_folder, $main_file_path, $sizes); //just before returning the ShortPixel backup folder, usually /wp-content/uploads/ShortpixelBackups. The $sizes are the sizes array from metadata.
 
223
 
224
- > apply_filters('shortpixel_image_exists', file_exists($path), $path, $post_id); //post ID is not always set, only if it's an image from Media Library
 
225
 
226
- > apply_filters('shortpixel_image_urls', $URLs, $post_id) // filters the URLs that will be sent to optimization, $URLs is a plain array
 
227
 
228
- > apply_filters('shortpixel/db/chunk_size', $chunk); //the $chunk is the value ShortPixel chooses to use as number of selected records in one query (based on total table size), some hosts work better with a different value
 
229
 
230
  In order to define custom thumbnails to be picked up by the optimization you have two options, both comma separated defines:
231
 
232
- define('SHORTPIXEL_CUSTOM_THUMB_SUFFIXES', '_tl,_tr'); will handle custom thumbnails like image-100x100_tl.jpg
 
 
 
 
 
 
 
233
 
234
- define('SHORTPIXEL_CUSTOM_THUMB_INFIXES', '-uae'); will handle custom thumbnails like image-uae-100x100.jpg
235
- define('SHORTPIXEL_USE_DOUBLE_WEBP_EXTENSION', true); will tell the plugin to create double extensions for the WebP image counterparts, for example image.jpg.webp for image.jpg
236
 
237
- define("SHORTPIXEL_NOFLOCK", true); // don't use flock queue, only activate this when you have flock() denied errors on your installation.
238
- .
239
- define("SHORTPIXEL_EXPERIMENTAL_SECURICACHE", true); // adds timestamps to URLS, to prevent hitting the cache. Useful for persistent caches.
240
 
241
- //Hide the Cloudflare settings by defining these constants in wp-config.php
242
- define('SHORTPIXEL_CFTOKEN', 'the Cloudflare API token that has Purge Cache right');
243
- define('SHORTPIXEL_CFZONE', 'The Zone ID from the domain settings in Cloudflare');
 
244
 
245
  == Screenshots ==
246
 
@@ -264,6 +281,12 @@ define('SHORTPIXEL_CFZONE', 'The Zone ID from the domain settings in Cloudflare'
264
 
265
  == Changelog ==
266
 
 
 
 
 
 
 
267
  = 4.16.2 =
268
 
269
  Release date: 27th February 2020
@@ -364,7 +387,7 @@ Release date: 27th November 2019
364
  = 4.14.6 =
365
 
366
  Release date: 9th October 2019
367
- * Don't convert to &lt;picture&gt; the &lt;img&gt;s with backgrounds.
368
  * Remove unused eval() call.
369
  * Restore the validate button next to API Key but change label to "Save and validate"
370
  * Fixed: PNGtoJPG issue with already uploaded images
@@ -401,11 +424,11 @@ Release date: 19th August 2019
401
  * Fixed: Warning: count() Parameter must be an array.
402
  * Language – 0 new strings added, 0 updated, 0 fuzzied, and 0 obsoleted
403
 
404
- == 4.14.3 ==
405
 
406
  Release date: 22nd July 2019
407
  * Compatibility with Flywheel hosting by not using flock if Flywheel detected
408
- * When using the PICTURE tag to deliver WebP, keep the width and height at <IMG> level
409
  * Refactoring of the API Key settings page, refactoring of Other media
410
  * Performance improvements for selecting from large wp_posts and wp_postmeta tables when doing bulk optimization
411
  * Display a message when bulk is skipping many processed images, if bulk processing is ran again.
@@ -414,17 +437,17 @@ Release date: 22nd July 2019
414
  * Conflict message: align the text vertically and provide space between text and button when displayed on any admin page
415
  * Fixed: Other media Restore fails when original file is readable, not writable
416
 
417
- == 4.14.2 ==
418
 
419
  Release date: 1st July 2019
420
  * add the possibility to define custom infixes for thumbnails (like image-uai-150x150.jpg for image.jpg) - comma separated define SHORTPIXEL_CUSTOM_THUMB_INFIXES
421
 
422
- == 4.14.1 ==
423
 
424
  Release date: 17th June 2019
425
  * Fix errors when DOMDocument not present
426
 
427
- == 4.14.0 ==
428
 
429
  Release date: 17th June 2019
430
  * Add new filters proposed by WP Stateless: shortpixel_backup_folder, shortpixel_image_exists, shortpixel_image_urls
4
  Requires at least: 3.2.0
5
  Tested up to: 5.3
6
  Requires PHP: 5.3
7
+ Stable tag: 4.16.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
34
  * option to automatically convert PNG to JPG if that will result in smaller images. Ideal for large images in PNG format.
35
  * no file size limit
36
  * option to freely convert any JPEG, PNG or GIF (even animated ones!) to **WebP** for more Google love. <a href="http://blog.shortpixel.com/how-webp-images-can-speed-up-your-site/" target="_blank">How to enable WebP?</a>
37
+ * option to include the generated WebP images into the front-end pages by using the `<picture>` tag instead of `<img>`
38
  * compatible with WP Retina 2x - all **retina images** are automatically compressed. <a href="http://blog.shortpixel.com/how-to-use-optimized-retina-images-on-your-wordpress-site-for-best-user-experience-on-apple-devices/" target="_blank">How to benefit from Retina displays?</a>
39
  * optimize thumbnails as well as featured images. You can also **select individual thumbnails to exclude** from optimization.
40
  * ability to optimize any image on your site including images in **NextGEN Gallery** and any other image galleries or sliders
91
  Let's get ShortPixel plugin running on your WordPress website:
92
 
93
 
94
+ 1. Sign up using your email at <a href="https://shortpixel.com/wp-apikey" target="_blank">https://shortpixel.com/wp-apikey</a>.
95
  2. You will receive your personal API key in a confirmation email, to the address you provided.
96
  3. Upload the ShortPixel plugin to the /wp-content/plugins/ directory
97
  4. Use your unique API key to activate ShortPixel plugin in the 'Plugins' menu in WordPress.
151
 
152
  = How do I activate the API key on a multisite? =
153
  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.
154
+ As an alternative, you can edit wp-config.php and add this line:
155
+
156
+ `define('SHORTPIXEL_API_KEY', 'APIKEY');`
157
+ where `APIKEY` is the API Key received upon sign up.
158
  If configured that way, the API key will be used for all the sites of the multisite but will only be visible on the main site’s Settings page, being hidden for the rest of the sites.
159
 
160
  = I am not the only one working in the WordPress Dashboard. How can I hide my API key? =
161
  There is a simple way to hide the API key, all you need to do is to add these two lines in your wp-config.php:
162
+
163
+ `define('SHORTPIXEL_API_KEY', '<<your api key here>>');`
164
+ `define('SHORTPIXEL_HIDE_API_KEY', true);`
165
 
166
  = How much is a credit? =
167
  A credit is used each time ShortPixel optimizes an image or thumbnail by at least 5%. If we're not able to optimize an image or thumbnail by at least 5% then no credit will be used :-)
215
  == Actions and Filters for Developers ==
216
 
217
  The ShortPixel Image Optimiser plugin calls the following actions and filters:
 
218
 
219
+ `do_action( 'shortpixel_image_optimised', $post_id );`
220
+ upon successful optimization;
221
+
222
+ `do_action("shortpixel_before_restore_image", $post_id);`
223
+ before restoring an image from backup;
224
 
225
+ `do_action("shortpixel_after_restore_image", $post_id);`
226
+ after succesful restore;
227
 
228
+ `apply_filters("shortpixel_backup_folder", $backup_folder, $main_file_path, $sizes);`
229
+ just before returning the ShortPixel backup folder, usually /wp-content/uploads/ShortpixelBackups. The `$sizes` are the sizes array from metadata;
230
 
231
+ `apply_filters('shortpixel_image_exists', file_exists($path), $path, $post_id);`
232
+ post ID is not always set, only if it's an image from Media Library;
233
 
234
+ `apply_filters('shortpixel_image_urls', $URLs, $post_id);`
235
+ filters the URLs that will be sent to optimization, `$URLs` is a plain array;
236
 
237
+ `apply_filters('shortpixel/db/chunk_size', $chunk);`
238
+ the `$chunk` is the value ShortPixel chooses to use as number of selected records in one query (based on total table size), some hosts work better with a different value;
239
 
240
  In order to define custom thumbnails to be picked up by the optimization you have two options, both comma separated defines:
241
 
242
+ `define('SHORTPIXEL_CUSTOM_THUMB_SUFFIXES', '_tl,_tr');`
243
+ will handle custom thumbnails like image-100x100_tl.jpg;
244
+
245
+ `define('SHORTPIXEL_CUSTOM_THUMB_INFIXES', '-uae');`
246
+ will handle custom thumbnails like image-uae-100x100.jpg;
247
+
248
+ `define('SHORTPIXEL_USE_DOUBLE_WEBP_EXTENSION', true);`
249
+ will tell the plugin to create double extensions for the WebP image counterparts, for example image.jpg.webp for image.jpg;
250
 
251
+ `define("SHORTPIXEL_NOFLOCK", true);`
252
+ don't use flock queue, only activate this when you have `flock()` denied errors on your installation;
253
 
254
+ `define("SHORTPIXEL_EXPERIMENTAL_SECURICACHE", true);`
255
+ adds timestamps to URLS, to prevent hitting the cache. Useful for persistent caches.
 
256
 
257
+ Hide the Cloudflare settings by defining these constants in wp-config.php:
258
+
259
+ `define('SHORTPIXEL_CFTOKEN', 'the Cloudflare API token that has Purge Cache right');`
260
+ `define('SHORTPIXEL_CFZONE', 'The Zone ID from the domain settings in Cloudflare');`
261
 
262
  == Screenshots ==
263
 
281
 
282
  == Changelog ==
283
 
284
+ = 4.16.3 =
285
+
286
+ Release date: 9th March 2020
287
+ * Fix missing button to choose a plan when running out of credits.
288
+ * Language – 0 new strings added, 0 updated, 0 fuzzied, and 0 obsoleted
289
+
290
  = 4.16.2 =
291
 
292
  Release date: 27th February 2020
387
  = 4.14.6 =
388
 
389
  Release date: 9th October 2019
390
+ * Don't convert to <picture> the <img>s with backgrounds.
391
  * Remove unused eval() call.
392
  * Restore the validate button next to API Key but change label to "Save and validate"
393
  * Fixed: PNGtoJPG issue with already uploaded images
424
  * Fixed: Warning: count() Parameter must be an array.
425
  * Language – 0 new strings added, 0 updated, 0 fuzzied, and 0 obsoleted
426
 
427
+ = 4.14.3 =
428
 
429
  Release date: 22nd July 2019
430
  * Compatibility with Flywheel hosting by not using flock if Flywheel detected
431
+ * When using the PICTURE tag to deliver WebP, keep the width and height at `<IMG>` level
432
  * Refactoring of the API Key settings page, refactoring of Other media
433
  * Performance improvements for selecting from large wp_posts and wp_postmeta tables when doing bulk optimization
434
  * Display a message when bulk is skipping many processed images, if bulk processing is ran again.
437
  * Conflict message: align the text vertically and provide space between text and button when displayed on any admin page
438
  * Fixed: Other media Restore fails when original file is readable, not writable
439
 
440
+ = 4.14.2 =
441
 
442
  Release date: 1st July 2019
443
  * add the possibility to define custom infixes for thumbnails (like image-uai-150x150.jpg for image.jpg) - comma separated define SHORTPIXEL_CUSTOM_THUMB_INFIXES
444
 
445
+ = 4.14.1 =
446
 
447
  Release date: 17th June 2019
448
  * Fix errors when DOMDocument not present
449
 
450
+ = 4.14.0 =
451
 
452
  Release date: 17th June 2019
453
  * Add new filters proposed by WP Stateless: shortpixel_backup_folder, shortpixel_image_exists, shortpixel_image_urls
shortpixel-plugin.php CHANGED
@@ -237,6 +237,14 @@ class ShortPixelPlugin
237
  foreach($notices as $notice)
238
  {
239
  echo $notice->getForDisplay();
 
 
 
 
 
 
 
 
240
  }
241
  }
242
  }
237
  foreach($notices as $notice)
238
  {
239
  echo $notice->getForDisplay();
240
+
241
+ if ($notice->getID() == adminNoticesController::MSG_QUOTA_REACHED || $notice->getID() == adminNoticesController::MSG_UPGRADE_MONTH
242
+ || $notice->getID() == adminNoticesController::MSG_UPGRADE_BULK)
243
+ {
244
+ wp_enqueue_script('jquery.knob.min.js');
245
+ wp_enqueue_script('jquery.tooltip.min.js');
246
+ wp_enqueue_script('shortpixel');
247
+ }
248
  }
249
  }
250
  }
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-settings" target="_blank">Settings &gt; ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
6
- * Version: 4.16.2
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  * Text Domain: shortpixel-image-optimiser
@@ -19,7 +19,7 @@ define('SHORTPIXEL_PLUGIN_DIR', __DIR__);
19
 
20
  //define('SHORTPIXEL_AFFILIATE_CODE', '');
21
 
22
- define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.16.2");
23
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
24
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
25
  define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');
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-settings" target="_blank">Settings &gt; ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
6
+ * Version: 4.16.3
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  * Text Domain: shortpixel-image-optimiser
19
 
20
  //define('SHORTPIXEL_AFFILIATE_CODE', '');
21
 
22
+ define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.16.3");
23
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
24
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
25
  define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');