ShortPixel Image Optimizer - Version 4.17.2

Version Description

Release date: 10th April 2020 * Fix for Over Quota notification that didn't go away even if there were enough credits; * From now on other ShortPixel notifications will only show up on ShortPixel related pages (Media Library, ShortPixel settings, Other Media page, Bulk Optimize page); * Added a constant which can be used to completely disable all ShortPixel notifications. To be used with care as in certain cases it can hide important notifications; * 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.17.2
Comparing to
See all releases

Code changes from version 4.17.1 to 4.17.2

class/controller/adminnotices_controller.php CHANGED
@@ -30,7 +30,15 @@ class adminNoticesController extends ShortPixelController
30
 
31
  public function __construct()
32
  {
33
- add_action('admin_notices', array($this, 'check_admin_notices'), 5); // run before the plugin admin notices
 
 
 
 
 
 
 
 
34
  }
35
 
36
  public static function getInstance()
@@ -76,16 +84,57 @@ class adminNoticesController extends ShortPixelController
76
  $noticeControl->update();
77
  }
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  /* General function to check on Hook for admin notices if there is something to show globally */
80
  public function check_admin_notices()
81
  {
 
 
 
82
  $this->doFilePermNotice();
83
  $this->doAPINotices();
84
  $this->doCompatNotices();
85
  $this->doUnlistedNotices();
86
  $this->doQuotaNotices();
87
 
88
-
89
  $this->doIntegrationNotices();
90
  }
91
 
@@ -270,12 +319,13 @@ class adminNoticesController extends ShortPixelController
270
  Notices::makePersistent($notice, self::MSG_UPGRADE_MONTH, YEAR_IN_SECONDS);
271
  }
272
  }
273
- elseif ($settings->quotaExceeded && \wpSPIO()->env()->is_screen_to_use)
274
  {
275
  $stats = $shortpixel->countAllIfNeeded($settings->currentStats, 86400);
276
  $quotaData = $stats;
277
 
278
  $message = $this->getQuotaExceededMessage($quotaData);
 
279
  $notice = Notices::addError($message);
280
  Notices::makePersistent($notice, self::MSG_QUOTA_REACHED, WEEK_IN_SECONDS);
281
 
30
 
31
  public function __construct()
32
  {
33
+ add_action('admin_notices', array($this, 'displayNotices'), 50); // notices occured before page load
34
+ add_action('admin_footer', array($this, 'displayNotices')); // called in views.
35
+
36
+ // no persistent notifications with this flag set.
37
+ if (defined('SHORTPIXEL_SILENT_MODE') && SHORTPIXEL_SILENT_MODE === true)
38
+ return;
39
+
40
+ add_action('admin_notices', array($this, 'check_admin_notices'), 5); // run before the plugin admin notices
41
+
42
  }
43
 
44
  public static function getInstance()
84
  $noticeControl->update();
85
  }
86
 
87
+ public function displayNotices()
88
+ {
89
+ if (! \wpSPIO()->env()->is_screen_to_use)
90
+ return; // suppress all when not our screen.
91
+
92
+ $noticeControl = Notices::getInstance();
93
+ $noticeControl->loadIcons(array(
94
+ 'normal' => '<img class="short-pixel-notice-icon" src="' . plugins_url('res/img/slider.png', SHORTPIXEL_PLUGIN_FILE) . '">',
95
+ 'success' => '<img class="short-pixel-notice-icon" src="' . plugins_url('res/img/robo-cool.png', SHORTPIXEL_PLUGIN_FILE) . '">',
96
+ 'warning' => '<img class="short-pixel-notice-icon" src="' . plugins_url('res/img/robo-scared.png', SHORTPIXEL_PLUGIN_FILE) . '">',
97
+ 'error' => '<img class="short-pixel-notice-icon" src="' . plugins_url('res/img/robo-scared.png', SHORTPIXEL_PLUGIN_FILE) . '">',
98
+ ));
99
+
100
+ if ($noticeControl->countNotices() > 0)
101
+ {
102
+ $notices = $noticeControl->getNoticesForDisplay();
103
+
104
+ if (count($notices) > 0)
105
+ {
106
+ wp_enqueue_style('shortpixel-notices');
107
+
108
+ foreach($notices as $notice)
109
+ {
110
+ echo $notice->getForDisplay();
111
+
112
+ if ($notice->getID() == adminNoticesController::MSG_QUOTA_REACHED || $notice->getID() == adminNoticesController::MSG_UPGRADE_MONTH
113
+ || $notice->getID() == adminNoticesController::MSG_UPGRADE_BULK)
114
+ {
115
+ wp_enqueue_script('jquery.knob.min.js');
116
+ wp_enqueue_script('jquery.tooltip.min.js');
117
+ wp_enqueue_script('shortpixel');
118
+ \wpSPIO()->load_style('shortpixel-modal');
119
+ }
120
+ }
121
+ }
122
+ }
123
+ $noticeControl->update(); // puts views, and updates
124
+ }
125
+
126
  /* General function to check on Hook for admin notices if there is something to show globally */
127
  public function check_admin_notices()
128
  {
129
+ if (! \wpSPIO()->env()->is_screen_to_use)
130
+ return; // suppress all when not our screen.
131
+
132
  $this->doFilePermNotice();
133
  $this->doAPINotices();
134
  $this->doCompatNotices();
135
  $this->doUnlistedNotices();
136
  $this->doQuotaNotices();
137
 
 
138
  $this->doIntegrationNotices();
139
  }
140
 
319
  Notices::makePersistent($notice, self::MSG_UPGRADE_MONTH, YEAR_IN_SECONDS);
320
  }
321
  }
322
+ elseif ($settings->quotaExceeded)
323
  {
324
  $stats = $shortpixel->countAllIfNeeded($settings->currentStats, 86400);
325
  $quotaData = $stats;
326
 
327
  $message = $this->getQuotaExceededMessage($quotaData);
328
+ Log::addtemp('Quota Exceeded message', $message);
329
  $notice = Notices::addError($message);
330
  Notices::makePersistent($notice, self::MSG_QUOTA_REACHED, WEEK_IN_SECONDS);
331
 
class/view/view-other-media.php CHANGED
@@ -13,6 +13,7 @@ if ( isset($_GET['noheader']) ) {
13
 
14
  echo $this->view->rewriteHREF;
15
 
 
16
  ?>
17
  <div class="wrap shortpixel-other-media">
18
  <h2>
13
 
14
  echo $this->view->rewriteHREF;
15
 
16
+
17
  ?>
18
  <div class="wrap shortpixel-other-media">
19
  <h2>
class/wp-short-pixel.php CHANGED
@@ -178,65 +178,6 @@ class WPShortPixel {
178
 
179
 
180
 
181
- // @hook admin menu
182
- // @todo move to plugin class
183
- /* Gone. Both pages moved elsewhere ( plugin class )
184
- function registerAdminPage( ) {
185
- return;
186
- if($this->spMetaDao->hasFoldersTable() && count($this->spMetaDao->getFolders())) {
187
-
188
- add_media_page( __('Other Media Optimized by ShortPixel','shortpixel-image-optimiser'), __('Other Media','shortpixel-image-optimiser'), 'edit_others_posts', 'wp-short-pixel-custom', array( &$this, 'listCustomMedia' ) );
189
- }
190
-
191
- add_media_page( __('ShortPixel Bulk Process','shortpixel-image-optimiser'), __('Bulk ShortPixel','shortpixel-image-optimiser'), 'edit_others_posts', 'wp-short-pixel-bulk', array( &$this, 'bulkProcess' ) );
192
- } */
193
-
194
- /*public static function shortPixelActivatePlugin()//reset some params to avoid trouble for plugins that were activated/deactivated/activated
195
- {
196
- self::shortPixelDeactivatePlugin();
197
- if(SHORTPIXEL_RESET_ON_ACTIVATE === true && WP_DEBUG === true) { //force reset plugin counters, only on specific occasions and on test environments
198
- WPShortPixelSettings::debugResetOptions();
199
-
200
- $settings = new WPShortPixelSettings();
201
- $spMetaDao = new ShortPixelCustomMetaDao(new WpShortPixelDb(), $settings->excludePatterns);
202
- $spMetaDao->dropTables();
203
- }
204
-
205
- $settingsControl = new \ShortPixel\SettingsController();
206
- $env = $settingsControl->getEnv();
207
-
208
-
209
- if(WPShortPixelSettings::getOpt('deliverWebp') == 3 && ! $env->is_nginx) {
210
- self::alterHtaccess(); //add the htaccess lines
211
- }
212
- WPShortPixelSettings::onActivate();
213
- } */
214
-
215
- /* public static function shortPixelDeactivatePlugin()//reset some params to avoid trouble for plugins that were activated/deactivated/activated
216
- {
217
- ShortPixelQueue::resetBulk();
218
- (! defined('SHORTPIXEL_NOFLOCK')) ? ShortPixelQueue::resetPrio() : ShortPixelQueueDB::resetPrio();
219
- WPShortPixelSettings::onDeactivate();
220
-
221
- $settingsControl = new \ShortPixel\SettingsController();
222
- $env = $settingsControl->getEnv();
223
-
224
- if (! $env->is_nginx)
225
- self::alterHtaccess(true);
226
-
227
- @unlink(SHORTPIXEL_BACKUP_FOLDER . "/shortpixel_log");
228
- } */
229
-
230
- /* public static function shortPixelUninstallPlugin()//reset some params to avoid trouble for plugins that were activated/deactivated/activated
231
- {
232
- $settings = new WPShortPixelSettings();
233
- if($settings->removeSettingsOnDeletePlugin == 1) {
234
- WPShortPixelSettings::debugResetOptions();
235
- insert_with_markers( get_home_path() . '.htaccess', 'ShortPixelWebp', '');
236
- }
237
- } */
238
-
239
-
240
  /** Displays notices to admin, if there are any
241
  * TODO - Probably should be a controller
242
  */
178
 
179
 
180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  /** Displays notices to admin, if there are any
182
  * TODO - Probably should be a controller
183
  */
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.4
6
  Requires PHP: 5.3
7
- Stable tag: 4.17.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -281,13 +281,20 @@ Hide the Cloudflare settings by defining these constants in wp-config.php:
281
 
282
  == Changelog ==
283
 
 
 
 
 
 
 
 
 
284
  = 4.17.1 =
285
 
286
  Release date: 6th April 2020
287
  * Fix for MySQL index errors for MySQL 5.6;
288
  * Language – 0 new strings added, 0 updated, 0 fuzzied, and 0 obsoleted.
289
 
290
-
291
  = 4.17.0 =
292
 
293
  Release date: 2nd April 2020
4
  Requires at least: 3.2.0
5
  Tested up to: 5.4
6
  Requires PHP: 5.3
7
+ Stable tag: 4.17.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
281
 
282
  == Changelog ==
283
 
284
+ = 4.17.2 =
285
+
286
+ Release date: 10th April 2020
287
+ * Fix for Over Quota notification that didn't go away even if there were enough credits;
288
+ * From now on other ShortPixel notifications will only show up on ShortPixel related pages (Media Library, ShortPixel settings, Other Media page, Bulk Optimize page);
289
+ * Added a constant which can be used to completely disable all ShortPixel notifications. To be used with care as in certain cases it can hide important notifications;
290
+ * Language – 0 new strings added, 0 updated, 0 fuzzied, and 0 obsoleted.
291
+
292
  = 4.17.1 =
293
 
294
  Release date: 6th April 2020
295
  * Fix for MySQL index errors for MySQL 5.6;
296
  * Language – 0 new strings added, 0 updated, 0 fuzzied, and 0 obsoleted.
297
 
 
298
  = 4.17.0 =
299
 
300
  Release date: 2nd April 2020
shortpixel-plugin.php CHANGED
@@ -46,6 +46,14 @@ class ShortPixelPlugin
46
  $this->is_noheaders = true;
47
  }
48
 
 
 
 
 
 
 
 
 
49
  // @todo Transitionary init for the time being, since plugin init functionality is still split between.
50
  global $shortPixelPluginInstance;
51
  $shortPixelPluginInstance = new \wpShortPixel();
@@ -161,9 +169,6 @@ class ShortPixelPlugin
161
  add_action('admin_enqueue_scripts', array($this, 'admin_scripts')); // admin scripts
162
  add_action('admin_enqueue_scripts', array($this, 'load_admin_scripts'), 90); // loader via route.
163
  // defer notices a little to allow other hooks ( notable adminnotices )
164
- add_action('admin_notices', array($this, 'admin_notices'), 50); // notices occured before page load
165
- add_action('admin_footer', array($this, 'admin_notices')); // called in views.
166
-
167
  }
168
 
169
  /** Hook in our admin pages */
@@ -217,41 +222,6 @@ class ShortPixelPlugin
217
 
218
  }
219
 
220
- public function admin_notices()
221
- {
222
- $noticeControl = Notices::getInstance();
223
- $noticeControl->loadIcons(array(
224
- 'normal' => '<img class="short-pixel-notice-icon" src="' . plugins_url('res/img/slider.png', SHORTPIXEL_PLUGIN_FILE) . '">',
225
- 'success' => '<img class="short-pixel-notice-icon" src="' . plugins_url('res/img/robo-cool.png', SHORTPIXEL_PLUGIN_FILE) . '">',
226
- 'warning' => '<img class="short-pixel-notice-icon" src="' . plugins_url('res/img/robo-scared.png', SHORTPIXEL_PLUGIN_FILE) . '">',
227
- 'error' => '<img class="short-pixel-notice-icon" src="' . plugins_url('res/img/robo-scared.png', SHORTPIXEL_PLUGIN_FILE) . '">',
228
- ));
229
-
230
- if ($noticeControl->countNotices() > 0)
231
- {
232
- $notices = $noticeControl->getNoticesForDisplay();
233
-
234
- if (count($notices) > 0)
235
- {
236
- wp_enqueue_style('shortpixel-notices');
237
-
238
- foreach($notices as $notice)
239
- {
240
- echo $notice->getForDisplay();
241
-
242
- if ($notice->getID() == adminNoticesController::MSG_QUOTA_REACHED || $notice->getID() == adminNoticesController::MSG_UPGRADE_MONTH
243
- || $notice->getID() == adminNoticesController::MSG_UPGRADE_BULK)
244
- {
245
- wp_enqueue_script('jquery.knob.min.js');
246
- wp_enqueue_script('jquery.tooltip.min.js');
247
- wp_enqueue_script('shortpixel');
248
- $this->load_style('shortpixel-modal');
249
- }
250
- }
251
- }
252
- }
253
- $noticeControl->update(); // puts views, and updates
254
- }
255
 
256
  /** Load Style via Route, on demand */
257
  public function load_style($name)
46
  $this->is_noheaders = true;
47
  }
48
 
49
+ /* Filter to prevent SPIO from starting. This can be used by third-parties to prevent init when needed for a particular situation.
50
+ * Hook into plugins_loaded with priority lower than 5 */
51
+ $init = apply_filters('shortpixel/plugin/init', true);
52
+
53
+ if (! $init)
54
+ return;
55
+
56
+
57
  // @todo Transitionary init for the time being, since plugin init functionality is still split between.
58
  global $shortPixelPluginInstance;
59
  $shortPixelPluginInstance = new \wpShortPixel();
169
  add_action('admin_enqueue_scripts', array($this, 'admin_scripts')); // admin scripts
170
  add_action('admin_enqueue_scripts', array($this, 'load_admin_scripts'), 90); // loader via route.
171
  // defer notices a little to allow other hooks ( notable adminnotices )
 
 
 
172
  }
173
 
174
  /** Hook in our admin pages */
222
 
223
  }
224
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
 
226
  /** Load Style via Route, on demand */
227
  public function load_style($name)
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.17.1
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.17.1");
23
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
24
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
25
  define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');
@@ -45,7 +45,6 @@ elseif($max_exec < 0) // some hosts like to set negative figures on this. Ignore
45
  define('SHORTPIXEL_MAX_EXECUTION_TIME', $max_exec);
46
 
47
  // ** @todo For what is this needed? */
48
- //require_once(ABSPATH . 'wp-admin/includes/file.php');
49
  require_once(SHORTPIXEL_PLUGIN_DIR . '/build/shortpixel/autoload.php');
50
 
51
  $sp__uploads = wp_upload_dir();
@@ -60,17 +59,11 @@ define('SHORTPIXEL_BACKUP_URL',
60
  : dirname(dirname($sp__uploads['baseurl'])))
61
  . '/' . SHORTPIXEL_BACKUP);
62
 
63
- /*
64
- if ( is_numeric(SHORTPIXEL_MAX_EXECUTION_TIME) && SHORTPIXEL_MAX_EXECUTION_TIME > 10 )
65
- define('SHORTPIXEL_MAX_EXECUTION_TIME', SHORTPIXEL_MAX_EXECUTION_TIME - 5 ); //in seconds
66
- else
67
- define('SHORTPIXEL_MAX_EXECUTION_TIME', 25 );
68
- */
69
-
70
  define('SHORTPIXEL_MAX_EXECUTION_TIME2', 2 );
71
  define("SHORTPIXEL_MAX_RESULTS_QUERY", 30);
72
  //define("SHORTPIXEL_NOFLOCK", true); // don't use flock queue, can cause instability.
73
  //define("SHORTPIXEL_EXPERIMENTAL_SECURICACHE", true); // tries to add timestamps to URLS, to prevent hitting the cache.
 
74
 
75
  /* Function to reach core function of ShortPixel
76
  * Use to get plugin url, plugin path, or certain core controllers
@@ -105,6 +98,7 @@ if (\ShortPixel\ShortPixelLogger\ShortPixelLogger::debugIsActive())
105
 
106
 
107
 
 
108
  register_activation_hook( __FILE__, array('\ShortPixel\ShortPixelPlugin','activatePlugin') );
109
  register_deactivation_hook( __FILE__, array('\ShortPixel\ShortPixelPlugin','deactivatePlugin') );
110
  register_uninstall_hook(__FILE__, array('\ShortPixel\ShortPixelPlugin','uninstallPlugin') );
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.17.2
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.17.2");
23
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
24
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
25
  define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');
45
  define('SHORTPIXEL_MAX_EXECUTION_TIME', $max_exec);
46
 
47
  // ** @todo For what is this needed? */
 
48
  require_once(SHORTPIXEL_PLUGIN_DIR . '/build/shortpixel/autoload.php');
49
 
50
  $sp__uploads = wp_upload_dir();
59
  : dirname(dirname($sp__uploads['baseurl'])))
60
  . '/' . SHORTPIXEL_BACKUP);
61
 
 
 
 
 
 
 
 
62
  define('SHORTPIXEL_MAX_EXECUTION_TIME2', 2 );
63
  define("SHORTPIXEL_MAX_RESULTS_QUERY", 30);
64
  //define("SHORTPIXEL_NOFLOCK", true); // don't use flock queue, can cause instability.
65
  //define("SHORTPIXEL_EXPERIMENTAL_SECURICACHE", true); // tries to add timestamps to URLS, to prevent hitting the cache.
66
+ //define('SHORTPIXEL_SILENT_MODE', true); // no global notifications. Can lead to data damage. After setting, reactivate plugin.
67
 
68
  /* Function to reach core function of ShortPixel
69
  * Use to get plugin url, plugin path, or certain core controllers
98
 
99
 
100
 
101
+
102
  register_activation_hook( __FILE__, array('\ShortPixel\ShortPixelPlugin','activatePlugin') );
103
  register_deactivation_hook( __FILE__, array('\ShortPixel\ShortPixelPlugin','deactivatePlugin') );
104
  register_uninstall_hook(__FILE__, array('\ShortPixel\ShortPixelPlugin','uninstallPlugin') );