ShortPixel Image Optimizer - Version 4.12.2

Version Description

Release date:

  • Improved: The Webp options interface. Now the user can implement Webp images both via .htaccess and by altering the page code on the server before being sent to the browser.
  • Improved: The settings data handling interface in the Plugin deactivation dialogue. Now the option to delete or keep the user settings on plugin deletion is more clear.
  • Added: Option to download image with thumbnails in a single archive file, to speed-up the optimization.
  • Added: A "shortpixel_get_backup" filter, which receives the local path of the media image and returns the ShortPixel backup path, if a backup image exists
  • Added: The "Simple Image Sizes" plugin to the conflicting plugins list
  • Added: A new compatibility check for the "Jetpack" plugin, alerting the user about potential overlapping functionality
  • Added: A safety alert before switching to Code Altering mode (where IMG tgs get inserted into PICTURE tags, to better serve Webp images)
  • Added: Enhanced "Envira" plugin compatibility by adding more suffixes to be looked for: _tl, _tr, _bl, _br
  • Added: More customized FAQ suggestions in the HelpScout Beacon helper, to address each Plugin TAB separately
  • Fixed: The post-uninstall redirect when uninstalling a plugin from within the respective plugin's Settings page
  • Fixed: The credits display on the Statistics page
  • Fixed: Refreshing a plugin page now loads directly in the previously selected TAB
  • Fixed: Removed a stray "SP_CELL_MESSAGE" div from the interface
Download this release

Release Info

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

Code changes from version 4.12.1 to 4.12.2

class/db/wp-shortpixel-media-library-adapter.php CHANGED
@@ -250,7 +250,9 @@ class WpShortPixelMediaLbraryAdapter {
250
  if (isset($val['mime-type']) && $val['mime-type'] == "image/webp") continue;
251
  if(!isset($val['file'])) continue;
252
  if (in_array($key, $exclude)) continue;
253
- $uniq[$val['file']] = $key;
 
 
254
  }
255
  return count($uniq);
256
  }
@@ -261,11 +263,13 @@ class WpShortPixelMediaLbraryAdapter {
261
  $sizes = array();
262
  $files = array();
263
  foreach($sizesAll as $key => $size) {
264
- if(strpos($key, ShortPixelMeta::FOUND_THUMB_PREFIX) === 0) continue;
265
- if(in_array($size['file'], $files)) continue;
266
- if(!isset($size['file'])) continue;
267
- $sizes[$key] = $size;
268
- $files[] = $size['file'];
 
 
269
  }
270
  $meta->setThumbs($sizes);
271
  $itemHandler->updateMeta($meta, true);
@@ -284,14 +288,20 @@ class WpShortPixelMediaLbraryAdapter {
284
  }
285
  }
286
  }
287
- if(defined('SHORTPIXEL_CUSTOM_THUMB_SUFFIX')) {
288
- $pattern = '/' . preg_quote($base, '/') . '-\d+x\d+'. SHORTPIXEL_CUSTOM_THUMB_SUFFIX . '\.'. $ext .'/';
289
  $thumbsCandidates = @glob($base . "-*." . $ext);
290
- $thumbs = array();
291
  if(is_array($thumbsCandidates)) {
292
- foreach($thumbsCandidates as $th) {
293
- if(preg_match($pattern, $th)) {
294
- $thumbs[]= $th;
 
 
 
 
 
 
 
 
295
  }
296
  }
297
  }
250
  if (isset($val['mime-type']) && $val['mime-type'] == "image/webp") continue;
251
  if(!isset($val['file'])) continue;
252
  if (in_array($key, $exclude)) continue;
253
+ $file = $val['file'];
254
+ if(is_array($file)) { $file = $file[0];} // HelpScout case 709692915
255
+ $uniq[$file] = $key;
256
  }
257
  return count($uniq);
258
  }
263
  $sizes = array();
264
  $files = array();
265
  foreach($sizesAll as $key => $size) {
266
+ if(strpos($key, ShortPixelMeta::FOUND_THUMB_PREFIX) === 0) continue;
267
+ if(!isset($size['file'])) continue;
268
+ $sizes[$key] = $size;
269
+ $file = $size['file'];
270
+ if(is_array($file)) { $file = $file[0];} // HelpScout case 709692915
271
+ if(in_array($file, $files)) continue;
272
+ $files[] = $file;
273
  }
274
  $meta->setThumbs($sizes);
275
  $itemHandler->updateMeta($meta, true);
288
  }
289
  }
290
  }
291
+ if( defined('SHORTPIXEL_CUSTOM_THUMB_SUFFIX') || defined('SHORTPIXEL_CUSTOM_THUMB_SUFFIXES') ){
 
292
  $thumbsCandidates = @glob($base . "-*." . $ext);
 
293
  if(is_array($thumbsCandidates)) {
294
+ $thumbs = array();
295
+ $suffixes = defined('SHORTPIXEL_CUSTOM_THUMB_SUFFIXES') ? explode(',', SHORTPIXEL_CUSTOM_THUMB_SUFFIXES) : array();
296
+ if( defined('SHORTPIXEL_CUSTOM_THUMB_SUFFIX') ){
297
+ $suffixes[] = SHORTPIXEL_CUSTOM_THUMB_SUFFIX;
298
+ }
299
+ foreach ($suffixes as $suffix){
300
+ $pattern = '/' . preg_quote($base, '/') . '-\d+x\d+'. $suffix . '\.'. $ext .'/';
301
+ foreach($thumbsCandidates as $th) {
302
+ if(preg_match($pattern, $th)) {
303
+ $thumbs[]= $th;
304
+ }
305
  }
306
  }
307
  }
class/shortpixel-tools.php CHANGED
@@ -70,4 +70,8 @@ class ShortPixelTools {
70
  }
71
  return false;
72
  }
 
 
 
 
73
  }
70
  }
71
  return false;
72
  }
73
+ }
74
+
75
+ function ShortPixelVDD($v){
76
+ return highlight_string("<?php\n\$data =\n" . var_export($v, true) . ";\n?>");
77
  }
class/view/shortpixel-feedback.php CHANGED
@@ -57,22 +57,28 @@ class ShortPixelFeedback {
57
  $html .= '<div class="shortpixel-deactivate-form-body">';
58
  if( is_array( $form['options'] ) ) {
59
  $html .= '<div class="shortpixel-deactivate-options">';
60
- $html .= '<span title="' . __( 'Check this if you don\\\'t plan to use ShortPixel in the future on this website. You might also want to run a Bulk Delete SP Metadata before removing the plugin (Media Library -> Bulk ShortPixel).', $this->plugin_name )
61
- . '"><input type="checkbox" name="shortpixel-remove-settings" id="shortpixel-remove-settings" value="yes"> <label for="shortpixel-remove-settings">'
62
- . esc_html__( 'Remove the ShortPixel settings on plugin delete.', $this->plugin_name ) . '</label></span><br>';
63
  $html .= '<p><strong>' . esc_html( $form['body'] ) . '</strong></p><p>';
64
  foreach( $form['options'] as $key => $option ) {
65
  $html .= '<input type="radio" name="shortpixel-deactivate-reason" id="' . esc_attr( $key ) . '" value="' . esc_attr( $key ) . '"> <label for="' . esc_attr( $key ) . '">' . esc_attr( $option ) . '</label><br>';
66
  }
67
  $html .= '</p><label id="shortpixel-deactivate-details-label" for="shortpixel-deactivate-reasons"><strong>' . esc_html( $form['details'] ) .'</strong></label><textarea name="shortpixel-deactivate-details" id="shortpixel-deactivate-details" rows="2" style="width:100%"></textarea>';
68
- $html .= '<label for="anonymous" title="'
69
- . __("If you UNCHECK this then your email address will be sent along with your feedback. This can be used by ShortPixel to get back to you for more info or a solution.",'shortpixel-image-optimiser')
70
- . '"><input type="checkbox" name="shortpixel-deactivate-tracking" checked="checked" id="anonymous"> ' . esc_html__( 'Send anonymous', $this->plugin_name ) . '</label><br>';
71
  $html .= '</div><!-- .shortpixel-deactivate-options -->';
72
  }
 
 
 
 
 
73
  $html .= '</div><!-- .shortpixel-deactivate-form-body -->';
74
  $html .= '<p class="deactivating-spinner"><span class="spinner"></span> ' . __( 'Submitting form', $this->plugin_name ) . '</p>';
75
- $html .= '<div class="shortpixel-deactivate-form-footer"><p><a id="shortpixel-deactivate-plugin" href="#">' . __( 'Just Deactivate', $this->plugin_name ) . '</a><a id="shortpixel-deactivate-submit-form" class="button button-primary" href="#" disabled>' . __( 'Submit and Deactivate', $this->plugin_name ) . '</a></p></div>'
 
 
 
 
 
 
 
76
  ?>
77
  <div class="shortpixel-deactivate-form-bg"></div>
78
  <style type="text/css">
@@ -100,7 +106,7 @@ class ShortPixelFeedback {
100
  bottom: 30px;
101
  left: 0;
102
  max-width: 500px;
103
- min-width: 330px;
104
  background: #fff;
105
  white-space: normal;
106
  }
@@ -110,9 +116,12 @@ class ShortPixelFeedback {
110
  padding: 8px 18px;
111
  }
112
  .shortpixel-deactivate-form-body {
113
- padding: 8px 18px;
114
  color: #444;
115
  }
 
 
 
116
  .deactivating-spinner {
117
  display: none;
118
  }
@@ -123,12 +132,19 @@ class ShortPixelFeedback {
123
  visibility: visible;
124
  }
125
  .shortpixel-deactivate-form-footer {
126
- padding: 8px 18px;
 
 
 
127
  }
128
  .shortpixel-deactivate-form-footer p {
129
  display: flex;
130
  align-items: center;
131
  justify-content: space-between;
 
 
 
 
132
  }
133
  .shortpixel-deactivate-form.process-response .shortpixel-deactivate-form-body,
134
  .shortpixel-deactivate-form.process-response .shortpixel-deactivate-form-footer {
@@ -149,7 +165,8 @@ class ShortPixelFeedback {
149
  <script>
150
  jQuery(document).ready(function($){
151
  var deactivateURL = $("#shortpixel-deactivate-link-<?php echo esc_attr( $this->plugin_name ); ?>"),
152
- formContainer = $('#shortpixel-deactivate-form-<?php echo esc_attr( $this->plugin_name ); ?>'),
 
153
  deactivated = true,
154
  detailsStrings = {
155
  'setup' : '<?php echo __( 'What was the dificult part ?', $this->plugin_name ) ?>',
@@ -160,9 +177,33 @@ class ShortPixelFeedback {
160
  'maintenance' : '<?php echo __( 'Please specify', $this->plugin_name ) ?>',
161
  };
162
 
163
- $( deactivateURL ).on("click",function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  // We'll send the user to this deactivation link when they've completed or dismissed the form
165
  var url = deactivateURL.attr( 'href' );
 
166
  $('body').toggleClass('shortpixel-deactivate-form-active');
167
  formContainer.fadeIn({complete: function(){
168
  var offset = formContainer.offset();
@@ -173,50 +214,43 @@ class ShortPixelFeedback {
173
  }});
174
  formContainer.html( '<?php echo $html; ?>');
175
 
176
- formContainer.on( 'change', 'input[name="shortpixel-deactivate-reason"]', function(){
177
- var detailsLabel = formContainer.find( '#shortpixel-deactivate-details-label strong' );
178
- var value = formContainer.find( 'input[name="shortpixel-deactivate-reason"]:checked' ).val();
 
 
 
179
  detailsLabel.text( detailsStrings[ value ] );
 
 
180
  if(deactivated) {
181
  deactivated = false;
182
  $('#shortpixel-deactivate-submit-form').removeAttr("disabled");
 
183
  formContainer.on('click', '#shortpixel-deactivate-submit-form', function(e){
 
184
  var data = {
185
- 'action': 'shortpixel_deactivate_plugin',
186
- 'security': "<?php echo wp_create_nonce ( 'shortpixel_deactivate_plugin' ); ?>",
187
- 'dataType': "json"
188
  };
189
- e.preventDefault();
190
- // As soon as we click, the body of the form should disappear
191
- formContainer.addClass( 'process-response' );
192
- // Fade in spinner
193
- formContainer.find(".deactivating-spinner").fadeIn();
194
-
195
- data['reason'] = formContainer.find( 'input[name="shortpixel-deactivate-reason"]:checked' ).val();
196
- data['details'] = formContainer.find('#shortpixel-deactivate-details').val();
197
- data['anonymous'] = formContainer.find( '#anonymous:checked' ).length;
198
- data['remove-settings'] = formContainer.find( '#shortpixel-remove-settings:checked').length;
199
-
200
- $.post(
201
- ajaxurl,
202
- data,
203
- function(response){
204
- // Redirect to original deactivation URL
205
- window.location.href = url;
206
- }
207
- );
208
  });
209
  }
210
  });
211
 
212
  formContainer.on('click', '#shortpixel-deactivate-submit-form', function(e){
213
  e.preventDefault();
 
 
 
 
 
214
  });
215
 
216
- formContainer.on('click', '#shortpixel-deactivate-plugin', function(e){
217
  e.preventDefault();
218
- window.location.href = url;
219
- });
220
 
221
  // If we click outside the form, the form will close
222
  $('.shortpixel-deactivate-form-bg').on('click',function(){
@@ -225,6 +259,7 @@ class ShortPixelFeedback {
225
  });
226
  });
227
  });
 
228
  </script>
229
  <?php }
230
 
@@ -253,8 +288,8 @@ class ShortPixelFeedback {
253
 
254
  check_ajax_referer( 'shortpixel_deactivate_plugin', 'security' );
255
 
 
256
  if ( isset($_POST['reason']) && isset($_POST['details']) && isset($_POST['anonymous']) ) {
257
- $_POST = $this->ctrl->validateFeedback($_POST);
258
  require_once 'shortpixel-plugin-request.php';
259
  $anonymous = isset($_POST['anonymous']) && $_POST['anonymous'];
260
  $args = array(
57
  $html .= '<div class="shortpixel-deactivate-form-body">';
58
  if( is_array( $form['options'] ) ) {
59
  $html .= '<div class="shortpixel-deactivate-options">';
 
 
 
60
  $html .= '<p><strong>' . esc_html( $form['body'] ) . '</strong></p><p>';
61
  foreach( $form['options'] as $key => $option ) {
62
  $html .= '<input type="radio" name="shortpixel-deactivate-reason" id="' . esc_attr( $key ) . '" value="' . esc_attr( $key ) . '"> <label for="' . esc_attr( $key ) . '">' . esc_attr( $option ) . '</label><br>';
63
  }
64
  $html .= '</p><label id="shortpixel-deactivate-details-label" for="shortpixel-deactivate-reasons"><strong>' . esc_html( $form['details'] ) .'</strong></label><textarea name="shortpixel-deactivate-details" id="shortpixel-deactivate-details" rows="2" style="width:100%"></textarea>';
 
 
 
65
  $html .= '</div><!-- .shortpixel-deactivate-options -->';
66
  }
67
+ $html .= '<hr/>';
68
+ $html .= '<span title="' . __( 'Un-check this if you don\\\'t plan to use ShortPixel in the future on this website. You might also want to run a Bulk Delete SP Metadata before removing the plugin (Media Library -> Bulk ShortPixel).', $this->plugin_name )
69
+ . '"><input type="checkbox" name="shortpixel-keep-settings" id="shortpixel-keep-settings" value="yes" checked> <label for="shortpixel-keep-settings">'
70
+ . esc_html__( 'Keep the ShortPixel settings on plugin deletion.', $this->plugin_name ) . '</label></span><br>';
71
+ $html .= '<hr/>';
72
  $html .= '</div><!-- .shortpixel-deactivate-form-body -->';
73
  $html .= '<p class="deactivating-spinner"><span class="spinner"></span> ' . __( 'Submitting form', $this->plugin_name ) . '</p>';
74
+ $html .= '<div class="shortpixel-deactivate-form-footer"><p>';
75
+ $html .= '<label for="anonymous" title="'
76
+ . __("If you UNCHECK this then your email address will be sent along with your feedback. This can be used by ShortPixel to get back to you for more info or a solution.",'shortpixel-image-optimiser')
77
+ . '"><input type="checkbox" name="shortpixel-deactivate-tracking" checked="checked" id="anonymous"> ' . esc_html__( 'Send anonymous', $this->plugin_name ) . '</label><br>';
78
+ $html .= '<a id="shortpixel-deactivate-submit-form" class="button button-primary" href="#">'
79
+ . __( '<span>Submit&nbsp;and&nbsp;</span>Deactivate', $this->plugin_name )
80
+ . '</a>';
81
+ $html .= '</p></div>';
82
  ?>
83
  <div class="shortpixel-deactivate-form-bg"></div>
84
  <style type="text/css">
106
  bottom: 30px;
107
  left: 0;
108
  max-width: 500px;
109
+ min-width: 360px;
110
  background: #fff;
111
  white-space: normal;
112
  }
116
  padding: 8px 18px;
117
  }
118
  .shortpixel-deactivate-form-body {
119
+ padding: 8px 18px 0;
120
  color: #444;
121
  }
122
+ .shortpixel-deactivate-form-body label[for="shortpixel-remove-settings"] {
123
+ font-weight: bold;
124
+ }
125
  .deactivating-spinner {
126
  display: none;
127
  }
132
  visibility: visible;
133
  }
134
  .shortpixel-deactivate-form-footer {
135
+ padding: 0 18px 8px;
136
+ }
137
+ .shortpixel-deactivate-form-footer label[for="anonymous"] {
138
+ visibility: hidden;
139
  }
140
  .shortpixel-deactivate-form-footer p {
141
  display: flex;
142
  align-items: center;
143
  justify-content: space-between;
144
+ margin: 0;
145
+ }
146
+ #shortpixel-deactivate-submit-form span {
147
+ display: none;
148
  }
149
  .shortpixel-deactivate-form.process-response .shortpixel-deactivate-form-body,
150
  .shortpixel-deactivate-form.process-response .shortpixel-deactivate-form-footer {
165
  <script>
166
  jQuery(document).ready(function($){
167
  var deactivateURL = $("#shortpixel-deactivate-link-<?php echo esc_attr( $this->plugin_name ); ?>"),
168
+ formID = '#shortpixel-deactivate-form-<?php echo esc_attr( $this->plugin_name ); ?>',
169
+ formContainer = $(formID),
170
  deactivated = true,
171
  detailsStrings = {
172
  'setup' : '<?php echo __( 'What was the dificult part ?', $this->plugin_name ) ?>',
177
  'maintenance' : '<?php echo __( 'Please specify', $this->plugin_name ) ?>',
178
  };
179
 
180
+ $( deactivateURL ).on("click", function(){
181
+
182
+ var SubmitFeedback = function(data, formContainer){
183
+ data['action'] = 'shortpixel_deactivate_plugin';
184
+ data['security'] = '<?php echo wp_create_nonce("shortpixel_deactivate_plugin" ); ?>';
185
+ data['dataType'] = 'json';
186
+ data['keep-settings'] = formContainer.find('#shortpixel-keep-settings:checked').length;
187
+
188
+ // As soon as we click, the body of the form should disappear
189
+ formContainer.addClass( 'process-response' );
190
+
191
+ // Fade in spinner
192
+ formContainer.find(".deactivating-spinner").fadeIn();
193
+
194
+ $.post(
195
+ ajaxurl,
196
+ data,
197
+ function(response){
198
+ // Redirect to original deactivation URL
199
+ window.location.href = url;
200
+ }
201
+ );
202
+ }
203
+
204
  // We'll send the user to this deactivation link when they've completed or dismissed the form
205
  var url = deactivateURL.attr( 'href' );
206
+
207
  $('body').toggleClass('shortpixel-deactivate-form-active');
208
  formContainer.fadeIn({complete: function(){
209
  var offset = formContainer.offset();
214
  }});
215
  formContainer.html( '<?php echo $html; ?>');
216
 
217
+ formContainer.on( 'change', 'input[type=radio]', function(){
218
+ console.log(formContainer);
219
+ var detailsLabel = formContainer.find( '#shortpixel-deactivate-details-label strong' ),
220
+ anonymousLabel = formContainer.find( 'label[for="anonymous"]' )[0],
221
+ submitSpan = formContainer.find( '#shortpixel-deactivate-submit-form span' )[0],
222
+ value = formContainer.find( 'input[name="shortpixel-deactivate-reason"]:checked' ).val();
223
  detailsLabel.text( detailsStrings[ value ] );
224
+ anonymousLabel.style.visibility = "visible";
225
+ submitSpan.style.display = "inline-block";
226
  if(deactivated) {
227
  deactivated = false;
228
  $('#shortpixel-deactivate-submit-form').removeAttr("disabled");
229
+ formContainer.off('click', '#shortpixel-deactivate-submit-form');
230
  formContainer.on('click', '#shortpixel-deactivate-submit-form', function(e){
231
+ e.preventDefault();
232
  var data = {
233
+ reason: formContainer.find('input[name="shortpixel-deactivate-reason"]:checked').val(),
234
+ details: formContainer.find('#shortpixel-deactivate-details').val(),
235
+ anonymous: formContainer.find('#anonymous:checked').length,
236
  };
237
+ SubmitFeedback(data, formContainer);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  });
239
  }
240
  });
241
 
242
  formContainer.on('click', '#shortpixel-deactivate-submit-form', function(e){
243
  e.preventDefault();
244
+ if( formContainer.find('#shortpixel-keep-settings:checked').length ) {
245
+ window.location.href = url;
246
+ } else {
247
+ SubmitFeedback({}, formContainer);
248
+ }
249
  });
250
 
251
+ /*formContainer.on('click', '#shortpixel-deactivate-plugin', function(e){
252
  e.preventDefault();
253
+ });*/
 
254
 
255
  // If we click outside the form, the form will close
256
  $('.shortpixel-deactivate-form-bg').on('click',function(){
259
  });
260
  });
261
  });
262
+
263
  </script>
264
  <?php }
265
 
288
 
289
  check_ajax_referer( 'shortpixel_deactivate_plugin', 'security' );
290
 
291
+ $_POST = $this->ctrl->validateFeedback($_POST);
292
  if ( isset($_POST['reason']) && isset($_POST['details']) && isset($_POST['anonymous']) ) {
 
293
  require_once 'shortpixel-plugin-request.php';
294
  $anonymous = isset($_POST['anonymous']) && $_POST['anonymous'];
295
  $args = array(
class/view/shortpixel_view.php CHANGED
@@ -78,7 +78,8 @@ class ShortPixelView {
78
 
79
  public static function displayActivationNotice($when = 'activate', $extra = '') {
80
  $extraStyle = ($when == 'compat' || $when == 'fileperms' ? "background-color: #ff9999;margin: 5px 20px 15px 0;'" : '');
81
- $icon = false; $extraClass = 'notice-warning';
 
82
  switch($when) {
83
  case 'compat': $extraClass = 'notice-error below-h2';
84
  case 'fileperms': $icon = 'scared'; $extraClass = 'notice-error'; break;
@@ -86,6 +87,7 @@ class ShortPixelView {
86
  case 'upgmonth':
87
  case 'upgbulk': $icon = 'notes'; $extraClass = 'notice-success'; break;
88
  case 'generic-err': $extraClass = 'notice-error is-dismissible'; break;
 
89
  }
90
  ?>
91
  <div class='notice <?php echo($extraClass);?> notice-warning' id='short-pixel-notice-<?php echo($when);?>' <?php echo($extraStyle);?>>
@@ -110,12 +112,12 @@ class ShortPixelView {
110
  if($when == 'generic-err') {?>
111
  <button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button>
112
  <?php }
 
113
  if($icon){ ?>
114
- <img src="<?php echo(plugins_url('/shortpixel-image-optimiser/res/img/robo-' . $icon . '.png'));?>"
115
- srcset='<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/robo-' . $icon . '.png' ));?> 1x, <?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/robo-' . $icon . '@2x.png' ));?> 2x'
116
- class='short-pixel-notice-icon'>
117
- <?php }
118
- } ?>
119
  <h3><?php _e('ShortPixel Image Optimizer','shortpixel-image-optimiser');
120
  if($when == 'compat') { echo(' '); _e('Warning','shortpixel-image-optimiser');}
121
  if($when == 'unlisted') { echo(' '); _e(' alert','shortpixel-image-optimiser');}
@@ -137,11 +139,16 @@ class ShortPixelView {
137
  break;
138
  case 'compat' :
139
  _e("The following plugins are not compatible with ShortPixel and may lead to unexpected results: ",'shortpixel-image-optimiser');
140
- echo('<ul>');
141
  foreach($extra as $plugin) {
 
 
 
 
 
142
  echo('<li class="sp-conflict-plugins-list"><strong>' . $plugin['name'] . '</strong>');
143
- echo('<a href="' . wp_nonce_url( admin_url( 'admin-post.php?action=shortpixel_deactivate_plugin&plugin=' . urlencode( $plugin['path'] ) ), 'sp_deactivate_plugin_nonce' ) . '" class="button button-primary">'
144
- . __( 'Deactivate', 'shortpixel_image_optimiser' ) . '</a>');
145
  }
146
  echo("</ul>");
147
  break;
@@ -150,10 +157,10 @@ class ShortPixelView {
150
  <p> <?php
151
  if($when == 'upgmonth') {
152
  printf(__("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>."
153
- . " You might need to upgrade you plan in order to have all your images optimized.", 'shortpixel_image_optimiser'), $extra['monthAvg'], $extra['monthlyQuota']);
154
  } else {
155
  printf(__("You currently have <strong>%d images and thumbnails to optimize</strong> but you only have <strong>%d images</strong> available in your current plan."
156
- . " You might need to upgrade you plan in order to have all your images optimized.", 'shortpixel_image_optimiser'), $extra['filesTodo'], $extra['quotaAvailable']);
157
  }?></p><?php
158
  self::includeProposeUpgradePopup();
159
  break;
@@ -222,12 +229,18 @@ class ShortPixelView {
222
  <div class="bulk-label"><?php _e('Already optimized thumbnails','shortpixel-image-optimiser');?></div>
223
  <div class="bulk-val"><?php echo(number_format($quotaData['totalProcessedMlFiles'] - $quotaData['mainProcessedMlFiles']));?></div><br>
224
  <?php } ?>
225
- <div class="bulk-label bulk-total"><?php _e('Total to be optimized','shortpixel-image-optimiser');?></div>
 
 
 
226
  <div class="bulk-val bulk-total" id='displayTotal'><?php echo(number_format(max( 0, $quotaData['totalMlFiles'] - $quotaData['totalProcessedMlFiles'])));?></div>
227
 
228
  <?php if($customCount > 0) { ?>
229
- <h3 style='margin-bottom:10px;'><?php _e('Your custom folders','shortpixel-image-optimiser');?></h3>
230
- <div class="bulk-label bulk-total"><?php _e('Total to be optimized','shortpixel-image-optimiser');?></div>
 
 
 
231
  <div class="bulk-val bulk-total" id='displayTotal'><?php echo(number_format($customCount));?></div>
232
  <?php } ?>
233
  </div>
@@ -356,7 +369,7 @@ class ShortPixelView {
356
  jQuery(function() {
357
  jQuery("#sp-total-optimization-dial").val("<?php echo("" . round($averageCompression))?>");
358
  ShortPixel.percentDial("#sp-total-optimization-dial", 60);
359
-
360
  jQuery(".sp-bulk-summary").spTooltip({
361
  tooltipSource: "inline",
362
  tooltipSourceID: "#sp-bulk-stats"
@@ -525,7 +538,7 @@ class ShortPixelView {
525
  <?php
526
  }
527
 
528
- public function displayBulkProcessingRunning($percent, $message, $remainingQuota, $averageCompression, $type) {
529
  $settings = $this->ctrl->getSettings();
530
  $dismissed = $settings->dismissedNotices ? $settings->dismissedNotices : array();
531
  ?>
@@ -534,8 +547,8 @@ class ShortPixelView {
534
  <?php $this->displayBulkProgressBar(true, $percent, $message, $remainingQuota, $averageCompression, $type);?>
535
 
536
  <!-- Partners: SQUIRLY -->
537
- <?php if(!isset($dismissed['squirrly'])) { ?>
538
- <div id="short-pixel-notice-squirrly" class="sp-notice sp-notice-info bulk-progress bulk-progress-partners sp-floating-block sp-full-width">
539
  <div style="float:right"><a href="javascript:dismissShortPixelNotice('squirrly')"><?php _e('Dismiss','shortpixel-image-optimiser');?></a></div>
540
  <a href="https://my.squirrly.co/go120073/squirrly.co/short-pixel-seo" target="_blank">
541
  <img src="<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/squirrly.png' ));?>" height="50">
@@ -664,11 +677,12 @@ class ShortPixelView {
664
  <input type="submit" class="button button-primary bulk-cancel" onclick="clearBulkProcessor();"
665
  name="bulkProcessStop" value="Stop" style="margin-left:10px"/>
666
  <input type="submit" class="button button-primary bulk-cancel" onclick="clearBulkProcessor();"
667
- name="<?php echo($running ? "bulkProcessPause" : "bulkProcessResume");?>" value="<?php echo($running ? __('Pause','shortpixel-image-optimiser') : __('Resume processing','shortpixel-image-optimiser'));?>"/>
668
  <?php if(!$running && $customPending) {?>
669
  <input type="submit" class="button button-primary bulk-cancel" onclick="clearBulkProcessor();"
670
  name="skipToCustom" value="<?php _e('Only other media','shortpixel-image-optimiser');?>" title="<?php _e('Process only the other media, skipping the Media Library','shortpixel-image-optimiser');?>" style="margin-right:10px"/>
671
  <?php }?>
 
672
  </form>
673
  <?php } else { ?>
674
  <a href="options-general.php?page=wp-shortpixel" class="button button-primary bulk-cancel" style="margin-left:10px"><?php _e('Manage custom folders','shortpixel-image-optimiser');?></a>
@@ -706,13 +720,13 @@ class ShortPixelView {
706
  </div>
707
  <?php
708
  }
709
-
710
  function displaySettings($showApiKey, $editApiKey, $quotaData, $notice, $resources = null, $averageCompression = null, $savedSpace = null, $savedBandwidth = null,
711
  $remainingImages = null, $totalCallsMade = null, $fileCount = null, $backupFolderSize = null,
712
- $customFolders = null, $folderMsg = false, $addedFolder = false, $showAdvanced = false, $cloudflareAPI = false) {
713
  //wp_enqueue_script('jquery.idTabs.js', plugins_url('/js/jquery.idTabs.js',__FILE__) );
714
  $this->ctrl->outputHSBeacon();
715
  ?>
 
716
  <h1><?php _e('ShortPixel Plugin Settings','shortpixel-image-optimiser');?></h1>
717
  <p style="font-size:18px">
718
  <a href="https://shortpixel.com/<?php
@@ -722,10 +736,19 @@ class ShortPixelView {
722
  </a> | <a href="https://shortpixel.com/pricing<?php echo(WPShortPixel::getAffiliateSufix()); ?>#faq" target="_blank" style="font-size:18px"><?php _e('FAQ','shortpixel-image-optimiser');?> </a> |
723
  <a href="https://shortpixel.com/contact<?php echo(WPShortPixel::getAffiliateSufix());?>" target="_blank" style="font-size:18px"><?php _e('Support','shortpixel-image-optimiser');?> </a>
724
  </p>
725
- <?php if($notice !== null) { ?>
 
 
 
 
 
 
726
  <br/>
727
- <div style="background-color: #fff; border-left: 4px solid <?php echo($notice['status'] == 'error' ? '#ff0000' : ($notice['status'] == 'warn' ? '#FFC800' : '#7ad03a'));?>; box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1); padding: 1px 12px;;width: 95%">
728
- <p><?php echo($notice['msg']);?></p>
 
 
 
729
  </div>
730
  <?php } ?>
731
  <?php if($folderMsg) { ?>
@@ -744,9 +767,9 @@ class ShortPixelView {
744
  $this->displaySettingsForm($showApiKey, $editApiKey, $quotaData);?>
745
  </section>
746
  <?php if($this->ctrl->getVerifiedKey()) {?>
747
- <section <?php echo($showAdvanced ? "class='sel-tab'" : "");?> id="tab-adv-settings">
748
  <h2><a class='tab-link' href='javascript:void(0);' data-id="tab-adv-settings"><?php _e('Advanced','shortpixel-image-optimiser');?></a></h2>
749
- <?php $this->displayAdvancedSettingsForm($customFolders, $addedFolder);?>
750
  </section>
751
  <?php } ?>
752
  </form><span style="display:none">&nbsp;</span><?php //the span is a trick to keep the sections ordered as nth-child in styles: 1,2,3,4 (otherwise the third section would be nth-child(2) too, because of the form)
@@ -768,28 +791,19 @@ class ShortPixelView {
768
  $remainingImages, $totalCallsMade, $fileCount, $backupFolderSize);?>
769
  </section>
770
  <?php }
771
- if($resources !== null) {?>
772
  <section id="tab-resources">
773
- <h2><a class='tab-link' href='javascript:void(0);' data-id="tab-resources"><?php _e('WP Resources','shortpixel-image-optimiser');?></a></h2>
774
- <?php echo((isset($resources['body']) ? $resources['body'] : __("Please reload",'shortpixel-image-optimiser')));?>
 
 
775
  </section>
776
  <?php } ?>
777
  </article>
778
  <script>
779
- jQuery(document).ready(function () {
780
- ShortPixel.adjustSettingsTabs();
781
- jQuery( window ).resize(function() {
782
- ShortPixel.adjustSettingsTabs();
783
- });
784
- if(window.location.hash) {
785
- var target = ('tab-' + window.location.hash.substring(window.location.hash.indexOf("#")+1)).replace(/\//, '');
786
- if(jQuery("section#" + target).length) {
787
- ShortPixel.switchSettingsTab(target);
788
- }
789
- }
790
- jQuery("article.sp-tabs a.tab-link").click(function(){ShortPixel.switchSettingsTab(jQuery(this).data("id"))});
791
- });
792
  </script>
 
793
  <?php
794
  }
795
 
@@ -805,7 +819,7 @@ class ShortPixelView {
805
  $adminEmail = get_bloginfo('admin_email');
806
  if($adminEmail == 'noreply@addendio.com') $adminEmail = false; //hack for the addendio sandbox e-mail
807
  ?>
808
- <div class="wp-shortpixel-options">
809
  <?php if($this->ctrl->getVerifiedKey()) { ?>
810
  <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>
811
  <?php } else {
@@ -939,35 +953,38 @@ class ShortPixelView {
939
  </td>
940
  </tr>
941
  <tr>
942
- <th scope="row"><label for="thumbnails"><?php _e('Also include thumbnails:','shortpixel-image-optimiser');?></label></th>
943
- <td><input name="thumbnails" type="checkbox" id="thumbnails" <?php echo( $checked );?>> <?php
944
- _e('Apply compression also to <strong>image thumbnails.</strong> ','shortpixel-image-optimiser');?>
945
- <?php echo($thumbnailsToProcess > 0 ? "(" . number_format($thumbnailsToProcess) . " " . __('thumbnails to optimize','shortpixel-image-optimiser') . ")" : "");?>
946
  <p class="settings-info">
947
  <?php _e('It is highly recommended that you optimize the thumbnails as they are usually the images most viewed by end users and can generate most traffic.<br>Please note that thumbnails count up to your total quota.','shortpixel-image-optimiser');?>
948
  </p>
949
  </td>
950
  </tr>
951
  <tr>
952
- <th scope="row"><label for="backupImages"><?php _e('Image backup','shortpixel-image-optimiser');?></label></th>
953
  <td>
954
- <input name="backupImages" type="checkbox" id="backupImages" <?php echo( $checkedBackupImages );?>> <?php _e('Save and keep a backup of your original images in a separate folder.','shortpixel-image-optimiser');?>
 
955
  <p class="settings-info"><?php _e('You <strong>need to have backup active</strong> in order to be able to restore images to originals or to convert from Lossy to Lossless and back.','shortpixel-image-optimiser');?></p>
956
  </td>
957
  </tr>
958
  <tr>
959
- <th scope="row"><label for="removeExif"><?php _e('Remove EXIF','shortpixel-image-optimiser');?></label></th>
960
  <td>
961
- <input name="removeExif" type="checkbox" id="removeExif" <?php echo( $removeExif );?>><?php _e('Remove the EXIF tag of the image (recommended).','shortpixel-image-optimiser');?>
 
962
  <p class="settings-info"> <?php _e('EXIF is a set of various pieces of information that are automatically embedded into the image upon creation. This can include GPS position, camera manufacturer, date and time, etc.
963
  Unless you really need that data to be preserved, we recommend removing it as it can lead to <a href="http://blog.shortpixel.com/how-much-smaller-can-be-images-without-exif-icc" target="_blank">better compression rates</a>.','shortpixel-image-optimiser');?></p>
964
  </td>
965
  </tr>
966
  <tr>
967
- <th scope="row"><label for="resize"><?php _e('Resize large images','shortpixel-image-optimiser');?></label></th>
968
  <td>
969
- <input name="resize" type="checkbox" id="resize" <?php echo( $resize );?>> <?php
970
- _e('to maximum','shortpixel-image-optimiser');?> <input type="text" name="width" id="width" style="width:70px" class="resize-sizes"
 
971
  value="<?php echo( $this->ctrl->getResizeWidth() > 0 ? $this->ctrl->getResizeWidth() : min(924, $minSizes['width']) );?>" <?php echo( $resizeDisabled );?>/> <?php
972
  _e('pixels wide &times;','shortpixel-image-optimiser');?>
973
  <input type="text" name="height" id="height" class="resize-sizes" style="width:70px"
@@ -1013,7 +1030,7 @@ class ShortPixelView {
1013
  <?php }
1014
  }
1015
 
1016
- public function displayAdvancedSettingsForm($customFolders = false, $addedFolder = false) {
1017
  $settings = $this->ctrl->getSettings();
1018
  $minSizes = $this->ctrl->getMaxIntermediateImageSize();
1019
  $hasNextGen = $this->ctrl->hasNextGen();
@@ -1021,7 +1038,37 @@ class ShortPixelView {
1021
  $includeNextGen = ($settings->includeNextGen ? 'checked' : '');
1022
  $cmyk2rgb = ($this->ctrl->getCMYKtoRGBconversion() ? 'checked' : '');
1023
  $createWebp = ($settings->createWebp ? 'checked' : '');
1024
- $createWebpMarkup = ($settings->createWebpMarkup ? 'checked' : '');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1025
  $autoMediaLibrary = ($settings->autoMediaLibrary ? 'checked' : '');
1026
  $optimizeRetina = ($settings->optimizeRetina ? 'checked' : '');
1027
  $optimizeUnlisted = ($settings->optimizeUnlisted ? 'checked' : '');
@@ -1042,7 +1089,7 @@ class ShortPixelView {
1042
  $allSizes = $this->ctrl->getAllThumbnailSizes();
1043
  $excludeSizes = $settings->excludeSizes;
1044
  ?>
1045
- <div class="wp-shortpixel-options">
1046
  <?php if(!$this->ctrl->getVerifiedKey()) { ?>
1047
  <p><?php _e('Please enter your API key in the General tab first.','shortpixel-image-optimiser');?></p>
1048
  <?php } else { //if valid key we display the rest of the options ?>
@@ -1139,9 +1186,9 @@ class ShortPixelView {
1139
  </tr>
1140
  <?php if($hasNextGen) { ?>
1141
  <tr>
1142
- <th scope="row"><label for="nextGen"><?php _e('Optimize NextGen galleries','shortpixel-image-optimiser');?></label></th>
1143
  <td>
1144
- <input name="nextGen" type="checkbox" id="nextGen" <?php echo( $includeNextGen );?>> <?php _e('Optimize NextGen galleries.','shortpixel-image-optimiser');?>
1145
  <p class="settings-info">
1146
  <?php _e('Check this to add all your current NextGen galleries to the custom folders list and to also have all the future NextGen galleries and images optimized automatically by ShortPixel.','shortpixel-image-optimiser');?>
1147
  </p>
@@ -1149,51 +1196,94 @@ class ShortPixelView {
1149
  </tr>
1150
  <?php } ?>
1151
  <tr>
1152
- <th scope="row"><label for="png2jpg"><?php _e('Convert PNG images to JPEG','shortpixel-image-optimiser');?></label></th>
1153
  <td>
1154
- <input name="png2jpg" type="checkbox" id="png2jpg" <?php echo( $convertPng2Jpg );?> <?php echo($gdInstalled ? '' : 'disabled') ?>> <?php
1155
- _e('Automatically convert the PNG images to JPEG if possible.','shortpixel-image-optimiser');?>
1156
- <input name="png2jpgForce" type="checkbox" id="png2jpgForce" <?php echo( $convertPng2JpgForce );?> <?php echo($gdInstalled ? '' : 'disabled') ?>> <?php
1157
- _e('Force conversion of images with transparency.','shortpixel-image-optimiser');
1158
  if(!$gdInstalled) {echo("&nbsp;<span style='color:red;'>" . __('You need PHP GD for this. Please ask your hosting to install it.','shortpixel-image-optimiser') . "</span>");}
1159
- ?>
1160
  <p class="settings-info">
1161
  <?php _e('Converts all PNGs that don\'t have transparent pixels to JPEG. This can dramatically reduce the file size, especially if you have camera pictures that are saved in PNG format. The plugin will also search for references of the image in posts and will replace them.','shortpixel-image-optimiser');?>
1162
  </p>
1163
  </td>
1164
  </tr>
1165
  <tr>
1166
- <th scope="row"><label for="cmyk2rgb"><?php _e('CMYK to RGB conversion','shortpixel-image-optimiser');?></label></th>
1167
  <td>
1168
- <input name="cmyk2rgb" type="checkbox" id="cmyk2rgb" <?php echo( $cmyk2rgb );?>><?php _e('Adjust your images\' colours for computer and mobile screen display.','shortpixel-image-optimiser');?>
 
1169
  <p class="settings-info"><?php _e('Images for the web only need RGB format and converting them from CMYK to RGB makes them smaller.','shortpixel-image-optimiser');?></p>
1170
  </td>
1171
  </tr>
1172
  <tr>
1173
- <th scope="row"><label for="createWebp"><?php _e('WebP versions','shortpixel-image-optimiser');?></label></th>
1174
  <td>
1175
- <input name="createWebp" type="checkbox" id="createWebp" <?php echo( $createWebp );?>> <?php _e('Create also <a href="http://blog.shortpixel.com/how-webp-images-can-speed-up-your-site/" target="_blank">WebP versions</a> of the images <strong>for free</strong>.','shortpixel-image-optimiser');?>
 
 
 
1176
  <p class="settings-info">
1177
  <?php _e('WebP images can be up to three times smaller than PNGs and 25% smaller than JPGs. Choosing this option <strong>does not use up additional credits</strong>.','shortpixel-image-optimiser');?>
1178
  <a href="http://blog.shortpixel.com/how-webp-images-can-speed-up-your-site/" target="_blank" class="shortpixel-help-link">
1179
  <span class="dashicons dashicons-editor-help"></span><?php _e('More info','shortpixel-image-optimiser');?>
1180
  </a>
1181
  </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1182
  </td>
1183
  </tr>
1184
  <tr>
1185
- <th scope="row"><label for="createWebpMarkup"><?php _e('Generate WebP markup','shortpixel-image-optimiser');?></label></th>
1186
- <td>
1187
- <input name="createWebpMarkup" type="checkbox" id="createWebpMarkup" <?php echo( $createWebpMarkup );?>> <?php _e('Generate the &lt;picture&gt; markup in the front-end.','shortpixel-image-optimiser');?>
1188
- <p class="settings-info">
1189
- <?php _e('Each &lt;img&gt; will be replaced with a &lt;picture&gt; tag that will also provide the WebP image as a choice for browsers that support it. Also loads the picturefill.js for browsers that don\'t support the &lt;picture&gt; tag. You don\'t need to activate this if you\'re using the Cache Enabler plugin because your WebP images are already handled by this plugin. <strong>Please make a test before using this option</strong>, as if the styles that your theme is using rely on the position of your &lt;img&gt; tag, you might experience display problems.','shortpixel-image-optimiser');?>
1190
- </p>
1191
- </td>
1192
- </tr>
1193
- <tr>
1194
- <th scope="row"><label for="optimizeRetina"><?php _e('Optimize Retina images','shortpixel-image-optimiser');?></label></th>
1195
  <td>
1196
- <input name="optimizeRetina" type="checkbox" id="optimizeRetina" <?php echo( $optimizeRetina );?>> <?php _e('Optimize also the Retina images (@2x) if they exist.','shortpixel-image-optimiser');?>
 
1197
  <p class="settings-info">
1198
  <?php _e('If you have a Retina plugin that generates Retina-specific images (@2x), ShortPixel can optimize them too, alongside the regular Media Library images and thumbnails.','shortpixel-image-optimiser');?>
1199
  <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" class="shortpixel-help-link">
@@ -1203,18 +1293,20 @@ class ShortPixelView {
1203
  </td>
1204
  </tr>
1205
  <tr>
1206
- <th scope="row"><label for="optimizeUnlisted"><?php _e('Optimize other thumbs','shortpixel-image-optimiser');?></label></th>
1207
  <td>
1208
- <input name="optimizeUnlisted" type="checkbox" id="optimizeUnlisted" <?php echo( $optimizeUnlisted );?>> <?php _e('Optimize also the unlisted thumbs if found.','shortpixel-image-optimiser');?>
 
1209
  <p class="settings-info">
1210
  <?php _e('Some plugins create thumbnails which are not registered in the metadata but instead only create them alongside the other thumbnails. Let ShortPixel optimize them as well.','shortpixel-image-optimiser');?>
1211
  </p>
1212
  </td>
1213
  </tr>
1214
  <tr>
1215
- <th scope="row"><label for="optimizePdfs"><?php _e('Optimize PDFs','shortpixel-image-optimiser');?></label></th>
1216
  <td>
1217
- <input name="optimizePdfs" type="checkbox" id="optimizePdfs" <?php echo( $optimizePdfs );?>> <?php _e('Automatically optimize PDF documents.','shortpixel-image-optimiser');?>
 
1218
  </td>
1219
  </tr>
1220
  <tr>
@@ -1251,18 +1343,20 @@ class ShortPixelView {
1251
  </td>
1252
  </tr>
1253
  <tr>
1254
- <th scope="row"><label for="frontBootstrap"><?php _e('Process in front-end','shortpixel-image-optimiser');?></label></th>
1255
  <td>
1256
- <input name="frontBootstrap" type="checkbox" id="frontBootstrap" <?php echo( $frontBootstrap );?>> <?php _e('Automatically optimize images added by users in front end.','shortpixel-image-optimiser');?>
 
1257
  <p class="settings-info">
1258
  <?php _e('Check this if you have users that add images or PDF documents from custom forms in the front-end. This could increase the load on your server if you have a lot of users simultaneously connected.','shortpixel-image-optimiser');?>
1259
  </p>
1260
  </td>
1261
  </tr>
1262
  <tr>
1263
- <th scope="row"><label for="autoMediaLibrary"><?php _e('Optimize media on upload','shortpixel-image-optimiser');?></label></th>
1264
  <td>
1265
- <input name="autoMediaLibrary" type="checkbox" id="autoMediaLibrary" <?php echo( $autoMediaLibrary );?>> <?php _e('Automatically optimize Media Library items after they are uploaded (recommended).','shortpixel-image-optimiser');?>
 
1266
  <p class="settings-info">
1267
  <?php _e('By default, ShortPixel will automatically optimize all the freshly uploaded image and PDF files. If you uncheck this you\'ll need to either run Bulk ShortPixel or go to Media Library (in list view) and click on the right side "Optimize now" button(s).','shortpixel-image-optimiser');?>
1268
  </p>
@@ -1301,14 +1395,16 @@ class ShortPixelView {
1301
  * @link wp-admin/options-general.php?page=wp-shortpixel
1302
  */
1303
  function display_cloudflare_settings_form()
1304
- {
1305
- $noCurl = !function_exists('curl_init');
1306
- if($noCurl) {
1307
- echo('<p style="font-weight:bold;color:red">' . __("Please enable PHP cURL extension for the Cloudflare integration to work.", 'shortpixel-image-optimiser') . '</p>' );
1308
- }
1309
- ?>
1310
- <p><?php _e("If you're using Cloudflare on your site then we advise you to fill in the details below. This will allow ShortPixel to work seamlessly with Cloudflare so that any image optimized/restored by ShortPixel will be automatically updated on Cloudflare as well.",'shortpixel-image-optimiser');?></p>
1311
- <form name='wp_shortpixel_cloudflareAPI' action='options-general.php?page=wp-shortpixel&noheader=true'
 
 
1312
  method='post' id='wp_shortpixel_cloudflareAPI'>
1313
  <table class="form-table">
1314
  <tbody>
@@ -1356,102 +1452,152 @@ class ShortPixelView {
1356
  value="<?php _e('Save Changes', 'shortpixel-image-optimiser'); ?>"> &nbsp;
1357
  </p>
1358
  </form>
1359
-
1360
  <?php }
1361
 
1362
  function displaySettingsStats($quotaData, $averageCompression, $savedSpace, $savedBandwidth,
 
1363
  $remainingImages, $totalCallsMade, $fileCount, $backupFolderSize) { ?>
1364
- <a id="facts"></a>
1365
- <h3><?php _e('Your ShortPixel Stats','shortpixel-image-optimiser');?></h3>
1366
- <table class="form-table">
1367
- <tbody>
1368
- <tr>
1369
- <th scope="row"><label for="averagCompression"><?php _e('Average compression of your files:','shortpixel-image-optimiser');?></label></th>
1370
- <td><?php echo($averageCompression);?>%</td>
1371
- </tr>
1372
- <tr>
1373
- <th scope="row"><label for="savedSpace"><?php _e('Saved disk space by ShortPixel','shortpixel-image-optimiser');?></label></th>
1374
- <td><?php echo($savedSpace);?></td>
1375
- </tr>
1376
- <tr>
1377
- <th scope="row"><label for="savedBandwidth"><?php _e('Bandwith* saved with ShortPixel:','shortpixel-image-optimiser');?></label></th>
1378
- <td><?php echo($savedBandwidth);?></td>
1379
- </tr>
1380
- </tbody>
1381
- </table>
 
 
 
 
 
 
1382
 
1383
- <p style="padding-top: 0px; color: #818181;" ><?php _e('* Saved bandwidth is calculated at 10,000 impressions/image','shortpixel-image-optimiser');?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1384
 
1385
- <h3><?php _e('Your ShortPixel Plan','shortpixel-image-optimiser');?></h3>
1386
- <table class="form-table">
1387
- <tbody>
1388
- <tr>
1389
- <th scope="row" bgcolor="#ffffff"><label for="apiQuota"><?php _e('Your monthly plan','shortpixel-image-optimiser');?>:</label></th>
1390
- <td bgcolor="#ffffff">
1391
- <?php
1392
- $DateNow = time();
1393
- $DateSubscription = strtotime($quotaData['APILastRenewalDate']);
1394
- $DaysToReset = 30 - ((($DateNow - $DateSubscription) / 84600) % 30);
1395
- printf(__('%s/month, renews in %s days, on %s ( <a href="https://shortpixel.com/login/%s" target="_blank">Need More? See the options available</a> )','shortpixel-image-optimiser'),
1396
- $quotaData['APICallsQuota'], $DaysToReset,
1397
- date('M d, Y', strtotime(date('M d, Y') . ' + ' . $DaysToReset . ' days')), (defined("SHORTPIXEL_HIDE_API_KEY") ? '' : $this->ctrl->getApiKey()));?><br/>
1398
- <?php printf(__('<a href="https://shortpixel.com/login/%s/tell-a-friend" target="_blank">Join our friend referral system</a> to win more credits. For each user that joins, you receive +100 images credits/month.','shortpixel-image-optimiser'),
1399
- (defined("SHORTPIXEL_HIDE_API_KEY") ? '' : $this->ctrl->getApiKey()));?>
1400
- </td>
1401
- </tr>
1402
- <tr>
1403
- <th scope="row"><label for="usedQUota"><?php _e('One time credits:','shortpixel-image-optimiser');?></label></th>
1404
- <td><?php echo( number_format($quotaData['APICallsQuotaOneTimeNumeric']));?></td>
1405
- </tr>
1406
- <tr>
1407
- <th scope="row"><label for="usedQUota"><?php _e('Number of images processed this month:','shortpixel-image-optimiser');?></label></th>
1408
- <td><?php echo($totalCallsMade);?> (<a href="https://<?php echo(SHORTPIXEL_API);?>/v2/report.php?key=<?php echo(defined("SHORTPIXEL_HIDE_API_KEY") ? '' : $this->ctrl->getApiKey());?>" target="_blank">
1409
- <?php _e('see report','shortpixel-image-optimiser');?>
1410
- </a>)
1411
- </td>
1412
- </tr>
1413
- <tr>
1414
- <th scope="row"><label for="remainingImages"><?php _e('Remaining** images in your plan:','shortpixel-image-optimiser');?></label></th>
1415
- <td><?php echo($remainingImages);?> <?php _e('images','shortpixel-image-optimiser');?></td>
1416
- </tr>
1417
- </tbody>
1418
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1419
 
1420
- <p style="padding-top: 0px; color: #818181;" >
1421
- <?php printf(__('** Increase your image quota by <a href="https://shortpixel.com/login/%s" target="_blank">upgrading your ShortPixel plan.</a>','shortpixel-image-optimiser'),
 
 
1422
  defined("SHORTPIXEL_HIDE_API_KEY") ? '' : $this->ctrl->getApiKey());?>
1423
- </p>
 
1424
 
1425
- <table class="form-table">
1426
- <tbody>
1427
- <tr>
1428
- <th scope="row"><label for="totalFiles"><?php _e('Total number of processed files:','shortpixel-image-optimiser');?></label></th>
1429
- <td><?php echo($fileCount);?></td>
1430
- </tr>
1431
- <?php if(true || $this->ctrl->backupImages()) { ?>
1432
- <tr>
1433
- <th scope="row"><label for="sizeBackup"><?php _e('Original images are stored in a backup folder. Your backup folder size is now:','shortpixel-image-optimiser');?></label></th>
1434
- <td>
1435
- <form action="" method="POST">
1436
- <?php if ($backupFolderSize === null) { ?>
1437
- <span id='backup-folder-size'>Calculating...</span>
1438
- <?php } else { echo($backupFolderSize); }?>
1439
- <input type="submit" style="margin-left: 15px; vertical-align: middle;" class="button button-secondary shortpixel-confirm"
1440
- name="emptyBackup" value="<?php _e('Empty backups','shortpixel-image-optimiser');?>"
1441
- data-confirm="<?php _e('Are you sure you want to delete all the backup images? You won\'t be able to restore from backup or to reoptimize with different settings if you delete the backups.','shortpixel-image-optimiser'); ?>"/>
1442
- </form>
1443
- </td>
1444
- </tr>
1445
- <?php } ?>
1446
- </tbody>
1447
- </table>
1448
- <div style="display:none">
1449
 
1450
- </div>
1451
- <?php
1452
  }
1453
 
1454
- public function renderCustomColumn($id, $data, $extended = false){ ?>
1455
  <div id='sp-msg-<?php echo($id);?>' class='column-wp-shortPixel'>
1456
 
1457
  <?php switch($data['status']) {
78
 
79
  public static function displayActivationNotice($when = 'activate', $extra = '') {
80
  $extraStyle = ($when == 'compat' || $when == 'fileperms' ? "background-color: #ff9999;margin: 5px 20px 15px 0;'" : '');
81
+ $icon = false;
82
+ $extraClass = 'notice-warning';
83
  switch($when) {
84
  case 'compat': $extraClass = 'notice-error below-h2';
85
  case 'fileperms': $icon = 'scared'; $extraClass = 'notice-error'; break;
87
  case 'upgmonth':
88
  case 'upgbulk': $icon = 'notes'; $extraClass = 'notice-success'; break;
89
  case 'generic-err': $extraClass = 'notice-error is-dismissible'; break;
90
+ case 'activate': $icon = 'scared'; break;
91
  }
92
  ?>
93
  <div class='notice <?php echo($extraClass);?> notice-warning' id='short-pixel-notice-<?php echo($when);?>' <?php echo($extraStyle);?>>
112
  if($when == 'generic-err') {?>
113
  <button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button>
114
  <?php }
115
+ }
116
  if($icon){ ?>
117
+ <img src="<?php echo(plugins_url('/shortpixel-image-optimiser/res/img/robo-' . $icon . '.png'));?>"
118
+ srcset='<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/robo-' . $icon . '.png' ));?> 1x, <?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/robo-' . $icon . '@2x.png' ));?> 2x'
119
+ class='short-pixel-notice-icon'>
120
+ <?php } ?>
 
121
  <h3><?php _e('ShortPixel Image Optimizer','shortpixel-image-optimiser');
122
  if($when == 'compat') { echo(' '); _e('Warning','shortpixel-image-optimiser');}
123
  if($when == 'unlisted') { echo(' '); _e(' alert','shortpixel-image-optimiser');}
139
  break;
140
  case 'compat' :
141
  _e("The following plugins are not compatible with ShortPixel and may lead to unexpected results: ",'shortpixel-image-optimiser');
142
+ echo('<ul class="sp-conflict-plugins">');
143
  foreach($extra as $plugin) {
144
+ //ShortPixelVDD($plugin);
145
+ $action = $plugin['action'];
146
+ $link = ( $action == 'Deactivate' )
147
+ ? wp_nonce_url( admin_url( 'admin-post.php?action=shortpixel_deactivate_plugin&plugin=' . urlencode( $plugin['path'] ) ), 'sp_deactivate_plugin_nonce' )
148
+ : $plugin['href'];
149
  echo('<li class="sp-conflict-plugins-list"><strong>' . $plugin['name'] . '</strong>');
150
+ echo('<a href="' . $link . '" class="button button-primary">'
151
+ . __( $action, 'shortpixel_image_optimiser' ) . '</a>');
152
  }
153
  echo("</ul>");
154
  break;
157
  <p> <?php
158
  if($when == 'upgmonth') {
159
  printf(__("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>."
160
+ . " You might need to upgrade your plan in order to have all your images optimized.", 'shortpixel_image_optimiser'), $extra['monthAvg'], $extra['monthlyQuota']);
161
  } else {
162
  printf(__("You currently have <strong>%d images and thumbnails to optimize</strong> but you only have <strong>%d images</strong> available in your current plan."
163
+ . " You might need to upgrade your plan in order to have all your images optimized.", 'shortpixel_image_optimiser'), $extra['filesTodo'], $extra['quotaAvailable']);
164
  }?></p><?php
165
  self::includeProposeUpgradePopup();
166
  break;
229
  <div class="bulk-label"><?php _e('Already optimized thumbnails','shortpixel-image-optimiser');?></div>
230
  <div class="bulk-val"><?php echo(number_format($quotaData['totalProcessedMlFiles'] - $quotaData['mainProcessedMlFiles']));?></div><br>
231
  <?php } ?>
232
+ <div class="bulk-label bulk-total">
233
+ <?php _e('Total to be optimized','shortpixel-image-optimiser');?>
234
+ <div class="reset"><?php _e('(Originals and thumbnails)','shortpixel-image-optimiser');?></div>
235
+ </div>
236
  <div class="bulk-val bulk-total" id='displayTotal'><?php echo(number_format(max( 0, $quotaData['totalMlFiles'] - $quotaData['totalProcessedMlFiles'])));?></div>
237
 
238
  <?php if($customCount > 0) { ?>
239
+ <h3 style='margin-bottom:10px;'><?php _e('Your custom folders','shortpixel-image-optimiser');?></h3>
240
+ <div class="bulk-label bulk-total">
241
+ <?php _e('Total to be optimized','shortpixel-image-optimiser');?>
242
+ <div class="reset"><?php _e('(Originals and thumbnails)','shortpixel-image-optimiser');?></div>
243
+ </div>
244
  <div class="bulk-val bulk-total" id='displayTotal'><?php echo(number_format($customCount));?></div>
245
  <?php } ?>
246
  </div>
369
  jQuery(function() {
370
  jQuery("#sp-total-optimization-dial").val("<?php echo("" . round($averageCompression))?>");
371
  ShortPixel.percentDial("#sp-total-optimization-dial", 60);
372
+
373
  jQuery(".sp-bulk-summary").spTooltip({
374
  tooltipSource: "inline",
375
  tooltipSourceID: "#sp-bulk-stats"
538
  <?php
539
  }
540
 
541
+ public function displayBulkProcessingRunning($percent, $message, $remainingQuota, $averageCompression, $type, $quotaData) {
542
  $settings = $this->ctrl->getSettings();
543
  $dismissed = $settings->dismissedNotices ? $settings->dismissedNotices : array();
544
  ?>
547
  <?php $this->displayBulkProgressBar(true, $percent, $message, $remainingQuota, $averageCompression, $type);?>
548
 
549
  <!-- Partners: SQUIRLY -->
550
+ <?php if(!isset($dismissed['squirrly']) && $quotaData['APICallsQuotaOneTimeNumeric']<10000 && $quotaData['APICallsQuotaNumeric']<5000) { ?>
551
+ <div id="short-pixel-notice-squirrly" class="sp-notice sp-notice-info bulk-progress bulk-progress-partners sp-floating-block sp-full-width">
552
  <div style="float:right"><a href="javascript:dismissShortPixelNotice('squirrly')"><?php _e('Dismiss','shortpixel-image-optimiser');?></a></div>
553
  <a href="https://my.squirrly.co/go120073/squirrly.co/short-pixel-seo" target="_blank">
554
  <img src="<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/squirrly.png' ));?>" height="50">
677
  <input type="submit" class="button button-primary bulk-cancel" onclick="clearBulkProcessor();"
678
  name="bulkProcessStop" value="Stop" style="margin-left:10px"/>
679
  <input type="submit" class="button button-primary bulk-cancel" onclick="clearBulkProcessor();"
680
+ name="<?php echo($running ? "bulkProcessPause" : "bulkProcessResume");?>" value="<?php echo($running ? __('Pause','shortpixel-image-optimiser') : __('All media','shortpixel-image-optimiser'));?>"/>
681
  <?php if(!$running && $customPending) {?>
682
  <input type="submit" class="button button-primary bulk-cancel" onclick="clearBulkProcessor();"
683
  name="skipToCustom" value="<?php _e('Only other media','shortpixel-image-optimiser');?>" title="<?php _e('Process only the other media, skipping the Media Library','shortpixel-image-optimiser');?>" style="margin-right:10px"/>
684
  <?php }?>
685
+ <span class="resumeLabel"><?php echo( !$running ? __('Resume: ','shortpixel-image-optimiser') : "");?></span>
686
  </form>
687
  <?php } else { ?>
688
  <a href="options-general.php?page=wp-shortpixel" class="button button-primary bulk-cancel" style="margin-left:10px"><?php _e('Manage custom folders','shortpixel-image-optimiser');?></a>
720
  </div>
721
  <?php
722
  }
 
723
  function displaySettings($showApiKey, $editApiKey, $quotaData, $notice, $resources = null, $averageCompression = null, $savedSpace = null, $savedBandwidth = null,
724
  $remainingImages = null, $totalCallsMade = null, $fileCount = null, $backupFolderSize = null,
725
+ $customFolders = null, $folderMsg = false, $addedFolder = false, $showAdvanced = false, $cloudflareAPI = false, $htaccessWriteable = false, $isNginx = false ) {
726
  //wp_enqueue_script('jquery.idTabs.js', plugins_url('/js/jquery.idTabs.js',__FILE__) );
727
  $this->ctrl->outputHSBeacon();
728
  ?>
729
+ <div class="wrap">
730
  <h1><?php _e('ShortPixel Plugin Settings','shortpixel-image-optimiser');?></h1>
731
  <p style="font-size:18px">
732
  <a href="https://shortpixel.com/<?php
736
  </a> | <a href="https://shortpixel.com/pricing<?php echo(WPShortPixel::getAffiliateSufix()); ?>#faq" target="_blank" style="font-size:18px"><?php _e('FAQ','shortpixel-image-optimiser');?> </a> |
737
  <a href="https://shortpixel.com/contact<?php echo(WPShortPixel::getAffiliateSufix());?>" target="_blank" style="font-size:18px"><?php _e('Support','shortpixel-image-optimiser');?> </a>
738
  </p>
739
+ <?php if($notice !== null) {
740
+ //die(ShortPixelVDD($notice['status']));
741
+ switch($notice['status']) {
742
+ case 'error': $extraClass = 'notice-error'; $icon = 'scared'; break;
743
+ case 'success': $extraClass = 'notice-success'; $icon = 'slider'; break;
744
+ }
745
+ ?>
746
  <br/>
747
+ <div class="clearfix <?php echo($extraClass);?>" style="background-color: #fff; border-left-style: solid; border-left-width: 4px; box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1); padding: 1px 12px;;width: 95%">
748
+ <img src="<?php echo(plugins_url('/shortpixel-image-optimiser/res/img/robo-' . $icon . '.png'));?>"
749
+ srcset='<?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/robo-' . $icon . '.png' ));?> 1x, <?php echo(plugins_url( 'shortpixel-image-optimiser/res/img/robo-' . $icon . '@2x.png' ));?> 2x'
750
+ class='short-pixel-notice-icon'>
751
+ <p><?php echo($notice['msg']);?></p>
752
  </div>
753
  <?php } ?>
754
  <?php if($folderMsg) { ?>
767
  $this->displaySettingsForm($showApiKey, $editApiKey, $quotaData);?>
768
  </section>
769
  <?php if($this->ctrl->getVerifiedKey()) {?>
770
+ <section <?php echo($showAdvanced ? "class='sel-tab'" : "");?> id="tab-adv-settings" class="clearfix">
771
  <h2><a class='tab-link' href='javascript:void(0);' data-id="tab-adv-settings"><?php _e('Advanced','shortpixel-image-optimiser');?></a></h2>
772
+ <?php $this->displayAdvancedSettingsForm($customFolders, $addedFolder, $htaccessWriteable, $isNginx );?>
773
  </section>
774
  <?php } ?>
775
  </form><span style="display:none">&nbsp;</span><?php //the span is a trick to keep the sections ordered as nth-child in styles: 1,2,3,4 (otherwise the third section would be nth-child(2) too, because of the form)
791
  $remainingImages, $totalCallsMade, $fileCount, $backupFolderSize);?>
792
  </section>
793
  <?php }
794
+ if( $resources !== null && $quotaData['APICallsQuotaOneTimeNumeric']<10000 && $quotaData['APICallsQuotaNumeric']<5000 ) {?>
795
  <section id="tab-resources">
796
+ <h2> <?php number_format($quotaData['APICallsQuotaOneTimeNumeric']); ?> <a class='tab-link' href='javascript:void(0);' data-id="tab-resources"><?php _e('WP Resources','shortpixel-image-optimiser');?></a></h2>
797
+ <div class="wp-shortpixel-tab-content">
798
+ <?php echo((isset($resources['body']) ? $resources['body'] : __("Please reload",'shortpixel-image-optimiser')));?>
799
+ </div>
800
  </section>
801
  <?php } ?>
802
  </article>
803
  <script>
804
+ jQuery(document).ready(function(){ ShortPixel.initSettings() });
 
 
 
 
 
 
 
 
 
 
 
 
805
  </script>
806
+ </div>
807
  <?php
808
  }
809
 
819
  $adminEmail = get_bloginfo('admin_email');
820
  if($adminEmail == 'noreply@addendio.com') $adminEmail = false; //hack for the addendio sandbox e-mail
821
  ?>
822
+ <div class="wp-shortpixel-options wp-shortpixel-tab-content">
823
  <?php if($this->ctrl->getVerifiedKey()) { ?>
824
  <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>
825
  <?php } else {
953
  </td>
954
  </tr>
955
  <tr>
956
+ <th scope="row"><?php _e('Also include thumbnails:','shortpixel-image-optimiser');?></th>
957
+ <td><input name="thumbnails" type="checkbox" id="thumbnails" <?php echo( $checked );?>>
958
+ <label for="thumbnails"><?php _e('Apply compression also to <strong>image thumbnails.</strong> ','shortpixel-image-optimiser');?></label>
959
+ <?php echo($thumbnailsToProcess > 0 ? "(" . number_format($thumbnailsToProcess) . " " . __('thumbnails to optimize','shortpixel-image-optimiser') . ")" : "");?>
960
  <p class="settings-info">
961
  <?php _e('It is highly recommended that you optimize the thumbnails as they are usually the images most viewed by end users and can generate most traffic.<br>Please note that thumbnails count up to your total quota.','shortpixel-image-optimiser');?>
962
  </p>
963
  </td>
964
  </tr>
965
  <tr>
966
+ <th scope="row"><?php _e('Image backup','shortpixel-image-optimiser');?></th>
967
  <td>
968
+ <input name="backupImages" type="checkbox" id="backupImages" <?php echo( $checkedBackupImages );?>>
969
+ <label for="backupImages"><?php _e('Save and keep a backup of your original images in a separate folder.','shortpixel-image-optimiser');?></label>
970
  <p class="settings-info"><?php _e('You <strong>need to have backup active</strong> in order to be able to restore images to originals or to convert from Lossy to Lossless and back.','shortpixel-image-optimiser');?></p>
971
  </td>
972
  </tr>
973
  <tr>
974
+ <th scope="row"><?php _e('Remove EXIF','shortpixel-image-optimiser');?></th>
975
  <td>
976
+ <input name="removeExif" type="checkbox" id="removeExif" <?php echo( $removeExif );?>>
977
+ <label for="removeExif"><?php _e('Remove the EXIF tag of the image (recommended).','shortpixel-image-optimiser');?></label>
978
  <p class="settings-info"> <?php _e('EXIF is a set of various pieces of information that are automatically embedded into the image upon creation. This can include GPS position, camera manufacturer, date and time, etc.
979
  Unless you really need that data to be preserved, we recommend removing it as it can lead to <a href="http://blog.shortpixel.com/how-much-smaller-can-be-images-without-exif-icc" target="_blank">better compression rates</a>.','shortpixel-image-optimiser');?></p>
980
  </td>
981
  </tr>
982
  <tr>
983
+ <th scope="row"><?php _e('Resize large images','shortpixel-image-optimiser');?></th>
984
  <td>
985
+ <input name="resize" type="checkbox" id="resize" <?php echo( $resize );?>>
986
+ <label for="resize"><?php _e('to maximum','shortpixel-image-optimiser');?></label>
987
+ <input type="text" name="width" id="width" style="width:70px" class="resize-sizes"
988
  value="<?php echo( $this->ctrl->getResizeWidth() > 0 ? $this->ctrl->getResizeWidth() : min(924, $minSizes['width']) );?>" <?php echo( $resizeDisabled );?>/> <?php
989
  _e('pixels wide &times;','shortpixel-image-optimiser');?>
990
  <input type="text" name="height" id="height" class="resize-sizes" style="width:70px"
1030
  <?php }
1031
  }
1032
 
1033
+ public function displayAdvancedSettingsForm($customFolders = false, $addedFolder = false, $htaccessWriteable = false, $isNginx = false ) {
1034
  $settings = $this->ctrl->getSettings();
1035
  $minSizes = $this->ctrl->getMaxIntermediateImageSize();
1036
  $hasNextGen = $this->ctrl->hasNextGen();
1038
  $includeNextGen = ($settings->includeNextGen ? 'checked' : '');
1039
  $cmyk2rgb = ($this->ctrl->getCMYKtoRGBconversion() ? 'checked' : '');
1040
  $createWebp = ($settings->createWebp ? 'checked' : '');
1041
+ $deliverWebp = $settings->deliverWebp;
1042
+ $deliverWebpChecked = ( $deliverWebp != 0 ? 'checked' : '');
1043
+ $deliverWebpAltered = ( ( $deliverWebp == 1 || $deliverWebp == 2 ) ? 'checked' : '');
1044
+ $deliverWebpAlteredGlobal = ( $deliverWebp == 1 ? 'checked' : '');
1045
+ $deliverWebpAlteredWP = ( $deliverWebp == 2 ? 'checked' : '');
1046
+ $deliverWebpUnaltered = ( $deliverWebp == 3 ? 'checked' : '');
1047
+
1048
+ $deliverWebpAlteredDisabled = '';
1049
+ $deliverWebpUnalteredDisabled = '';
1050
+ $deliverWebpAlteredDisabledNotice = false;
1051
+ $deliverWebpUnalteredLabel ='';
1052
+
1053
+ //$isNginx = false;
1054
+ //$htaccessWriteable = false;
1055
+
1056
+ if( $isNginx ){
1057
+ $deliverWebpUnaltered = ''; // Uncheck
1058
+ $deliverWebpUnalteredDisabled = 'disabled'; // Disable
1059
+ $deliverWebpUnalteredLabel = __('It looks like you\'re running your site on an NginX server. This means that you can only achieve this functionality by directly configuring the server config files and .htaccess file. Please follow the following link for instructions on how to achieve this:','shortpixel-image-optimiser')." <a href=\"javascript:void(0)\" data-beacon-article=\"5bfeb9de2c7d3a31944e78ee\">Open article</a>";
1060
+ } else {
1061
+ if( !$htaccessWriteable ){
1062
+ $deliverWebpUnalteredDisabled = 'disabled'; // Disable
1063
+ if( $deliverWebp == 3 ){
1064
+ $deliverWebpAlteredDisabled = 'disabled'; // Disable
1065
+ $deliverWebpUnalteredLabel = __('It looks like you recently moved from an Apache server to an NGINX server, while the option to use .htacces was in use. Please follow this tutorial to see how you could implement by yourself this functionality, outside of the WP plugin. ','shortpixel-image-optimiser');
1066
+ } else {
1067
+ $deliverWebpUnalteredLabel = __('It looks like your .htaccess file cannot be written. Please fix this and then return to refresh this page to enable this option.','shortpixel-image-optimiser');
1068
+ }
1069
+ }
1070
+ }
1071
+
1072
  $autoMediaLibrary = ($settings->autoMediaLibrary ? 'checked' : '');
1073
  $optimizeRetina = ($settings->optimizeRetina ? 'checked' : '');
1074
  $optimizeUnlisted = ($settings->optimizeUnlisted ? 'checked' : '');
1089
  $allSizes = $this->ctrl->getAllThumbnailSizes();
1090
  $excludeSizes = $settings->excludeSizes;
1091
  ?>
1092
+ <div class="wp-shortpixel-options wp-shortpixel-tab-content">
1093
  <?php if(!$this->ctrl->getVerifiedKey()) { ?>
1094
  <p><?php _e('Please enter your API key in the General tab first.','shortpixel-image-optimiser');?></p>
1095
  <?php } else { //if valid key we display the rest of the options ?>
1186
  </tr>
1187
  <?php if($hasNextGen) { ?>
1188
  <tr>
1189
+ <th scope="row"><?php _e('Optimize NextGen galleries','shortpixel-image-optimiser');?></th>
1190
  <td>
1191
+ <input name="nextGen" type="checkbox" id="nextGen" <?php echo( $includeNextGen );?>> <label for="nextGen"><?php _e('Optimize NextGen galleries.','shortpixel-image-optimiser');?></label>
1192
  <p class="settings-info">
1193
  <?php _e('Check this to add all your current NextGen galleries to the custom folders list and to also have all the future NextGen galleries and images optimized automatically by ShortPixel.','shortpixel-image-optimiser');?>
1194
  </p>
1196
  </tr>
1197
  <?php } ?>
1198
  <tr>
1199
+ <th scope="row"><?php _e('Convert PNG images to JPEG','shortpixel-image-optimiser');?></th>
1200
  <td>
1201
+ <input name="png2jpg" type="checkbox" id="png2jpg" <?php echo( $convertPng2Jpg );?> <?php echo($gdInstalled ? '' : 'disabled') ?>>
1202
+ <label for="png2jpg"><?php _e('Automatically convert the PNG images to JPEG if possible.','shortpixel-image-optimiser');?></label>
1203
+ <input name="png2jpgForce" type="checkbox" id="png2jpgForce" <?php echo( $convertPng2JpgForce );?> <?php echo($gdInstalled ? '' : 'disabled') ?>>
1204
+ <label for="png2jpgForce"><?php _e('Force conversion of images with transparency.','shortpixel-image-optimiser');
1205
  if(!$gdInstalled) {echo("&nbsp;<span style='color:red;'>" . __('You need PHP GD for this. Please ask your hosting to install it.','shortpixel-image-optimiser') . "</span>");}
1206
+ ?></label>
1207
  <p class="settings-info">
1208
  <?php _e('Converts all PNGs that don\'t have transparent pixels to JPEG. This can dramatically reduce the file size, especially if you have camera pictures that are saved in PNG format. The plugin will also search for references of the image in posts and will replace them.','shortpixel-image-optimiser');?>
1209
  </p>
1210
  </td>
1211
  </tr>
1212
  <tr>
1213
+ <th scope="row"><?php _e('CMYK to RGB conversion','shortpixel-image-optimiser');?></th>
1214
  <td>
1215
+ <input name="cmyk2rgb" type="checkbox" id="cmyk2rgb" <?php echo( $cmyk2rgb );?>>
1216
+ <label for="cmyk2rgb"><?php _e('Adjust your images\' colours for computer and mobile screen display.','shortpixel-image-optimiser');?></label>
1217
  <p class="settings-info"><?php _e('Images for the web only need RGB format and converting them from CMYK to RGB makes them smaller.','shortpixel-image-optimiser');?></p>
1218
  </td>
1219
  </tr>
1220
  <tr>
1221
+ <th scope="row"><?php _e('WebP Images:','shortpixel-image-optimiser');?></th>
1222
  <td>
1223
+ <input name="createWebp" type="checkbox" id="createWebp" <?php echo( $createWebp );?>>
1224
+ <label for="createWebp">
1225
+ <?php _e('Also create <a href="http://blog.shortpixel.com/how-webp-images-can-speed-up-your-site/" target="_blank">WebP versions</a> of the images, <strong>for free</strong>.','shortpixel-image-optimiser');?>
1226
+ </label>
1227
  <p class="settings-info">
1228
  <?php _e('WebP images can be up to three times smaller than PNGs and 25% smaller than JPGs. Choosing this option <strong>does not use up additional credits</strong>.','shortpixel-image-optimiser');?>
1229
  <a href="http://blog.shortpixel.com/how-webp-images-can-speed-up-your-site/" target="_blank" class="shortpixel-help-link">
1230
  <span class="dashicons dashicons-editor-help"></span><?php _e('More info','shortpixel-image-optimiser');?>
1231
  </a>
1232
  </p>
1233
+ <div class="deliverWebpSettings">
1234
+ <input name="deliverWebp" type="checkbox" id="deliverWebp" <?php echo( $deliverWebpChecked );?>>
1235
+ <label for="deliverWebp">
1236
+ <?php _e('Deliver the WebP versions of the images in the front-end:','shortpixel-image-optimiser');?>
1237
+ </label>
1238
+ <ul class="deliverWebpTypes">
1239
+ <li>
1240
+ <input type="radio" name="deliverWebpType" id="deliverWebpUnaltered" <?php echo( $deliverWebpUnaltered );?> <?php echo( $deliverWebpUnalteredDisabled );?> value="deliverWebpUnaltered">
1241
+ <label for="deliverWebpUnaltered">
1242
+ <?php _e('Without altering the page code (via .htaccess)','shortpixel-image-optimiser')?>
1243
+ </label>
1244
+ <?php if($deliverWebpUnalteredLabel){ ?>
1245
+ <p class="sp-notice">
1246
+ <?php echo( $deliverWebpUnalteredLabel );?>
1247
+ </p>
1248
+ <?php } ?>
1249
+ </li>
1250
+ <li>
1251
+ <input type="radio" name="deliverWebpType" id="deliverWebpAltered" <?php echo( $deliverWebpAltered );?> <?php echo( $deliverWebpAlteredDisabled );?> value="deliverWebpAltered">
1252
+ <label for="deliverWebpAltered">
1253
+ <?php _e('Altering the page code, using the &lt;PICTURE&gt; tag syntax (might break some third party plugins and/or styles that depend on &lt;IMG&gt; tags)','shortpixel-image-optimiser');?>
1254
+ </label>
1255
+ <?php if($deliverWebpAlteredDisabledNotice){ ?>
1256
+ <p class="sp-notice">
1257
+ <?php _e('After the option to work on .htaccess was selected, the .htaccess file has become unaccessible / readonly. Please make the .htaccess file writeable again to be able to further set up this option.','shortpixel-image-optimiser')?>
1258
+ </p>
1259
+ <?php } ?>
1260
+ <p class="settings-info">
1261
+ <?php _e('Each &lt;img&gt; will be replaced with a &lt;picture&gt; tag that will also provide the WebP image as a choice for browsers that support it. Also loads the picturefill.js for browsers that don\'t support the &lt;picture&gt; tag. You don\'t need to activate this if you\'re using the Cache Enabler plugin because your WebP images are already handled by this plugin. <strong>Please make a test before using this option</strong>, as if the styles that your theme is using rely on the position of your &lt;img&gt; tag, you might experience display problems.','shortpixel-image-optimiser');?>
1262
+ </p>
1263
+ <ul class="deliverWebpAlteringTypes">
1264
+ <li>
1265
+ <input type="radio" name="deliverWebpAlteringType" id="deliverWebpAlteredWP" <?php echo( $deliverWebpAlteredWP );?> value="deliverWebpAlteredWP">
1266
+ <label for="deliverWebpAlteredWP">
1267
+ <?php _e('Only via Wordpress hooks (like the_content, the_excerpt, etc)');?>
1268
+ </label>
1269
+ </li>
1270
+ <li>
1271
+ <input type="radio" name="deliverWebpAlteringType" id="deliverWebpAlteredGlobal" <?php echo( $deliverWebpAlteredGlobal );?> value="deliverWebpAlteredGlobal">
1272
+ <label for="deliverWebpAlteredGlobal">
1273
+ <?php _e('Global (processes the whole output buffer before sending the HTML to the browser)','shortpixel-image-optimiser');?>
1274
+ </label>
1275
+ </li>
1276
+ </ul>
1277
+ </li>
1278
+ </ul>
1279
+ </div>
1280
  </td>
1281
  </tr>
1282
  <tr>
1283
+ <th scope="row"><?php _e('Optimize Retina images','shortpixel-image-optimiser');?></th>
 
 
 
 
 
 
 
 
 
1284
  <td>
1285
+ <input name="optimizeRetina" type="checkbox" id="optimizeRetina" <?php echo( $optimizeRetina );?>>
1286
+ <label for="optimizeRetina"><?php _e('Also optimize the Retina images (@2x) if they exist.','shortpixel-image-optimiser');?></label>
1287
  <p class="settings-info">
1288
  <?php _e('If you have a Retina plugin that generates Retina-specific images (@2x), ShortPixel can optimize them too, alongside the regular Media Library images and thumbnails.','shortpixel-image-optimiser');?>
1289
  <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" class="shortpixel-help-link">
1293
  </td>
1294
  </tr>
1295
  <tr>
1296
+ <th scope="row"><?php _e('Optimize other thumbs','shortpixel-image-optimiser');?></th>
1297
  <td>
1298
+ <input name="optimizeUnlisted" type="checkbox" id="optimizeUnlisted" <?php echo( $optimizeUnlisted );?>>
1299
+ <label for="optimizeUnlisted"><?php _e('Also optimize the unlisted thumbs if found.','shortpixel-image-optimiser');?></label>
1300
  <p class="settings-info">
1301
  <?php _e('Some plugins create thumbnails which are not registered in the metadata but instead only create them alongside the other thumbnails. Let ShortPixel optimize them as well.','shortpixel-image-optimiser');?>
1302
  </p>
1303
  </td>
1304
  </tr>
1305
  <tr>
1306
+ <th scope="row"><?php _e('Optimize PDFs','shortpixel-image-optimiser');?></th>
1307
  <td>
1308
+ <input name="optimizePdfs" type="checkbox" id="optimizePdfs" <?php echo( $optimizePdfs );?>>
1309
+ <label for="optimizePdfs"><?php _e('Automatically optimize PDF documents.','shortpixel-image-optimiser');?></label>
1310
  </td>
1311
  </tr>
1312
  <tr>
1343
  </td>
1344
  </tr>
1345
  <tr>
1346
+ <th scope="row"><?php _e('Process in front-end','shortpixel-image-optimiser');?></th>
1347
  <td>
1348
+ <input name="frontBootstrap" type="checkbox" id="frontBootstrap" <?php echo( $frontBootstrap );?>>
1349
+ <label for="frontBootstrap"><?php _e('Automatically optimize images added by users in front end.','shortpixel-image-optimiser');?></label>
1350
  <p class="settings-info">
1351
  <?php _e('Check this if you have users that add images or PDF documents from custom forms in the front-end. This could increase the load on your server if you have a lot of users simultaneously connected.','shortpixel-image-optimiser');?>
1352
  </p>
1353
  </td>
1354
  </tr>
1355
  <tr>
1356
+ <th scope="row"><?php _e('Optimize media on upload','shortpixel-image-optimiser');?></th>
1357
  <td>
1358
+ <input name="autoMediaLibrary" type="checkbox" id="autoMediaLibrary" <?php echo( $autoMediaLibrary );?>>
1359
+ <label for="autoMediaLibrary"><?php _e('Automatically optimize Media Library items after they are uploaded (recommended).','shortpixel-image-optimiser');?></label>
1360
  <p class="settings-info">
1361
  <?php _e('By default, ShortPixel will automatically optimize all the freshly uploaded image and PDF files. If you uncheck this you\'ll need to either run Bulk ShortPixel or go to Media Library (in list view) and click on the right side "Optimize now" button(s).','shortpixel-image-optimiser');?>
1362
  </p>
1395
  * @link wp-admin/options-general.php?page=wp-shortpixel
1396
  */
1397
  function display_cloudflare_settings_form()
1398
+ { ?>
1399
+ <div class="wp-shortpixel-tab-content">
1400
+ <?php
1401
+ $noCurl = !function_exists('curl_init');
1402
+ if($noCurl) {
1403
+ echo('<p style="font-weight:bold;color:red">' . __("Please enable PHP cURL extension for the Cloudflare integration to work.", 'shortpixel-image-optimiser') . '</p>' );
1404
+ }
1405
+ ?>
1406
+ <p><?php _e("If you're using Cloudflare on your site then we advise you to fill in the details below. This will allow ShortPixel to work seamlessly with Cloudflare so that any image optimized/restored by ShortPixel will be automatically updated on Cloudflare as well.",'shortpixel-image-optimiser');?></p>
1407
+ <form name='wp_shortpixel_cloudflareAPI' action='options-general.php?page=wp-shortpixel&noheader=true'
1408
  method='post' id='wp_shortpixel_cloudflareAPI'>
1409
  <table class="form-table">
1410
  <tbody>
1452
  value="<?php _e('Save Changes', 'shortpixel-image-optimiser'); ?>"> &nbsp;
1453
  </p>
1454
  </form>
1455
+ </div>
1456
  <?php }
1457
 
1458
  function displaySettingsStats($quotaData, $averageCompression, $savedSpace, $savedBandwidth,
1459
+
1460
  $remainingImages, $totalCallsMade, $fileCount, $backupFolderSize) { ?>
1461
+ <div class="wp-shortpixel-tab-content">
1462
+ <a id="facts"></a>
1463
+ <h3><?php _e('Your ShortPixel Stats','shortpixel-image-optimiser');?></h3>
1464
+ <table class="form-table">
1465
+ <tbody>
1466
+ <tr>
1467
+ <th scope="row">
1468
+ <?php _e('Average compression of your files:','shortpixel-image-optimiser');?>
1469
+ </th>
1470
+ <td>
1471
+ <strong><?php echo($averageCompression);?>%</strong>
1472
+ <div class="sp-bulk-summary">
1473
+ <input type="text" value="<?php echo("" . round($averageCompression))?>" id="sp-total-optimization-dial" class="dial">
1474
+ </div>
1475
+ <div id="sp-bulk-stats" style="display:none">
1476
+ <?php
1477
+ $under5PercentCount = $this->ctrl->getSettings()->under5Percent;//amount of under 5% optimized imgs.
1478
+ $this->displayBulkStats($quotaData['totalProcessedFiles'], $quotaData['mainProcessedFiles'], $under5PercentCount, $averageCompression, $savedSpace);
1479
+ ?>
1480
+ </div>
1481
+ <script>
1482
+ jQuery(function() {
1483
+ jQuery("#sp-total-optimization-dial").val("<?php echo("" . round($averageCompression))?>");
1484
+ ShortPixel.percentDial("#sp-total-optimization-dial", 160);
1485
 
1486
+ jQuery(".sp-bulk-summary").spTooltip({
1487
+ tooltipSource: "inline",
1488
+ tooltipSourceID: "#sp-bulk-stats"
1489
+ });
1490
+ });
1491
+ !function(d,s,id){//Just optimized my site with ShortPixel image optimization plugin
1492
+ var js,
1493
+ fjs=d.getElementsByTagName(s)[0],
1494
+ p=/^http:/.test(d.location)?'http':'https';
1495
+ if(!d.getElementById(id)){js=d.createElement(s);
1496
+ js.id=id;js.src=p+'://platform.twitter.com/widgets.js';
1497
+ fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');
1498
+ </script>
1499
+ </td>
1500
+ </tr>
1501
+ <tr>
1502
+ <th scope="row">
1503
+ <?php _e('Disk space saved by ShortPixel:','shortpixel-image-optimiser');?>
1504
+ </th>
1505
+ <td><?php echo($savedSpace);?></td>
1506
+ </tr>
1507
+ <tr>
1508
+ <th scope="row">
1509
+ <?php _e('Bandwith* saved by ShortPixel:','shortpixel-image-optimiser');?>
1510
+ </th>
1511
+ <td><?php echo($savedBandwidth);?></td>
1512
+ </tr>
1513
+ </tbody>
1514
+ </table>
1515
 
1516
+ <h3><?php _e('Your ShortPixel Credits','shortpixel-image-optimiser');?></h3>
1517
+ <table class="form-table">
1518
+ <tbody>
1519
+ <tr>
1520
+ <th scope="row" bgcolor="#ffffff">
1521
+ <?php _e('Your monthly plan','shortpixel-image-optimiser');?>:
1522
+ </th>
1523
+ <td bgcolor="#ffffff">
1524
+ <?php
1525
+ $DateNow = time();
1526
+ $DateSubscription = strtotime($quotaData['APILastRenewalDate']);
1527
+ $DaysToReset = 30 - ((($DateNow - $DateSubscription) / 84600) % 30);
1528
+ printf(__('%s/month, renews in %s days, on %s ( <a href="https://shortpixel.com/login/%s" target="_blank">Need More? See the options available</a> )','shortpixel-image-optimiser'),
1529
+ $quotaData['APICallsQuota'], $DaysToReset,
1530
+ date('M d, Y', strtotime(date('M d, Y') . ' + ' . $DaysToReset . ' days')), (defined("SHORTPIXEL_HIDE_API_KEY") ? '' : $this->ctrl->getApiKey()));?><br/>
1531
+ <?php printf(__('<a href="https://shortpixel.com/login/%s/tell-a-friend" target="_blank">Join our friend referral system</a> to win more credits. For each user that joins, you receive +100 images credits/month.','shortpixel-image-optimiser'),
1532
+ (defined("SHORTPIXEL_HIDE_API_KEY") ? '' : $this->ctrl->getApiKey()));?>
1533
+ <br><br>
1534
+ <?php _e('Consumed: ','shortpixel-image-optimiser'); ?>
1535
+ <strong><?php echo( $totalCallsMade['plan'] ); ?></strong>
1536
+ <?php _e('; Remaining: ','shortpixel-image-optimiser'); ?>
1537
+ <strong><?php echo( $quotaData['APICallsQuota'] - $totalCallsMade['plan'] ); ?></strong>
1538
+ </td>
1539
+ </tr>
1540
+ <tr>
1541
+ <th scope="row">
1542
+ <?php _e('Your One Time credits:','shortpixel-image-optimiser');?>
1543
+ </th>
1544
+ <td>
1545
+ <?php _e('Total: ','shortpixel-image-optimiser'); ?>
1546
+ <strong><?php echo( number_format($quotaData['APICallsQuotaOneTimeNumeric'])); ?></strong>
1547
+ <br><br>
1548
+ <?php _e('Consumed: ','shortpixel-image-optimiser'); ?>
1549
+ <strong><?php echo( $totalCallsMade['oneTime'] ); ?></strong>
1550
+ <?php _e('; Remaining: ','shortpixel-image-optimiser'); ?>
1551
+ <strong><?php echo( $remainingImages ); ?></strong>**
1552
+ </td>
1553
+ </tr>
1554
+ <tr>
1555
+ <th><a href="https://<?php echo(SHORTPIXEL_API);?>/v2/report.php?key=<?php echo(defined("SHORTPIXEL_HIDE_API_KEY") ? '' : $this->ctrl->getApiKey());?>" target="_blank">
1556
+ <?php _e('See report (last 40 days)','shortpixel-image-optimiser');?>
1557
+ </a></th>
1558
+ <td>&nbsp;</td>
1559
+ </tr>
1560
+ <tr>
1561
+ <th scope="row">
1562
+ <?php _e('Credits consumed on','shortpixel-image-optimiser');?>
1563
+ <?php echo(parse_url(get_site_url(),PHP_URL_HOST));?>:
1564
+ </th>
1565
+ <td><strong><?php echo($fileCount);?></strong></td>
1566
+ </tr>
1567
+ <?php if(true || $this->ctrl->backupImages()) { ?>
1568
+ <tr>
1569
+ <th scope="row">
1570
+ <?php _e('Original images are stored in a backup folder. Your backup folder\'s size is now:','shortpixel-image-optimiser');?>
1571
+ </th>
1572
+ <td>
1573
+ <form action="" method="POST">
1574
+ <?php if ($backupFolderSize === null) { ?>
1575
+ <span id='backup-folder-size'>Calculating...</span>
1576
+ <?php } else { echo($backupFolderSize); }?>
1577
+ <input type="submit" style="margin-left: 15px; vertical-align: middle;" class="button button-secondary shortpixel-confirm"
1578
+ name="emptyBackup" value="<?php _e('Empty backups','shortpixel-image-optimiser');?>"
1579
+ data-confirm="<?php _e('Are you sure you want to delete all the backup images? You won\'t be able to restore from backup or to reoptimize with different settings if you delete the backups.','shortpixel-image-optimiser'); ?>"/>
1580
+ </form>
1581
+ </td>
1582
+ </tr>
1583
+ <?php } ?>
1584
+ </tbody>
1585
+ </table>
1586
+ <div style="display:none">
1587
 
1588
+ </div>
1589
+ <p style="padding-top: 0px; color: #818181;" ><?php _e('* Saved bandwidth is calculated at 10,000 impressions/image','shortpixel-image-optimiser');?></p>
1590
+ <p style="padding-top: 0px; color: #818181;" >
1591
+ <?php printf(__('** Increase your image quota by <a href="https://shortpixel.com/login/%s" target="_blank">upgrading your ShortPixel plan.</a>','shortpixel-image-optimiser'),
1592
  defined("SHORTPIXEL_HIDE_API_KEY") ? '' : $this->ctrl->getApiKey());?>
1593
+ </p>
1594
+ </div>
1595
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1596
 
1597
+ <?php
 
1598
  }
1599
 
1600
+ public function renderCustomColumn($id, $data, $extended = false){ ?>
1601
  <div id='sp-msg-<?php echo($id);?>' class='column-wp-shortPixel'>
1602
 
1603
  <?php switch($data['status']) {
class/wp-short-pixel.php CHANGED
@@ -41,8 +41,9 @@ class WPShortPixel {
41
 
42
  if(is_plugin_active('envira-gallery/envira-gallery.php') || is_plugin_active('soliloquy-lite/soliloquy-lite.php')) {
43
  define('SHORTPIXEL_CUSTOM_THUMB_SUFFIX', '_c');
 
44
  }
45
-
46
  $this->setDefaultViewModeList();//set default mode as list. only @ first run
47
 
48
  //add hook for image upload processing
@@ -81,6 +82,7 @@ class WPShortPixel {
81
 
82
  add_action( 'shortpixel-thumbnails-before-regenerate', array( &$this, 'thumbnailsBeforeRegenerateHook' ), 10, 1);
83
  add_action( 'shortpixel-thumbnails-regenerated', array( &$this, 'thumbnailsRegeneratedHook' ), 10, 4);
 
84
 
85
  if($isAdminUser) {
86
  //add settings page
@@ -195,33 +197,118 @@ class WPShortPixel {
195
  $settings = new WPShortPixelSettings();
196
  if($settings->removeSettingsOnDeletePlugin == 1) {
197
  WPShortPixelSettings::debugResetOptions();
 
198
  }
199
  }
200
 
201
  public function getConflictingPlugins() {
202
  $conflictPlugins = array(
203
- 'WP Smush - Image Optimization' => 'wp-smushit/wp-smush.php',
204
- 'Imagify Image Optimizer' => 'imagify/imagify.php',
205
- 'Compress JPEG & PNG images (TinyPNG)' => 'tiny-compress-images/tiny-compress-images.php',
206
- 'Kraken.io Image Optimizer' => 'kraken-image-optimizer/kraken.php',
207
- 'Optimus - WordPress Image Optimizer' => 'optimus/optimus.php',
208
- 'EWWW Image Optimizer' => 'ewww-image-optimizer/ewww-image-optimizer.php',
209
- 'ImageRecycle pdf & image compression' => 'imagerecycle-pdf-image-compression/wp-image-recycle.php',
210
- 'CheetahO Image Optimizer' => 'cheetaho-image-optimizer/cheetaho.php',
211
- 'Zara 4 Image Compression' => 'zara-4/zara-4.php',
212
- 'Prizm Image' => 'prizm-image/wp-prizmimage.php',
213
- 'CW Image Optimizer' => 'cw-image-optimizer/cw-image-optimizer.php'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  );
215
  if($this->_settings->processThumbnails) {
216
  $conflictPlugins = array_merge($conflictPlugins, array(
217
- 'Regenerate Thumbnails: recreating image files may require re-optimization of the resulting thumbnails, even if they were previously optimized.' => 'regenerate-thumbnails/regenerate-thumbnails.php',
218
- 'Force Regenerate Thumbnails: recreating image files may require re-optimization of the resulting thumbnails, even if they were previously optimized.' => 'force-regenerate-thumbnails/force-regenerate-thumbnails.php'
 
 
 
 
 
 
 
 
 
 
219
  ));
220
  }
221
  $found = array();
222
  foreach($conflictPlugins as $name => $path) {
223
- if(is_plugin_active($path)) {
224
- $found[] = array('name' => $name, 'path' => $path);
 
 
 
 
 
 
 
 
225
  }
226
  }
227
  return $found;
@@ -371,28 +458,8 @@ class WPShortPixel {
371
  array("__SP_FIRST_TYPE__", "__SP_SECOND_TYPE__"), "__SP_CELL_MESSAGE__", 'sp-column-actions-template');
372
  }
373
  }
374
- ?><!--SP ARCHIVE is <?php echo($this->_settings->downloadArchive . " CRC: " . crc32(get_site_url())%10); ?> -->
375
  <script type="text/javascript" >
376
- var ShortPixelConstants = {
377
- STATUS_SUCCESS: <?php echo ShortPixelAPI::STATUS_SUCCESS; ?>,
378
- STATUS_EMPTY_QUEUE: <?php echo self::BULK_EMPTY_QUEUE; ?>,
379
- STATUS_ERROR: <?php echo ShortPixelAPI::STATUS_ERROR; ?>,
380
- STATUS_FAIL: <?php echo ShortPixelAPI::STATUS_FAIL; ?>,
381
- STATUS_QUOTA_EXCEEDED: <?php echo ShortPixelAPI::STATUS_QUOTA_EXCEEDED; ?>,
382
- STATUS_SKIP: <?php echo ShortPixelAPI::STATUS_SKIP; ?>,
383
- STATUS_NO_KEY: <?php echo ShortPixelAPI::STATUS_NO_KEY; ?>,
384
- STATUS_RETRY: <?php echo ShortPixelAPI::STATUS_RETRY; ?>,
385
- STATUS_QUEUE_FULL: <?php echo ShortPixelAPI::STATUS_QUEUE_FULL; ?>,
386
- STATUS_MAINTENANCE: <?php echo ShortPixelAPI::STATUS_MAINTENANCE; ?>,
387
- WP_PLUGIN_URL: '<?php echo plugins_url( '', SHORTPIXEL_PLUGIN_FILE ); ?>',
388
- WP_ADMIN_URL: '<?php echo admin_url(); ?>',
389
- API_KEY: "<?php echo(defined("SHORTPIXEL_HIDE_API_KEY") ? '' : $this->_settings->apiKey); ?>",
390
- DEFAULT_COMPRESSION: <?php echo(0 + $this->_settings->compressionType); ?>,
391
- MEDIA_ALERT: '<?php echo $this->_settings->mediaAlert ? "done" : "todo"; ?>',
392
- FRONT_BOOTSTRAP: <?php echo $this->_settings->frontBootstrap && (!isset($this->_settings->lastBackAction) || (time() - $this->_settings->lastBackAction > 600)) ? 1 : 0; ?>,
393
- AJAX_URL: '<?php echo admin_url('admin-ajax.php'); ?>',
394
- AFFILIATE: '<?php echo(self::getAffiliateSufix());?>'
395
- };
396
  //check after 10 seconds if ShortPixel initialized OK, if not, force the init (could happen if a JS error somewhere else stopped the JS execution).
397
  function delayedInit() {
398
  if(typeof ShortPixel !== "undefined") {
@@ -406,6 +473,29 @@ class WPShortPixel {
406
  wp_enqueue_style('short-pixel.min.css', plugins_url('/res/css/short-pixel.min.css',SHORTPIXEL_PLUGIN_FILE), array(), SHORTPIXEL_IMAGE_OPTIMISER_VERSION);
407
 
408
  wp_register_script('short-pixel' . $this->jsSuffix, plugins_url('/res/js/short-pixel' . $this->jsSuffix,SHORTPIXEL_PLUGIN_FILE), array(), SHORTPIXEL_IMAGE_OPTIMISER_VERSION);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
409
  $jsTranslation = array(
410
  'optimizeWithSP' => __( 'Optimize with ShortPixel', 'shortpixel-image-optimiser' ),
411
  'redoLossy' => __( 'Re-optimize Lossy', 'shortpixel-image-optimiser' ),
@@ -435,6 +525,7 @@ class WPShortPixel {
435
  'confirmBulkCleanupPending' => __( "Are you sure you want to cleanup the pending metadata?", 'shortpixel-image-optimiser' )
436
  );
437
  wp_localize_script( 'short-pixel' . $this->jsSuffix, '_spTr', $jsTranslation );
 
438
  wp_enqueue_script('short-pixel' . $this->jsSuffix);
439
 
440
  wp_enqueue_script('jquery.knob.min.js', plugins_url('/res/js/jquery.knob.min.js',SHORTPIXEL_PLUGIN_FILE) );
@@ -584,7 +675,7 @@ class WPShortPixel {
584
 
585
  $t = get_transient("wp-short-pixel-regenerating");
586
  if(is_array($t) && isset($t[$ID])) {
587
- return;
588
  }
589
 
590
  self::log("Handle Media Library Image Upload #{$ID}");
@@ -1298,7 +1389,7 @@ class WPShortPixel {
1298
  }
1299
 
1300
  private function sendToProcessing($itemHandler, $compressionType = false, $onlyThumbs = false) {
1301
-
1302
  //conversion of PNG 2 JPG for existing images
1303
  if($itemHandler->getType() == ShortPixelMetaFacade::MEDIA_LIBRARY_TYPE) { //currently only for ML
1304
  $rawMeta = $this->checkConvertMediaPng2Jpg($itemHandler);
@@ -1495,7 +1586,12 @@ class WPShortPixel {
1495
  }
1496
  }
1497
  }
1498
-
 
 
 
 
 
1499
  //WP/LR Sync plugin integration
1500
  public function onWpLrUpdateMedia($imageId, $galleryIdsUnused) {
1501
  $meta = wp_get_attachment_metadata($imageId);
@@ -1932,9 +2028,26 @@ class WPShortPixel {
1932
  if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'sp_deactivate_plugin_nonce' ) ) {
1933
  wp_nonce_ays( '' );
1934
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1935
  deactivate_plugins( $_GET['plugin'] );
1936
- wp_safe_redirect( wp_get_referer() );
1937
  die();
 
1938
  }
1939
 
1940
  public function countAllIfNeeded($quotaData, $time) {
@@ -2152,7 +2265,7 @@ class WPShortPixel {
2152
  $this->view->displayBulkProcessingRunning($this->getPercent($quotaData), $msg, $quotaData['APICallsRemaining'], $this->getAverageCompression(),
2153
  $this->prioQ->getBulkType() == ShortPixelQueue::BULK_TYPE_RESTORE ? 0 :
2154
  ( $this->prioQ->getBulkType() == ShortPixelQueue::BULK_TYPE_CLEANUP
2155
- || $this->prioQ->getBulkType() == ShortPixelQueue::BULK_TYPE_CLEANUP_PENDING ? -1 : ($pendingMeta !== null ? ($this->prioQ->bulkRunning() ? 3 : 2) : 1)));
2156
 
2157
  } else
2158
  {
@@ -2422,8 +2535,6 @@ class WPShortPixel {
2422
  $folder->setFileCount($folder->countFiles());
2423
  $this->spMetaDao->update($folder);
2424
  }
2425
- //echo ("mt: " . $mt);
2426
- //die(var_dump($folder));
2427
  } catch(ShortPixelFileRightsException $ex) {
2428
  if(is_array($notice)) {
2429
  if($notice['status'] == 'error') {
@@ -2437,7 +2548,30 @@ class WPShortPixel {
2437
  }
2438
  return $customFolders;
2439
  }
2440
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2441
  public function renderSettingsMenu() {
2442
  if ( !current_user_can( 'manage_options' ) ) {
2443
  wp_die(__('You do not have sufficient permissions to access this page.','shortpixel-image-optimiser'));
@@ -2453,7 +2587,24 @@ class WPShortPixel {
2453
  $addedFolder = false;
2454
 
2455
  $this->_settings->redirectedSettings = 2;
2456
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2457
  //by default we try to fetch the API Key from wp-config.php (if defined)
2458
  if ( defined("SHORTPIXEL_API_KEY") && strlen(SHORTPIXEL_API_KEY) == 20)
2459
  {
@@ -2500,8 +2651,7 @@ class WPShortPixel {
2500
  //handle API Key - common for save and validate.
2501
  $_POST['key'] = trim(str_replace("*", "", isset($_POST['key']) ? $_POST['key'] : $this->_settings->apiKey)); //the API key might not be set if the editing is disabled.
2502
 
2503
- if ( strlen($_POST['key']) <> 20 )
2504
- {
2505
  $KeyLength = strlen($_POST['key']);
2506
 
2507
  $notice = array("status" => "error",
@@ -2514,8 +2664,7 @@ class WPShortPixel {
2514
  . __(' or ','shortpixel-image-optimiser')
2515
  . "<a href='https://shortpixel.com/contact' target='_blank'>" . __('here','shortpixel-image-optimiser') . "</a>.");
2516
  }
2517
- else
2518
- {
2519
  if(isset($_POST['save']) || isset($_POST['saveAdv'])) {
2520
  //these are needed for the call to api-status, set them first.
2521
  $this->_settings->siteAuthUser = (isset($_POST['siteAuthUser']) ? $_POST['siteAuthUser'] : $this->_settings->siteAuthUser);
@@ -2593,7 +2742,43 @@ class WPShortPixel {
2593
  }
2594
 
2595
  $this->_settings->createWebp = (isset($_POST['createWebp']) ? 1: 0);
2596
- $this->_settings->createWebpMarkup = (isset($_POST['createWebpMarkup']) ? 1: 0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2597
  $this->_settings->optimizeRetina = (isset($_POST['optimizeRetina']) ? 1: 0);
2598
  $this->_settings->optimizeUnlisted = (isset($_POST['optimizeUnlisted']) ? 1: 0);
2599
  $this->_settings->optimizePdfs = (isset($_POST['optimizePdfs']) ? 1: 0);
@@ -2673,7 +2858,7 @@ class WPShortPixel {
2673
  }
2674
  $remainingImages = $quotaData['APICallsRemaining'];
2675
  $remainingImages = ( $remainingImages < 0 ) ? 0 : number_format($remainingImages);
2676
- $totalCallsMade = number_format($quotaData['APICallsMadeNumeric'] + $quotaData['APICallsMadeOneTimeNumeric']);
2677
 
2678
  $resources = wp_remote_post($this->_settings->httpProto . "://shortpixel.com/resources-frag");
2679
  if(is_wp_error( $resources )) {
@@ -2681,10 +2866,11 @@ class WPShortPixel {
2681
  }
2682
 
2683
  $cloudflareAPI = true;
 
2684
  $this->view->displaySettings($showApiKey, $editApiKey,
2685
  $quotaData, $notice, $resources, $averageCompression, $savedSpace, $savedBandwidth, $remainingImages,
2686
  $totalCallsMade, $fileCount, null /*folder size now on AJAX*/, $customFolders,
2687
- $folderMsg, $folderMsg ? $addedFolder : false, isset($_POST['saveAdv']), $cloudflareAPI);
2688
  } else {
2689
  $this->view->displaySettings($showApiKey, $editApiKey, $quotaData, $notice);
2690
  }
@@ -2900,7 +3086,7 @@ class WPShortPixel {
2900
  if(!is_array($data)) {
2901
  $data = unserialize($data);
2902
  }
2903
- //if($extended) {var_dump(wp_get_attachment_url($id)); echo(json_encode($data));}
2904
  $fileExtension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
2905
  $invalidKey = !$this->_settings->verifiedKey;
2906
  $quotaExceeded = $this->_settings->quotaExceeded;
@@ -3407,8 +3593,29 @@ class WPShortPixel {
3407
  return array_values(array_diff(array(0, 1, 2), array(0 + $compressionType)));
3408
  }
3409
 
3410
- function outputHSBeacon() {
3411
- ?><script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3412
  !function(e,o,n){ window.HSCW=o,window.HS=n,n.beacon=n.beacon||{};var t=n.beacon;t.userConfig={
3413
  color: "#1CBECB",
3414
  icon: "question",
@@ -3432,34 +3639,14 @@ class WPShortPixel {
3432
  email: "<?php $u = wp_get_current_user(); echo($u->user_email); ?>",
3433
  apiKey: "<?php echo($this->getApiKey());?>"
3434
  });
3435
- HS.beacon.suggest([<?php
3436
- $screen = get_current_screen();
3437
- if($screen) {
3438
- switch($screen->id) {
3439
- case 'media_page_wp-short-pixel-bulk':
3440
- echo(" '5a5de2782c7d3a19436843af', '5a5de6902c7d3a19436843e9', '5a5de5c42c7d3a19436843d0', '5a9945e42c7d3a75495145d0', '5a5de1c2042863193801047c',
3441
- '5a5de66f2c7d3a19436843e0', '5a9946e62c7d3a75495145d8', '5a5de4f02c7d3a19436843c8', '5a5de65f042863193801049f', '5a5de2df0428631938010485' ");
3442
- break;
3443
- case 'settings_page_wp-shortpixel':
3444
- echo(" '5a5de1de2c7d3a19436843a8', '5a6612032c7d3a39e6263a1d', '5a5de1c2042863193801047c', '5a5de2782c7d3a19436843af', '5a6610c62c7d3a39e6263a02',
3445
- '5a9945e42c7d3a75495145d0', '5a5de66f2c7d3a19436843e0', '5a6597e80428632faf620487', '5a5de5c42c7d3a19436843d0', '5a5de5642c7d3a19436843cc' ");
3446
- break;
3447
- case 'media_page_wp-short-pixel-custom':
3448
- echo(" '5a9946e62c7d3a75495145d8', '5a5de1c2042863193801047c', '5a5de2782c7d3a19436843af', '5a5de6902c7d3a19436843e9', '5a5de4f02c7d3a19436843c8',
3449
- '5a6610c62c7d3a39e6263a02', '5a9945e42c7d3a75495145d0', '5a5de46c2c7d3a19436843c1', '5a5de1de2c7d3a19436843a8', '5a5de25c2c7d3a19436843ad' ");
3450
- break;
3451
- default:
3452
- die($screen->id);
3453
- }
3454
- }
3455
- ?>]);
3456
  });
3457
  </script><?php
3458
  }
3459
 
3460
  public function validateFeedback($params) {
3461
- if(isset($params['remove-settings'])) {
3462
- $this->_settings->removeSettingsOnDeletePlugin = $params['remove-settings'];
3463
  }
3464
  return $params;
3465
  }
41
 
42
  if(is_plugin_active('envira-gallery/envira-gallery.php') || is_plugin_active('soliloquy-lite/soliloquy-lite.php')) {
43
  define('SHORTPIXEL_CUSTOM_THUMB_SUFFIX', '_c');
44
+ define('SHORTPIXEL_CUSTOM_THUMB_SUFFIXES', '_tl,_tr,_br,_bl');
45
  }
46
+
47
  $this->setDefaultViewModeList();//set default mode as list. only @ first run
48
 
49
  //add hook for image upload processing
82
 
83
  add_action( 'shortpixel-thumbnails-before-regenerate', array( &$this, 'thumbnailsBeforeRegenerateHook' ), 10, 1);
84
  add_action( 'shortpixel-thumbnails-regenerated', array( &$this, 'thumbnailsRegeneratedHook' ), 10, 4);
85
+ add_filter( 'shortpixel_get_backup', array( &$this, 'shortpixelGetBackupFilter' ), 10, 1 );
86
 
87
  if($isAdminUser) {
88
  //add settings page
197
  $settings = new WPShortPixelSettings();
198
  if($settings->removeSettingsOnDeletePlugin == 1) {
199
  WPShortPixelSettings::debugResetOptions();
200
+ insert_with_markers( get_home_path() . '.htaccess', 'ShortPixelWebp', '');
201
  }
202
  }
203
 
204
  public function getConflictingPlugins() {
205
  $conflictPlugins = array(
206
+ 'WP Smush - Image Optimization'
207
+ => array(
208
+ 'action'=>'Deactivate',
209
+ 'data'=>'wp-smushit/wp-smush.php',
210
+ 'page'=>'wp-smush-bulk'
211
+ ),
212
+ 'Imagify Image Optimizer'
213
+ => array(
214
+ 'action'=>'Deactivate',
215
+ 'data'=>'imagify/imagify.php',
216
+ 'page'=>'imagify'
217
+ ),
218
+ 'Compress JPEG & PNG images (TinyPNG)'
219
+ => array(
220
+ 'action'=>'Deactivate',
221
+ 'data'=>'tiny-compress-images/tiny-compress-images.php',
222
+ 'page'=>'tinify'
223
+ ),
224
+ 'Kraken.io Image Optimizer'
225
+ => array(
226
+ 'action'=>'Deactivate',
227
+ 'data'=>'kraken-image-optimizer/kraken.php',
228
+ 'page'=>'wp-krakenio'
229
+ ),
230
+ 'Optimus - WordPress Image Optimizer'
231
+ => array(
232
+ 'action'=>'Deactivate',
233
+ 'data'=>'optimus/optimus.php',
234
+ 'page'=>'optimus'
235
+ ),
236
+ 'EWWW Image Optimizer'
237
+ => array(
238
+ 'action'=>'Deactivate',
239
+ 'data'=>'ewww-image-optimizer/ewww-image-optimizer.php',
240
+ 'page'=>'ewww-image-optimizer%2F'
241
+ ),
242
+ 'EWWW Image Optimizer Cloud'
243
+ => array(
244
+ 'action'=>'Deactivate',
245
+ 'data'=>'ewww-image-optimizer-cloud/ewww-image-optimizer-cloud.php',
246
+ 'page'=>'ewww-image-optimizer-cloud%2F'
247
+ ),
248
+ 'ImageRecycle pdf & image compression'
249
+ => array(
250
+ 'action'=>'Deactivate',
251
+ 'data'=>'imagerecycle-pdf-image-compression/wp-image-recycle.php',
252
+ 'page'=>'option-image-recycle'
253
+ ),
254
+ 'CheetahO Image Optimizer'
255
+ => array(
256
+ 'action'=>'Deactivate',
257
+ 'data'=>'cheetaho-image-optimizer/cheetaho.php',
258
+ 'page'=>'cheetaho'
259
+ ),
260
+ 'Zara 4 Image Compression'
261
+ => array(
262
+ 'action'=>'Deactivate',
263
+ 'data'=>'zara-4/zara-4.php',
264
+ 'page'=>'zara-4'
265
+ ),
266
+ 'CW Image Optimizer'
267
+ => array(
268
+ 'action'=>'Deactivate',
269
+ 'data'=>'cw-image-optimizer/cw-image-optimizer.php',
270
+ 'page'=>'cw-image-optimizer'
271
+ ),
272
+ 'Simple Image Sizes'
273
+ => array(
274
+ 'action'=>'Deactivate',
275
+ 'data'=>'simple-image-sizes/simple_image_sizes.php'
276
+ ),
277
+ 'Jetpack by WordPress.com - The Speed up image load times Option'
278
+ => array(
279
+ 'action'=>'Change Setting',
280
+ 'data'=>'jetpack/jetpack.php',
281
+ 'href'=>'admin.php?page=jetpack#/settings'
282
+ )
283
  );
284
  if($this->_settings->processThumbnails) {
285
  $conflictPlugins = array_merge($conflictPlugins, array(
286
+ 'Regenerate Thumbnails: recreating image files may require re-optimization of the resulting thumbnails, even if they were previously optimized.'
287
+ => array(
288
+ 'action'=>'Deactivate',
289
+ 'data'=>'regenerate-thumbnails/regenerate-thumbnails.php',
290
+ 'page'=>'regenerate-thumbnails'
291
+ ),
292
+ 'Force Regenerate Thumbnails: recreating image files may require re-optimization of the resulting thumbnails, even if they were previously optimized.'
293
+ => array(
294
+ 'action'=>'Deactivate',
295
+ 'data'=>'force-regenerate-thumbnails/force-regenerate-thumbnails.php',
296
+ 'page'=>'force-regenerate-thumbnails'
297
+ )
298
  ));
299
  }
300
  $found = array();
301
  foreach($conflictPlugins as $name => $path) {
302
+ $action = ( isset($path['action']) ) ? $path['action'] : null;
303
+ $data = ( isset($path['data']) ) ? $path['data'] : null;
304
+ $href = ( isset($path['href']) ) ? $path['href'] : null;
305
+ $page = ( isset($path['page']) ) ? $path['page'] : null;
306
+ if(is_plugin_active($data)) {
307
+ if( $data == 'jetpack/jetpack.php' ){
308
+ $jetPackPhoton = get_option('jetpack_active_modules') ? in_array('photon', get_option('jetpack_active_modules')) : false;
309
+ if( !$jetPackPhoton ){ continue; }
310
+ }
311
+ $found[] = array( 'name' => $name, 'action'=> $action, 'path' => $data, 'href' => $href , 'page' => $page );
312
  }
313
  }
314
  return $found;
458
  array("__SP_FIRST_TYPE__", "__SP_SECOND_TYPE__"), "__SP_CELL_MESSAGE__", 'sp-column-actions-template');
459
  }
460
  }
461
+ ?>
462
  <script type="text/javascript" >
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
463
  //check after 10 seconds if ShortPixel initialized OK, if not, force the init (could happen if a JS error somewhere else stopped the JS execution).
464
  function delayedInit() {
465
  if(typeof ShortPixel !== "undefined") {
473
  wp_enqueue_style('short-pixel.min.css', plugins_url('/res/css/short-pixel.min.css',SHORTPIXEL_PLUGIN_FILE), array(), SHORTPIXEL_IMAGE_OPTIMISER_VERSION);
474
 
475
  wp_register_script('short-pixel' . $this->jsSuffix, plugins_url('/res/js/short-pixel' . $this->jsSuffix,SHORTPIXEL_PLUGIN_FILE), array(), SHORTPIXEL_IMAGE_OPTIMISER_VERSION);
476
+
477
+ // Using an Array within another Array to protect the primitive values from being cast to strings
478
+ $ShortPixelConstants = array(array(
479
+ 'STATUS_SUCCESS'=>ShortPixelAPI::STATUS_SUCCESS,
480
+ 'STATUS_EMPTY_QUEUE'=>self::BULK_EMPTY_QUEUE,
481
+ 'STATUS_ERROR'=>ShortPixelAPI::STATUS_ERROR,
482
+ 'STATUS_FAIL'=>ShortPixelAPI::STATUS_FAIL,
483
+ 'STATUS_QUOTA_EXCEEDED'=>ShortPixelAPI::STATUS_QUOTA_EXCEEDED,
484
+ 'STATUS_SKIP'=>ShortPixelAPI::STATUS_SKIP,
485
+ 'STATUS_NO_KEY'=>ShortPixelAPI::STATUS_NO_KEY,
486
+ 'STATUS_RETRY'=>ShortPixelAPI::STATUS_RETRY,
487
+ 'STATUS_QUEUE_FULL'=>ShortPixelAPI::STATUS_QUEUE_FULL,
488
+ 'STATUS_MAINTENANCE'=>ShortPixelAPI::STATUS_MAINTENANCE,
489
+ 'WP_PLUGIN_URL'=>plugins_url( '', SHORTPIXEL_PLUGIN_FILE ),
490
+ 'WP_ADMIN_URL'=>admin_url(),
491
+ 'API_KEY'=> (defined("SHORTPIXEL_HIDE_API_KEY" ) || !is_admin() ) ? '' : $this->_settings->apiKey,
492
+ 'DEFAULT_COMPRESSION'=>0 + $this->_settings->compressionType,
493
+ 'MEDIA_ALERT'=>$this->_settings->mediaAlert ? "done" : "todo",
494
+ 'FRONT_BOOTSTRAP'=>$this->_settings->frontBootstrap && (!isset($this->_settings->lastBackAction) || (time() - $this->_settings->lastBackAction > 600)) ? 1 : 0,
495
+ 'AJAX_URL'=>admin_url('admin-ajax.php'),
496
+ 'AFFILIATE'=>self::getAffiliateSufix()
497
+ ));
498
+
499
  $jsTranslation = array(
500
  'optimizeWithSP' => __( 'Optimize with ShortPixel', 'shortpixel-image-optimiser' ),
501
  'redoLossy' => __( 'Re-optimize Lossy', 'shortpixel-image-optimiser' ),
525
  'confirmBulkCleanupPending' => __( "Are you sure you want to cleanup the pending metadata?", 'shortpixel-image-optimiser' )
526
  );
527
  wp_localize_script( 'short-pixel' . $this->jsSuffix, '_spTr', $jsTranslation );
528
+ wp_localize_script( 'short-pixel' . $this->jsSuffix, 'ShortPixelConstants', $ShortPixelConstants );
529
  wp_enqueue_script('short-pixel' . $this->jsSuffix);
530
 
531
  wp_enqueue_script('jquery.knob.min.js', plugins_url('/res/js/jquery.knob.min.js',SHORTPIXEL_PLUGIN_FILE) );
675
 
676
  $t = get_transient("wp-short-pixel-regenerating");
677
  if(is_array($t) && isset($t[$ID])) {
678
+ return $meta;
679
  }
680
 
681
  self::log("Handle Media Library Image Upload #{$ID}");
1389
  }
1390
 
1391
  private function sendToProcessing($itemHandler, $compressionType = false, $onlyThumbs = false) {
1392
+
1393
  //conversion of PNG 2 JPG for existing images
1394
  if($itemHandler->getType() == ShortPixelMetaFacade::MEDIA_LIBRARY_TYPE) { //currently only for ML
1395
  $rawMeta = $this->checkConvertMediaPng2Jpg($itemHandler);
1586
  }
1587
  }
1588
  }
1589
+
1590
+ public function shortpixelGetBackupFilter($imagePath) {
1591
+ $backup = str_replace(dirname(dirname(dirname(SHORTPIXEL_BACKUP_FOLDER))),SHORTPIXEL_BACKUP_FOLDER, $imagePath);
1592
+ return file_exists($backup) ? $backup : false;
1593
+ }
1594
+
1595
  //WP/LR Sync plugin integration
1596
  public function onWpLrUpdateMedia($imageId, $galleryIdsUnused) {
1597
  $meta = wp_get_attachment_metadata($imageId);
2028
  if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'sp_deactivate_plugin_nonce' ) ) {
2029
  wp_nonce_ays( '' );
2030
  }
2031
+
2032
+ $referrer_url = wp_get_referer();
2033
+ $conflict = $this->getConflictingPlugins();
2034
+ foreach($conflict as $c => $value) {
2035
+ $conflictingString = $value['page'];
2036
+ if($conflictingString != null && strpos($referrer_url, $conflictingString) !== false){
2037
+ $this->deactivateAndRedirect(get_dashboard_url());
2038
+ break;
2039
+ }
2040
+ }
2041
+ $this->deactivateAndRedirect(wp_get_referer());
2042
+
2043
+ }
2044
+
2045
+ protected function deactivateAndRedirect($url){
2046
+ //die(ShortPixelVDD($url));
2047
  deactivate_plugins( $_GET['plugin'] );
2048
+ wp_safe_redirect( $url );
2049
  die();
2050
+
2051
  }
2052
 
2053
  public function countAllIfNeeded($quotaData, $time) {
2265
  $this->view->displayBulkProcessingRunning($this->getPercent($quotaData), $msg, $quotaData['APICallsRemaining'], $this->getAverageCompression(),
2266
  $this->prioQ->getBulkType() == ShortPixelQueue::BULK_TYPE_RESTORE ? 0 :
2267
  ( $this->prioQ->getBulkType() == ShortPixelQueue::BULK_TYPE_CLEANUP
2268
+ || $this->prioQ->getBulkType() == ShortPixelQueue::BULK_TYPE_CLEANUP_PENDING ? -1 : ($pendingMeta !== null ? ($this->prioQ->bulkRunning() ? 3 : 2) : 1)), $quotaData);
2269
 
2270
  } else
2271
  {
2535
  $folder->setFileCount($folder->countFiles());
2536
  $this->spMetaDao->update($folder);
2537
  }
 
 
2538
  } catch(ShortPixelFileRightsException $ex) {
2539
  if(is_array($notice)) {
2540
  if($notice['status'] == 'error') {
2548
  }
2549
  return $customFolders;
2550
  }
2551
+
2552
+ protected function alterHtaccess( $clear = false ){
2553
+ if ( $clear ) {
2554
+ insert_with_markers( get_home_path() . '.htaccess', 'ShortPixelWebp', '');
2555
+ } else {
2556
+ insert_with_markers( get_home_path() . '.htaccess', 'ShortPixelWebp', '
2557
+ <IfModule mod_rewrite.c>
2558
+ RewriteEngine On
2559
+ RewriteCond %{HTTP_ACCEPT} image/webp
2560
+ RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
2561
+ RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
2562
+ </IfModule>
2563
+
2564
+ <IfModule mod_headers.c>
2565
+ Header append Vary Accept env=REDIRECT_accept
2566
+ </IfModule>
2567
+
2568
+ <IfModule mod_mime.c>
2569
+ AddType image/webp .webp
2570
+ </IfModule>
2571
+ ' );
2572
+ }
2573
+ }
2574
+
2575
  public function renderSettingsMenu() {
2576
  if ( !current_user_can( 'manage_options' ) ) {
2577
  wp_die(__('You do not have sufficient permissions to access this page.','shortpixel-image-optimiser'));
2587
  $addedFolder = false;
2588
 
2589
  $this->_settings->redirectedSettings = 2;
2590
+
2591
+ // Check if NGINX Server
2592
+ $isNginx = strpos($_SERVER["SERVER_SOFTWARE"], 'nginx') !== false ? true : false;
2593
+
2594
+ // BEGIN: Verify .htaccess writeability
2595
+ $htaccessWriteable = true;
2596
+ if( !$isNginx ) {
2597
+ $htaccessPath = get_home_path() . '.htaccess';
2598
+ $htaccessExisted = file_exists( $htaccessPath );
2599
+ //$htaccessWriteable = insert_with_markers( get_home_path() . '.htaccess', 'ShortPixelWebp', '' );
2600
+ $htaccessWriteable = fopen($htaccessPath, "a+") ? true : false;
2601
+ if( !$htaccessExisted ){
2602
+ unlink( $htaccessPath );
2603
+ }
2604
+ }
2605
+ // END: Verify .htaccess writeability
2606
+
2607
+
2608
  //by default we try to fetch the API Key from wp-config.php (if defined)
2609
  if ( defined("SHORTPIXEL_API_KEY") && strlen(SHORTPIXEL_API_KEY) == 20)
2610
  {
2651
  //handle API Key - common for save and validate.
2652
  $_POST['key'] = trim(str_replace("*", "", isset($_POST['key']) ? $_POST['key'] : $this->_settings->apiKey)); //the API key might not be set if the editing is disabled.
2653
 
2654
+ if ( strlen($_POST['key']) <> 20 ){
 
2655
  $KeyLength = strlen($_POST['key']);
2656
 
2657
  $notice = array("status" => "error",
2664
  . __(' or ','shortpixel-image-optimiser')
2665
  . "<a href='https://shortpixel.com/contact' target='_blank'>" . __('here','shortpixel-image-optimiser') . "</a>.");
2666
  }
2667
+ else {
 
2668
  if(isset($_POST['save']) || isset($_POST['saveAdv'])) {
2669
  //these are needed for the call to api-status, set them first.
2670
  $this->_settings->siteAuthUser = (isset($_POST['siteAuthUser']) ? $_POST['siteAuthUser'] : $this->_settings->siteAuthUser);
2742
  }
2743
 
2744
  $this->_settings->createWebp = (isset($_POST['createWebp']) ? 1: 0);
2745
+
2746
+
2747
+
2748
+ if( isset( $_POST['createWebp'] ) && $_POST['createWebp'] == 'on' ){
2749
+ if( isset( $_POST['deliverWebp'] ) && $_POST['deliverWebp'] == 'on' ){
2750
+ if( isset( $_POST['deliverWebpType'] ) ) {
2751
+ switch( $_POST['deliverWebpType'] ) {
2752
+ case 'deliverWebpUnaltered':
2753
+ $this->_settings->deliverWebp = 3;
2754
+ $this->alterHtaccess();
2755
+ break;
2756
+ case 'deliverWebpAltered':
2757
+ $this->alterHtaccess(true);
2758
+ if( isset( $_POST['deliverWebpAlteringType'] ) ){
2759
+ switch ($_POST['deliverWebpAlteringType']) {
2760
+ case 'deliverWebpAlteredWP':
2761
+ $this->_settings->deliverWebp = 2;
2762
+ break;
2763
+ case 'deliverWebpAlteredGlobal':
2764
+ $this->_settings->deliverWebp = 1;
2765
+ break;
2766
+ }
2767
+ }
2768
+ break;
2769
+ }
2770
+ }
2771
+ } else {
2772
+ $this->_settings->deliverWebp = 0;
2773
+ }
2774
+ } else {
2775
+ $this->_settings->deliverWebp = 0;
2776
+ }
2777
+
2778
+ //die(ShortPixelVDD($_POST));
2779
+
2780
+ //if(isset($_POST['optimizeRetina'])
2781
+
2782
  $this->_settings->optimizeRetina = (isset($_POST['optimizeRetina']) ? 1: 0);
2783
  $this->_settings->optimizeUnlisted = (isset($_POST['optimizeUnlisted']) ? 1: 0);
2784
  $this->_settings->optimizePdfs = (isset($_POST['optimizePdfs']) ? 1: 0);
2858
  }
2859
  $remainingImages = $quotaData['APICallsRemaining'];
2860
  $remainingImages = ( $remainingImages < 0 ) ? 0 : number_format($remainingImages);
2861
+ $totalCallsMade = array( 'plan'=>number_format( $quotaData['APICallsMadeNumeric'] ), 'oneTime'=>number_format( $quotaData['APICallsMadeOneTimeNumeric'] ) );
2862
 
2863
  $resources = wp_remote_post($this->_settings->httpProto . "://shortpixel.com/resources-frag");
2864
  if(is_wp_error( $resources )) {
2866
  }
2867
 
2868
  $cloudflareAPI = true;
2869
+
2870
  $this->view->displaySettings($showApiKey, $editApiKey,
2871
  $quotaData, $notice, $resources, $averageCompression, $savedSpace, $savedBandwidth, $remainingImages,
2872
  $totalCallsMade, $fileCount, null /*folder size now on AJAX*/, $customFolders,
2873
+ $folderMsg, $folderMsg ? $addedFolder : false, isset($_POST['saveAdv']), $cloudflareAPI, $htaccessWriteable, $isNginx );
2874
  } else {
2875
  $this->view->displaySettings($showApiKey, $editApiKey, $quotaData, $notice);
2876
  }
3086
  if(!is_array($data)) {
3087
  $data = unserialize($data);
3088
  }
3089
+ //if($extended) {var_dump(wp_get_attachment_url($id)); echo('<br>BK: ' . apply_filters('shortpixel_get_backup', get_attached_file($id))); echo(json_encode($data));}
3090
  $fileExtension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
3091
  $invalidKey = !$this->_settings->verifiedKey;
3092
  $quotaExceeded = $this->_settings->quotaExceeded;
3593
  return array_values(array_diff(array(0, 1, 2), array(0 + $compressionType)));
3594
  }
3595
 
3596
+ function outputHSBeacon() { ?>
3597
+ <script>
3598
+ <?php
3599
+ $screen = get_current_screen();
3600
+ if($screen) {
3601
+ switch($screen->id) {
3602
+ case 'media_page_wp-short-pixel-bulk':
3603
+ echo("var shortpixel_suggestions = [ '5a5de2782c7d3a19436843af', '5a5de6902c7d3a19436843e9', '5a5de5c42c7d3a19436843d0', '5a9945e42c7d3a75495145d0', '5a5de1c2042863193801047c', '5a5de66f2c7d3a19436843e0', '5a9946e62c7d3a75495145d8', '5a5de4f02c7d3a19436843c8', '5a5de65f042863193801049f', '5a5de2df0428631938010485' ]; ");
3604
+ $suggestions = "shortpixel_suggestions";
3605
+ break;
3606
+ case 'settings_page_wp-shortpixel':
3607
+ echo("var shortpixel_suggestions_settings = [ '5a5de1de2c7d3a19436843a8', '5a6612032c7d3a39e6263a1d', '5a5de1c2042863193801047c', '5a5de2782c7d3a19436843af', '5a6610c62c7d3a39e6263a02', '5a9945e42c7d3a75495145d0', '5a5de66f2c7d3a19436843e0', '5a6597e80428632faf620487', '5a5de5c42c7d3a19436843d0', '5a5de5642c7d3a19436843cc' ]; ");
3608
+ echo("var shortpixel_suggestions_adv_settings = [ '5a5de4f02c7d3a19436843c8', '5a8431f00428634376d01dc4', '5a5de58b0428631938010497', '5a5de65f042863193801049f', '5a9945e42c7d3a75495145d0', '5a9946e62c7d3a75495145d8', '5a5de57c0428631938010495', '5a5de2d22c7d3a19436843b1', '5a5de5c42c7d3a19436843d0', '5a5de5642c7d3a19436843cc' ]; ");
3609
+ echo("var shortpixel_suggestions_cloudflare = [ '5a5de1f62c7d3a19436843a9', '5a5de58b0428631938010497', '5a5de66f2c7d3a19436843e0', '5a5de5c42c7d3a19436843d0', '5a5de6902c7d3a19436843e9', '5a5de51a2c7d3a19436843c9', '5a9946e62c7d3a75495145d8', '5a5de46c2c7d3a19436843c1', '5a5de1de2c7d3a19436843a8', '5a6597e80428632faf620487' ]; ");
3610
+ $suggestions = "shortpixel_suggestions_settings";
3611
+ break;
3612
+ case 'media_page_wp-short-pixel-custom':
3613
+ echo("var shortpixel_suggestions = [ '5a9946e62c7d3a75495145d8', '5a5de1c2042863193801047c', '5a5de2782c7d3a19436843af', '5a5de6902c7d3a19436843e9', '5a5de4f02c7d3a19436843c8', '5a6610c62c7d3a39e6263a02', '5a9945e42c7d3a75495145d0', '5a5de46c2c7d3a19436843c1', '5a5de1de2c7d3a19436843a8', '5a5de25c2c7d3a19436843ad' ]; ");
3614
+ $suggestions = "shortpixel_suggestions";
3615
+ break;
3616
+ }
3617
+ }
3618
+ ?>
3619
  !function(e,o,n){ window.HSCW=o,window.HS=n,n.beacon=n.beacon||{};var t=n.beacon;t.userConfig={
3620
  color: "#1CBECB",
3621
  icon: "question",
3639
  email: "<?php $u = wp_get_current_user(); echo($u->user_email); ?>",
3640
  apiKey: "<?php echo($this->getApiKey());?>"
3641
  });
3642
+ HS.beacon.suggest( <?php echo( $suggestions ) ?> );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3643
  });
3644
  </script><?php
3645
  }
3646
 
3647
  public function validateFeedback($params) {
3648
+ if(isset($params['keep-settings'])) {
3649
+ $this->_settings->removeSettingsOnDeletePlugin = 1 - $params['keep-settings'];
3650
  }
3651
  return $params;
3652
  }
class/wp-shortpixel-settings.php CHANGED
@@ -26,7 +26,7 @@ class WPShortPixelSettings {
26
  'keepExif' => array('key' => 'wp-short-pixel-keep-exif', 'default' => 0, 'group' => 'options'),
27
  'CMYKtoRGBconversion' => array('key' => 'wp-short-pixel_cmyk2rgb', 'default' => 1, 'group' => 'options'),
28
  'createWebp' => array('key' => 'wp-short-create-webp', 'default' => null, 'group' => 'options'),
29
- 'createWebpMarkup' => array('key' => 'wp-short-pixel-create-webp-markup', 'default' => null, 'group' => 'options'),
30
  'optimizeRetina' => array('key' => 'wp-short-pixel-optimize-retina', 'default' => 1, 'group' => 'options'),
31
  'optimizeUnlisted' => array('key' => 'wp-short-pixel-optimize-unlisted', 'default' => 0, 'group' => 'options'),
32
  'backupImages' => array('key' => 'wp-short-backup_images', 'default' => 1, 'group' => 'options'),
26
  'keepExif' => array('key' => 'wp-short-pixel-keep-exif', 'default' => 0, 'group' => 'options'),
27
  'CMYKtoRGBconversion' => array('key' => 'wp-short-pixel_cmyk2rgb', 'default' => 1, 'group' => 'options'),
28
  'createWebp' => array('key' => 'wp-short-create-webp', 'default' => null, 'group' => 'options'),
29
+ 'deliverWebp' => array('key' => 'wp-short-pixel-create-webp-markup', 'default' => null, 'group' => 'options'),
30
  'optimizeRetina' => array('key' => 'wp-short-pixel-optimize-retina', 'default' => 1, 'group' => 'options'),
31
  'optimizeUnlisted' => array('key' => 'wp-short-pixel-optimize-unlisted', 'default' => 0, 'group' => 'options'),
32
  'backupImages' => array('key' => 'wp-short-backup_images', 'default' => 1, 'group' => 'options'),
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.0
6
  Requires PHP: 5.2
7
- Stable tag: 4.12.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -17,7 +17,7 @@ Speed up your website and boost your SEO by compressing old & new images and PDF
17
  Increase your website's SEO ranking, number of visitors and ultimately your sales by optimizing any image or PDF document on your website.
18
  ShortPixel is an easy to use, lightweight, install-and-forget-about-it <a href="https://shortpixel.com" target="_blank">image optimization</a> plugin that can compress all your past images and PDF documents with a single click. New images are automatically resized/rescaled and optimized on the fly, in the background.
19
 
20
- **Ready for a quick DEMO? Test <a href="https://addendio.com/try-plugin/?slug=shortpixel-image-optimiser" target="_blank">here</a> or <a href="http://poopy.life/create?url=/wp-admin/admin.php?page=sandbox" target="_blank">here</a> (no e-mail required).**
21
 
22
  Short Pixel uses minimal resources and works well with any shared, cloud, VPS or dedicated web hosting. It can optimize any image you have on your website even the images that aren't listed in Media Library like those in galleries like <a href="https://wordpress.org/plugins/nextgen-gallery/" target="_blank">NextGEN</a>, <a href="https://wordpress.org/plugins/modula-best-grid-gallery/" target="_blank">Modula</a> or added directly via FTP!
23
 
@@ -29,7 +29,7 @@ Make an instant <a href="http://shortpixel.com/image-compression-test" target="_
29
 
30
  **Why is ShortPixel the best choice when it comes to image optimization or PDF compression?**
31
 
32
- * popular plugin with over 80,000 active installations according to WordPress
33
  * compress JPG, PNG, GIF (still or animated) images and also PDF documents
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
@@ -241,6 +241,24 @@ The ShortPixel Image Optimiser plugin calls the following actions and filters:
241
 
242
  == Changelog ==
243
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  = 4.12.1 =
245
 
246
  Release date: 6th November 2018
@@ -358,4 +376,4 @@ Release date: 3rd July 2018
358
  * display the x close link for the bulk warning box.
359
 
360
  = EARLIER VERSIONS =
361
- * please refer to the changelog.txt file inside the plugin archive.
4
  Requires at least: 3.2.0
5
  Tested up to: 5.0
6
  Requires PHP: 5.2
7
+ Stable tag: 4.12.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
17
  Increase your website's SEO ranking, number of visitors and ultimately your sales by optimizing any image or PDF document on your website.
18
  ShortPixel is an easy to use, lightweight, install-and-forget-about-it <a href="https://shortpixel.com" target="_blank">image optimization</a> plugin that can compress all your past images and PDF documents with a single click. New images are automatically resized/rescaled and optimized on the fly, in the background.
19
 
20
+ **Ready for a quick DEMO? Test <a href="http://sandboxwordpress.com/" target="_blank">here</a> or <a href="http://poopy.life/create?url=/wp-admin/admin.php?page=sandbox" target="_blank">here</a> (no e-mail required).**
21
 
22
  Short Pixel uses minimal resources and works well with any shared, cloud, VPS or dedicated web hosting. It can optimize any image you have on your website even the images that aren't listed in Media Library like those in galleries like <a href="https://wordpress.org/plugins/nextgen-gallery/" target="_blank">NextGEN</a>, <a href="https://wordpress.org/plugins/modula-best-grid-gallery/" target="_blank">Modula</a> or added directly via FTP!
23
 
29
 
30
  **Why is ShortPixel the best choice when it comes to image optimization or PDF compression?**
31
 
32
+ * popular plugin with over 100,000 active installations according to WordPress
33
  * compress JPG, PNG, GIF (still or animated) images and also PDF documents
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
241
 
242
  == Changelog ==
243
 
244
+ = 4.12.2 =
245
+
246
+ Release date:
247
+
248
+ * Improved: The Webp options interface. Now the user can implement Webp images both via .htaccess and by altering the page code on the server before being sent to the browser.
249
+ * Improved: The settings data handling interface in the Plugin deactivation dialogue. Now the option to delete or keep the user settings on plugin deletion is more clear.
250
+ * Added: Option to download image with thumbnails in a single archive file, to speed-up the optimization.
251
+ * Added: A "shortpixel_get_backup" filter, which receives the local path of the media image and returns the ShortPixel backup path, if a backup image exists
252
+ * Added: The "Simple Image Sizes" plugin to the conflicting plugins list
253
+ * Added: A new compatibility check for the "Jetpack" plugin, alerting the user about potential overlapping functionality
254
+ * Added: A safety alert before switching to Code Altering mode (where IMG tgs get inserted into PICTURE tags, to better serve Webp images)
255
+ * Added: Enhanced "Envira" plugin compatibility by adding more suffixes to be looked for: _tl, _tr, _bl, _br
256
+ * Added: More customized FAQ suggestions in the HelpScout Beacon helper, to address each Plugin TAB separately
257
+ * Fixed: The post-uninstall redirect when uninstalling a plugin from within the respective plugin's Settings page
258
+ * Fixed: The credits display on the Statistics page
259
+ * Fixed: Refreshing a plugin page now loads directly in the previously selected TAB
260
+ * Fixed: Removed a stray "SP_CELL_MESSAGE" div from the interface
261
+
262
  = 4.12.1 =
263
 
264
  Release date: 6th November 2018
376
  * display the x close link for the bulk warning box.
377
 
378
  = EARLIER VERSIONS =
379
+ * please refer to the changelog.txt file inside the plugin archive.
res/css/short-pixel.css CHANGED
@@ -1,3 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  /* Dropdown Button */
2
  .sp-dropbtn.button {
3
  padding: 1px 24px 20px 5px;
@@ -84,6 +100,19 @@ div.fb-like {
84
  .sp-notice-warning {
85
  border-left-color: #f1e02a;
86
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  li.sp-conflict-plugins-list {
88
  line-height: 28px;
89
  list-style: disc;
@@ -206,6 +235,12 @@ input.dial {
206
  width: 15%;
207
  }
208
 
 
 
 
 
 
 
209
  .form-table table.shortpixel-folders-list tr {
210
  background-color: #eee;
211
  }
@@ -629,7 +664,7 @@ article.sp-tabs {
629
  position: relative;
630
  display: block;
631
  width: 100%;
632
- height: 1100px;
633
  margin: 2em auto;
634
  }
635
  article.sp-tabs section {
@@ -637,14 +672,24 @@ article.sp-tabs section {
637
  display: block;
638
  top: 1.8em;
639
  left: 0;
640
- height: 1100px;
641
- width:94%;
 
 
642
  padding: 10px 20px;
643
- background-color: #ddd;
644
  /* border-radius: 5px; */
645
- box-shadow: 0 3px 3px rgba(0,0,0,0.1);
646
  z-index: 0;
647
  }
 
 
 
 
 
 
 
 
 
648
  article.sp-tabs section:first-child {
649
  z-index: 1;
650
  }
@@ -694,6 +739,34 @@ article.sp-tabs section.sel-tab h2 {
694
  background-color: #fff;
695
  z-index: 2;
696
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
697
  /*article.sp-tabs section,
698
  article.sp-tabs section h2 {
699
  -webkit-transition: all 500ms ease;
@@ -775,10 +848,14 @@ section#tab-resources p {
775
  }
776
 
777
  /*workaround for bad style inline css in the plugin <<WooCommerce Remove /product & /product-category>> that's causing conflict*/
778
- .sp-tabs h2:before{
779
  content:none;
780
  }
781
 
 
 
 
 
782
  #wpadminbar .shortpixel-toolbar-processing .cssload-container {
783
  width: 100%;
784
  height: 24px;
1
+ .reset {
2
+ font-weight: normal;
3
+ font-style: normal;
4
+ }
5
+
6
+ .clearfix:before, .clearfix:after { content: " "; /* 1 */ display: table; /* 2 */}
7
+ .clearfix:after { clear: both; }
8
+ .clearfix { zoom: 1; }
9
+
10
+ .resumeLabel {
11
+ float: right;
12
+ line-height: 30px;
13
+ margin-right: 20px;
14
+ font-size: 16px;
15
+ }
16
+
17
  /* Dropdown Button */
18
  .sp-dropbtn.button {
19
  padding: 1px 24px 20px 5px;
100
  .sp-notice-warning {
101
  border-left-color: #f1e02a;
102
  }
103
+
104
+ .sp-conflict-plugins {
105
+ display: table;
106
+ border-spacing: 10px;
107
+ border-collapse: separate;
108
+ }
109
+ .sp-conflict-plugins li {
110
+ display: table-row;
111
+ }
112
+ .sp-conflict-plugins li > * {
113
+ display: table-cell;
114
+ }
115
+
116
  li.sp-conflict-plugins-list {
117
  line-height: 28px;
118
  list-style: disc;
235
  width: 15%;
236
  }
237
 
238
+ .form-table th {
239
+ width: 220px;
240
+ }
241
+ .form-table td {
242
+ position: relative;
243
+ }
244
  .form-table table.shortpixel-folders-list tr {
245
  background-color: #eee;
246
  }
664
  position: relative;
665
  display: block;
666
  width: 100%;
667
+ /*height: 1100px;*/
668
  margin: 2em auto;
669
  }
670
  article.sp-tabs section {
672
  display: block;
673
  top: 1.8em;
674
  left: 0;
675
+ /*height: 1100px;*/
676
+ width:100%;
677
+ max-width:100%;
678
+ box-sizing: border-box;
679
  padding: 10px 20px;
680
+ /*background-color: #ddd;*/
681
  /* border-radius: 5px; */
 
682
  z-index: 0;
683
  }
684
+ article.sp-tabs section.sel-tab {
685
+ box-shadow: 0 3px 3px rgba(0,0,0,0.1);
686
+ }
687
+ article.sp-tabs section .wp-shortpixel-tab-content {
688
+ visibility: hidden;
689
+ }
690
+ article.sp-tabs section.sel-tab .wp-shortpixel-tab-content {
691
+ visibility: visible;
692
+ }
693
  article.sp-tabs section:first-child {
694
  z-index: 1;
695
  }
739
  background-color: #fff;
740
  z-index: 2;
741
  }
742
+ #tab-stats .sp-bulk-summary {
743
+ position: absolute;
744
+ right: 0;
745
+ top: 0;
746
+ z-index: 100;
747
+ }
748
+
749
+ .deliverWebpSettings, .deliverWebpTypes, .deliverWebpAlteringTypes {
750
+ display: none;
751
+ }
752
+ .deliverWebpTypes .sp-notice {
753
+ color: red;
754
+ }
755
+ .deliverWebpSettings {
756
+ margin: 16px 0;
757
+ }
758
+ .deliverWebpSettings input:disabled+label {
759
+ color: #818181;
760
+ }
761
+ .deliverWebpTypes, .deliverWebpAlteringTypes {
762
+ margin: 16px 0 16px 16px;
763
+ }
764
+ article.sp-tabs section #createWebp:checked ~ .deliverWebpSettings,
765
+ article.sp-tabs section #deliverWebp:checked ~ .deliverWebpTypes,
766
+ article.sp-tabs section #deliverWebpAltered:checked ~ .deliverWebpAlteringTypes
767
+ {
768
+ display: block;
769
+ }
770
  /*article.sp-tabs section,
771
  article.sp-tabs section h2 {
772
  -webkit-transition: all 500ms ease;
848
  }
849
 
850
  /*workaround for bad style inline css in the plugin <<WooCommerce Remove /product & /product-category>> that's causing conflict*/
851
+ .sp-tabs h2:before {
852
  content:none;
853
  }
854
 
855
+ .sp-column-actions-template + .sp-column-info {
856
+ display: none;
857
+ }
858
+
859
  #wpadminbar .shortpixel-toolbar-processing .cssload-container {
860
  width: 100%;
861
  height: 24px;
res/css/short-pixel.min.css CHANGED
@@ -1 +1 @@
1
- .sp-dropbtn.button{padding:1px 24px 20px 5px;font-size:20px;cursor:pointer}.sp-dropdown{position:relative;display:inline-block}.sp-dropdown-content{display:none;right:0;position:absolute;background-color:#f9f9f9;min-width:190px;box-shadow:0 8px 16px 0 rgba(0,0,0,0.2);z-index:1}.sp-dropdown-content a{color:black;padding:12px 16px;text-decoration:none;display:block}.sp-dropdown-content a:hover{background-color:#f1f1f1}.sp-dropdown.sp-show .sp-dropdown-content{display:block}div.fb-like{transform:scale(1.3);-ms-transform:scale(1.3);-webkit-transform:scale(1.3);-o-transform:scale(1.3);-moz-transform:scale(1.3);transform-origin:bottom left;-ms-transform-origin:bottom left;-webkit-transform-origin:bottom left;-moz-transform-origin:bottom left;-webkit-transform-origin:bottom left}.wp-core-ui .button.button-alert,.wp-core-ui .button.button-alert:hover{background:#f79797}.wp-core-ui .button.remove-folder-button{min-width:120px}.sp-notice{background:#fff;border-left:4px solid #fff;-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,.1);box-shadow:0 1px 1px 0 rgba(0,0,0,.1);padding:1px 12px}@media(max-width:1249px){.sp-notice{margin:5px 15px 2px}}.sp-notice-info{border-left-color:#00a0d2}.sp-notice-success{border-left-color:#46b450}.sp-notice-warning{border-left-color:#f1e02a}li.sp-conflict-plugins-list{line-height:28px;list-style:disc;margin-left:80px}li.sp-conflict-plugins-list a.button{margin-left:10px}div.short-pixel-bulk-page input.dial{font-size:16px !important}div.short-pixel-bulk-page h1{margin-bottom:20px}div.bulk-progress div.sp-h2{margin-top:0;margin-bottom:10px;font-size:23px;font-weight:400;padding:9px 15px 4px 0;line-height:29px}div.bulk-progress-partners{margin-top:20px}div.bulk-progress.bulk-progress-partners a div{display:inline-block;vertical-align:top;line-height:50px;margin-left:30px;font-size:1.2em}div.bulk-progress .bulk-progress-indicator,div.sp-quota-exceeded-alert .bulk-progress-indicator{display:inline-block;text-align:center;padding:0 10px;margin-left:10px;float:left;height:90px;overflow:hidden;border:1px solid #1caecb}div.wrap.short-pixel-bulk-page .bulk-notice-container{margin-top:15px;position:absolute;width:500px}div.wrap.short-pixel-bulk-page .bulk-notice-container .bulk-notice-msg{text-align:center;margin:10px 0 0 32px;overflow:hidden;border:1px solid #1caecb;background-color:#9ddbe0;border-radius:5px;padding:7px 10px 10px;display:none;max-width:600px;margin-right:20px}div.wrap.short-pixel-bulk-page .bulk-notice-container .bulk-notice-msg.bulk-error{border:1px solid #b5914d;background-color:#ffe996;margin-right:20px;position:relative;z-index:10}div.wrap.short-pixel-bulk-page .bulk-notice-container .bulk-notice-msg.bulk-error.bulk-error-fatal{border:1px solid #c32525;background-color:#ff969d}div.wrap.short-pixel-bulk-page .bulk-notice-msg img{float:left;margin-top:3px;margin-right:5px}div.sp-bulk-summary{float:right;margin:8px 5px 3px 20px}.sp-notice .bulk-error-show{cursor:pointer}.sp-notice div.bulk-error-list{background-color:#f1f1f1;padding:0 10px;display:none;max-height:200px;overflow-y:scroll}.sp-notice div.bulk-error-list ul{padding:3px 0 0;margin-top:5px}.sp-notice div.bulk-error-list ul>li:not(:last-child){border-bottom:1px solid white;padding-bottom:4px}input.dial{box-shadow:none}.shortpixel-table .column-filename{max-width:32em;width:40%}.shortpixel-table .column-folder{max-width:20em;width:20%}.shortpixel-table .column-media_type{max-width:8em;width:10%}.shortpixel-table .column-status{max-width:16em;width:15%}.shortpixel-table .column-options{max-width:16em;width:15%}.form-table table.shortpixel-folders-list tr{background-color:#eee}.form-table table.shortpixel-folders-list td{padding:5px 10px}div.shortpixel-rate-us{display:inline-block;margin-left:10px;vertical-align:top;font-weight:bold}div.shortpixel-rate-us>a{vertical-align:middle;padding:1px 5px 0;text-align:center;display:inline-block}div.shortpixel-rate-us>a>span{display:inline-block;vertical-align:top;margin-top:5px}div.shortpixel-rate-us>a>img{padding-top:7px}div.shortpixel-rate-us>a:active,div.shortpixel-rate-us>a:hover,div.shortpixel-rate-us>a:focus{outline:0;border-style:none}.sp-loading-small{margin-top:2px;float:left;margin-right:5px}li.shortpixel-toolbar-processing>a.ab-item>div,#wpadminbar li.shortpixel-toolbar-processing>a.ab-item>div{height:33px;margin-top:-1px;padding:0 3px}li.shortpixel-toolbar-processing>a.ab-item>div>img,#wpadminbar li.shortpixel-toolbar-processing>a.ab-item>div>img{margin-right:2px;margin-top:6px}li.shortpixel-toolbar-processing>a.ab-item>div>span.shp-alert,#wpadminbar li.shortpixel-toolbar-processing>a.ab-item>div>span.shp-alert{display:none}li.shortpixel-toolbar-processing.shortpixel-alert>a.ab-item>div>span.shp-alert,#wpadminbar li.shortpixel-toolbar-processing.shortpixel-alert>a.ab-item>div>span.shp-alert{display:inline;font-size:26px;color:red;font-weight:bold;vertical-align:top}li.shortpixel-toolbar-processing.shortpixel-alert>a.ab-item>div,#wpadminbar li.shortpixel-toolbar-processing.shortpixel-alert>a.ab-item>div{background-image:none}.sp-quota-exceeded-alert{background-color:#fff;border-left:4px solid red;box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);padding:1px 12px}.shortpixel-clearfix{width:100%;float:left}div.sp-modal-shade{display:none;position:fixed;z-index:10;left:0;top:0;width:100%;height:100%;overflow:auto;background-color:#000;background-color:rgba(0,0,0,0.4)}div.shortpixel-modal{background-color:#fefefe;margin:8% auto;padding:20px;border:1px solid #888;width:30%;min-width:300px}div.shortpixel-modal .sp-close-button,div.shortpixel-modal .sp-close-upgrade-button{float:right;margin-top:0;background:transparent;border:0;font-size:22px;line-height:10px;cursor:pointer}.twentytwenty-horizontal .twentytwenty-before-label:before,.twentytwenty-horizontal .twentytwenty-after-label:before{font-family:inherit;font-size:16px}div.sp-modal-title{font-size:22px}div.sp-modal-body{margin-top:20px}.short-pixel-bulk-page p{margin:.6em 0}div.shortpixel-modal .sptw-modal-spinner{background-image:url("../img/spinner2.gif");background-repeat:no-repeat;background-position:center}.short-pixel-bulk-page form.start{display:table;content:" ";width:98%;background-color:white;padding:10px 10px 0;position:relative}.bulk-stats-container{display:inline-block;min-width:450px;width:45%;float:left;padding-right:50px;font-size:1.1em;line-height:1.5em}.bulk-text-container{display:inline-block;min-width:440px;width:45%;float:left;padding-right:50px}.bulk-text-container h3{border-bottom:1px solid #a8a8a8;margin-bottom:.5em;padding-bottom:.5em}.bulk-wide{display:inline-block;width:90%;float:left;margin-top:25px}.bulk-stats-container .bulk-label{width:220px;display:inline-block}.bulk-stats-container .bulk-val{width:50px;display:inline-block;text-align:right}.bulk-stats-container .bulk-total{font-weight:bold;margin-top:10px;margin-bottom:10px}.wp-core-ui .bulk-play{display:inline;width:310px;float:left;margin-bottom:20px}.wp-core-ui .bulk-play.bulk-nothing-optimize{font-weight:bold;color:#0080b2;border:1px solid;border-radius:5px;margin-top:60px;padding:5px 12px}.wp-core-ui .bulk-play a.button{height:60px;margin-top:27px;width:290px;overflow:hidden}.wp-core-ui .column-wp-shortPixel .sp-column-actions{max-width:140px;float:right;text-align:right}.wp-core-ui .column-wp-shortPixel .sp-column-actions .button.button-smaller{margin-right:0}.wp-core-ui .column-wp-shortPixel .button.button-smaller{font-size:13px;padding:0 5px;margin-bottom:4px;height:20px;line-height:16px;float:right}th.sortable.column-wp-shortPixel a,th.sorted.column-wp-shortPixel a{display:inline-block}.column-wp-shortPixel .sorting-indicator{display:inline-block}.wp-core-ui .bulk-play a.button .bulk-btn-img{float:left;display:inline-block;padding-top:6px}.wp-core-ui .bulk-play a.button .bulk-btn-txt{float:left;display:inline-block;text-align:right;line-height:1.3em;margin:11px 10px}.wp-core-ui .bulk-play a.button .bulk-btn-txt span.label{font-size:1.6em}.wp-core-ui .bulk-play a.button .bulk-btn-txt span.total{font-size:1.4em}.short-pixel-notice-icon{float:left;margin:10px 10px 10px 0}.bulk-progress{padding:20px 32px 17px;background-color:#fff}.bulk-progress.bulk-stats>div{display:inline-block}.bulk-progress.bulk-stats>div.label{width:320px}.bulk-progress.bulk-stats>div.stat-value{width:80px;text-align:right}.short-pixel-bulk-page .progress{background-color:#ecedee;height:30px;position:relative;width:60%;display:inline-block;margin-right:28px;overflow:visible}.progress .progress-img{position:absolute;top:-10px;z-index:2;margin-left:-35px;line-height:48px;font-size:22px;font-weight:bold}.progress .progress-img span{vertical-align:top;margin-left:-7px}.progress .progress-left{background-color:#1cbecb;bottom:0;left:0;position:absolute;top:0;z-index:1;font-size:22px;font-weight:bold;line-height:28px;text-align:center;color:#fff}.bulk-estimate{font-size:20px;line-height:30px;vertical-align:top;display:inline-block}.wp-core-ui .button-primary.bulk-cancel{float:right;height:30px}.short-pixel-block-title{font-size:22px;font-weight:bold;margin-bottom:15px;text-align:center;margin-bottom:30px}.sp-floating-block.bulk-slider-container{display:none}.sp-floating-block.sp-notice.bulk-notices-parent{padding:0;margin:0;float:right;margin-right:500px !important}.bulk-slider-container{margin-top:20px;min-height:300px;overflow:hidden}.bulk-slider-container h2{margin-bottom:15px}.bulk-slider-container span.filename{font-weight:normal}.bulk-slider{display:table;margin:0 auto}.bulk-slider .bulk-slide{margin:0 auto;padding-left:120px;display:inline-block;font-weight:bold}.bulk-slider .img-original,.bulk-slider .img-optimized{display:inline-block;margin-right:20px;text-align:center}.bulk-slider .img-original div,.bulk-slider .img-optimized div{max-height:450px;overflow:hidden}.bulk-slider .img-original img,.bulk-slider .img-optimized img{max-width:300px}.bulk-slider .img-info{display:inline-block;vertical-align:top;font-size:48px;max-width:150px;padding:10px 0 0 20px}.bulk-slide-images{display:inline-block;border:1px solid #1caecb;padding:15px 0 0 20px}p.settings-info{padding-top:0;color:#818181;font-size:13px !important}p.settings-info.shortpixel-settings-error{color:#c32525}.shortpixel-key-valid{font-weight:bold}.shortpixel-key-valid .dashicons-yes:before{font-size:2em;line-height:25px;color:#3485ba;margin-left:-20px}.shortpixel-compression .shortpixel-compression-options{color:#999}.shortpixel-compression strong{line-height:22px}.shortpixel-compression .shortpixel-compression-options{display:inline-block}.shortpixel-compression label{width:158px;margin:0 -2px;background-color:#e2faff;font-weight:bold;display:inline-block}.shortpixel-compression label span{text-align:center;font-size:18px;padding:8px 0;display:block}.shortpixel-compression label input{display:none}.shortpixel-compression input:checked+span{background-color:#0085ba;color:#f7f7f7}.shortpixel-compression .shortpixel-radio-info{min-height:60px}article.sp-tabs{position:relative;display:block;width:100%;height:1100px;margin:2em auto}article.sp-tabs section{position:absolute;display:block;top:1.8em;left:0;height:1100px;width:94%;padding:10px 20px;background-color:#ddd;box-shadow:0 3px 3px rgba(0,0,0,0.1);z-index:0}article.sp-tabs section:first-child{z-index:1}article.sp-tabs section h2{position:absolute;font-size:1.3em;font-weight:normal;width:180px;height:1.8em;top:-1.8em;left:10px;padding:0;margin:0;color:#999;background-color:#ddd}article.sp-tabs section:nth-child(2) h2{left:192px}article.sp-tabs section:nth-child(3) h2{left:374px}article.sp-tabs section:nth-child(4) h2{left:556px}article.sp-tabs section:nth-child(5) h2{left:738px}article.sp-tabs section h2 a{display:block;width:100%;line-height:1.8em;text-align:center;text-decoration:none;color:#23282d;outline:0 none}article.sp-tabs section h2 a:focus,article.sp-tabs section#tab-resources a:focus{box-shadow:none;outline:0}article.sp-tabs section.sel-tab,article.sp-tabs section.sel-tab h2{color:#333;background-color:#fff;z-index:2}.shortpixel-help-link span.dashicons{text-decoration:none;margin-top:-1px}@media(min-width:1000px){section#tab-resources .col-md-6{display:inline-block;width:45%}}@media(max-width:999px){section#tab-resources .col-sm-12{display:inline-block;width:100%}}section#tab-resources .text-center{text-align:center}section#tab-resources p{font-size:16px}.wrap.short-pixel-bulk-page{margin-right:0}.sp-container{overflow:hidden;display:block;width:100%}.sp-floating-block{overflow:hidden;display:inline-block;float:left;margin-right:1.1% !important}.sp-full-width{width:98.8%;box-sizing:border-box}.sp-double-width{width:65.52%;box-sizing:border-box}.sp-single-width{width:32.23%;box-sizing:border-box}@media(max-width:1759px){.sp-floating-block{margin-right:1.3% !important}.sp-double-width,.sp-full-width{width:98.65%}.sp-single-width{width:48.7%}}@media(max-width:1249px){.sp-floating-block{margin-right:2% !important}.sp-double-width,.sp-full-width,.sp-single-width{width:97%}}.sp-tabs h2:before{content:none}#wpadminbar .shortpixel-toolbar-processing .cssload-container{width:100%;height:24px;text-align:center;position:absolute;top:0;left:-1px}#wpadminbar .shortpixel-toolbar-processing.shortpixel-quota-exceeded .cssload-container,#wpadminbar .shortpixel-toolbar-processing.shortpixel-alert .cssload-container{display:none}#wpadminbar .shortpixel-toolbar-processing .cssload-speeding-wheel{width:24px;height:24px;opacity:.7;margin:0 auto;border:4px solid #1cbfcb;border-radius:50%;border-left-color:transparent;animation:cssload-spin 2000ms infinite linear;-o-animation:cssload-spin 2000ms infinite linear;-ms-animation:cssload-spin 2000ms infinite linear;-webkit-animation:cssload-spin 2000ms infinite linear;-moz-animation:cssload-spin 2000ms infinite linear}@keyframes cssload-spin{100%{transform:rotate(360deg);transform:rotate(360deg)}}@-o-keyframes cssload-spin{100%{-o-transform:rotate(360deg);transform:rotate(360deg)}}@-ms-keyframes cssload-spin{100%{-ms-transform:rotate(360deg);transform:rotate(360deg)}}@-webkit-keyframes cssload-spin{100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@-moz-keyframes cssload-spin{100%{-moz-transform:rotate(360deg);transform:rotate(360deg)}}
1
+ .reset{font-weight:normal;font-style:normal}.clearfix:before,.clearfix:after{content:" ";display:table}.clearfix:after{clear:both}.clearfix{zoom:1}.resumeLabel{float:right;line-height:30px;margin-right:20px;font-size:16px}.sp-dropbtn.button{padding:1px 24px 20px 5px;font-size:20px;cursor:pointer}.sp-dropdown{position:relative;display:inline-block}.sp-dropdown-content{display:none;right:0;position:absolute;background-color:#f9f9f9;min-width:190px;box-shadow:0 8px 16px 0 rgba(0,0,0,0.2);z-index:1}.sp-dropdown-content a{color:black;padding:12px 16px;text-decoration:none;display:block}.sp-dropdown-content a:hover{background-color:#f1f1f1}.sp-dropdown.sp-show .sp-dropdown-content{display:block}div.fb-like{transform:scale(1.3);-ms-transform:scale(1.3);-webkit-transform:scale(1.3);-o-transform:scale(1.3);-moz-transform:scale(1.3);transform-origin:bottom left;-ms-transform-origin:bottom left;-webkit-transform-origin:bottom left;-moz-transform-origin:bottom left;-webkit-transform-origin:bottom left}.wp-core-ui .button.button-alert,.wp-core-ui .button.button-alert:hover{background:#f79797}.wp-core-ui .button.remove-folder-button{min-width:120px}.sp-notice{background:#fff;border-left:4px solid #fff;-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,.1);box-shadow:0 1px 1px 0 rgba(0,0,0,.1);padding:1px 12px}@media(max-width:1249px){.sp-notice{margin:5px 15px 2px}}.sp-notice-info{border-left-color:#00a0d2}.sp-notice-success{border-left-color:#46b450}.sp-notice-warning{border-left-color:#f1e02a}.sp-conflict-plugins{display:table;border-spacing:10px;border-collapse:separate}.sp-conflict-plugins li{display:table-row}.sp-conflict-plugins li>*{display:table-cell}li.sp-conflict-plugins-list{line-height:28px;list-style:disc;margin-left:80px}li.sp-conflict-plugins-list a.button{margin-left:10px}div.short-pixel-bulk-page input.dial{font-size:16px !important}div.short-pixel-bulk-page h1{margin-bottom:20px}div.bulk-progress div.sp-h2{margin-top:0;margin-bottom:10px;font-size:23px;font-weight:400;padding:9px 15px 4px 0;line-height:29px}div.bulk-progress-partners{margin-top:20px}div.bulk-progress.bulk-progress-partners a div{display:inline-block;vertical-align:top;line-height:50px;margin-left:30px;font-size:1.2em}div.bulk-progress .bulk-progress-indicator,div.sp-quota-exceeded-alert .bulk-progress-indicator{display:inline-block;text-align:center;padding:0 10px;margin-left:10px;float:left;height:90px;overflow:hidden;border:1px solid #1caecb}div.wrap.short-pixel-bulk-page .bulk-notice-container{margin-top:15px;position:absolute;width:500px}div.wrap.short-pixel-bulk-page .bulk-notice-container .bulk-notice-msg{text-align:center;margin:10px 0 0 32px;overflow:hidden;border:1px solid #1caecb;background-color:#9ddbe0;border-radius:5px;padding:7px 10px 10px;display:none;max-width:600px;margin-right:20px}div.wrap.short-pixel-bulk-page .bulk-notice-container .bulk-notice-msg.bulk-error{border:1px solid #b5914d;background-color:#ffe996;margin-right:20px;position:relative;z-index:10}div.wrap.short-pixel-bulk-page .bulk-notice-container .bulk-notice-msg.bulk-error.bulk-error-fatal{border:1px solid #c32525;background-color:#ff969d}div.wrap.short-pixel-bulk-page .bulk-notice-msg img{float:left;margin-top:3px;margin-right:5px}div.sp-bulk-summary{float:right;margin:8px 5px 3px 20px}.sp-notice .bulk-error-show{cursor:pointer}.sp-notice div.bulk-error-list{background-color:#f1f1f1;padding:0 10px;display:none;max-height:200px;overflow-y:scroll}.sp-notice div.bulk-error-list ul{padding:3px 0 0;margin-top:5px}.sp-notice div.bulk-error-list ul>li:not(:last-child){border-bottom:1px solid white;padding-bottom:4px}input.dial{box-shadow:none}.shortpixel-table .column-filename{max-width:32em;width:40%}.shortpixel-table .column-folder{max-width:20em;width:20%}.shortpixel-table .column-media_type{max-width:8em;width:10%}.shortpixel-table .column-status{max-width:16em;width:15%}.shortpixel-table .column-options{max-width:16em;width:15%}.form-table th{width:220px}.form-table td{position:relative}.form-table table.shortpixel-folders-list tr{background-color:#eee}.form-table table.shortpixel-folders-list td{padding:5px 10px}div.shortpixel-rate-us{display:inline-block;margin-left:10px;vertical-align:top;font-weight:bold}div.shortpixel-rate-us>a{vertical-align:middle;padding:1px 5px 0;text-align:center;display:inline-block}div.shortpixel-rate-us>a>span{display:inline-block;vertical-align:top;margin-top:5px}div.shortpixel-rate-us>a>img{padding-top:7px}div.shortpixel-rate-us>a:active,div.shortpixel-rate-us>a:hover,div.shortpixel-rate-us>a:focus{outline:0;border-style:none}.sp-loading-small{margin-top:2px;float:left;margin-right:5px}li.shortpixel-toolbar-processing>a.ab-item>div,#wpadminbar li.shortpixel-toolbar-processing>a.ab-item>div{height:33px;margin-top:-1px;padding:0 3px}li.shortpixel-toolbar-processing>a.ab-item>div>img,#wpadminbar li.shortpixel-toolbar-processing>a.ab-item>div>img{margin-right:2px;margin-top:6px}li.shortpixel-toolbar-processing>a.ab-item>div>span.shp-alert,#wpadminbar li.shortpixel-toolbar-processing>a.ab-item>div>span.shp-alert{display:none}li.shortpixel-toolbar-processing.shortpixel-alert>a.ab-item>div>span.shp-alert,#wpadminbar li.shortpixel-toolbar-processing.shortpixel-alert>a.ab-item>div>span.shp-alert{display:inline;font-size:26px;color:red;font-weight:bold;vertical-align:top}li.shortpixel-toolbar-processing.shortpixel-alert>a.ab-item>div,#wpadminbar li.shortpixel-toolbar-processing.shortpixel-alert>a.ab-item>div{background-image:none}.sp-quota-exceeded-alert{background-color:#fff;border-left:4px solid red;box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);padding:1px 12px}.shortpixel-clearfix{width:100%;float:left}div.sp-modal-shade{display:none;position:fixed;z-index:10;left:0;top:0;width:100%;height:100%;overflow:auto;background-color:#000;background-color:rgba(0,0,0,0.4)}div.shortpixel-modal{background-color:#fefefe;margin:8% auto;padding:20px;border:1px solid #888;width:30%;min-width:300px}div.shortpixel-modal .sp-close-button,div.shortpixel-modal .sp-close-upgrade-button{float:right;margin-top:0;background:transparent;border:0;font-size:22px;line-height:10px;cursor:pointer}.twentytwenty-horizontal .twentytwenty-before-label:before,.twentytwenty-horizontal .twentytwenty-after-label:before{font-family:inherit;font-size:16px}div.sp-modal-title{font-size:22px}div.sp-modal-body{margin-top:20px}.short-pixel-bulk-page p{margin:.6em 0}div.shortpixel-modal .sptw-modal-spinner{background-image:url("../img/spinner2.gif");background-repeat:no-repeat;background-position:center}.short-pixel-bulk-page form.start{display:table;content:" ";width:98%;background-color:white;padding:10px 10px 0;position:relative}.bulk-stats-container{display:inline-block;min-width:450px;width:45%;float:left;padding-right:50px;font-size:1.1em;line-height:1.5em}.bulk-text-container{display:inline-block;min-width:440px;width:45%;float:left;padding-right:50px}.bulk-text-container h3{border-bottom:1px solid #a8a8a8;margin-bottom:.5em;padding-bottom:.5em}.bulk-wide{display:inline-block;width:90%;float:left;margin-top:25px}.bulk-stats-container .bulk-label{width:220px;display:inline-block}.bulk-stats-container .bulk-val{width:50px;display:inline-block;text-align:right}.bulk-stats-container .bulk-total{font-weight:bold;margin-top:10px;margin-bottom:10px}.wp-core-ui .bulk-play{display:inline;width:310px;float:left;margin-bottom:20px}.wp-core-ui .bulk-play.bulk-nothing-optimize{font-weight:bold;color:#0080b2;border:1px solid;border-radius:5px;margin-top:60px;padding:5px 12px}.wp-core-ui .bulk-play a.button{height:60px;margin-top:27px;width:290px;overflow:hidden}.wp-core-ui .column-wp-shortPixel .sp-column-actions{max-width:140px;float:right;text-align:right}.wp-core-ui .column-wp-shortPixel .sp-column-actions .button.button-smaller{margin-right:0}.wp-core-ui .column-wp-shortPixel .button.button-smaller{font-size:13px;padding:0 5px;margin-bottom:4px;height:20px;line-height:16px;float:right}th.sortable.column-wp-shortPixel a,th.sorted.column-wp-shortPixel a{display:inline-block}.column-wp-shortPixel .sorting-indicator{display:inline-block}.wp-core-ui .bulk-play a.button .bulk-btn-img{float:left;display:inline-block;padding-top:6px}.wp-core-ui .bulk-play a.button .bulk-btn-txt{float:left;display:inline-block;text-align:right;line-height:1.3em;margin:11px 10px}.wp-core-ui .bulk-play a.button .bulk-btn-txt span.label{font-size:1.6em}.wp-core-ui .bulk-play a.button .bulk-btn-txt span.total{font-size:1.4em}.short-pixel-notice-icon{float:left;margin:10px 10px 10px 0}.bulk-progress{padding:20px 32px 17px;background-color:#fff}.bulk-progress.bulk-stats>div{display:inline-block}.bulk-progress.bulk-stats>div.label{width:320px}.bulk-progress.bulk-stats>div.stat-value{width:80px;text-align:right}.short-pixel-bulk-page .progress{background-color:#ecedee;height:30px;position:relative;width:60%;display:inline-block;margin-right:28px;overflow:visible}.progress .progress-img{position:absolute;top:-10px;z-index:2;margin-left:-35px;line-height:48px;font-size:22px;font-weight:bold}.progress .progress-img span{vertical-align:top;margin-left:-7px}.progress .progress-left{background-color:#1cbecb;bottom:0;left:0;position:absolute;top:0;z-index:1;font-size:22px;font-weight:bold;line-height:28px;text-align:center;color:#fff}.bulk-estimate{font-size:20px;line-height:30px;vertical-align:top;display:inline-block}.wp-core-ui .button-primary.bulk-cancel{float:right;height:30px}.short-pixel-block-title{font-size:22px;font-weight:bold;margin-bottom:15px;text-align:center;margin-bottom:30px}.sp-floating-block.bulk-slider-container{display:none}.sp-floating-block.sp-notice.bulk-notices-parent{padding:0;margin:0;float:right;margin-right:500px !important}.bulk-slider-container{margin-top:20px;min-height:300px;overflow:hidden}.bulk-slider-container h2{margin-bottom:15px}.bulk-slider-container span.filename{font-weight:normal}.bulk-slider{display:table;margin:0 auto}.bulk-slider .bulk-slide{margin:0 auto;padding-left:120px;display:inline-block;font-weight:bold}.bulk-slider .img-original,.bulk-slider .img-optimized{display:inline-block;margin-right:20px;text-align:center}.bulk-slider .img-original div,.bulk-slider .img-optimized div{max-height:450px;overflow:hidden}.bulk-slider .img-original img,.bulk-slider .img-optimized img{max-width:300px}.bulk-slider .img-info{display:inline-block;vertical-align:top;font-size:48px;max-width:150px;padding:10px 0 0 20px}.bulk-slide-images{display:inline-block;border:1px solid #1caecb;padding:15px 0 0 20px}p.settings-info{padding-top:0;color:#818181;font-size:13px !important}p.settings-info.shortpixel-settings-error{color:#c32525}.shortpixel-key-valid{font-weight:bold}.shortpixel-key-valid .dashicons-yes:before{font-size:2em;line-height:25px;color:#3485ba;margin-left:-20px}.shortpixel-compression .shortpixel-compression-options{color:#999}.shortpixel-compression strong{line-height:22px}.shortpixel-compression .shortpixel-compression-options{display:inline-block}.shortpixel-compression label{width:158px;margin:0 -2px;background-color:#e2faff;font-weight:bold;display:inline-block}.shortpixel-compression label span{text-align:center;font-size:18px;padding:8px 0;display:block}.shortpixel-compression label input{display:none}.shortpixel-compression input:checked+span{background-color:#0085ba;color:#f7f7f7}.shortpixel-compression .shortpixel-radio-info{min-height:60px}article.sp-tabs{position:relative;display:block;width:100%;margin:2em auto}article.sp-tabs section{position:absolute;display:block;top:1.8em;left:0;width:100%;max-width:100%;box-sizing:border-box;padding:10px 20px;z-index:0}article.sp-tabs section.sel-tab{box-shadow:0 3px 3px rgba(0,0,0,0.1)}article.sp-tabs section .wp-shortpixel-tab-content{visibility:hidden}article.sp-tabs section.sel-tab .wp-shortpixel-tab-content{visibility:visible}article.sp-tabs section:first-child{z-index:1}article.sp-tabs section h2{position:absolute;font-size:1.3em;font-weight:normal;width:180px;height:1.8em;top:-1.8em;left:10px;padding:0;margin:0;color:#999;background-color:#ddd}article.sp-tabs section:nth-child(2) h2{left:192px}article.sp-tabs section:nth-child(3) h2{left:374px}article.sp-tabs section:nth-child(4) h2{left:556px}article.sp-tabs section:nth-child(5) h2{left:738px}article.sp-tabs section h2 a{display:block;width:100%;line-height:1.8em;text-align:center;text-decoration:none;color:#23282d;outline:0 none}article.sp-tabs section h2 a:focus,article.sp-tabs section#tab-resources a:focus{box-shadow:none;outline:0}article.sp-tabs section.sel-tab,article.sp-tabs section.sel-tab h2{color:#333;background-color:#fff;z-index:2}#tab-stats .sp-bulk-summary{position:absolute;right:0;top:0;z-index:100}.deliverWebpSettings,.deliverWebpTypes,.deliverWebpAlteringTypes{display:none}.deliverWebpTypes .sp-notice{color:red}.deliverWebpSettings{margin:16px 0}.deliverWebpSettings input:disabled+label{color:#818181}.deliverWebpTypes,.deliverWebpAlteringTypes{margin:16px 0 16px 16px}article.sp-tabs section #createWebp:checked ~ .deliverWebpSettings,article.sp-tabs section #deliverWebp:checked ~ .deliverWebpTypes,article.sp-tabs section #deliverWebpAltered:checked ~ .deliverWebpAlteringTypes{display:block}.shortpixel-help-link span.dashicons{text-decoration:none;margin-top:-1px}@media(min-width:1000px){section#tab-resources .col-md-6{display:inline-block;width:45%}}@media(max-width:999px){section#tab-resources .col-sm-12{display:inline-block;width:100%}}section#tab-resources .text-center{text-align:center}section#tab-resources p{font-size:16px}.wrap.short-pixel-bulk-page{margin-right:0}.sp-container{overflow:hidden;display:block;width:100%}.sp-floating-block{overflow:hidden;display:inline-block;float:left;margin-right:1.1% !important}.sp-full-width{width:98.8%;box-sizing:border-box}.sp-double-width{width:65.52%;box-sizing:border-box}.sp-single-width{width:32.23%;box-sizing:border-box}@media(max-width:1759px){.sp-floating-block{margin-right:1.3% !important}.sp-double-width,.sp-full-width{width:98.65%}.sp-single-width{width:48.7%}}@media(max-width:1249px){.sp-floating-block{margin-right:2% !important}.sp-double-width,.sp-full-width,.sp-single-width{width:97%}}.sp-tabs h2:before{content:none}.sp-column-actions-template+.sp-column-info{display:none}#wpadminbar .shortpixel-toolbar-processing .cssload-container{width:100%;height:24px;text-align:center;position:absolute;top:0;left:-1px}#wpadminbar .shortpixel-toolbar-processing.shortpixel-quota-exceeded .cssload-container,#wpadminbar .shortpixel-toolbar-processing.shortpixel-alert .cssload-container{display:none}#wpadminbar .shortpixel-toolbar-processing .cssload-speeding-wheel{width:24px;height:24px;opacity:.7;margin:0 auto;border:4px solid #1cbfcb;border-radius:50%;border-left-color:transparent;animation:cssload-spin 2000ms infinite linear;-o-animation:cssload-spin 2000ms infinite linear;-ms-animation:cssload-spin 2000ms infinite linear;-webkit-animation:cssload-spin 2000ms infinite linear;-moz-animation:cssload-spin 2000ms infinite linear}@keyframes cssload-spin{100%{transform:rotate(360deg);transform:rotate(360deg)}}@-o-keyframes cssload-spin{100%{-o-transform:rotate(360deg);transform:rotate(360deg)}}@-ms-keyframes cssload-spin{100%{-ms-transform:rotate(360deg);transform:rotate(360deg)}}@-webkit-keyframes cssload-spin{100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@-moz-keyframes cssload-spin{100%{-moz-transform:rotate(360deg);transform:rotate(360deg)}}
res/js/short-pixel.js CHANGED
@@ -2,7 +2,7 @@
2
  * Short Pixel WordPress Plugin javascript
3
  */
4
 
5
- jQuery(document).ready(function($){ShortPixel.init();});
6
 
7
 
8
  var ShortPixel = function() {
@@ -20,7 +20,8 @@ var ShortPixel = function() {
20
  + '</option>');
21
  }
22
 
23
- ShortPixel.setOptions(ShortPixelConstants);
 
24
 
25
  if(jQuery('#backup-folder-size').length) {
26
  jQuery('#backup-folder-size').html(ShortPixel.getBackupSize());
@@ -161,13 +162,69 @@ var ShortPixel = function() {
161
  jQuery("div.bulk-play span.total").text(total);
162
  jQuery("#displayTotal").text(total);
163
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
  function switchSettingsTab(target){
166
- var section = jQuery("section#" +target);
 
 
 
 
 
 
 
 
 
167
  if(section.length > 0){
168
  jQuery("section").removeClass("sel-tab");
169
  jQuery("section#" +target).addClass("sel-tab");
170
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  }
172
 
173
  function adjustSettingsTabsHeight(){
@@ -175,7 +232,7 @@ var ShortPixel = function() {
175
  sectionHeight = Math.max(sectionHeight, jQuery('section#tab-adv-settings .wp-shortpixel-options').height() + 20);
176
  sectionHeight = Math.max(sectionHeight, jQuery('section#tab-resources .area1').height() + 60);
177
  jQuery('#shortpixel-settings-tabs').css('height', sectionHeight);
178
- jQuery('#shortpixel-settings-tabs section').css('height', sectionHeight);
179
  }
180
 
181
  function dismissMediaAlert() {
@@ -621,6 +678,7 @@ var ShortPixel = function() {
621
  apiKeyChanged : apiKeyChanged,
622
  setupAdvancedTab : setupAdvancedTab,
623
  checkThumbsUpdTotal : checkThumbsUpdTotal,
 
624
  switchSettingsTab : switchSettingsTab,
625
  adjustSettingsTabs : adjustSettingsTabsHeight,
626
  onBulkThumbsCheck : onBulkThumbsCheck,
@@ -1130,7 +1188,6 @@ function sliderUpdate(id, thumb, bkThumb, percent, filename){
1130
  }
1131
  jQuery(".bulk-opt-percent", newSlide).html('<input type="text" class="dial" value="' + percent + '"/>');
1132
 
1133
- //debugger;
1134
  jQuery(".bulk-slider").append(newSlide);
1135
  ShortPixel.percentDial("#" + newSlide.attr("id") + " .dial", 100);
1136
 
2
  * Short Pixel WordPress Plugin javascript
3
  */
4
 
5
+ jQuery(document).ready(function(){ShortPixel.init();});
6
 
7
 
8
  var ShortPixel = function() {
20
  + '</option>');
21
  }
22
 
23
+ // Extracting the protected Array from within the 0 element of the parent array
24
+ ShortPixel.setOptions(ShortPixelConstants[0]);
25
 
26
  if(jQuery('#backup-folder-size').length) {
27
  jQuery('#backup-folder-size').html(ShortPixel.getBackupSize());
162
  jQuery("div.bulk-play span.total").text(total);
163
  jQuery("#displayTotal").text(total);
164
  }
165
+
166
+ function initSettings() {
167
+ ShortPixel.adjustSettingsTabs();
168
+ jQuery( window ).resize(function() {
169
+ ShortPixel.adjustSettingsTabs();
170
+ });
171
+ if(window.location.hash) {
172
+ var target = ('tab-' + window.location.hash.substring(window.location.hash.indexOf("#")+1)).replace(/\//, '');
173
+ if(jQuery("section#" + target).length) {
174
+ ShortPixel.switchSettingsTab( target );
175
+ }
176
+ }
177
+ jQuery("article.sp-tabs a.tab-link").click(function(){
178
+ var theID = jQuery(this).data("id");
179
+ ShortPixel.switchSettingsTab( theID );
180
+ });
181
+
182
+ jQuery('input[type=radio][name=deliverWebpType]').change(function() {
183
+ if (this.value == 'deliverWebpAltered') {
184
+ if(window.confirm("Warning: Using this method alters the structure of the HTML code (IMG tags get included in PICTURE tags),\nwhich can lead to CSS/JS inconsistencies with the existing code.\n\nPlease test this functionality thoroughly before using it!")){
185
+ var selectedItems = jQuery('input[type=radio][name=deliverWebpAlteringType]:checked').length;
186
+ if (selectedItems == 0) {
187
+ jQuery('#deliverWebpAlteredWP').prop('checked',true);
188
+ }
189
+ } else {
190
+ jQuery(this).prop('checked', false);
191
+ }
192
+ }
193
+ });
194
+ }
195
 
196
  function switchSettingsTab(target){
197
+ var tab = target.replace("tab-",""),
198
+ beacon = "",
199
+ section = jQuery("section#" +target),
200
+ url = location.href.replace(location.hash,"") + '#' + tab;
201
+ if(history.pushState) {
202
+ history.pushState(null, null, url);
203
+ }
204
+ else {
205
+ location.hash = url;
206
+ }
207
  if(section.length > 0){
208
  jQuery("section").removeClass("sel-tab");
209
  jQuery("section#" +target).addClass("sel-tab");
210
  }
211
+ if(typeof HS.beacon.suggest !== 'undefined' ){
212
+ switch(tab){
213
+ case "settings":
214
+ beacon = shortpixel_suggestions_settings;
215
+ break;
216
+ case "adv-settings":
217
+ beacon = shortpixel_suggestions_adv_settings;
218
+ break;
219
+ case "cloudflare":
220
+ case "stats":
221
+ beacon = shortpixel_suggestions_cloudflare;
222
+ break;
223
+ default:
224
+ break;
225
+ }
226
+ HS.beacon.suggest(beacon);
227
+ }
228
  }
229
 
230
  function adjustSettingsTabsHeight(){
232
  sectionHeight = Math.max(sectionHeight, jQuery('section#tab-adv-settings .wp-shortpixel-options').height() + 20);
233
  sectionHeight = Math.max(sectionHeight, jQuery('section#tab-resources .area1').height() + 60);
234
  jQuery('#shortpixel-settings-tabs').css('height', sectionHeight);
235
+ //jQuery('#shortpixel-settings-tabs section').css('height', sectionHeight);
236
  }
237
 
238
  function dismissMediaAlert() {
678
  apiKeyChanged : apiKeyChanged,
679
  setupAdvancedTab : setupAdvancedTab,
680
  checkThumbsUpdTotal : checkThumbsUpdTotal,
681
+ initSettings : initSettings,
682
  switchSettingsTab : switchSettingsTab,
683
  adjustSettingsTabs : adjustSettingsTabsHeight,
684
  onBulkThumbsCheck : onBulkThumbsCheck,
1188
  }
1189
  jQuery(".bulk-opt-percent", newSlide).html('<input type="text" class="dial" value="' + percent + '"/>');
1190
 
 
1191
  jQuery(".bulk-slider").append(newSlide);
1192
  ShortPixel.percentDial("#" + newSlide.attr("id") + " .dial", 100);
1193
 
res/js/short-pixel.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(a){ShortPixel.init()});var ShortPixel=function(){function H(){if(typeof ShortPixel.API_KEY!=="undefined"){return}if(jQuery("table.wp-list-table.media").length>0){jQuery('select[name^="action"] option:last-child').before('<option value="short-pixel-bulk">'+_spTr.optimizeWithSP+'</option><option value="short-pixel-bulk-lossy"> → '+_spTr.redoLossy+'</option><option value="short-pixel-bulk-glossy"> → '+_spTr.redoGlossy+'</option><option value="short-pixel-bulk-lossless"> → '+_spTr.redoLossless+'</option><option value="short-pixel-bulk-restore"> → '+_spTr.restoreOriginal+"</option>")}ShortPixel.setOptions(ShortPixelConstants);if(jQuery("#backup-folder-size").length){jQuery("#backup-folder-size").html(ShortPixel.getBackupSize())}if(ShortPixel.MEDIA_ALERT=="todo"&&jQuery("div.media-frame.mode-grid").length>0){jQuery("div.media-frame.mode-grid").before('<div id="short-pixel-media-alert" class="notice notice-warning"><p>'+_spTr.changeMLToListMode.format('<a href="upload.php?mode=list" class="view-list"><span class="screen-reader-text">'," </span>",'</a><a class="alignright" href="javascript:ShortPixel.dismissMediaAlert();">',"</a>")+"</p></div>")}jQuery(window).on("beforeunload",function(){if(ShortPixel.bulkProcessor==true){clearBulkProcessor()}});checkQuotaExceededAlert();checkBulkProgress()}function l(P){for(var Q in P){ShortPixel[Q]=P[Q]}}function s(P){return/^\w+([\.+-]?\w+)*@\w+([\.-]?\w+)*(\.\w{1,63})+$/.test(P)}function m(){var P=jQuery("#pluginemail").val();if(ShortPixel.isEmailValid(P)){jQuery("#request_key").removeClass("disabled")}jQuery("#request_key").attr("href",jQuery("#request_key").attr("href").split("?")[0]+"?pluginemail="+P)}function a(){jQuery("#valid").val("validate");jQuery("#wp_shortpixel_options").submit()}jQuery("#key").keypress(function(P){if(P.which==13){jQuery("#valid").val("validate")}});function K(P){if(jQuery(P).is(":checked")){jQuery("#width,#height").removeAttr("disabled")}else{jQuery("#width,#height").attr("disabled","disabled")}}function e(P,R,T){for(var Q=0,S=null;Q<P.length;Q++){P[Q].onclick=function(){if(this!==S){S=this}if(typeof ShortPixel.setupGeneralTabAlert!=="undefined"){return}alert(_spTr.alertOnlyAppliesToNewImages);ShortPixel.setupGeneralTabAlert=1}}ShortPixel.enableResize("#resize");jQuery("#resize").change(function(){K(this)});jQuery(".resize-sizes").blur(function(V){var W=jQuery(this);if(ShortPixel.resizeSizesAlert==W.val()){return}ShortPixel.resizeSizesAlert=W.val();var U=jQuery("#min-"+W.attr("name")).val();if(W.val()<Math.min(U,1024)){if(U>1024){alert(_spTr.pleaseDoNotSetLesser1024.format(W.attr("name")))}else{alert(_spTr.pleaseDoNotSetLesserSize.format(W.attr("name"),W.attr("name"),U))}V.preventDefault();W.focus()}else{this.defaultValue=W.val()}});jQuery(".shortpixel-confirm").click(function(V){var U=confirm(V.target.getAttribute("data-confirm"));if(!U){V.preventDefault();return false}return true})}function B(){jQuery(".wp-shortpixel-options .shortpixel-key-valid").css("display","none");jQuery(".wp-shortpixel-options button#validate").css("display","inline-block")}function t(){jQuery("input.remove-folder-button").click(function(){var Q=jQuery(this).data("value");var P=confirm(_spTr.areYouSureStopOptimizing.format(Q));if(P==true){jQuery("#removeFolder").val(Q);jQuery("#wp_shortpixel_options").submit()}});jQuery("input.recheck-folder-button").click(function(){var Q=jQuery(this).data("value");var P=confirm(_spTr.areYouSureStopOptimizing.format(Q));if(P==true){jQuery("#recheckFolder").val(Q);jQuery("#wp_shortpixel_options").submit()}})}function J(P){var Q=jQuery("#"+(P.checked?"total":"main")+"ToProcess").val();jQuery("div.bulk-play span.total").text(Q);jQuery("#displayTotal").text(Q)}function w(Q){var P=jQuery("section#"+Q);if(P.length>0){jQuery("section").removeClass("sel-tab");jQuery("section#"+Q).addClass("sel-tab")}}function x(){var P=jQuery("section#tab-settings .wp-shortpixel-options").height()+90;P=Math.max(P,jQuery("section#tab-adv-settings .wp-shortpixel-options").height()+20);P=Math.max(P,jQuery("section#tab-resources .area1").height()+60);jQuery("#shortpixel-settings-tabs").css("height",P);jQuery("#shortpixel-settings-tabs section").css("height",P)}function L(){var P={action:"shortpixel_dismiss_media_alert"};jQuery.get(ShortPixel.AJAX_URL,P,function(Q){P=JSON.parse(Q);if(P.Status=="success"){jQuery("#short-pixel-media-alert").hide();console.log("dismissed")}})}function j(){var P={action:"shortpixel_check_quota"};jQuery.get(ShortPixel.AJAX_URL,P,function(){console.log("quota refreshed")})}function A(P){if(P.checked){jQuery("#with-thumbs").css("display","inherit");jQuery("#without-thumbs").css("display","none")}else{jQuery("#without-thumbs").css("display","inherit");jQuery("#with-thumbs").css("display","none")}}function b(T,R,Q,S,P){return(R>0?"<div class='sp-column-info'>"+_spTr.reducedBy+" <strong><span class='percent'>"+R+"%</span></strong> ":"")+(R>0&&R<5?"<br>":"")+(R<5?_spTr.bonusProcessing:"")+(Q.length>0?" ("+Q+")":"")+(0+S>0?"<br>"+_spTr.plusXthumbsOpt.format(S):"")+(0+P>0?"<br>"+_spTr.plusXretinasOpt.format(P):"")+"</div>"}function o(Q,P){jQuery(Q).knob({readOnly:true,width:P,height:P,fgColor:"#1CAECB",format:function(R){return R+"%"}})}function c(W,R,U,T,Q,V){if(Q==1){var S=jQuery(".sp-column-actions-template").clone();if(!S.length){return false}var P;if(R.length==0){P=["lossy","lossless"]}else{P=["lossy","glossy","lossless"].filter(function(X){return !(X==R)})}S.html(S.html().replace(/__SP_ID__/g,W));if(V.substr(V.lastIndexOf(".")+1).toLowerCase()=="pdf"){jQuery(".sp-action-compare",S).remove()}if(U==0&&T>0){S.html(S.html().replace("__SP_THUMBS_TOTAL__",T))}else{jQuery(".sp-action-optimize-thumbs",S).remove();jQuery(".sp-dropbtn",S).removeClass("button-primary")}S.html(S.html().replace(/__SP_FIRST_TYPE__/g,P[0]));S.html(S.html().replace(/__SP_SECOND_TYPE__/g,P[1]));return S.html()}return""}function h(T,S){T=T.substring(2);if(jQuery(".shortpixel-other-media").length){var R=["optimize","retry","restore","redo","quota","view"];for(var Q=0,P=R.length;Q<P;Q++){jQuery("#"+R[Q]+"_"+T).css("display","none")}for(var Q=0,P=S.length;Q<P;Q++){jQuery("#"+S[Q]+"_"+T).css("display","")}}}function i(P){ShortPixel.retries++;if(isNaN(ShortPixel.retries)){ShortPixel.retries=1}if(ShortPixel.retries<6){console.log("Invalid response from server (Error: "+P+"). Retrying pass "+(ShortPixel.retries+1)+"...");setTimeout(checkBulkProgress,5000)}else{ShortPixel.bulkShowError(-1,"Invalid response from server received 6 times. Please retry later by reloading this page, or <a href='https://shortpixel.com/contact' target='_blank'>contact support</a>. (Error: "+P+")","");console.log("Invalid response from server 6 times. Giving up.")}}function k(P){P.action="shortpixel_browse_content";var Q="";jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:P,success:function(R){Q=R},async:false});return Q}function d(){var P={action:"shortpixel_get_backup_size"};var Q="";jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:P,success:function(R){Q=R},async:false});return Q}function f(Q){if(!jQuery("#tos").is(":checked")){Q.preventDefault();jQuery("#tos-robo").fadeIn(400,function(){jQuery("#tos-hand").fadeIn()});jQuery("#tos").click(function(){jQuery("#tos-robo").css("display","none");jQuery("#tos-hand").css("display","none")});return}jQuery("#request_key").addClass("disabled");jQuery("#pluginemail_spinner").addClass("is-active");ShortPixel.updateSignupEmail();if(ShortPixel.isEmailValid(jQuery("#pluginemail").val())){jQuery("#pluginemail-error").css("display","none");var P={action:"shortpixel_new_api_key",email:jQuery("#pluginemail").val()};jQuery.ajax({type:"POST",async:false,url:ShortPixel.AJAX_URL,data:P,success:function(R){data=JSON.parse(R);if(data.Status=="success"){Q.preventDefault();window.location.reload()}else{if(data.Status=="invalid"){jQuery("#pluginemail-error").html("<b>"+data.Details+"</b>");jQuery("#pluginemail-error").css("display","");jQuery("#pluginemail-info").css("display","none");Q.preventDefault()}else{}}}});jQuery("#request_key").removeAttr("onclick")}else{jQuery("#pluginemail-error").css("display","");jQuery("#pluginemail-info").css("display","none");Q.preventDefault()}jQuery("#request_key").removeClass("disabled");jQuery("#pluginemail_spinner").removeClass("is-active")}function M(){jQuery("#shortPixelProposeUpgrade .sp-modal-body").addClass("sptw-modal-spinner");jQuery("#shortPixelProposeUpgrade .sp-modal-body").html("");jQuery("#shortPixelProposeUpgradeShade").css("display","block");jQuery("#shortPixelProposeUpgrade").removeClass("shortpixel-hide");var P={action:"shortpixel_propose_upgrade"};jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:P,success:function(Q){jQuery("#shortPixelProposeUpgrade .sp-modal-body").removeClass("sptw-modal-spinner");jQuery("#shortPixelProposeUpgrade .sp-modal-body").html(Q)}})}function F(){jQuery("#shortPixelProposeUpgradeShade").css("display","none");jQuery("#shortPixelProposeUpgrade").addClass("shortpixel-hide");if(ShortPixel.toRefresh){ShortPixel.recheckQuota()}}function u(){jQuery("#short-pixel-notice-unlisted").hide();jQuery("#optimizeUnlisted").prop("checked",true);var P={action:"shortpixel_dismiss_notice",notice_id:"unlisted",notice_data:"true"};jQuery.get(ShortPixel.AJAX_URL,P,function(Q){P=JSON.parse(Q);if(P.Status==ShortPixel.STATUS_SUCCESS){console.log("dismissed")}})}function n(){jQuery(".select-folder-button").click(function(){jQuery(".sp-folder-picker-shade").css("display","block");jQuery(".sp-folder-picker").fileTree({script:ShortPixel.browseContent,multiFolder:false})});jQuery(".shortpixel-modal input.select-folder-cancel").click(function(){jQuery(".sp-folder-picker-shade").css("display","none")});jQuery(".shortpixel-modal input.select-folder").click(function(){var P=jQuery("UL.jqueryFileTree LI.directory.selected A").attr("rel").trim();if(P){var Q=jQuery("#customFolderBase").val()+P;if(Q.slice(-1)=="/"){Q=Q.slice(0,-1)}jQuery("#addCustomFolder").val(Q);jQuery("#addCustomFolderView").val(Q);jQuery(".sp-folder-picker-shade").css("display","none")}else{alert("Please select a folder from the list.")}})}function E(T,S,R){var Q=jQuery(".bulk-notice-msg.bulk-lengthy");if(Q.length==0){return}var P=jQuery("a",Q);P.text(S);if(R){P.attr("href",R)}else{P.attr("href",P.data("href").replace("__ID__",T))}Q.css("display","block")}function z(){jQuery(".bulk-notice-msg.bulk-lengthy").css("display","none")}function v(P){var Q=jQuery(".bulk-notice-msg.bulk-"+P);if(Q.length==0){return}Q.css("display","block")}function N(P){jQuery(".bulk-notice-msg.bulk-"+P).css("display","none")}function r(V,T,U,S){var P=jQuery("#bulk-error-template");if(P.length==0){return}var R=P.clone();R.attr("id","bulk-error-"+V);if(V==-1){jQuery("span.sp-err-title",R).remove();R.addClass("bulk-error-fatal")}else{jQuery("img",R).remove();jQuery("#bulk-error-".id).remove()}jQuery("span.sp-err-content",R).html(T);var Q=jQuery("a.sp-post-link",R);if(S){Q.attr("href",S)}else{Q.attr("href",Q.attr("href").replace("__ID__",V))}Q.text(U);P.after(R);R.css("display","block")}function C(P,Q){if(!confirm(_spTr["confirmBulk"+P])){Q.stopPropagation();Q.preventDefault();return false}return true}function q(P){jQuery(P).parent().parent().remove()}function G(P){return P.substring(0,2)=="C-"}function I(){window.location.href=window.location.href+(window.location.href.indexOf("?")>0?"&":"?")+"checkquota=1"}function g(Q){Q.preventDefault();if(!this.menuCloseEvent){jQuery(window).click(function(R){if(!R.target.matches(".sp-dropbtn")){jQuery(".sp-dropdown.sp-show").removeClass("sp-show")}});this.menuCloseEvent=true}var P=Q.target.parentElement.classList.contains("sp-show");jQuery(".sp-dropdown.sp-show").removeClass("sp-show");if(!P){Q.target.parentElement.classList.add("sp-show")}}function O(P){this.comparerData.origUrl=false;if(this.comparerData.cssLoaded===false){jQuery("<link>").appendTo("head").attr({type:"text/css",rel:"stylesheet",href:this.WP_PLUGIN_URL+"/res/css/twentytwenty.min.css"});this.comparerData.cssLoaded=2}if(this.comparerData.jsLoaded===false){jQuery.getScript(this.WP_PLUGIN_URL+"/res/js/jquery.twentytwenty.min.js",function(){ShortPixel.comparerData.jsLoaded=2;if(ShortPixel.comparerData.origUrl.length>0){ShortPixel.displayComparerPopup(ShortPixel.comparerData.width,ShortPixel.comparerData.height,ShortPixel.comparerData.origUrl,ShortPixel.comparerData.optUrl)}});this.comparerData.jsLoaded=1;jQuery(".sp-close-button").click(ShortPixel.closeComparerPopup)}if(this.comparerData.origUrl===false){jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:{action:"shortpixel_get_comparer_data",id:P},success:function(Q){data=JSON.parse(Q);jQuery.extend(ShortPixel.comparerData,data);if(ShortPixel.comparerData.jsLoaded==2){ShortPixel.displayComparerPopup(ShortPixel.comparerData.width,ShortPixel.comparerData.height,ShortPixel.comparerData.origUrl,ShortPixel.comparerData.optUrl)}}});this.comparerData.origUrl=""}}function D(T,R,Q,S){var W=T;var V=(R<150||T<350);var U=jQuery(V?"#spUploadCompareSideBySide":"#spUploadCompare");if(!V){jQuery("#spCompareSlider").html('<img class="spUploadCompareOriginal"/><img class="spUploadCompareOptimized"/>')}T=Math.max(350,Math.min(800,(T<350?(T+25)*2:(R<150?T+25:T))));R=Math.max(150,(V?(W>350?2*(R+45):R+45):R*T/W));jQuery(".sp-modal-body",U).css("width",T);jQuery(".shortpixel-slider",U).css("width",T);U.css("width",T);jQuery(".sp-modal-body",U).css("height",R);U.css("display","block");U.parent().css("display","block");if(!V){jQuery("#spCompareSlider").twentytwenty({slider_move:"mousemove"})}jQuery(document).on("keyup.sp_modal_active",ShortPixel.closeComparerPopup);var P=jQuery(".spUploadCompareOptimized",U);jQuery(".spUploadCompareOriginal",U).attr("src",Q);setTimeout(function(){jQuery(window).trigger("resize")},1000);P.load(function(){jQuery(window).trigger("resize")});P.attr("src",S)}function p(P){jQuery("#spUploadCompareSideBySide").parent().css("display","none");jQuery("#spUploadCompareSideBySide").css("display","none");jQuery("#spUploadCompare").css("display","none");jQuery(document).unbind("keyup.sp_modal_active")}function y(P){var Q=document.createElement("a");Q.href=P;if(P.indexOf(Q.protocol+"//"+Q.hostname)<0){return Q.href}return P.replace(Q.protocol+"//"+Q.hostname,Q.protocol+"//"+Q.hostname.split(".").map(function(R){return sp_punycode.toASCII(R)}).join("."))}return{init:H,setOptions:l,isEmailValid:s,updateSignupEmail:m,validateKey:a,enableResize:K,setupGeneralTab:e,apiKeyChanged:B,setupAdvancedTab:t,checkThumbsUpdTotal:J,switchSettingsTab:w,adjustSettingsTabs:x,onBulkThumbsCheck:A,dismissMediaAlert:L,checkQuota:j,percentDial:o,successMsg:b,successActions:c,otherMediaUpdateActions:h,retry:i,initFolderSelector:n,browseContent:k,getBackupSize:d,newApiKey:f,proposeUpgrade:M,closeProposeUpgrade:F,includeUnlisted:u,bulkShowLengthyMsg:E,bulkHideLengthyMsg:z,bulkShowMaintenanceMsg:v,bulkHideMaintenanceMsg:N,bulkShowError:r,confirmBulkAction:C,removeBulkMsg:q,isCustomImageId:G,recheckQuota:I,openImageMenu:g,menuCloseEvent:false,loadComparer:O,displayComparerPopup:D,closeComparerPopup:p,convertPunycode:y,comparerData:{cssLoaded:false,jsLoaded:false,origUrl:false,optUrl:false,width:0,height:0},toRefresh:false,resizeSizesAlert:false}}();function showToolBarAlert(c,b,d){var a=jQuery("li.shortpixel-toolbar-processing");switch(c){case ShortPixel.STATUS_QUOTA_EXCEEDED:if(window.location.href.search("wp-short-pixel-bulk")>0&&jQuery(".sp-quota-exceeded-alert").length==0){location.reload();return}a.addClass("shortpixel-alert");a.addClass("shortpixel-quota-exceeded");jQuery("a",a).attr("href","options-general.php?page=wp-shortpixel");jQuery("a div",a).attr("title","ShortPixel quota exceeded. Click for details.");break;case ShortPixel.STATUS_SKIP:case ShortPixel.STATUS_FAIL:a.addClass("shortpixel-alert shortpixel-processing");jQuery("a div",a).attr("title",b);if(typeof d!=="undefined"){jQuery("a",a).attr("href","post.php?post="+d+"&action=edit")}break;case ShortPixel.STATUS_NO_KEY:a.addClass("shortpixel-alert");a.addClass("shortpixel-quota-exceeded");jQuery("a",a).attr("href","options-general.php?page=wp-shortpixel");jQuery("a div",a).attr("title","Get API Key");break;case ShortPixel.STATUS_SUCCESS:case ShortPixel.STATUS_RETRY:a.addClass("shortpixel-processing");a.removeClass("shortpixel-alert");jQuery("a",a).removeAttr("target");jQuery("a",a).attr("href",jQuery("a img",a).attr("success-url"))}a.removeClass("shortpixel-hide")}function hideToolBarAlert(){jQuery("li.shortpixel-toolbar-processing.shortpixel-processing").addClass("shortpixel-hide")}function hideQuotaExceededToolBarAlert(){jQuery("li.shortpixel-toolbar-processing.shortpixel-quota-exceeded").addClass("shortpixel-hide")}function checkQuotaExceededAlert(){if(typeof shortPixelQuotaExceeded!="undefined"){if(shortPixelQuotaExceeded==1){showToolBarAlert(ShortPixel.STATUS_QUOTA_EXCEEDED)}else{hideQuotaExceededToolBarAlert()}}}function checkBulkProgress(){var b=function(e){if(!d){d=true;return e}return"/"};var d=false;var a=window.location.href.toLowerCase().replace(/\/\//g,b);d=false;var c=ShortPixel.WP_ADMIN_URL.toLowerCase().replace(/\/\//g,b);if(a.search(c)<0){a=ShortPixel.convertPunycode(a);c=ShortPixel.convertPunycode(c)}if(a.search(c+"upload.php")<0&&a.search(c+"edit.php")<0&&a.search(c+"edit-tags.php")<0&&a.search(c+"post-new.php")<0&&a.search(c+"post.php")<0&&a.search("page=nggallery-manage-gallery")<0&&(ShortPixel.FRONT_BOOTSTRAP==0||a.search(c)==0)){hideToolBarAlert();return}if(ShortPixel.bulkProcessor==true&&window.location.href.search("wp-short-pixel-bulk")<0&&typeof localStorage.bulkPage!=="undefined"&&localStorage.bulkPage>0){ShortPixel.bulkProcessor=false}if(window.location.href.search("wp-short-pixel-bulk")>=0){ShortPixel.bulkProcessor=true;localStorage.bulkTime=Math.floor(Date.now()/1000);localStorage.bulkPage=1}if(ShortPixel.bulkProcessor==true||typeof localStorage.bulkTime=="undefined"||Math.floor(Date.now()/1000)-localStorage.bulkTime>90){ShortPixel.bulkProcessor=true;localStorage.bulkPage=(window.location.href.search("wp-short-pixel-bulk")>=0?1:0);localStorage.bulkTime=Math.floor(Date.now()/1000);console.log(localStorage.bulkTime);checkBulkProcessingCallApi()}else{setTimeout(checkBulkProgress,5000)}}function checkBulkProcessingCallApi(){var a={action:"shortpixel_image_processing"};jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:a,success:function(g){if(g.length>0){var i=null;try{var i=JSON.parse(g)}catch(k){ShortPixel.retry(k.message);return}ShortPixel.retries=0;var d=i.ImageID;var j=(jQuery("div.short-pixel-bulk-page").length>0);switch(i.Status){case ShortPixel.STATUS_NO_KEY:setCellMessage(d,i.Message,"<a class='button button-smaller button-primary' href=\"https://shortpixel.com/wp-apikey"+ShortPixel.AFFILIATE+'" target="_blank">'+_spTr.getApiKey+"</a>");showToolBarAlert(ShortPixel.STATUS_NO_KEY);break;case ShortPixel.STATUS_QUOTA_EXCEEDED:setCellMessage(d,i.Message,"<a class='button button-smaller button-primary' href=\"https://shortpixel.com/login/"+ShortPixel.API_KEY+'" target="_blank">'+_spTr.extendQuota+"</a><a class='button button-smaller' href='admin.php?action=shortpixel_check_quota'>"+_spTr.check__Quota+"</a>");showToolBarAlert(ShortPixel.STATUS_QUOTA_EXCEEDED);if(i.Stop==false){setTimeout(checkBulkProgress,5000)}ShortPixel.otherMediaUpdateActions(d,["quota","view"]);break;case ShortPixel.STATUS_FAIL:setCellMessage(d,i.Message,"<a class='button button-smaller button-primary' href=\"javascript:manualOptimization('"+d+"', false)\">"+_spTr.retry+"</a>");showToolBarAlert(ShortPixel.STATUS_FAIL,i.Message,d);if(j){ShortPixel.bulkShowError(d,i.Message,i.Filename,i.CustomImageLink);if(i.BulkPercent){progressUpdate(i.BulkPercent,i.BulkMsg)}ShortPixel.otherMediaUpdateActions(d,["retry","view"])}console.log(i.Message);setTimeout(checkBulkProgress,5000);break;case ShortPixel.STATUS_EMPTY_QUEUE:console.log(i.Message);clearBulkProcessor();hideToolBarAlert();var c=jQuery("#bulk-progress");if(j&&c.length&&i.BulkStatus!="2"){progressUpdate(100,"Bulk finished!");jQuery("a.bulk-cancel").attr("disabled","disabled");hideSlider();setTimeout(function(){window.location.reload()},3000)}break;case ShortPixel.STATUS_SUCCESS:if(j){ShortPixel.bulkHideLengthyMsg();ShortPixel.bulkHideMaintenanceMsg()}var l=i.PercentImprovement;showToolBarAlert(ShortPixel.STATUS_SUCCESS,"");var b=ShortPixel.isCustomImageId(d)?"":ShortPixel.successActions(d,i.Type,i.ThumbsCount,i.ThumbsTotal,i.BackupEnabled,i.Filename);setCellMessage(d,ShortPixel.successMsg(d,l,i.Type,i.ThumbsCount,i.RetinasCount),b);var h=jQuery(["restore","view","redolossy","redoglossy","redolossless"]).not(["redo"+i.Type]).get();ShortPixel.otherMediaUpdateActions(d,h);var f=new PercentageAnimator("#sp-msg-"+d+" span.percent",l);f.animate(l);if(j&&typeof i.Thumb!=="undefined"){if(i.BulkPercent){progressUpdate(i.BulkPercent,i.BulkMsg)}if(i.Thumb.length>0){sliderUpdate(d,i.Thumb,i.BkThumb,i.PercentImprovement,i.Filename);if(typeof i.AverageCompression!=="undefined"&&0+i.AverageCompression>0){jQuery("#sp-avg-optimization").html('<input type="text" class="dial" value="'+Math.round(i.AverageCompression)+'"/>');ShortPixel.percentDial("#sp-avg-optimization .dial",60)}}}console.log("Server response: "+g);if(j&&typeof i.BulkPercent!=="undefined"){progressUpdate(i.BulkPercent,i.BulkMsg)}setTimeout(checkBulkProgress,5000);break;case ShortPixel.STATUS_SKIP:if(i.Silent!==1){ShortPixel.bulkShowError(d,i.Message,i.Filename,i.CustomImageLink)}case ShortPixel.STATUS_ERROR:if(typeof i.Message!=="undefined"){showToolBarAlert(ShortPixel.STATUS_SKIP,i.Message+" Image ID: "+d);setCellMessage(d,i.Message,"")}ShortPixel.otherMediaUpdateActions(d,["retry","view"]);case ShortPixel.STATUS_RETRY:console.log("Server response: "+g);showToolBarAlert(ShortPixel.STATUS_RETRY,"");if(j&&typeof i.BulkPercent!=="undefined"){progressUpdate(i.BulkPercent,i.BulkMsg)}if(j&&i.Count>3){ShortPixel.bulkShowLengthyMsg(d,i.Filename,i.CustomImageLink)}setTimeout(checkBulkProgress,5000);break;case ShortPixel.STATUS_MAINTENANCE:ShortPixel.bulkShowMaintenanceMsg("maintenance");setTimeout(checkBulkProgress,60000);break;case ShortPixel.STATUS_QUEUE_FULL:ShortPixel.bulkShowMaintenanceMsg("queue-full");setTimeout(checkBulkProgress,60000);break;default:ShortPixel.retry("Unknown status "+i.Status+". Retrying...");break}}},error:function(b){ShortPixel.retry(b.statusText)}})}function clearBulkProcessor(){ShortPixel.bulkProcessor=false;localStorage.bulkTime=0;if(window.location.href.search("wp-short-pixel-bulk")>=0){localStorage.bulkPage=0}}function setCellMessage(d,a,c){var b=jQuery("#sp-msg-"+d);if(b.length>0){b.html("<div class='sp-column-actions'>"+c+"</div><div class='sp-column-info'>"+a+"</div>");b.css("color","")}b=jQuery("#sp-cust-msg-"+d);if(b.length>0){b.html("<div class='sp-column-info'>"+a+"</div>")}}function manualOptimization(c,a){setCellMessage(c,"<img src='"+ShortPixel.WP_PLUGIN_URL+"/res/img/loading.gif' class='sp-loading-small'>Image waiting to be processed","");jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-alert");jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");var b={action:"shortpixel_manual_optimization",image_id:c,cleanup:a};jQuery.ajax({type:"GET",url:ShortPixel.AJAX_URL,data:b,success:function(d){var e=JSON.parse(d);if(e.Status==ShortPixel.STATUS_SUCCESS){setTimeout(checkBulkProgress,2000)}else{setCellMessage(c,typeof e.Message!=="undefined"?e.Message:_spTr.thisContentNotProcessable,"")}},error:function(d){b.action="shortpixel_check_status";jQuery.ajax({type:"GET",url:ShortPixel.AJAX_URL,data:b,success:function(e){var f=JSON.parse(e);if(f.Status!==ShortPixel.STATUS_SUCCESS){setCellMessage(c,typeof f.Message!=="undefined"?f.Message:_spTr.thisContentNotProcessable,"")}}})}})}function reoptimize(c,a){setCellMessage(c,"<img src='"+ShortPixel.WP_PLUGIN_URL+"/res/img/loading.gif' class='sp-loading-small'>Image waiting to be reprocessed","");jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");var b={action:"shortpixel_redo",attachment_ID:c,type:a};jQuery.get(ShortPixel.AJAX_URL,b,function(d){b=JSON.parse(d);if(b.Status==ShortPixel.STATUS_SUCCESS){setTimeout(checkBulkProgress,2000)}else{$msg=typeof b.Message!=="undefined"?b.Message:_spTr.thisContentNotProcessable;setCellMessage(c,$msg,"");showToolBarAlert(ShortPixel.STATUS_FAIL,$msg)}})}function optimizeThumbs(b){setCellMessage(b,"<img src='"+ShortPixel.WP_PLUGIN_URL+"/res/img/loading.gif' class='sp-loading-small'>"+_spTr.imageWaitOptThumbs,"");jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");var a={action:"shortpixel_optimize_thumbs",attachment_ID:b};jQuery.get(ShortPixel.AJAX_URL,a,function(c){a=JSON.parse(c);if(a.Status==ShortPixel.STATUS_SUCCESS){setTimeout(checkBulkProgress,2000)}else{setCellMessage(b,typeof a.Message!=="undefined"?a.Message:_spTr.thisContentNotProcessable,"")}})}function dismissShortPixelNoticeExceed(b){jQuery("#wp-admin-bar-shortpixel_processing").hide();var a={action:"shortpixel_dismiss_notice",notice_id:"exceed"};jQuery.get(ShortPixel.AJAX_URL,a,function(c){a=JSON.parse(c);if(a.Status==ShortPixel.STATUS_SUCCESS){console.log("dismissed")}});b.preventDefault()}function dismissShortPixelNotice(b){jQuery("#short-pixel-notice-"+b).hide();var a={action:"shortpixel_dismiss_notice",notice_id:b};jQuery.get(ShortPixel.AJAX_URL,a,function(c){a=JSON.parse(c);if(a.Status==ShortPixel.STATUS_SUCCESS){console.log("dismissed")}})}function PercentageAnimator(b,a){this.animationSpeed=10;this.increment=2;this.curPercentage=0;this.targetPercentage=a;this.outputSelector=b;this.animate=function(c){this.targetPercentage=c;setTimeout(PercentageTimer.bind(null,this),this.animationSpeed)}}function PercentageTimer(a){if(a.curPercentage-a.targetPercentage<-a.increment){a.curPercentage+=a.increment}else{if(a.curPercentage-a.targetPercentage>a.increment){a.curPercentage-=a.increment}else{a.curPercentage=a.targetPercentage}}jQuery(a.outputSelector).text(a.curPercentage+"%");if(a.curPercentage!=a.targetPercentage){setTimeout(PercentageTimer.bind(null,a),a.animationSpeed)}}function progressUpdate(c,b){var a=jQuery("#bulk-progress");if(a.length){jQuery(".progress-left",a).css("width",c+"%");jQuery(".progress-img",a).css("left",c+"%");if(c>24){jQuery(".progress-img span",a).html("");jQuery(".progress-left",a).html(c+"%")}else{jQuery(".progress-img span",a).html(c+"%");jQuery(".progress-left",a).html("")}jQuery(".bulk-estimate").html(b)}}function sliderUpdate(g,c,d,e,b){var f=jQuery(".bulk-slider div.bulk-slide:first-child");if(f.length===0){return}if(f.attr("id")!="empty-slide"){f.hide()}f.css("z-index",1000);jQuery(".bulk-img-opt",f).attr("src","");if(typeof d==="undefined"){d=""}if(d.length>0){jQuery(".bulk-img-orig",f).attr("src","")}var a=f.clone();a.attr("id","slide-"+g);jQuery(".bulk-img-opt",a).attr("src",c);if(d.length>0){jQuery(".img-original",a).css("display","inline-block");jQuery(".bulk-img-orig",a).attr("src",d)}else{jQuery(".img-original",a).css("display","none")}jQuery(".bulk-opt-percent",a).html('<input type="text" class="dial" value="'+e+'"/>');jQuery(".bulk-slider").append(a);ShortPixel.percentDial("#"+a.attr("id")+" .dial",100);jQuery(".bulk-slider-container span.filename").html("&nbsp;&nbsp;"+b);if(f.attr("id")=="empty-slide"){f.remove();jQuery(".bulk-slider-container").css("display","block")}else{f.animate({left:f.width()+f.position().left},"slow","swing",function(){f.remove();a.fadeIn("slow")})}}function hideSlider(){jQuery(".bulk-slider-container").css("display","none")}function showStats(){var a=jQuery(".bulk-stats");if(a.length>0){}}if(!(typeof String.prototype.format=="function")){String.prototype.format=function(){var b=this,a=arguments.length;while(a--){b=b.replace(new RegExp("\\{"+a+"\\}","gm"),arguments[a])}return b}};
1
+ jQuery(document).ready(function(){ShortPixel.init()});var ShortPixel=function(){function I(){if(typeof ShortPixel.API_KEY!=="undefined"){return}if(jQuery("table.wp-list-table.media").length>0){jQuery('select[name^="action"] option:last-child').before('<option value="short-pixel-bulk">'+_spTr.optimizeWithSP+'</option><option value="short-pixel-bulk-lossy"> → '+_spTr.redoLossy+'</option><option value="short-pixel-bulk-glossy"> → '+_spTr.redoGlossy+'</option><option value="short-pixel-bulk-lossless"> → '+_spTr.redoLossless+'</option><option value="short-pixel-bulk-restore"> → '+_spTr.restoreOriginal+"</option>")}ShortPixel.setOptions(ShortPixelConstants[0]);if(jQuery("#backup-folder-size").length){jQuery("#backup-folder-size").html(ShortPixel.getBackupSize())}if(ShortPixel.MEDIA_ALERT=="todo"&&jQuery("div.media-frame.mode-grid").length>0){jQuery("div.media-frame.mode-grid").before('<div id="short-pixel-media-alert" class="notice notice-warning"><p>'+_spTr.changeMLToListMode.format('<a href="upload.php?mode=list" class="view-list"><span class="screen-reader-text">'," </span>",'</a><a class="alignright" href="javascript:ShortPixel.dismissMediaAlert();">',"</a>")+"</p></div>")}jQuery(window).on("beforeunload",function(){if(ShortPixel.bulkProcessor==true){clearBulkProcessor()}});checkQuotaExceededAlert();checkBulkProgress()}function m(Q){for(var R in Q){ShortPixel[R]=Q[R]}}function t(Q){return/^\w+([\.+-]?\w+)*@\w+([\.-]?\w+)*(\.\w{1,63})+$/.test(Q)}function n(){var Q=jQuery("#pluginemail").val();if(ShortPixel.isEmailValid(Q)){jQuery("#request_key").removeClass("disabled")}jQuery("#request_key").attr("href",jQuery("#request_key").attr("href").split("?")[0]+"?pluginemail="+Q)}function a(){jQuery("#valid").val("validate");jQuery("#wp_shortpixel_options").submit()}jQuery("#key").keypress(function(Q){if(Q.which==13){jQuery("#valid").val("validate")}});function L(Q){if(jQuery(Q).is(":checked")){jQuery("#width,#height").removeAttr("disabled")}else{jQuery("#width,#height").attr("disabled","disabled")}}function e(Q,S,U){for(var R=0,T=null;R<Q.length;R++){Q[R].onclick=function(){if(this!==T){T=this}if(typeof ShortPixel.setupGeneralTabAlert!=="undefined"){return}alert(_spTr.alertOnlyAppliesToNewImages);ShortPixel.setupGeneralTabAlert=1}}ShortPixel.enableResize("#resize");jQuery("#resize").change(function(){L(this)});jQuery(".resize-sizes").blur(function(W){var X=jQuery(this);if(ShortPixel.resizeSizesAlert==X.val()){return}ShortPixel.resizeSizesAlert=X.val();var V=jQuery("#min-"+X.attr("name")).val();if(X.val()<Math.min(V,1024)){if(V>1024){alert(_spTr.pleaseDoNotSetLesser1024.format(X.attr("name")))}else{alert(_spTr.pleaseDoNotSetLesserSize.format(X.attr("name"),X.attr("name"),V))}W.preventDefault();X.focus()}else{this.defaultValue=X.val()}});jQuery(".shortpixel-confirm").click(function(W){var V=confirm(W.target.getAttribute("data-confirm"));if(!V){W.preventDefault();return false}return true})}function C(){jQuery(".wp-shortpixel-options .shortpixel-key-valid").css("display","none");jQuery(".wp-shortpixel-options button#validate").css("display","inline-block")}function u(){jQuery("input.remove-folder-button").click(function(){var R=jQuery(this).data("value");var Q=confirm(_spTr.areYouSureStopOptimizing.format(R));if(Q==true){jQuery("#removeFolder").val(R);jQuery("#wp_shortpixel_options").submit()}});jQuery("input.recheck-folder-button").click(function(){var R=jQuery(this).data("value");var Q=confirm(_spTr.areYouSureStopOptimizing.format(R));if(Q==true){jQuery("#recheckFolder").val(R);jQuery("#wp_shortpixel_options").submit()}})}function K(Q){var R=jQuery("#"+(Q.checked?"total":"main")+"ToProcess").val();jQuery("div.bulk-play span.total").text(R);jQuery("#displayTotal").text(R)}function g(){ShortPixel.adjustSettingsTabs();jQuery(window).resize(function(){ShortPixel.adjustSettingsTabs()});if(window.location.hash){var Q=("tab-"+window.location.hash.substring(window.location.hash.indexOf("#")+1)).replace(/\//,"");if(jQuery("section#"+Q).length){ShortPixel.switchSettingsTab(Q)}}jQuery("article.sp-tabs a.tab-link").click(function(){var R=jQuery(this).data("id");ShortPixel.switchSettingsTab(R)});jQuery("input[type=radio][name=deliverWebpType]").change(function(){if(this.value=="deliverWebpAltered"){if(window.confirm("Warning: Using this method alters the structure of the HTML code (IMG tags get included in PICTURE tags),\nwhich can lead to CSS/JS inconsistencies with the existing code.\n\nPlease test this functionality thoroughly before using it!")){var R=jQuery("input[type=radio][name=deliverWebpAlteringType]:checked").length;if(R==0){jQuery("#deliverWebpAlteredWP").prop("checked",true)}}else{jQuery(this).prop("checked",false)}}})}function x(U){var S=U.replace("tab-",""),Q="",T=jQuery("section#"+U),R=location.href.replace(location.hash,"")+"#"+S;if(history.pushState){history.pushState(null,null,R)}else{location.hash=R}if(T.length>0){jQuery("section").removeClass("sel-tab");jQuery("section#"+U).addClass("sel-tab")}if(typeof HS.beacon.suggest!=="undefined"){switch(S){case"settings":Q=shortpixel_suggestions_settings;break;case"adv-settings":Q=shortpixel_suggestions_adv_settings;break;case"cloudflare":case"stats":Q=shortpixel_suggestions_cloudflare;break;default:break}HS.beacon.suggest(Q)}}function y(){var Q=jQuery("section#tab-settings .wp-shortpixel-options").height()+90;Q=Math.max(Q,jQuery("section#tab-adv-settings .wp-shortpixel-options").height()+20);Q=Math.max(Q,jQuery("section#tab-resources .area1").height()+60);jQuery("#shortpixel-settings-tabs").css("height",Q)}function M(){var Q={action:"shortpixel_dismiss_media_alert"};jQuery.get(ShortPixel.AJAX_URL,Q,function(R){Q=JSON.parse(R);if(Q.Status=="success"){jQuery("#short-pixel-media-alert").hide();console.log("dismissed")}})}function k(){var Q={action:"shortpixel_check_quota"};jQuery.get(ShortPixel.AJAX_URL,Q,function(){console.log("quota refreshed")})}function B(Q){if(Q.checked){jQuery("#with-thumbs").css("display","inherit");jQuery("#without-thumbs").css("display","none")}else{jQuery("#without-thumbs").css("display","inherit");jQuery("#with-thumbs").css("display","none")}}function b(U,S,R,T,Q){return(S>0?"<div class='sp-column-info'>"+_spTr.reducedBy+" <strong><span class='percent'>"+S+"%</span></strong> ":"")+(S>0&&S<5?"<br>":"")+(S<5?_spTr.bonusProcessing:"")+(R.length>0?" ("+R+")":"")+(0+T>0?"<br>"+_spTr.plusXthumbsOpt.format(T):"")+(0+Q>0?"<br>"+_spTr.plusXretinasOpt.format(Q):"")+"</div>"}function p(R,Q){jQuery(R).knob({readOnly:true,width:Q,height:Q,fgColor:"#1CAECB",format:function(S){return S+"%"}})}function c(X,S,V,U,R,W){if(R==1){var T=jQuery(".sp-column-actions-template").clone();if(!T.length){return false}var Q;if(S.length==0){Q=["lossy","lossless"]}else{Q=["lossy","glossy","lossless"].filter(function(Y){return !(Y==S)})}T.html(T.html().replace(/__SP_ID__/g,X));if(W.substr(W.lastIndexOf(".")+1).toLowerCase()=="pdf"){jQuery(".sp-action-compare",T).remove()}if(V==0&&U>0){T.html(T.html().replace("__SP_THUMBS_TOTAL__",U))}else{jQuery(".sp-action-optimize-thumbs",T).remove();jQuery(".sp-dropbtn",T).removeClass("button-primary")}T.html(T.html().replace(/__SP_FIRST_TYPE__/g,Q[0]));T.html(T.html().replace(/__SP_SECOND_TYPE__/g,Q[1]));return T.html()}return""}function i(U,T){U=U.substring(2);if(jQuery(".shortpixel-other-media").length){var S=["optimize","retry","restore","redo","quota","view"];for(var R=0,Q=S.length;R<Q;R++){jQuery("#"+S[R]+"_"+U).css("display","none")}for(var R=0,Q=T.length;R<Q;R++){jQuery("#"+T[R]+"_"+U).css("display","")}}}function j(Q){ShortPixel.retries++;if(isNaN(ShortPixel.retries)){ShortPixel.retries=1}if(ShortPixel.retries<6){console.log("Invalid response from server (Error: "+Q+"). Retrying pass "+(ShortPixel.retries+1)+"...");setTimeout(checkBulkProgress,5000)}else{ShortPixel.bulkShowError(-1,"Invalid response from server received 6 times. Please retry later by reloading this page, or <a href='https://shortpixel.com/contact' target='_blank'>contact support</a>. (Error: "+Q+")","");console.log("Invalid response from server 6 times. Giving up.")}}function l(Q){Q.action="shortpixel_browse_content";var R="";jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:Q,success:function(S){R=S},async:false});return R}function d(){var Q={action:"shortpixel_get_backup_size"};var R="";jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:Q,success:function(S){R=S},async:false});return R}function f(R){if(!jQuery("#tos").is(":checked")){R.preventDefault();jQuery("#tos-robo").fadeIn(400,function(){jQuery("#tos-hand").fadeIn()});jQuery("#tos").click(function(){jQuery("#tos-robo").css("display","none");jQuery("#tos-hand").css("display","none")});return}jQuery("#request_key").addClass("disabled");jQuery("#pluginemail_spinner").addClass("is-active");ShortPixel.updateSignupEmail();if(ShortPixel.isEmailValid(jQuery("#pluginemail").val())){jQuery("#pluginemail-error").css("display","none");var Q={action:"shortpixel_new_api_key",email:jQuery("#pluginemail").val()};jQuery.ajax({type:"POST",async:false,url:ShortPixel.AJAX_URL,data:Q,success:function(S){data=JSON.parse(S);if(data.Status=="success"){R.preventDefault();window.location.reload()}else{if(data.Status=="invalid"){jQuery("#pluginemail-error").html("<b>"+data.Details+"</b>");jQuery("#pluginemail-error").css("display","");jQuery("#pluginemail-info").css("display","none");R.preventDefault()}else{}}}});jQuery("#request_key").removeAttr("onclick")}else{jQuery("#pluginemail-error").css("display","");jQuery("#pluginemail-info").css("display","none");R.preventDefault()}jQuery("#request_key").removeClass("disabled");jQuery("#pluginemail_spinner").removeClass("is-active")}function N(){jQuery("#shortPixelProposeUpgrade .sp-modal-body").addClass("sptw-modal-spinner");jQuery("#shortPixelProposeUpgrade .sp-modal-body").html("");jQuery("#shortPixelProposeUpgradeShade").css("display","block");jQuery("#shortPixelProposeUpgrade").removeClass("shortpixel-hide");var Q={action:"shortpixel_propose_upgrade"};jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:Q,success:function(R){jQuery("#shortPixelProposeUpgrade .sp-modal-body").removeClass("sptw-modal-spinner");jQuery("#shortPixelProposeUpgrade .sp-modal-body").html(R)}})}function G(){jQuery("#shortPixelProposeUpgradeShade").css("display","none");jQuery("#shortPixelProposeUpgrade").addClass("shortpixel-hide");if(ShortPixel.toRefresh){ShortPixel.recheckQuota()}}function v(){jQuery("#short-pixel-notice-unlisted").hide();jQuery("#optimizeUnlisted").prop("checked",true);var Q={action:"shortpixel_dismiss_notice",notice_id:"unlisted",notice_data:"true"};jQuery.get(ShortPixel.AJAX_URL,Q,function(R){Q=JSON.parse(R);if(Q.Status==ShortPixel.STATUS_SUCCESS){console.log("dismissed")}})}function o(){jQuery(".select-folder-button").click(function(){jQuery(".sp-folder-picker-shade").css("display","block");jQuery(".sp-folder-picker").fileTree({script:ShortPixel.browseContent,multiFolder:false})});jQuery(".shortpixel-modal input.select-folder-cancel").click(function(){jQuery(".sp-folder-picker-shade").css("display","none")});jQuery(".shortpixel-modal input.select-folder").click(function(){var Q=jQuery("UL.jqueryFileTree LI.directory.selected A").attr("rel").trim();if(Q){var R=jQuery("#customFolderBase").val()+Q;if(R.slice(-1)=="/"){R=R.slice(0,-1)}jQuery("#addCustomFolder").val(R);jQuery("#addCustomFolderView").val(R);jQuery(".sp-folder-picker-shade").css("display","none")}else{alert("Please select a folder from the list.")}})}function F(U,T,S){var R=jQuery(".bulk-notice-msg.bulk-lengthy");if(R.length==0){return}var Q=jQuery("a",R);Q.text(T);if(S){Q.attr("href",S)}else{Q.attr("href",Q.data("href").replace("__ID__",U))}R.css("display","block")}function A(){jQuery(".bulk-notice-msg.bulk-lengthy").css("display","none")}function w(Q){var R=jQuery(".bulk-notice-msg.bulk-"+Q);if(R.length==0){return}R.css("display","block")}function O(Q){jQuery(".bulk-notice-msg.bulk-"+Q).css("display","none")}function s(W,U,V,T){var Q=jQuery("#bulk-error-template");if(Q.length==0){return}var S=Q.clone();S.attr("id","bulk-error-"+W);if(W==-1){jQuery("span.sp-err-title",S).remove();S.addClass("bulk-error-fatal")}else{jQuery("img",S).remove();jQuery("#bulk-error-".id).remove()}jQuery("span.sp-err-content",S).html(U);var R=jQuery("a.sp-post-link",S);if(T){R.attr("href",T)}else{R.attr("href",R.attr("href").replace("__ID__",W))}R.text(V);Q.after(S);S.css("display","block")}function D(Q,R){if(!confirm(_spTr["confirmBulk"+Q])){R.stopPropagation();R.preventDefault();return false}return true}function r(Q){jQuery(Q).parent().parent().remove()}function H(Q){return Q.substring(0,2)=="C-"}function J(){window.location.href=window.location.href+(window.location.href.indexOf("?")>0?"&":"?")+"checkquota=1"}function h(R){R.preventDefault();if(!this.menuCloseEvent){jQuery(window).click(function(S){if(!S.target.matches(".sp-dropbtn")){jQuery(".sp-dropdown.sp-show").removeClass("sp-show")}});this.menuCloseEvent=true}var Q=R.target.parentElement.classList.contains("sp-show");jQuery(".sp-dropdown.sp-show").removeClass("sp-show");if(!Q){R.target.parentElement.classList.add("sp-show")}}function P(Q){this.comparerData.origUrl=false;if(this.comparerData.cssLoaded===false){jQuery("<link>").appendTo("head").attr({type:"text/css",rel:"stylesheet",href:this.WP_PLUGIN_URL+"/res/css/twentytwenty.min.css"});this.comparerData.cssLoaded=2}if(this.comparerData.jsLoaded===false){jQuery.getScript(this.WP_PLUGIN_URL+"/res/js/jquery.twentytwenty.min.js",function(){ShortPixel.comparerData.jsLoaded=2;if(ShortPixel.comparerData.origUrl.length>0){ShortPixel.displayComparerPopup(ShortPixel.comparerData.width,ShortPixel.comparerData.height,ShortPixel.comparerData.origUrl,ShortPixel.comparerData.optUrl)}});this.comparerData.jsLoaded=1;jQuery(".sp-close-button").click(ShortPixel.closeComparerPopup)}if(this.comparerData.origUrl===false){jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:{action:"shortpixel_get_comparer_data",id:Q},success:function(R){data=JSON.parse(R);jQuery.extend(ShortPixel.comparerData,data);if(ShortPixel.comparerData.jsLoaded==2){ShortPixel.displayComparerPopup(ShortPixel.comparerData.width,ShortPixel.comparerData.height,ShortPixel.comparerData.origUrl,ShortPixel.comparerData.optUrl)}}});this.comparerData.origUrl=""}}function E(U,S,R,T){var X=U;var W=(S<150||U<350);var V=jQuery(W?"#spUploadCompareSideBySide":"#spUploadCompare");if(!W){jQuery("#spCompareSlider").html('<img class="spUploadCompareOriginal"/><img class="spUploadCompareOptimized"/>')}U=Math.max(350,Math.min(800,(U<350?(U+25)*2:(S<150?U+25:U))));S=Math.max(150,(W?(X>350?2*(S+45):S+45):S*U/X));jQuery(".sp-modal-body",V).css("width",U);jQuery(".shortpixel-slider",V).css("width",U);V.css("width",U);jQuery(".sp-modal-body",V).css("height",S);V.css("display","block");V.parent().css("display","block");if(!W){jQuery("#spCompareSlider").twentytwenty({slider_move:"mousemove"})}jQuery(document).on("keyup.sp_modal_active",ShortPixel.closeComparerPopup);var Q=jQuery(".spUploadCompareOptimized",V);jQuery(".spUploadCompareOriginal",V).attr("src",R);setTimeout(function(){jQuery(window).trigger("resize")},1000);Q.load(function(){jQuery(window).trigger("resize")});Q.attr("src",T)}function q(Q){jQuery("#spUploadCompareSideBySide").parent().css("display","none");jQuery("#spUploadCompareSideBySide").css("display","none");jQuery("#spUploadCompare").css("display","none");jQuery(document).unbind("keyup.sp_modal_active")}function z(Q){var R=document.createElement("a");R.href=Q;if(Q.indexOf(R.protocol+"//"+R.hostname)<0){return R.href}return Q.replace(R.protocol+"//"+R.hostname,R.protocol+"//"+R.hostname.split(".").map(function(S){return sp_punycode.toASCII(S)}).join("."))}return{init:I,setOptions:m,isEmailValid:t,updateSignupEmail:n,validateKey:a,enableResize:L,setupGeneralTab:e,apiKeyChanged:C,setupAdvancedTab:u,checkThumbsUpdTotal:K,initSettings:g,switchSettingsTab:x,adjustSettingsTabs:y,onBulkThumbsCheck:B,dismissMediaAlert:M,checkQuota:k,percentDial:p,successMsg:b,successActions:c,otherMediaUpdateActions:i,retry:j,initFolderSelector:o,browseContent:l,getBackupSize:d,newApiKey:f,proposeUpgrade:N,closeProposeUpgrade:G,includeUnlisted:v,bulkShowLengthyMsg:F,bulkHideLengthyMsg:A,bulkShowMaintenanceMsg:w,bulkHideMaintenanceMsg:O,bulkShowError:s,confirmBulkAction:D,removeBulkMsg:r,isCustomImageId:H,recheckQuota:J,openImageMenu:h,menuCloseEvent:false,loadComparer:P,displayComparerPopup:E,closeComparerPopup:q,convertPunycode:z,comparerData:{cssLoaded:false,jsLoaded:false,origUrl:false,optUrl:false,width:0,height:0},toRefresh:false,resizeSizesAlert:false}}();function showToolBarAlert(c,b,d){var a=jQuery("li.shortpixel-toolbar-processing");switch(c){case ShortPixel.STATUS_QUOTA_EXCEEDED:if(window.location.href.search("wp-short-pixel-bulk")>0&&jQuery(".sp-quota-exceeded-alert").length==0){location.reload();return}a.addClass("shortpixel-alert");a.addClass("shortpixel-quota-exceeded");jQuery("a",a).attr("href","options-general.php?page=wp-shortpixel");jQuery("a div",a).attr("title","ShortPixel quota exceeded. Click for details.");break;case ShortPixel.STATUS_SKIP:case ShortPixel.STATUS_FAIL:a.addClass("shortpixel-alert shortpixel-processing");jQuery("a div",a).attr("title",b);if(typeof d!=="undefined"){jQuery("a",a).attr("href","post.php?post="+d+"&action=edit")}break;case ShortPixel.STATUS_NO_KEY:a.addClass("shortpixel-alert");a.addClass("shortpixel-quota-exceeded");jQuery("a",a).attr("href","options-general.php?page=wp-shortpixel");jQuery("a div",a).attr("title","Get API Key");break;case ShortPixel.STATUS_SUCCESS:case ShortPixel.STATUS_RETRY:a.addClass("shortpixel-processing");a.removeClass("shortpixel-alert");jQuery("a",a).removeAttr("target");jQuery("a",a).attr("href",jQuery("a img",a).attr("success-url"))}a.removeClass("shortpixel-hide")}function hideToolBarAlert(){jQuery("li.shortpixel-toolbar-processing.shortpixel-processing").addClass("shortpixel-hide")}function hideQuotaExceededToolBarAlert(){jQuery("li.shortpixel-toolbar-processing.shortpixel-quota-exceeded").addClass("shortpixel-hide")}function checkQuotaExceededAlert(){if(typeof shortPixelQuotaExceeded!="undefined"){if(shortPixelQuotaExceeded==1){showToolBarAlert(ShortPixel.STATUS_QUOTA_EXCEEDED)}else{hideQuotaExceededToolBarAlert()}}}function checkBulkProgress(){var b=function(e){if(!d){d=true;return e}return"/"};var d=false;var a=window.location.href.toLowerCase().replace(/\/\//g,b);d=false;var c=ShortPixel.WP_ADMIN_URL.toLowerCase().replace(/\/\//g,b);if(a.search(c)<0){a=ShortPixel.convertPunycode(a);c=ShortPixel.convertPunycode(c)}if(a.search(c+"upload.php")<0&&a.search(c+"edit.php")<0&&a.search(c+"edit-tags.php")<0&&a.search(c+"post-new.php")<0&&a.search(c+"post.php")<0&&a.search("page=nggallery-manage-gallery")<0&&(ShortPixel.FRONT_BOOTSTRAP==0||a.search(c)==0)){hideToolBarAlert();return}if(ShortPixel.bulkProcessor==true&&window.location.href.search("wp-short-pixel-bulk")<0&&typeof localStorage.bulkPage!=="undefined"&&localStorage.bulkPage>0){ShortPixel.bulkProcessor=false}if(window.location.href.search("wp-short-pixel-bulk")>=0){ShortPixel.bulkProcessor=true;localStorage.bulkTime=Math.floor(Date.now()/1000);localStorage.bulkPage=1}if(ShortPixel.bulkProcessor==true||typeof localStorage.bulkTime=="undefined"||Math.floor(Date.now()/1000)-localStorage.bulkTime>90){ShortPixel.bulkProcessor=true;localStorage.bulkPage=(window.location.href.search("wp-short-pixel-bulk")>=0?1:0);localStorage.bulkTime=Math.floor(Date.now()/1000);console.log(localStorage.bulkTime);checkBulkProcessingCallApi()}else{setTimeout(checkBulkProgress,5000)}}function checkBulkProcessingCallApi(){var a={action:"shortpixel_image_processing"};jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:a,success:function(g){if(g.length>0){var i=null;try{var i=JSON.parse(g)}catch(k){ShortPixel.retry(k.message);return}ShortPixel.retries=0;var d=i.ImageID;var j=(jQuery("div.short-pixel-bulk-page").length>0);switch(i.Status){case ShortPixel.STATUS_NO_KEY:setCellMessage(d,i.Message,"<a class='button button-smaller button-primary' href=\"https://shortpixel.com/wp-apikey"+ShortPixel.AFFILIATE+'" target="_blank">'+_spTr.getApiKey+"</a>");showToolBarAlert(ShortPixel.STATUS_NO_KEY);break;case ShortPixel.STATUS_QUOTA_EXCEEDED:setCellMessage(d,i.Message,"<a class='button button-smaller button-primary' href=\"https://shortpixel.com/login/"+ShortPixel.API_KEY+'" target="_blank">'+_spTr.extendQuota+"</a><a class='button button-smaller' href='admin.php?action=shortpixel_check_quota'>"+_spTr.check__Quota+"</a>");showToolBarAlert(ShortPixel.STATUS_QUOTA_EXCEEDED);if(i.Stop==false){setTimeout(checkBulkProgress,5000)}ShortPixel.otherMediaUpdateActions(d,["quota","view"]);break;case ShortPixel.STATUS_FAIL:setCellMessage(d,i.Message,"<a class='button button-smaller button-primary' href=\"javascript:manualOptimization('"+d+"', false)\">"+_spTr.retry+"</a>");showToolBarAlert(ShortPixel.STATUS_FAIL,i.Message,d);if(j){ShortPixel.bulkShowError(d,i.Message,i.Filename,i.CustomImageLink);if(i.BulkPercent){progressUpdate(i.BulkPercent,i.BulkMsg)}ShortPixel.otherMediaUpdateActions(d,["retry","view"])}console.log(i.Message);setTimeout(checkBulkProgress,5000);break;case ShortPixel.STATUS_EMPTY_QUEUE:console.log(i.Message);clearBulkProcessor();hideToolBarAlert();var c=jQuery("#bulk-progress");if(j&&c.length&&i.BulkStatus!="2"){progressUpdate(100,"Bulk finished!");jQuery("a.bulk-cancel").attr("disabled","disabled");hideSlider();setTimeout(function(){window.location.reload()},3000)}break;case ShortPixel.STATUS_SUCCESS:if(j){ShortPixel.bulkHideLengthyMsg();ShortPixel.bulkHideMaintenanceMsg()}var l=i.PercentImprovement;showToolBarAlert(ShortPixel.STATUS_SUCCESS,"");var b=ShortPixel.isCustomImageId(d)?"":ShortPixel.successActions(d,i.Type,i.ThumbsCount,i.ThumbsTotal,i.BackupEnabled,i.Filename);setCellMessage(d,ShortPixel.successMsg(d,l,i.Type,i.ThumbsCount,i.RetinasCount),b);var h=jQuery(["restore","view","redolossy","redoglossy","redolossless"]).not(["redo"+i.Type]).get();ShortPixel.otherMediaUpdateActions(d,h);var f=new PercentageAnimator("#sp-msg-"+d+" span.percent",l);f.animate(l);if(j&&typeof i.Thumb!=="undefined"){if(i.BulkPercent){progressUpdate(i.BulkPercent,i.BulkMsg)}if(i.Thumb.length>0){sliderUpdate(d,i.Thumb,i.BkThumb,i.PercentImprovement,i.Filename);if(typeof i.AverageCompression!=="undefined"&&0+i.AverageCompression>0){jQuery("#sp-avg-optimization").html('<input type="text" class="dial" value="'+Math.round(i.AverageCompression)+'"/>');ShortPixel.percentDial("#sp-avg-optimization .dial",60)}}}console.log("Server response: "+g);if(j&&typeof i.BulkPercent!=="undefined"){progressUpdate(i.BulkPercent,i.BulkMsg)}setTimeout(checkBulkProgress,5000);break;case ShortPixel.STATUS_SKIP:if(i.Silent!==1){ShortPixel.bulkShowError(d,i.Message,i.Filename,i.CustomImageLink)}case ShortPixel.STATUS_ERROR:if(typeof i.Message!=="undefined"){showToolBarAlert(ShortPixel.STATUS_SKIP,i.Message+" Image ID: "+d);setCellMessage(d,i.Message,"")}ShortPixel.otherMediaUpdateActions(d,["retry","view"]);case ShortPixel.STATUS_RETRY:console.log("Server response: "+g);showToolBarAlert(ShortPixel.STATUS_RETRY,"");if(j&&typeof i.BulkPercent!=="undefined"){progressUpdate(i.BulkPercent,i.BulkMsg)}if(j&&i.Count>3){ShortPixel.bulkShowLengthyMsg(d,i.Filename,i.CustomImageLink)}setTimeout(checkBulkProgress,5000);break;case ShortPixel.STATUS_MAINTENANCE:ShortPixel.bulkShowMaintenanceMsg("maintenance");setTimeout(checkBulkProgress,60000);break;case ShortPixel.STATUS_QUEUE_FULL:ShortPixel.bulkShowMaintenanceMsg("queue-full");setTimeout(checkBulkProgress,60000);break;default:ShortPixel.retry("Unknown status "+i.Status+". Retrying...");break}}},error:function(b){ShortPixel.retry(b.statusText)}})}function clearBulkProcessor(){ShortPixel.bulkProcessor=false;localStorage.bulkTime=0;if(window.location.href.search("wp-short-pixel-bulk")>=0){localStorage.bulkPage=0}}function setCellMessage(d,a,c){var b=jQuery("#sp-msg-"+d);if(b.length>0){b.html("<div class='sp-column-actions'>"+c+"</div><div class='sp-column-info'>"+a+"</div>");b.css("color","")}b=jQuery("#sp-cust-msg-"+d);if(b.length>0){b.html("<div class='sp-column-info'>"+a+"</div>")}}function manualOptimization(c,a){setCellMessage(c,"<img src='"+ShortPixel.WP_PLUGIN_URL+"/res/img/loading.gif' class='sp-loading-small'>Image waiting to be processed","");jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-alert");jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");var b={action:"shortpixel_manual_optimization",image_id:c,cleanup:a};jQuery.ajax({type:"GET",url:ShortPixel.AJAX_URL,data:b,success:function(d){var e=JSON.parse(d);if(e.Status==ShortPixel.STATUS_SUCCESS){setTimeout(checkBulkProgress,2000)}else{setCellMessage(c,typeof e.Message!=="undefined"?e.Message:_spTr.thisContentNotProcessable,"")}},error:function(d){b.action="shortpixel_check_status";jQuery.ajax({type:"GET",url:ShortPixel.AJAX_URL,data:b,success:function(e){var f=JSON.parse(e);if(f.Status!==ShortPixel.STATUS_SUCCESS){setCellMessage(c,typeof f.Message!=="undefined"?f.Message:_spTr.thisContentNotProcessable,"")}}})}})}function reoptimize(c,a){setCellMessage(c,"<img src='"+ShortPixel.WP_PLUGIN_URL+"/res/img/loading.gif' class='sp-loading-small'>Image waiting to be reprocessed","");jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");var b={action:"shortpixel_redo",attachment_ID:c,type:a};jQuery.get(ShortPixel.AJAX_URL,b,function(d){b=JSON.parse(d);if(b.Status==ShortPixel.STATUS_SUCCESS){setTimeout(checkBulkProgress,2000)}else{$msg=typeof b.Message!=="undefined"?b.Message:_spTr.thisContentNotProcessable;setCellMessage(c,$msg,"");showToolBarAlert(ShortPixel.STATUS_FAIL,$msg)}})}function optimizeThumbs(b){setCellMessage(b,"<img src='"+ShortPixel.WP_PLUGIN_URL+"/res/img/loading.gif' class='sp-loading-small'>"+_spTr.imageWaitOptThumbs,"");jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");var a={action:"shortpixel_optimize_thumbs",attachment_ID:b};jQuery.get(ShortPixel.AJAX_URL,a,function(c){a=JSON.parse(c);if(a.Status==ShortPixel.STATUS_SUCCESS){setTimeout(checkBulkProgress,2000)}else{setCellMessage(b,typeof a.Message!=="undefined"?a.Message:_spTr.thisContentNotProcessable,"")}})}function dismissShortPixelNoticeExceed(b){jQuery("#wp-admin-bar-shortpixel_processing").hide();var a={action:"shortpixel_dismiss_notice",notice_id:"exceed"};jQuery.get(ShortPixel.AJAX_URL,a,function(c){a=JSON.parse(c);if(a.Status==ShortPixel.STATUS_SUCCESS){console.log("dismissed")}});b.preventDefault()}function dismissShortPixelNotice(b){jQuery("#short-pixel-notice-"+b).hide();var a={action:"shortpixel_dismiss_notice",notice_id:b};jQuery.get(ShortPixel.AJAX_URL,a,function(c){a=JSON.parse(c);if(a.Status==ShortPixel.STATUS_SUCCESS){console.log("dismissed")}})}function PercentageAnimator(b,a){this.animationSpeed=10;this.increment=2;this.curPercentage=0;this.targetPercentage=a;this.outputSelector=b;this.animate=function(c){this.targetPercentage=c;setTimeout(PercentageTimer.bind(null,this),this.animationSpeed)}}function PercentageTimer(a){if(a.curPercentage-a.targetPercentage<-a.increment){a.curPercentage+=a.increment}else{if(a.curPercentage-a.targetPercentage>a.increment){a.curPercentage-=a.increment}else{a.curPercentage=a.targetPercentage}}jQuery(a.outputSelector).text(a.curPercentage+"%");if(a.curPercentage!=a.targetPercentage){setTimeout(PercentageTimer.bind(null,a),a.animationSpeed)}}function progressUpdate(c,b){var a=jQuery("#bulk-progress");if(a.length){jQuery(".progress-left",a).css("width",c+"%");jQuery(".progress-img",a).css("left",c+"%");if(c>24){jQuery(".progress-img span",a).html("");jQuery(".progress-left",a).html(c+"%")}else{jQuery(".progress-img span",a).html(c+"%");jQuery(".progress-left",a).html("")}jQuery(".bulk-estimate").html(b)}}function sliderUpdate(g,c,d,e,b){var f=jQuery(".bulk-slider div.bulk-slide:first-child");if(f.length===0){return}if(f.attr("id")!="empty-slide"){f.hide()}f.css("z-index",1000);jQuery(".bulk-img-opt",f).attr("src","");if(typeof d==="undefined"){d=""}if(d.length>0){jQuery(".bulk-img-orig",f).attr("src","")}var a=f.clone();a.attr("id","slide-"+g);jQuery(".bulk-img-opt",a).attr("src",c);if(d.length>0){jQuery(".img-original",a).css("display","inline-block");jQuery(".bulk-img-orig",a).attr("src",d)}else{jQuery(".img-original",a).css("display","none")}jQuery(".bulk-opt-percent",a).html('<input type="text" class="dial" value="'+e+'"/>');jQuery(".bulk-slider").append(a);ShortPixel.percentDial("#"+a.attr("id")+" .dial",100);jQuery(".bulk-slider-container span.filename").html("&nbsp;&nbsp;"+b);if(f.attr("id")=="empty-slide"){f.remove();jQuery(".bulk-slider-container").css("display","block")}else{f.animate({left:f.width()+f.position().left},"slow","swing",function(){f.remove();a.fadeIn("slow")})}}function hideSlider(){jQuery(".bulk-slider-container").css("display","none")}function showStats(){var a=jQuery(".bulk-stats");if(a.length>0){}}if(!(typeof String.prototype.format=="function")){String.prototype.format=function(){var b=this,a=arguments.length;while(a--){b=b.replace(new RegExp("\\{"+a+"\\}","gm"),arguments[a])}return b}};
shortpixel_api.php CHANGED
@@ -85,9 +85,12 @@ class ShortPixelAPI {
85
  if(!count($URLs)) {
86
  $meta = $itemHandler->getMeta();
87
  if(count($meta->getThumbsMissing())) {
 
88
  $files = " (";
89
  foreach ($meta->getThumbsMissing() as $miss) {
 
90
  $files .= $miss . ", ";
 
91
  }
92
  if(strrpos($files, ', ')) {
93
  $files = substr_replace($files , ')', strrpos($files , ', '));
@@ -383,23 +386,25 @@ class ShortPixelAPI {
383
  * @return array status /message array
384
  */
385
  private function handleDownload($optimizedUrl, $optimizedSize, $originalSize, $webpUrl){
 
386
  $downloadTimeout = max(ini_get('max_execution_time') - 10, 15);
387
-
388
  $webpTempFile = "NA";
389
  if($webpUrl !== "NA") {
390
  $webpURL = $this->setPreferredProtocol(urldecode($webpUrl));
391
  $webpTempFile = download_url($webpURL, $downloadTimeout);
392
  $webpTempFile = is_wp_error( $webpTempFile ) ? "NA" : $webpTempFile;
393
- }
394
-
395
  //if there is no improvement in size then we do not download this file
396
  if ( $originalSize == $optimizedSize )
397
  return array("Status" => self::STATUS_UNCHANGED, "Message" => "File wasn't optimized so we do not download it.", "WebP" => $webpTempFile);
398
-
399
  $correctFileSize = $optimizedSize;
400
  $fileURL = $this->setPreferredProtocol(urldecode($optimizedUrl));
401
 
402
  $tempFile = download_url($fileURL, $downloadTimeout);
 
403
  if(is_wp_error( $tempFile ))
404
  { //try to switch the default protocol
405
  $fileURL = $this->setPreferredProtocol(urldecode($optimizedUrl), true); //force recheck of the protocol
@@ -550,6 +555,8 @@ class ShortPixelAPI {
550
  * @return array status/message
551
  */
552
  private function handleSuccess($APIresponse, $PATHs, $itemHandler, $compressionType) {
 
 
553
  $counter = $savedSpace = $originalSpace = $optimizedSpace = $averageCompression = 0;
554
  $NoBackup = true;
555
 
85
  if(!count($URLs)) {
86
  $meta = $itemHandler->getMeta();
87
  if(count($meta->getThumbsMissing())) {
88
+ $added = array();
89
  $files = " (";
90
  foreach ($meta->getThumbsMissing() as $miss) {
91
+ if(isset($added[$miss])) continue;
92
  $files .= $miss . ", ";
93
+ $added[$miss] = true;
94
  }
95
  if(strrpos($files, ', ')) {
96
  $files = substr_replace($files , ')', strrpos($files , ', '));
386
  * @return array status /message array
387
  */
388
  private function handleDownload($optimizedUrl, $optimizedSize, $originalSize, $webpUrl){
389
+
390
  $downloadTimeout = max(ini_get('max_execution_time') - 10, 15);
391
+
392
  $webpTempFile = "NA";
393
  if($webpUrl !== "NA") {
394
  $webpURL = $this->setPreferredProtocol(urldecode($webpUrl));
395
  $webpTempFile = download_url($webpURL, $downloadTimeout);
396
  $webpTempFile = is_wp_error( $webpTempFile ) ? "NA" : $webpTempFile;
397
+ }
398
+
399
  //if there is no improvement in size then we do not download this file
400
  if ( $originalSize == $optimizedSize )
401
  return array("Status" => self::STATUS_UNCHANGED, "Message" => "File wasn't optimized so we do not download it.", "WebP" => $webpTempFile);
402
+
403
  $correctFileSize = $optimizedSize;
404
  $fileURL = $this->setPreferredProtocol(urldecode($optimizedUrl));
405
 
406
  $tempFile = download_url($fileURL, $downloadTimeout);
407
+ WPShortPixel::log('Downloading file: '.json_encode($tempFile));
408
  if(is_wp_error( $tempFile ))
409
  { //try to switch the default protocol
410
  $fileURL = $this->setPreferredProtocol(urldecode($optimizedUrl), true); //force recheck of the protocol
555
  * @return array status/message
556
  */
557
  private function handleSuccess($APIresponse, $PATHs, $itemHandler, $compressionType) {
558
+ WPShortPixel::log('Handling Success!');
559
+
560
  $counter = $savedSpace = $originalSpace = $optimizedSpace = $averageCompression = 0;
561
  $NoBackup = true;
562
 
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: 4.12.1
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  * Text Domain: shortpixel-image-optimiser
@@ -18,7 +18,7 @@ define('SHORTPIXEL_PLUGIN_FILE', __FILE__);
18
 
19
  //define('SHORTPIXEL_AFFILIATE_CODE', '');
20
 
21
- define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.12.1");
22
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
23
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
24
  define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');
@@ -185,12 +185,16 @@ function shortPixelInitOB() {
185
  }
186
  }
187
 
188
- if ( get_option('wp-short-pixel-create-webp-markup')) {
189
- //add_filter( 'the_content', 'shortPixelConvertImgToPictureAddWebp', 10000 ); // priority big, so it will be executed last
190
- //add_filter( 'the_excerpt', 'shortPixelConvertImgToPictureAddWebp', 10000 );
191
- //add_filter( 'post_thumbnail_html', 'shortPixelConvertImgToPictureAddWebp');
192
- add_action( 'wp_head', 'shortPixelAddPictureJs');
193
- add_action( 'init', 'shortPixelInitOB', 1 );
 
 
 
 
194
  // add_action( 'wp_enqueue_scripts', 'spAddPicturefillJs' );
195
  }
196
 
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: 4.12.2
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  * Text Domain: shortpixel-image-optimiser
18
 
19
  //define('SHORTPIXEL_AFFILIATE_CODE', '');
20
 
21
+ define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.12.2");
22
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
23
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
24
  define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');
185
  }
186
  }
187
 
188
+ if ( get_option('wp-short-pixel-create-webp-markup') ) {
189
+ $option = get_option('wp-short-pixel-create-webp-markup');
190
+ if( $option == 1 ){
191
+ add_action( 'wp_head', 'shortPixelAddPictureJs');
192
+ add_action( 'init', 'shortPixelInitOB', 1 );
193
+ } elseif ($option == 2){
194
+ add_filter( 'the_content', 'shortPixelConvertImgToPictureAddWebp', 10000 ); // priority big, so it will be executed last
195
+ add_filter( 'the_excerpt', 'shortPixelConvertImgToPictureAddWebp', 10000 );
196
+ add_filter( 'post_thumbnail_html', 'shortPixelConvertImgToPictureAddWebp');
197
+ }
198
  // add_action( 'wp_enqueue_scripts', 'spAddPicturefillJs' );
199
  }
200