ShortPixel Image Optimizer - Version 4.15.3

Version Description

Release date: 20th December 2019 * Hide the "Process in front-end" option if "Optimize media on upload" unchecked * Add ALT text for plugin images in Admin * Moved CSS for the admin bar to the actual admin bar stylesheet, other css no longer loading on those pages * Fixes for windows specific paths * Fixed: warning flood when using old version of S3-offload * Fix for frontend and error shortpixel in top toolbar * Fixed: Pancake menu now showing proper actions ( none ) if backup is not there. * Fixed: Windows paths in wp-short-pixel getBackupFolderInternal * Language 4 new strings added, 0 updated, 0 fuzzied, and 0 obsoleted

Download this release

Release Info

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

Code changes from version 4.15.2 to 4.15.3

class/controller/edit_media_controller.php CHANGED
@@ -18,7 +18,7 @@ class editMediaController extends ShortPixelController
18
  {
19
 
20
  $this->loadModel($this->model);
21
- $this->loadModel('image');
22
  parent::__construct();
23
  }
24
 
@@ -212,11 +212,13 @@ class editMediaController extends ShortPixelController
212
 
213
  protected function getDebugInfo()
214
  {
215
- if(! Log::debugIsActive())
216
  {
217
- return null;
218
  }
219
 
 
 
220
  $imageObj = new ImageModel();
221
  $imageObj->setByPostID($this->post_id);
222
  $imageFile = $imageObj->getFile();
@@ -225,9 +227,12 @@ class editMediaController extends ShortPixelController
225
 
226
  $debugInfo = array();
227
  $debugInfo[] = array(__('URL', 'shortpixel_image_optiser'), wp_get_attachment_url($this->post_id));
 
 
 
228
  $debugInfo[] = array(__('WPML Duplicates'), json_encode(\ShortPixelMetaFacade::getWPMLDuplicates($this->post_id)) );
229
- $debugInfo[] = array(__('Data'), $this->data);
230
- $debugInfo[] = array(__('Meta'), wp_get_attachment_metadata($this->post_id) );
231
  if ($imageFile->hasBackup())
232
  {
233
  $backupFile = $imageFile->getBackupFile();
@@ -245,8 +250,22 @@ class editMediaController extends ShortPixelController
245
  $debugInfo[] = array(__('Backup'), $orbackup->getFullPath() . '(' . \ShortPixelTools::formatBytes($orbackup->getFileSize()) . ')');
246
  }
247
 
248
- $debugInfo[] = array(__('Status'), $this->imageModel->getMeta()->getStatus() );
249
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  return $debugInfo;
251
  }
252
 
18
  {
19
 
20
  $this->loadModel($this->model);
21
+ // $this->loadModel('image');
22
  parent::__construct();
23
  }
24
 
212
 
213
  protected function getDebugInfo()
214
  {
215
+ if(! \wpSPIO()->env()->is_debug )
216
  {
217
+ return array();
218
  }
219
 
220
+ $meta = \wp_get_attachment_metadata($this->post_id);
221
+
222
  $imageObj = new ImageModel();
223
  $imageObj->setByPostID($this->post_id);
224
  $imageFile = $imageObj->getFile();
227
 
228
  $debugInfo = array();
229
  $debugInfo[] = array(__('URL', 'shortpixel_image_optiser'), wp_get_attachment_url($this->post_id));
230
+ $debugInfo[] = array(__('File'), get_attached_file($this->post_id));
231
+ $debugInfo[] = array(__('Status'), $this->imageModel->getMeta()->getStatus() );
232
+
233
  $debugInfo[] = array(__('WPML Duplicates'), json_encode(\ShortPixelMetaFacade::getWPMLDuplicates($this->post_id)) );
234
+ $debugInfo['shortpixeldata'] = array(__('Data'), $this->data);
235
+ $debugInfo['wpmetadata'] = array(__('Meta'), $meta );
236
  if ($imageFile->hasBackup())
237
  {
238
  $backupFile = $imageFile->getBackupFile();
250
  $debugInfo[] = array(__('Backup'), $orbackup->getFullPath() . '(' . \ShortPixelTools::formatBytes($orbackup->getFileSize()) . ')');
251
  }
252
 
 
253
 
254
+
255
+ if (! isset($meta['sizes']) )
256
+ {
257
+ $debugInfo[] = array('', __('Thumbnails were not generated', 'shortpixel-image-optimiser'));
258
+ }
259
+ else
260
+ {
261
+ foreach($meta['sizes'] as $size => $data)
262
+ {
263
+ $display_size = ucfirst(str_replace("_", " ", $size));
264
+ $img = wp_get_attachment_image_src($this->post_id, $size);
265
+ //var_dump($img);
266
+ $debugInfo[] = array('', "<div class='$size previewwrapper'><img src='" . $img[0] . "'><span class='label'>$img[0] ( $display_size )</span></div>");
267
+ }
268
+ }
269
  return $debugInfo;
270
  }
271
 
class/db/shortpixel-meta-facade.php CHANGED
@@ -528,6 +528,7 @@ class ShortPixelMetaFacade {
528
  $cacheController = new Cache();
529
  Log::adDDebug('Removing Item Cache -> ' . $this->getCacheName() );
530
  $cacheController->deleteItem( $this->getCacheName());
 
531
 
532
  }
533
 
@@ -607,7 +608,7 @@ class ShortPixelMetaFacade {
607
 
608
  // new WP 5.3 function, check if file has original ( was scaled )
609
  $origFile = $imageObj->has_original();
610
- Log::addDebug('Get Paths and such, original', $origFile);
611
  if (is_object($origFile))
612
  {
613
  //$origFile = $imageObj->getOriginalFile();
@@ -1024,14 +1025,13 @@ class ShortPixelMetaFacade {
1024
  */
1025
  static public function returnSubDir($file)
1026
  {
1027
-
1028
  // Experimental FS handling for relativePath. Should be able to cope with more exceptions. See Unit Tests
1029
- $fs = new ShortPixel\FileSystemController();
1030
  $directory = $fs->getDirectory($file);
1031
- if ($relpath = $directory->getRelativePath())
 
1032
  return $relpath;
1033
 
1034
-
1035
  $homePath = get_home_path();
1036
  if($homePath == '/') {
1037
  $homePath = ABSPATH;
528
  $cacheController = new Cache();
529
  Log::adDDebug('Removing Item Cache -> ' . $this->getCacheName() );
530
  $cacheController->deleteItem( $this->getCacheName());
531
+ $this->getMeta(true); // reload the meta.
532
 
533
  }
534
 
608
 
609
  // new WP 5.3 function, check if file has original ( was scaled )
610
  $origFile = $imageObj->has_original();
611
+ Log::addDebug('Get Paths and such, original', (string) $origFile);
612
  if (is_object($origFile))
613
  {
614
  //$origFile = $imageObj->getOriginalFile();
1025
  */
1026
  static public function returnSubDir($file)
1027
  {
 
1028
  // Experimental FS handling for relativePath. Should be able to cope with more exceptions. See Unit Tests
1029
+ $fs = \wpSPIO()->filesystem();
1030
  $directory = $fs->getDirectory($file);
1031
+ $relpath = $directory->getRelativePath();
1032
+ if ($relpath !== false)
1033
  return $relpath;
1034
 
 
1035
  $homePath = get_home_path();
1036
  if($homePath == '/') {
1037
  $homePath = ABSPATH;
class/db/wp-shortpixel-media-library-adapter.php CHANGED
@@ -671,6 +671,11 @@ class WpShortPixelMediaLbraryAdapter {
671
  $file = $fs->getFile($mainFile);
672
 
673
  $directory = $file->getFileDir();
 
 
 
 
 
674
  /* Directory could not exist if, for instance, the request path is URL, S3 or some external exotic. */
675
  if (! $directory->check())
676
  {
671
  $file = $fs->getFile($mainFile);
672
 
673
  $directory = $file->getFileDir();
674
+ if (is_null($directory)) // means filepath might be empty and could not resolve directory.
675
+ {
676
+ Log::addWarn('FindThumbs - Given FileDirectory failed ' . $mainFile);
677
+ return array();
678
+ }
679
  /* Directory could not exist if, for instance, the request path is URL, S3 or some external exotic. */
680
  if (! $directory->check())
681
  {
class/external/helpscout.php CHANGED
@@ -90,7 +90,7 @@ class HelpScout
90
  <div id="shortpixel-hs-button-blind" class="shortpixel-hs-button-blind"></div>
91
  <div id="shortpixel-hs-tools" class="shortpixel-hs-tools">
92
  <a href="javascript:shortpixelToggleHS();" class="shortpixel-hs-tools-docs" title="<?php _e('Search through our online documentation.', 'shortpixel-image-optimiser'); ?>">
93
- <img src="<?php echo( wpSPIO()->plugin_url('res/img/notes-sp.png') );?>" style="margin-bottom: 2px;width: 36px;">
94
  </a>
95
  </div>
96
  <script>
90
  <div id="shortpixel-hs-button-blind" class="shortpixel-hs-button-blind"></div>
91
  <div id="shortpixel-hs-tools" class="shortpixel-hs-tools">
92
  <a href="javascript:shortpixelToggleHS();" class="shortpixel-hs-tools-docs" title="<?php _e('Search through our online documentation.', 'shortpixel-image-optimiser'); ?>">
93
+ <img alt="<?php _e('ShortPixel document icon', 'shortpixel-image-optimiser'); ?>" src="<?php echo( wpSPIO()->plugin_url('res/img/notes-sp.png') );?>" style="margin-bottom: 2px;width: 36px;">
94
  </a>
95
  </div>
96
  <script>
class/external/nextgen.php CHANGED
@@ -9,8 +9,18 @@ class NextGen
9
  public function __construct()
10
  {
11
  add_action('ngg_added_new_image', array($this,'new_image'));
 
12
  }
13
 
 
 
 
 
 
 
 
 
 
14
 
15
  public static function getInstance()
16
  {
9
  public function __construct()
10
  {
11
  add_action('ngg_added_new_image', array($this,'new_image'));
12
+ add_filter('shortpixel/init/optimize_on_screens', array($this, 'add_screen_loads'));
13
  }
14
 
15
+ public function add_screen_loads($use_screens)
16
+ {
17
+ $use_screens[] = 'toplevel_page_nextgen-gallery'; // toplevel
18
+ $use_screens[] = 'gallery_page_ngg_addgallery'; // add gallery
19
+ $use_screens[] = 'nggallery-manage-gallery'; // manage gallery
20
+ $use_screens[] = 'gallery_page_nggallery-manage-album'; // manage album
21
+
22
+ return $use_screens;
23
+ }
24
 
25
  public static function getInstance()
26
  {
class/external/wp-offload-media.php CHANGED
@@ -22,7 +22,7 @@ class wpOffload
22
  {
23
  if (! class_exists('\DeliciousBrains\WP_Offload_Media\Items\Media_Library_Item'))
24
  {
25
- Notice::addWarning(__('Your S3-Offload plugin version doesn\'t seem to be compatible. Please upgrade the S3-Offload plugin', 'shortpixel-image-optimiser'));
26
  }
27
  else {
28
  $this->itemClassName = '\DeliciousBrains\WP_Offload_Media\Items\Media_Library_Item';
@@ -40,7 +40,7 @@ class wpOffload
40
  add_action('shortpixel_image_optimised', array($this, 'image_upload'));
41
  add_action('shortpixel_after_restore_image', array($this, 'image_restore')); // hit this when restoring.
42
  add_action('shortpixel/image/convertpng2jpg_after', array($this, 'image_converted'));
43
- add_action('shortpixel_restore_after_pathget', array($this, 'remove_remote')); // not optimal -> has to do w/ doRestore and when URL/PATH is available when not on server .
44
  add_action('shortpixel/image/convertpng2jpg_before', array($this, 'remove_remote'));
45
  add_filter('as3cf_attachment_file_paths', array($this, 'add_webp_paths'));
46
  add_filter('as3cf_remove_attachment_paths', array($this, 'remove_webp_paths'));
22
  {
23
  if (! class_exists('\DeliciousBrains\WP_Offload_Media\Items\Media_Library_Item'))
24
  {
25
+ Notice::addWarning(__('Your S3-Offload plugin version doesn\'t seem to be compatible. Please upgrade the S3-Offload plugin', 'shortpixel-image-optimiser'), true);
26
  }
27
  else {
28
  $this->itemClassName = '\DeliciousBrains\WP_Offload_Media\Items\Media_Library_Item';
40
  add_action('shortpixel_image_optimised', array($this, 'image_upload'));
41
  add_action('shortpixel_after_restore_image', array($this, 'image_restore')); // hit this when restoring.
42
  add_action('shortpixel/image/convertpng2jpg_after', array($this, 'image_converted'));
43
+ add_action('shortpixel_restore_after_pathget', array($this, 'remove_remote')); // not optimal -> has to do w/ doRestore and when URL/PATH is available when not on server .
44
  add_action('shortpixel/image/convertpng2jpg_before', array($this, 'remove_remote'));
45
  add_filter('as3cf_attachment_file_paths', array($this, 'add_webp_paths'));
46
  add_filter('as3cf_remove_attachment_paths', array($this, 'remove_webp_paths'));
class/model/environment_model.php CHANGED
@@ -1,5 +1,6 @@
1
  <?php
2
  namespace ShortPixel;
 
3
 
4
  /** Loads a few environment variables handy to have nearby
5
  *
@@ -26,9 +27,11 @@ class EnvironmentModel extends ShortPixelModel
26
  public $is_ajaxcall = false;
27
 
28
  private $screen_is_set = false;
29
- public $is_screen_to_use = false; // where shortpixel loads
30
- public $is_our_screen = false;
31
 
 
 
32
 
33
  protected static $instance;
34
 
@@ -66,16 +69,26 @@ class EnvironmentModel extends ShortPixelModel
66
  $this->is_multisite = (function_exists("is_multisite") && is_multisite()) ? true : false;
67
  $this->is_mainsite = is_main_site();
68
 
69
- if ( is_admin() )
70
- $this->is_admin = true;
71
- else
72
- $this->is_front = true;
73
 
74
  if (defined('DOING_AJAX') && DOING_AJAX)
75
  {
76
  $this->is_ajaxcall = true;
77
  }
78
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
 
81
  public function setScreen()
@@ -89,12 +102,27 @@ class EnvironmentModel extends ShortPixelModel
89
  return false;
90
 
91
  // WordPress pages where we'll be active on.
92
- if(in_array($screen->id, array('upload', 'edit', 'edit-tags', 'post-new', 'post', 'attachment'))) {
 
 
 
 
 
 
 
 
 
 
 
 
93
  $this->is_screen_to_use = true;
94
  }
95
 
96
  // Our pages.
97
  $pages = \wpSPIO()->get_admin_pages();
 
 
 
98
 
99
  /* pages can be null in certain cases i.e. plugin activation.
100
  * treat those cases as improper screen set.
1
  <?php
2
  namespace ShortPixel;
3
+ use ShortPixel\ShortpixelLogger\ShortPixelLogger as Log;
4
 
5
  /** Loads a few environment variables handy to have nearby
6
  *
27
  public $is_ajaxcall = false;
28
 
29
  private $screen_is_set = false;
30
+ public $is_screen_to_use = false; // where shortpixel optimizer loads
31
+ public $is_our_screen = false; // where shortpixel hooks in more complicated functions.
32
 
33
+ // Debug flag
34
+ public $is_debug = false;
35
 
36
  protected static $instance;
37
 
69
  $this->is_multisite = (function_exists("is_multisite") && is_multisite()) ? true : false;
70
  $this->is_mainsite = is_main_site();
71
 
72
+ $this->determineFrontBack();
73
+
 
 
74
 
75
  if (defined('DOING_AJAX') && DOING_AJAX)
76
  {
77
  $this->is_ajaxcall = true;
78
  }
79
 
80
+ $this->is_debug = Log::debugIsActive();
81
+
82
+ }
83
+
84
+ // check if this request is front or back.
85
+ protected function determineFrontBack()
86
+ {
87
+ if ( is_admin() )
88
+ $this->is_admin = true;
89
+ else
90
+ $this->is_front = true;
91
+
92
  }
93
 
94
  public function setScreen()
102
  return false;
103
 
104
  // WordPress pages where we'll be active on.
105
+ // https://codex.wordpress.org/Plugin_API/Admin_Screen_Reference
106
+ $use_screens = array(
107
+ 'edit-post_tag', // edit tags
108
+ 'upload', // media library
109
+ 'attachment', // edit media
110
+ 'post', // post screen
111
+ 'edit-post', // edit post
112
+ 'new-post', // new post
113
+ 'edit-page', // all pages
114
+ );
115
+ $use_screens = apply_filters('shortpixel/init/optimize_on_screens', $use_screens);
116
+
117
+ if(in_array($screen->id, $use_screens)) {
118
  $this->is_screen_to_use = true;
119
  }
120
 
121
  // Our pages.
122
  $pages = \wpSPIO()->get_admin_pages();
123
+ // the main WP pages where SPIO hooks a lot of functions into, our operating area.
124
+ $wp_pages = array('upload', 'attachment');
125
+ $pages = array_merge($pages, $wp_pages);
126
 
127
  /* pages can be null in certain cases i.e. plugin activation.
128
  * treat those cases as improper screen set.
class/model/file_model.php CHANGED
@@ -26,6 +26,7 @@ class FileModel extends ShortPixelModel
26
  protected $exists = null;
27
  protected $is_writable = null;
28
  protected $is_readable = null;
 
29
 
30
  protected $status;
31
 
@@ -63,9 +64,12 @@ class FileModel extends ShortPixelModel
63
 
64
  $info = pathinfo($this->fullpath);
65
  // Todo, maybe replace this with splFileINfo.
66
- $this->filename = isset($info['basename']) ? $info['basename'] : null; // filename + extension
67
- $this->filebase = isset($info['filename']) ? $info['filename'] : null; // only filename
68
- $this->extension = isset($info['extension']) ? $info['extension'] : null; // only (last) extension
 
 
 
69
 
70
  }
71
 
@@ -74,6 +78,7 @@ class FileModel extends ShortPixelModel
74
  {
75
  $this->is_writable = null;
76
  $this->is_readable = null;
 
77
  $this->exists = null;
78
  }
79
 
@@ -101,6 +106,26 @@ class FileModel extends ShortPixelModel
101
  return $this->is_readable;
102
  }
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  public function getModified()
105
  {
106
  return filemtime($this->fullpath);
@@ -114,7 +139,7 @@ class FileModel extends ShortPixelModel
114
 
115
  $backupFile = $directory . $this->getFileName();
116
 
117
- if (file_exists($backupFile) && ! is_dir($backupFile) )
118
  return true;
119
  else {
120
  return false;
@@ -141,8 +166,10 @@ class FileModel extends ShortPixelModel
141
  {
142
  // create this only when needed.
143
  if (is_null($this->directory) && strlen($this->fullpath) > 0)
144
- $this->directory = new DirectoryModel(dirname($this->fullpath));
145
-
 
 
146
  return $this->directory;
147
  }
148
 
@@ -303,7 +330,8 @@ class FileModel extends ShortPixelModel
303
  $path = wp_normalize_path($path);
304
 
305
  // if path does not contain basepath.
306
- if (strpos($path, ABSPATH) === false && strpos($path, $this->getUploadPath()) === false)
 
307
  $path = $this->relativeToFullPath($path);
308
 
309
 
26
  protected $exists = null;
27
  protected $is_writable = null;
28
  protected $is_readable = null;
29
+ protected $is_file = null;
30
 
31
  protected $status;
32
 
64
 
65
  $info = pathinfo($this->fullpath);
66
  // Todo, maybe replace this with splFileINfo.
67
+ if ($this->is_file()) // only set fileinfo when it's an actual file.
68
+ {
69
+ $this->filename = isset($info['basename']) ? $info['basename'] : null; // filename + extension
70
+ $this->filebase = isset($info['filename']) ? $info['filename'] : null; // only filename
71
+ $this->extension = isset($info['extension']) ? $info['extension'] : null; // only (last) extension
72
+ }
73
 
74
  }
75
 
78
  {
79
  $this->is_writable = null;
80
  $this->is_readable = null;
81
+ $this->is_file = null;
82
  $this->exists = null;
83
  }
84
 
106
  return $this->is_readable;
107
  }
108
 
109
+ /* Function checks if path is actually a file. This can be used to check possible confusion if a directory path is given to filemodel */
110
+ public function is_file()
111
+ {
112
+ if (is_null($this->is_file))
113
+ {
114
+ if ($this->exists())
115
+ $this->is_file = is_file($this->fullpath);
116
+ else // file can not exist, but still have a valid filepath format. In that case, if file should return true.
117
+ {
118
+ //$pathinfo = pathinfo($this->fullpath);
119
+ //if (isset($pathinfo['extension'])) // extension means file.
120
+
121
+ // if file does not exist on disk, anything can become a file ( with/ without extension, etc). Meaning everything non-existing is a potential file ( or directory ) until created.
122
+ $this->is_file = true;
123
+
124
+ }
125
+ }
126
+ return $this->is_file;
127
+ }
128
+
129
  public function getModified()
130
  {
131
  return filemtime($this->fullpath);
139
 
140
  $backupFile = $directory . $this->getFileName();
141
 
142
+ if (file_exists($backupFile) && ! is_dir($backupFile) )
143
  return true;
144
  else {
145
  return false;
166
  {
167
  // create this only when needed.
168
  if (is_null($this->directory) && strlen($this->fullpath) > 0)
169
+ {
170
+ // Feed to full path to DirectoryModel since it checks if input is file, or dir. Using dirname here would cause errors when fullpath is already just a dirpath ( faulty input )
171
+ $this->directory = new DirectoryModel($this->fullpath);
172
+ }
173
  return $this->directory;
174
  }
175
 
330
  $path = wp_normalize_path($path);
331
 
332
  // if path does not contain basepath.
333
+ $uploadPath = wp_normalize_path($this->getUploadPath()); // mixed slashes and dashes can also be a config-error in WP.
334
+ if (strpos($path, ABSPATH) === false && strpos($path, $uploadPath) === false)
335
  $path = $this->relativeToFullPath($path);
336
 
337
 
class/model/image_model.php CHANGED
@@ -19,11 +19,13 @@ class ImageModel extends ShortPixelModel
19
  private $facade; // ShortPixelMetaFacade
20
 
21
  protected $thumbsnails = array(); // thumbnails of this
22
- protected $original_file;
23
 
24
- private $post_id;
25
- private $is_scaled = false;
26
 
 
 
 
27
 
28
  public function __construct()
29
  {
@@ -38,6 +40,7 @@ class ImageModel extends ShortPixelModel
38
  $this->facade = new \ShortPixelMetaFacade($post_id);
39
  $this->meta = $this->facade->getMeta();
40
 
 
41
  $this->file = $fs->getAttachedFile($post_id);
42
 
43
  // WP 5.3 and higher. Check for original file.
@@ -47,6 +50,21 @@ class ImageModel extends ShortPixelModel
47
  }
48
  }
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  protected function setOriginalFile()
52
  {
@@ -57,7 +75,7 @@ class ImageModel extends ShortPixelModel
57
 
58
  $originalFile = $fs->getOriginalPath($this->post_id);
59
 
60
- if ($originalFile->getFullPath() !== $this->file->getfullPath() )
61
  {
62
  $this->original_file = $originalFile;
63
  $this->is_scaled = true;
@@ -111,6 +129,45 @@ class ImageModel extends ShortPixelModel
111
  // $this->recount();
112
  }
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  // Rebuild the ThumbsOptList and others to fix old info, wrong builds.
115
  private function reCheckThumbnails()
116
  {
@@ -119,6 +176,11 @@ class ImageModel extends ShortPixelModel
119
  {
120
  return;
121
  }
 
 
 
 
 
122
  $data = $this->facade->getRawMeta();
123
  $oldList = array();
124
  if (isset($data['ShortPixel']['thumbsOptList']))
19
  private $facade; // ShortPixelMetaFacade
20
 
21
  protected $thumbsnails = array(); // thumbnails of this
22
+ protected $original_file; // the original instead of the possibly _scaled one created by WP 5.3 >
23
 
24
+ private $post_id; // attachment id
 
25
 
26
+ private $is_scaled = false; // if this is WP 5.3 scaled
27
+ private $is_optimized = false; // if this is optimized
28
+ private $is_png2jpg = false; // todo implement.
29
 
30
  public function __construct()
31
  {
40
  $this->facade = new \ShortPixelMetaFacade($post_id);
41
  $this->meta = $this->facade->getMeta();
42
 
43
+ $this->setImageStatus();
44
  $this->file = $fs->getAttachedFile($post_id);
45
 
46
  // WP 5.3 and higher. Check for original file.
50
  }
51
  }
52
 
53
+ /** This function sets various status attributes for imageModel.
54
+ * Goal is to make the status of images more consistent and don't have to rely constantly on getting and ready the whole meta
55
+ * with it's various marks. */
56
+ protected function setImageStatus()
57
+ {
58
+ $status = $this->meta->getStatus();
59
+ if ($status == \ShortPixelMeta::FILE_STATUS_SUCCESS)
60
+ $this->is_optimized = true;
61
+
62
+ $png2jpg = $this->meta->getPng2Jpg();
63
+ if(is_array($png2jpg))
64
+ {
65
+ $this->is_png2jpg = true;
66
+ }
67
+ }
68
 
69
  protected function setOriginalFile()
70
  {
75
 
76
  $originalFile = $fs->getOriginalPath($this->post_id);
77
 
78
+ if ($originalFile->exists() && $originalFile->getFullPath() !== $this->file->getfullPath() )
79
  {
80
  $this->original_file = $originalFile;
81
  $this->is_scaled = true;
129
  // $this->recount();
130
  }
131
 
132
+ /** Removed the current attachment, with hopefully removing everything we set.
133
+ * @return ShortPixelFacade Legacy return, to do something with replacing
134
+ */
135
+ public function delete()
136
+ {
137
+ $itemHandler = $this->facade;
138
+ //$itemHandler = new ShortPixelMetaFacade($post_id);
139
+ $urlsPaths = $itemHandler->getURLsAndPATHs(true, false, true, array(), true, true);
140
+
141
+ // @todo move this to some better permanent structure w/ png2jpg class.
142
+ if ($this->is_png2jpg)
143
+ {
144
+ $png2jpg = $this->meta->getPng2Jpg();
145
+ if (isset($png2jpg['originalFile']))
146
+ {
147
+ $urlsPaths['PATHs'][] = $png2jpg['originalFile'];
148
+ }
149
+ if (isset($png2jpg['originalSizes']))
150
+ {
151
+ foreach($png2jpg['originalSizes'] as $size => $data)
152
+ {
153
+ if (isset($data['file']))
154
+ {
155
+ $filedir = (string) $this->file->getFileDir();
156
+ $urlsPaths['PATHs'][] = $filedir . $data['file'];
157
+ }
158
+ }
159
+ }
160
+ }
161
+ if(count($urlsPaths['PATHs'])) {
162
+ Log::addDebug('Removing Backups and Webps', $urlsPaths);
163
+ \wpSPIO()->getShortPixel()->maybeDumpFromProcessedOnServer($itemHandler, $urlsPaths);
164
+ \wpSPIO()->getShortPixel()->deleteBackupsAndWebPs($urlsPaths['PATHs']);
165
+ }
166
+
167
+ $itemHandler->deleteItemCache();
168
+ return $itemHandler; //return it because we call it also on replace and on replace we need to follow this by deleting SP metadata, on delete it
169
+ }
170
+
171
  // Rebuild the ThumbsOptList and others to fix old info, wrong builds.
172
  private function reCheckThumbnails()
173
  {
176
  {
177
  return;
178
  }
179
+ if (! $this->file->exists())
180
+ {
181
+ Log::addInfo('Checking thumbnails for non-existing file', array($this->file));
182
+ return;
183
+ }
184
  $data = $this->facade->getRawMeta();
185
  $oldList = array();
186
  if (isset($data['ShortPixel']['thumbsOptList']))
class/model/shortpixel-folder.php CHANGED
@@ -43,7 +43,6 @@ class ShortPixelFolder extends ShortPixelEntity{
43
  if (! $dir->exists() )
44
  {
45
  $dir->check();
46
- //$result = @mkdir($folder, 0777, true);
47
  self::protectDirectoryListing($folder);
48
  $result = true;
49
  }
43
  if (! $dir->exists() )
44
  {
45
  $dir->check();
 
46
  self::protectDirectoryListing($folder);
47
  $result = true;
48
  }
class/shortpixel-png2jpg.php CHANGED
@@ -6,7 +6,8 @@
6
  */
7
 
8
  use ShortPixel\ShortPixelLogger\ShortPixelLogger as Log;
9
-
 
10
 
11
  //TODO decouple from directly using WP metadata, in order to be able to use it for custom images
12
  class ShortPixelPng2Jpg {
@@ -92,12 +93,12 @@ class ShortPixelPng2Jpg {
92
  }
93
  }
94
 
95
- WPShortPixel::log("PNG2JPG doConvert img ready");
96
  $x = imagesx($img);
97
  $y = imagesy($img);
98
  WPShortPixel::log("PNG2JPG doConvert width $x height $y");
99
  $bg = imagecreatetruecolor($x, $y);
100
- WPShortPixel::log("PNG2JPG doConvert img created truecolor");
101
  if(!$bg) return (object)array("params" => $params, "unlink" => false);
102
  imagefill($bg, 0, 0, imagecolorallocate($bg, 255, 255, 255));
103
  imagealphablending($bg, 1);
@@ -109,18 +110,14 @@ class ShortPixelPng2Jpg {
109
  $filename = $fsFile->getFileName();
110
  $newFileName = $fsFile->getFileBase() . '.jpg'; // convert extension to .png
111
 
112
- $uniquepath = wp_unique_filename($fsFile->getFullPath(), $newFileName);
113
- $newPath = (string) $fsFile->getFileDir() . $uniquepath;
 
 
114
 
115
  // check old filename, replace with uniqued filename.
116
- $newUrl = str_replace($filename, $uniquepath, $params['url']); //preg_replace("/\.png$/i", ".jpg", $params['url']);
117
- /*(for ($i = 1; file_exists($newPath); $i++) {
118
- if($suffixRegex) {
119
- $newPath = preg_replace("/(" . $suffixRegex . ")\.png$/i", $i . '-$1.jpg', $image);
120
- }else {
121
- $newPath = preg_replace("/\.png$/i", "-" . $i . ".jpg", $image);
122
- }
123
- } */
124
  if (imagejpeg($bg, $newPath, 90)) {
125
  WPShortPixel::log("PNG2JPG doConvert created JPEG at $newPath");
126
  $newSize = filesize($newPath);
@@ -164,6 +161,30 @@ class ShortPixelPng2Jpg {
164
  return (object)array("params" => $params, "unlink" => $image);
165
  }
166
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  protected function isExcluded($params) {
168
  if(is_array($this->_settings->excludePatterns)) {
169
  foreach($this->_settings->excludePatterns as $item) {
@@ -341,7 +362,7 @@ class ShortPixelPng2Jpg {
341
  $filesConverted[$info['file']] = false;
342
  }
343
  }
344
- $meta['ShortPixelPng2Jpg'] = array('originalFile' => $imagePath, 'originalSizes' => $originalSizes, 'originalSizes2' => $originalSizes,
345
  'backup' => $this->_settings->backupImages,
346
  'optimizationPercent' => round(100.0 * (1.00 - $jpgSize / $pngSize)));
347
  //wp_update_attachment_metadata($ID, $meta);
@@ -354,7 +375,7 @@ class ShortPixelPng2Jpg {
354
  if(count($toReplace)) {
355
  self::png2JpgUpdateUrls(array(), $toReplace);
356
  }
357
- $fs = new \ShortPixel\FileSystemController();
358
 
359
  foreach($toUnlink as $unlink) {
360
  if($unlink) {
@@ -416,7 +437,7 @@ class ShortPixelPng2Jpg {
416
  */
417
  public static function png2JpgUpdateUrls($options, $map){
418
  global $wpdb;
419
- WPShortPixel::log("PNG2JPG update URLS " . json_encode($map));
420
  $results = array();
421
  $queries = array(
422
  'content' => array("UPDATE $wpdb->posts SET post_content = replace(post_content, %s, %s)", __('Content Items (Posts, Pages, Custom Post Types, Revisions)','shortpixel-image-optimiser') ),
@@ -431,7 +452,7 @@ class ShortPixelPng2Jpg {
431
  }
432
  $startTime = microtime(true);
433
  foreach($options as $option){
434
- WPShortPixel::log("PNG2JPG update URLS on $option ");
435
  if( $option == 'custom' ){
436
  $n = 0;
437
  $page_size = WpShortPixelMediaLbraryAdapter::getOptimalChunkSize('postmeta');
6
  */
7
 
8
  use ShortPixel\ShortPixelLogger\ShortPixelLogger as Log;
9
+ use ShortPixel\FileModel as FileModel;
10
+ use ShortPixel\Directorymodel as DirectoryModel;
11
 
12
  //TODO decouple from directly using WP metadata, in order to be able to use it for custom images
13
  class ShortPixelPng2Jpg {
93
  }
94
  }
95
 
96
+ // WPShortPixel::log("PNG2JPG doConvert img ready");
97
  $x = imagesx($img);
98
  $y = imagesy($img);
99
  WPShortPixel::log("PNG2JPG doConvert width $x height $y");
100
  $bg = imagecreatetruecolor($x, $y);
101
+ // WPShortPixel::log("PNG2JPG doConvert img created truecolor");
102
  if(!$bg) return (object)array("params" => $params, "unlink" => false);
103
  imagefill($bg, 0, 0, imagecolorallocate($bg, 255, 255, 255));
104
  imagealphablending($bg, 1);
110
  $filename = $fsFile->getFileName();
111
  $newFileName = $fsFile->getFileBase() . '.jpg'; // convert extension to .png
112
 
113
+ $fsNewFile = $fs->getFile($fsFile->getFileDir() . $newFileName);
114
+
115
+ $uniquefile = $this->unique_file( $fsFile->getFileDir(), $fsNewFile);
116
+ $newPath = $uniquefile->getFullPath(); //(string) $fsFile->getFileDir() . $uniquepath;
117
 
118
  // check old filename, replace with uniqued filename.
119
+ $newUrl = str_replace($filename, $uniquefile->getFileName(), $params['url']); //preg_replace("/\.png$/i", ".jpg", $params['url']);
120
+
 
 
 
 
 
 
121
  if (imagejpeg($bg, $newPath, 90)) {
122
  WPShortPixel::log("PNG2JPG doConvert created JPEG at $newPath");
123
  $newSize = filesize($newPath);
161
  return (object)array("params" => $params, "unlink" => $image);
162
  }
163
 
164
+ /** Own function to get a unique filename since the WordPress wp_unique_filename seems to not function properly w/ thumbnails */
165
+ private function unique_file(DirectoryModel $dir, FileModel $file, $number = 0)
166
+ {
167
+ if (! $file->exists())
168
+ return $file;
169
+
170
+ $number = 0;
171
+ $fs = \wpSPIO()->filesystem();
172
+
173
+ $base = $file->getFileBase();
174
+ $ext = $file->getExtension();
175
+
176
+ while($file->exists())
177
+ {
178
+ $number++;
179
+ $numberbase = $base . '-' . $number;
180
+ Log::addDebug('check for unique file -- ' . $dir->getPath() . $numberbase . '.' . $ext);
181
+ $file = $fs->getFile($dir->getPath() . $numberbase . '.' . $ext);
182
+ }
183
+
184
+ return $file;
185
+
186
+ }
187
+
188
  protected function isExcluded($params) {
189
  if(is_array($this->_settings->excludePatterns)) {
190
  foreach($this->_settings->excludePatterns as $item) {
362
  $filesConverted[$info['file']] = false;
363
  }
364
  }
365
+ $meta['ShortPixelPng2Jpg'] = array('originalFile' => $imagePath, 'originalSizes' => $originalSizes,
366
  'backup' => $this->_settings->backupImages,
367
  'optimizationPercent' => round(100.0 * (1.00 - $jpgSize / $pngSize)));
368
  //wp_update_attachment_metadata($ID, $meta);
375
  if(count($toReplace)) {
376
  self::png2JpgUpdateUrls(array(), $toReplace);
377
  }
378
+ $fs = \wpSPIO()->filesystem();
379
 
380
  foreach($toUnlink as $unlink) {
381
  if($unlink) {
437
  */
438
  public static function png2JpgUpdateUrls($options, $map){
439
  global $wpdb;
440
+ Log::addDebug("PNG2JPG update URLS " . json_encode($map));
441
  $results = array();
442
  $queries = array(
443
  'content' => array("UPDATE $wpdb->posts SET post_content = replace(post_content, %s, %s)", __('Content Items (Posts, Pages, Custom Post Types, Revisions)','shortpixel-image-optimiser') ),
452
  }
453
  $startTime = microtime(true);
454
  foreach($options as $option){
455
+ // WPShortPixel::log("PNG2JPG update URLS on $option ");
456
  if( $option == 'custom' ){
457
  $n = 0;
458
  $page_size = WpShortPixelMediaLbraryAdapter::getOptimalChunkSize('postmeta');
class/view/settings/part-advanced.php CHANGED
@@ -27,7 +27,7 @@ namespace ShortPixel;
27
  } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false) {
28
  // Show a message about the risks and caveats of serving WEBP images via .htaccess
29
  $deliverWebpUnalteredLabel = '<span style="color: initial;">'.__('Based on testing your particular hosting configuration, we determined that your server','shortpixel-image-optimiser').
30
- '&nbsp;<img src="'. plugins_url( 'res/img/test.jpg' , SHORTPIXEL_PLUGIN_FILE) .'">&nbsp;'.
31
  __('serve the WEBP versions of the JPEG files seamlessly, via .htaccess.','shortpixel-image-optimiser').' <a href="javascript:void(0)" data-beacon-article="5c1d050e04286304a71d9ce4">Open article to read more about this.</a></span>';
32
  }
33
  }
@@ -85,7 +85,7 @@ namespace ShortPixel;
85
  <td>
86
  <?php if(!($st == "Empty")) { ?>
87
  <a href="javascript:none();" title="<?php echo $fullStat; ?>" style="text-decoration: none;">
88
- <img src='<?php echo( wpSPIO()->plugin_url('res/img/info-icon.png' ));?>' style="margin-bottom: -2px;"/>
89
  </a>&nbsp;<?php } echo($typ.$st.$err); ?>
90
 
91
  </td>
@@ -311,24 +311,37 @@ namespace ShortPixel;
311
  </td>
312
  </tr>
313
  <tr>
314
- <th scope="row"><?php _e('Process in front-end','shortpixel-image-optimiser');?></th>
315
  <td>
316
- <input name="frontBootstrap" type="checkbox" id="frontBootstrap" value="1" <?php checked( $view->data->frontBootstrap, '1' );?>>
317
- <label for="frontBootstrap"><?php _e('Automatically optimize images added by users in front end.','shortpixel-image-optimiser');?></label>
318
  <p class="settings-info">
319
- <?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');?>
320
  </p>
321
  </td>
322
  </tr>
323
- <tr>
324
- <th scope="row"><?php _e('Optimize media on upload','shortpixel-image-optimiser');?></th>
325
  <td>
326
- <input name="autoMediaLibrary" type="checkbox" id="autoMediaLibrary" value="1" <?php checked( $view->data->autoMediaLibrary, "1" );?>>
327
- <label for="autoMediaLibrary"><?php _e('Automatically optimize Media Library items after they are uploaded (recommended).','shortpixel-image-optimiser');?></label>
328
  <p class="settings-info">
329
- <?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');?>
330
  </p>
331
  </td>
 
 
 
 
 
 
 
 
 
 
 
 
 
332
  </tr>
333
  <tr>
334
  <th scope="row"><label for="excludeSizes"><?php _e('Exclude thumbnail sizes','shortpixel-image-optimiser');?></label></th>
27
  } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false) {
28
  // Show a message about the risks and caveats of serving WEBP images via .htaccess
29
  $deliverWebpUnalteredLabel = '<span style="color: initial;">'.__('Based on testing your particular hosting configuration, we determined that your server','shortpixel-image-optimiser').
30
+ '&nbsp;<img alt="can or can not" src="'. plugins_url( 'res/img/test.jpg' , SHORTPIXEL_PLUGIN_FILE) .'">&nbsp;'.
31
  __('serve the WEBP versions of the JPEG files seamlessly, via .htaccess.','shortpixel-image-optimiser').' <a href="javascript:void(0)" data-beacon-article="5c1d050e04286304a71d9ce4">Open article to read more about this.</a></span>';
32
  }
33
  }
85
  <td>
86
  <?php if(!($st == "Empty")) { ?>
87
  <a href="javascript:none();" title="<?php echo $fullStat; ?>" style="text-decoration: none;">
88
+ <img alt='Info icon' src='<?php echo( wpSPIO()->plugin_url('res/img/info-icon.png' ));?>' style="margin-bottom: -2px;"/>
89
  </a>&nbsp;<?php } echo($typ.$st.$err); ?>
90
 
91
  </td>
311
  </td>
312
  </tr>
313
  <tr>
314
+ <th scope="row"><?php _e('Optimize media on upload','shortpixel-image-optimiser');?></th>
315
  <td>
316
+ <input name="autoMediaLibrary" type="checkbox" id="autoMediaLibrary" value="1" <?php checked( $view->data->autoMediaLibrary, "1" );?>>
317
+ <label for="autoMediaLibrary"><?php _e('Automatically optimize Media Library items after they are uploaded (recommended).','shortpixel-image-optimiser');?></label>
318
  <p class="settings-info">
319
+ <?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');?>
320
  </p>
321
  </td>
322
  </tr>
323
+ <tr id="frontBootstrapRow">
324
+ <th scope="row"><?php _e('Process in front-end','shortpixel-image-optimiser');?></th>
325
  <td>
326
+ <input name="frontBootstrap" type="checkbox" id="frontBootstrap" value="1" <?php checked( $view->data->frontBootstrap, '1' );?>>
327
+ <label for="frontBootstrap"><?php _e('Automatically optimize images added by users in front end.','shortpixel-image-optimiser');?></label>
328
  <p class="settings-info">
329
+ <?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');?>
330
  </p>
331
  </td>
332
+ <script>
333
+ var spaiAML = document.getElementById('autoMediaLibrary');
334
+ document.getElementById('frontBootstrapRow').setAttribute('style', spaiAML.checked ? '' : 'display:none;');
335
+ spaiAML.addEventListener('change', function() {
336
+ if(this.checked) {
337
+ jQuery('#frontBootstrapRow').show(500);
338
+ } else {
339
+ jQuery('#frontBootstrapRow').hide(500);
340
+ }
341
+ });
342
+
343
+
344
+ </script>
345
  </tr>
346
  <tr>
347
  <th scope="row"><label for="excludeSizes"><?php _e('Exclude thumbnail sizes','shortpixel-image-optimiser');?></label></th>
class/view/settings/part-general.php CHANGED
@@ -159,11 +159,11 @@
159
  </p>
160
  <div style="margin-top: 10px;">
161
  <input type="radio" name="resizeType" id="resize_type_outer" value="outer" <?php echo($view->data->resizeType == 'inner' ? '' : 'checked') ?> style="margin: -50px 10px 60px 0;">
162
- <img src="<?php echo(wpSPIO()->plugin_url('res/img/resize-outer.png' ));?>"
163
  srcset='<?php echo(wpSPIO()->plugin_url('res/img/resize-outer.png' ));?> 1x, <?php echo(wpSPIO()->plugin_url('res/img/resize-outer@2x.png' ));?> 2x'
164
  title="<?php _e('Sizes will be greater or equal to the corresponding value. For example, if you set the resize dimensions at 1000x1200, an image of 2000x3000px will be resized to 1000x1500px while an image of 3000x2000px will be resized to 1800x1200px','shortpixel-image-optimiser');?>">
165
  <input type="radio" name="resizeType" id="resize_type_inner" value="inner" <?php echo($view->data->resizeType == 'inner' ? 'checked' : '') ?> style="margin: -50px 10px 60px 35px;">
166
- <img src="<?php echo(wpSPIO()->plugin_url('res/img/resize-inner.png' ));?>"
167
  srcset='<?php echo(wpSPIO()->plugin_url('res/img/resize-inner.png' ));?> 1x, <?php echo(wpSPIO()->plugin_url('res/img/resize-inner@2x.png' ));?> 2x'
168
  title="<?php _e('Sizes will be smaller or equal to the corresponding value. For example, if you set the resize dimensions at 1000x1200, an image of 2000x3000px will be resized to 800x1200px while an image of 3000x2000px will be resized to 1000x667px','shortpixel-image-optimiser');?>">
169
  <div style="display:inline-block;margin-left: 20px;"><a href="https://blog.shortpixel.com/resize-images/" class="shortpixel-help-link" target="_blank">
159
  </p>
160
  <div style="margin-top: 10px;">
161
  <input type="radio" name="resizeType" id="resize_type_outer" value="outer" <?php echo($view->data->resizeType == 'inner' ? '' : 'checked') ?> style="margin: -50px 10px 60px 0;">
162
+ <img alt="<?php _e('Resize outer','shortpixel-image-optimiser'); ?>" src="<?php echo(wpSPIO()->plugin_url('res/img/resize-outer.png' ));?>"
163
  srcset='<?php echo(wpSPIO()->plugin_url('res/img/resize-outer.png' ));?> 1x, <?php echo(wpSPIO()->plugin_url('res/img/resize-outer@2x.png' ));?> 2x'
164
  title="<?php _e('Sizes will be greater or equal to the corresponding value. For example, if you set the resize dimensions at 1000x1200, an image of 2000x3000px will be resized to 1000x1500px while an image of 3000x2000px will be resized to 1800x1200px','shortpixel-image-optimiser');?>">
165
  <input type="radio" name="resizeType" id="resize_type_inner" value="inner" <?php echo($view->data->resizeType == 'inner' ? 'checked' : '') ?> style="margin: -50px 10px 60px 35px;">
166
+ <img alt="<?php _e('Resize inner','shortpixel-image-optimiser'); ?>" src="<?php echo(wpSPIO()->plugin_url('res/img/resize-inner.png' ));?>"
167
  srcset='<?php echo(wpSPIO()->plugin_url('res/img/resize-inner.png' ));?> 1x, <?php echo(wpSPIO()->plugin_url('res/img/resize-inner@2x.png' ));?> 2x'
168
  title="<?php _e('Sizes will be smaller or equal to the corresponding value. For example, if you set the resize dimensions at 1000x1200, an image of 2000x3000px will be resized to 800x1200px while an image of 3000x2000px will be resized to 1000x667px','shortpixel-image-optimiser');?>">
169
  <div style="display:inline-block;margin-left: 20px;"><a href="https://blog.shortpixel.com/resize-images/" class="shortpixel-help-link" target="_blank">
class/view/settings/part-nokey.php CHANGED
@@ -64,8 +64,10 @@ if($adminEmail == 'noreply@addendio.com') $adminEmail = false; //hack for the ad
64
  }
65
  ?><br><span style="position:relative;">
66
  <input name="tos" type="checkbox" id="tos">
67
- <img id="tos-robo" src="<?php echo(wpSPIO()->plugin_url('res/img/slider.png' ));?>" style="position: absolute;left: -95px;bottom: -26px;display:none;">
68
- <img id="tos-hand" src="<?php echo(wpSPIO()->plugin_url('res/img/point.png' ));?>" style="position: absolute;left: -39px;bottom: -9px;display:none;">
 
 
69
  </span>
70
  <?php _e('I have read and I agree to the <a href="https://shortpixel.com/tos" target="_blank">Terms of Service</a> and the <a href="https://shortpixel.com/privacy" target="_blank">Privacy Policy</a> (<a href="https://shortpixel.com/privacy#gdpr" target="_blank">GDPR compliant</a>).','shortpixel-image-optimiser');
71
  ?>
64
  }
65
  ?><br><span style="position:relative;">
66
  <input name="tos" type="checkbox" id="tos">
67
+ <img id="tos-robo" alt="<?php _e('ShortPixel logo', 'shortpixel-image-optimiser'); ?>"
68
+ src="<?php echo(wpSPIO()->plugin_url('res/img/slider.png' ));?>" style="position: absolute;left: -95px;bottom: -26px;display:none;">
69
+ <img id="tos-hand" alt="<?php _e('Hand pointing', 'shortpixel-image-optimiser'); ?>"
70
+ src="<?php echo(wpSPIO()->plugin_url('res/img/point.png' ));?>" style="position: absolute;left: -39px;bottom: -9px;display:none;">
71
  </span>
72
  <?php _e('I have read and I agree to the <a href="https://shortpixel.com/tos" target="_blank">Terms of Service</a> and the <a href="https://shortpixel.com/privacy" target="_blank">Privacy Policy</a> (<a href="https://shortpixel.com/privacy#gdpr" target="_blank">GDPR compliant</a>).','shortpixel-image-optimiser');
73
  ?>
class/view/shortpixel_view.php CHANGED
@@ -1685,8 +1685,13 @@ class ShortPixelView {
1685
  $controller->setLegacyView($this);
1686
  $controller->setShortPixel($this->ctrl);
1687
  $controller->load($id);
 
 
 
 
1688
  return;
1689
  }
 
1690
  ?>
1691
  <div id='sp-msg-<?php echo($id);?>' class='column-wp-shortPixel'>
1692
 
@@ -1746,34 +1751,7 @@ class ShortPixelView {
1746
  $excluded = (isset($data['excludeSizes']) ? count($data['excludeSizes']) : 0);
1747
  $successText = $this->getSuccessText($data['percent'],$data['bonus'],$data['type'],$data['thumbsOpt'],$data['thumbsTotal'], $data['retinasOpt'], $data['excludeSizes']);
1748
  $todoSizes = $missingThumbs = $excludeSizes = '';
1749
- /*if($extended) {
1750
- if(isset($data['thumbsToOptimizeList']) && count($data['thumbsToOptimizeList'])) {
1751
- $todoSizes .= "<br><span style='word-break: break-all;'> <span style='font-weight: bold;'>" . __("To optimize:", 'shortpixel-image-optimiser') . "</span>";
1752
- foreach($data['thumbsToOptimizeList'] as $todoItem) {
1753
- $todoSizes .= "<br> &#8226;&nbsp;" . $todoItem;
1754
- }
1755
- $todoSizes .= '</span>';
1756
- }
1757
- if(isset($data['excludeSizes'])) {
1758
- $excludeSizes .= "<br><span style='word-break: break-all;'> <span style='font-weight: bold;'>" . __("Excluded thumbnails:", 'shortpixel-image-optimiser') . "</span>";
1759
- foreach($data['excludeSizes'] as $excludedItem) {
1760
- $excludeSizes .= "<br> &#8226;&nbsp;" . $excludedItem;
1761
- }
1762
- $excludeSizes .= '</span>';
1763
- }
1764
- if(count($data['thumbsMissing'])) {
1765
- $missingThumbs .= "<br><span style='word-break: break-all;'> <span style='font-weight: bold;'>" . __("Missing thumbnails:", 'shortpixel-image-optimiser') . "</span>";
1766
- foreach($data['thumbsMissing'] as $miss) {
1767
- $missingThumbs .= "<br> &#8226&nbsp;" . $miss;
1768
- }
1769
- $missingThumbs .= '</span>';
1770
- }
1771
- $successText .= ($data['webpCount'] ? "<br>+" . $data['webpCount'] . __(" WebP images", 'shortpixel-image-optimiser') : "")
1772
- . "<br>EXIF: " . ($data['exifKept'] ? __('kept','shortpixel-image-optimiser') : __('removed','shortpixel-image-optimiser'))
1773
- . ($data['png2jpg'] ? '<br>' . __('Converted from PNG','shortpixel-image-optimiser'): '')
1774
- . "<br>" . __("Optimized on", 'shortpixel-image-optimiser') . ": " . $data['date']
1775
- . $todoSizes . $excludeSizes . $missingThumbs;
1776
- } */
1777
  $this->renderListCell($id, $data['status'], $data['showActions'], $data['thumbsToOptimize'],
1778
  $data['backup'], $data['type'], $data['invType'], $successText);
1779
 
1685
  $controller->setLegacyView($this);
1686
  $controller->setShortPixel($this->ctrl);
1687
  $controller->load($id);
1688
+ if (\wpSPIO()->env()->is_debug)
1689
+ {
1690
+ \wpSPIO()->load_script('shortpixel-debug');
1691
+ }
1692
  return;
1693
  }
1694
+
1695
  ?>
1696
  <div id='sp-msg-<?php echo($id);?>' class='column-wp-shortPixel'>
1697
 
1751
  $excluded = (isset($data['excludeSizes']) ? count($data['excludeSizes']) : 0);
1752
  $successText = $this->getSuccessText($data['percent'],$data['bonus'],$data['type'],$data['thumbsOpt'],$data['thumbsTotal'], $data['retinasOpt'], $data['excludeSizes']);
1753
  $todoSizes = $missingThumbs = $excludeSizes = '';
1754
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1755
  $this->renderListCell($id, $data['status'], $data['showActions'], $data['thumbsToOptimize'],
1756
  $data['backup'], $data['type'], $data['invType'], $successText);
1757
 
class/view/view-edit-media.php CHANGED
@@ -7,20 +7,24 @@ use ShortPixel\ShortpixelLogger\ShortPixelLogger as Log;
7
  <div id='sp-msg-<?php echo($view->id);?>' class='column-wp-shortPixel view-edit-media'>
8
  <?php // Debug Data
9
  if (! is_null($view->debugInfo)): ?>
10
- <div class='debugInfo'>
11
- <ul>
12
- <?php foreach($view->debugInfo as $item): ?>
13
- <li><strong><?php echo $item[0]; ?></strong>
14
- <?php
15
- if (is_array($item[1]) || is_object($item[1]))
16
- echo "<PRE>" . print_r($item[1], true) . "</PRE>";
17
- else
18
- echo $item[1];
19
- ?>
20
- </li>
21
- <?php endforeach; ?>
22
- </ul>
23
-
 
 
 
 
24
  </div>
25
  <?php endif; ?>
26
 
7
  <div id='sp-msg-<?php echo($view->id);?>' class='column-wp-shortPixel view-edit-media'>
8
  <?php // Debug Data
9
  if (! is_null($view->debugInfo)): ?>
10
+ <div class='debugInfo' id='debugInfo'>
11
+ <a class='debugModal' data-modal="debugInfo" ><?php _e('Debug Window', 'shortpixel-image-optimiser') ?></a>
12
+ <div class='content wrapper'>
13
+ <?php foreach($view->debugInfo as $index => $item): ?>
14
+ <ul class="debug-<?php echo $index ?>">
15
+ <li><strong><?php echo $item[0]; ?></strong>
16
+ <?php
17
+ if (is_array($item[1]) || is_object($item[1]))
18
+ echo "<PRE>" . print_r($item[1], true) . "</PRE>";
19
+ else
20
+ echo $item[1];
21
+ ?>
22
+ </li>
23
+ </ul>
24
+ <?php endforeach; ?>
25
+ <p>&nbsp;</p>
26
+ <p>&nbsp;</p>
27
+ </div>
28
  </div>
29
  <?php endif; ?>
30
 
class/wp-short-pixel.php CHANGED
@@ -2,6 +2,9 @@
2
  //use ShortPixel\DebugItem as DebugItem;
3
  use ShortPixel\ShortPixelLogger\ShortPixelLogger as Log;
4
  use ShortPixel\Notices\NoticeController as Notices;
 
 
 
5
 
6
  class WPShortPixel {
7
 
@@ -144,7 +147,7 @@ class WPShortPixel {
144
 
145
  //toolbar notifications
146
  add_action( 'admin_bar_menu', array( &$this, 'toolbar_shortpixel_processing'), 999 );
147
- add_action( 'wp_head', array( $this, 'headCSS'));
148
  //deactivate plugin
149
  add_action( 'admin_post_shortpixel_deactivate_plugin', array(&$this, 'deactivatePlugin'));
150
  //only if the key is not yet valid or the user hasn't bought any credits.
@@ -311,6 +314,11 @@ class WPShortPixel {
311
  'action'=>'Deactivate',
312
  'data'=>'simple-image-sizes/simple_image_sizes.php'
313
  ),
 
 
 
 
 
314
  //DEACTIVATED TEMPORARILY - it seems that the customers get scared.
315
  /* 'Jetpack by WordPress.com - The Speed up image load times Option'
316
  => array(
@@ -498,16 +506,22 @@ class WPShortPixel {
498
  function shortPixelJS() {
499
 
500
  if (! \wpSPIO()->env()->is_screen_to_use )
501
- return; // not ours, don't load JS and such.
 
 
 
 
 
502
 
503
  //require_once(ABSPATH . 'wp-admin/includes/screen.php');
504
- if(function_exists('get_current_screen')) {
505
- $screen = get_current_screen();
506
 
507
- if(is_object($screen)) {
508
 
509
- wp_enqueue_style('short-pixel-bar.min.css', plugins_url('/res/css/short-pixel-bar.min.css',SHORTPIXEL_PLUGIN_FILE), array(), SHORTPIXEL_IMAGE_OPTIMISER_VERSION);
510
- if( in_array($screen->id, array('attachment', 'upload', 'settings_page_wp-shortpixel', 'media_page_wp-short-pixel-bulk', 'media_page_wp-short-pixel-custom'))) {
 
511
  wp_enqueue_style('short-pixel.min.css', plugins_url('/res/css/short-pixel.min.css',SHORTPIXEL_PLUGIN_FILE), array(), SHORTPIXEL_IMAGE_OPTIMISER_VERSION);
512
  //modal - used in settings for selecting folder
513
  wp_enqueue_style('short-pixel-modal.min.css', plugins_url('/res/css/short-pixel-modal.min.css',SHORTPIXEL_PLUGIN_FILE), array(), SHORTPIXEL_IMAGE_OPTIMISER_VERSION);
@@ -516,8 +530,8 @@ class WPShortPixel {
516
  wp_register_style('shortpixel-admin', plugins_url('/res/css/shortpixel-admin.css', SHORTPIXEL_PLUGIN_FILE),array(), SHORTPIXEL_IMAGE_OPTIMISER_VERSION );
517
  wp_enqueue_style('shortpixel-admin');
518
  }
519
- }
520
- }
521
 
522
 
523
  wp_register_script('shortpixel' . $this->jsSuffix, plugins_url('/res/js/shortpixel' . $this->jsSuffix,SHORTPIXEL_PLUGIN_FILE), array('jquery'), SHORTPIXEL_IMAGE_OPTIMISER_VERSION, true);
@@ -582,7 +596,11 @@ class WPShortPixel {
582
  'confirmBulkCleanupPending' => __( "Are you sure you want to cleanup the pending metadata?", 'shortpixel-image-optimiser' ),
583
  'alertDeliverWebPAltered' => __( "Warning: Using this method alters the structure of the rendered HTML code (IMG tags get included in PICTURE tags),\nwhich in some rare cases can lead to CSS/JS inconsistencies.\n\nPlease test this functionality thoroughly after activating!\n\nIf you notice any issue, just deactivate it and the HTML will will revert to the previous state.", 'shortpixel-image-optimiser' ),
584
  'alertDeliverWebPUnaltered' => __('This option will serve both WebP and the original image using the same URL, based on the web browser capabilities, please make sure you\'re serving the images from your server and not using a CDN which caches the images.', 'shortpixel-image-optimiser' ),
585
- );
 
 
 
 
586
  wp_localize_script( 'shortpixel' . $this->jsSuffix, '_spTr', $jsTranslation );
587
  wp_localize_script( 'shortpixel' . $this->jsSuffix, 'ShortPixelConstants', $ShortPixelConstants );
588
  wp_enqueue_script('shortpixel' . $this->jsSuffix);
@@ -635,6 +653,9 @@ class WPShortPixel {
635
  */
636
  function toolbar_shortpixel_processing( $wp_admin_bar ) {
637
 
 
 
 
638
  $extraClasses = " shortpixel-hide";
639
  /*translators: toolbar icon tooltip*/
640
  $id = 'short-pixel-notice-toolbar';
@@ -665,7 +686,7 @@ class WPShortPixel {
665
 
666
  $args = array(
667
  'id' => 'shortpixel_processing',
668
- 'title' => '<div id="' . $id . '" title="' . $tooltip . '" ><img src="'
669
  . plugins_url( 'res/img/'.$icon, SHORTPIXEL_PLUGIN_FILE ) . '" success-url="' . $successLink . '"><span class="shp-alert">!</span>'
670
  .'<div class="cssload-container"><div class="cssload-speeding-wheel"></div></div></div>',
671
  'href' => $link,
@@ -1826,9 +1847,9 @@ class WPShortPixel {
1826
  /** Manual optimization request. This is only called from the Media Library, never from the Custom media */
1827
  public function handleManualOptimization() {
1828
  $imageId = intval($_GET['image_id']);
1829
- $cleanup = $_GET['cleanup'];
1830
 
1831
- Log::addInfo("Handle Manual Optimization #{$imageId}");
1832
 
1833
  switch(substr($imageId, 0, 2)) {
1834
  case "N-":
@@ -1877,6 +1898,15 @@ class WPShortPixel {
1877
 
1878
  $itemFile = \wpSPIO()->filesystem()->getAttachedFile($imageId);
1879
 
 
 
 
 
 
 
 
 
 
1880
  if(!$manual && 'pdf' === $itemFile->getExtension() && !$this->_settings->optimizePdfs) {
1881
  $ret = array("Status" => ShortPixelAPI::STATUS_SKIP, "Message" => $imageId);
1882
  } else {
@@ -1991,27 +2021,72 @@ class WPShortPixel {
1991
  }
1992
 
1993
  /* Gets backup folder of file
1994
- * @param string $file Filepath - probably
1995
- * @return string backupFolder
1996
  */
1997
  public function getBackupFolder($file) {
1998
- if(realpath($file)) {
1999
- $ret = $this->getBackupFolderInternal(realpath($file)); //found cases when $file contains for example /wp/../wp-content - clean it up
2000
- if($ret) return $ret;
2001
- }
 
 
 
 
 
 
 
 
2002
  //another chance at glory, maybe cleanup was too much? (we tried first the cleaned up version for historical reason, don't disturb the sleeping dragon, right? :))
2003
- return $this->getBackupFolderInternal($file);
2004
  }
2005
 
2006
  /** Gets backup from file
2007
- * @param string $file Filename
2008
- * @return string FolderName
2009
  */
2010
- private function getBackupFolderInternal($file) {
2011
- $fileExtension = strtolower(substr($file,strrpos($file,".")+1));
 
2012
  $SubDir = ShortPixelMetaFacade::returnSubDir($file);
2013
  $SubDirOld = ShortPixelMetaFacade::returnSubDirOld($file);
 
 
2014
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2015
  if ( !file_exists(SHORTPIXEL_BACKUP_FOLDER . '/' . $SubDir . ShortPixelAPI::MB_basename($file))
2016
  && !file_exists(SHORTPIXEL_BACKUP_FOLDER . '/' . date("Y") . "/" . date("m") . "/" . ShortPixelAPI::MB_basename($file)) ) {
2017
  $SubDir = $SubDirOld; //maybe the folder was saved with the old method that returned the full path if the wp-content was not inside the root of the site.
@@ -2028,6 +2103,7 @@ class WPShortPixel {
2028
  }
2029
  }
2030
  return SHORTPIXEL_BACKUP_FOLDER . '/' . $SubDir;
 
2031
  }
2032
 
2033
  /** Gets BackupFolder. If that doesn't work, search thumbs for a backupFolder
@@ -2131,7 +2207,7 @@ class WPShortPixel {
2131
  $image = $rawMeta['file']; // relative file
2132
  $imageUrl = wp_get_attachment_url($attachmentID); // URL can be anything.
2133
 
2134
- Log::addDebug('OriginFile -- ' . $fsFile->getFullPath() );
2135
 
2136
  $imageName = $fsFile->getFileName();
2137
 
@@ -2236,7 +2312,7 @@ class WPShortPixel {
2236
  if ($bkOrigFile && $bkOrigFile->exists())
2237
  $bkOrigFile->move($origFile);
2238
 
2239
- Log::addDebug('Restore result - Backup oringal file', array($bkOrigFile, $origFile));
2240
  }
2241
  //$this->renameWithRetina($bkFile, $file);
2242
  if (! $bkFile->move($fsFile))
@@ -2310,6 +2386,7 @@ class WPShortPixel {
2310
  if($png2jpgMain) {
2311
  $crtMeta['file'] = trailingslashit(dirname($crtMeta['file'])) . $fsFile->getFileName();
2312
  update_attached_file($ID, $crtMeta['file']);
 
2313
  if($png2jpgSizes && count($png2jpgSizes)) {
2314
  $crtMeta['sizes'] = $png2jpgSizes;
2315
  } else {
@@ -2493,9 +2570,10 @@ class WPShortPixel {
2493
  }
2494
 
2495
  public function handleRedo() {
2496
- self::log("Handle Redo #{$_GET['attachment_ID']} type {$_GET['type']}");
2497
-
2498
- die(json_encode($this->redo($_GET['attachment_ID'], $_GET['type'])));
 
2499
  }
2500
 
2501
  public function redo($qID, $type = false) {
@@ -3935,14 +4013,14 @@ class WPShortPixel {
3935
  * @return itemHandler ItemHandler object.
3936
  */
3937
  public function onDeleteImage($post_id) {
3938
- $itemHandler = new ShortPixelMetaFacade($post_id);
3939
- $urlsPaths = $itemHandler->getURLsAndPATHs(true, false, true, array(), true, true);
3940
- if(count($urlsPaths['PATHs'])) {
3941
- $this->maybeDumpFromProcessedOnServer($itemHandler, $urlsPaths);
3942
- $this->deleteBackupsAndWebPs($urlsPaths['PATHs']);
3943
- }
3944
- $itemHandler->deleteItemCache();
3945
- return $itemHandler; //return it because we call it also on replace and on replace we need to follow this by deleting SP metadata, on delete it
3946
  }
3947
 
3948
  /** Removes webp and backup from specified paths
@@ -3957,10 +4035,10 @@ class WPShortPixel {
3957
  return;
3958
  }
3959
 
3960
-
3961
  $fs = \wpSPIO()->filesystem();
3962
 
3963
  $backupFolder = trailingslashit($this->getBackupFolder($paths[0]));
 
3964
  foreach($paths as $path) {
3965
  $pos = strrpos($path, ".");
3966
  $pathFile = $fs->getFile($path);
@@ -3979,10 +4057,11 @@ class WPShortPixel {
3979
  $backupFile = $fs->getFile($backupFolder . $fileName);
3980
  if ($backupFile->exists())
3981
  $backupFile->delete();
 
3982
  //@unlink($backupFolder . $fileName);
3983
 
3984
  $backupFile = $fs->getFile($backupFolder . preg_replace("/\." . $extension . "$/i", '@2x.' . $extension, $fileName));
3985
- if ($backupFile->exists())
3986
  $backupFile->delete();
3987
 
3988
  // @unlink($backupFolder . preg_replace("/\." . $extension . "$/i", '@2x.' . $extension, $fileName));
2
  //use ShortPixel\DebugItem as DebugItem;
3
  use ShortPixel\ShortPixelLogger\ShortPixelLogger as Log;
4
  use ShortPixel\Notices\NoticeController as Notices;
5
+ use ShortPixel\FileModel as FileModel;
6
+ use ShortPixel\Directorymodel as DirectoryModel;
7
+ use ShortPixel\ImageModel as ImageModel;
8
 
9
  class WPShortPixel {
10
 
147
 
148
  //toolbar notifications
149
  add_action( 'admin_bar_menu', array( &$this, 'toolbar_shortpixel_processing'), 999 );
150
+ add_action( 'wp_head', array( $this, 'headCSS')); // for the front-end
151
  //deactivate plugin
152
  add_action( 'admin_post_shortpixel_deactivate_plugin', array(&$this, 'deactivatePlugin'));
153
  //only if the key is not yet valid or the user hasn't bought any credits.
314
  'action'=>'Deactivate',
315
  'data'=>'simple-image-sizes/simple_image_sizes.php'
316
  ),
317
+ 'Regenerate Thumbnails and Delete Unused'
318
+ => array(
319
+ 'action' => 'Deactivate',
320
+ 'data' => 'regenerate-thumbnails-and-delete-unused/regenerate_wpregenerate.php',
321
+ ),
322
  //DEACTIVATED TEMPORARILY - it seems that the customers get scared.
323
  /* 'Jetpack by WordPress.com - The Speed up image load times Option'
324
  => array(
506
  function shortPixelJS() {
507
 
508
  if (! \wpSPIO()->env()->is_screen_to_use )
509
+ {
510
+ if (! wpSPIO()->env()->is_front) // exeception if this is called to load from your frontie.
511
+ return; // not ours, don't load JS and such.
512
+ }
513
+ // load everywhere, because we are inconsistent.
514
+ wp_enqueue_style('short-pixel-bar.min.css', plugins_url('/res/css/short-pixel-bar.min.css',SHORTPIXEL_PLUGIN_FILE), array(), SHORTPIXEL_IMAGE_OPTIMISER_VERSION);
515
 
516
  //require_once(ABSPATH . 'wp-admin/includes/screen.php');
517
+ //if(function_exists('get_current_screen')) {
518
+ // $screen = get_current_screen();
519
 
520
+ // if(is_object($screen)) {
521
 
522
+ if ( \wpSPIO()->env()->is_our_screen )
523
+ {
524
+ /*if( in_array($screen->id, array('attachment', 'upload', 'settings_page_wp-shortpixel', 'media_page_wp-short-pixel-bulk', 'media_page_wp-short-pixel-custom'))) { */
525
  wp_enqueue_style('short-pixel.min.css', plugins_url('/res/css/short-pixel.min.css',SHORTPIXEL_PLUGIN_FILE), array(), SHORTPIXEL_IMAGE_OPTIMISER_VERSION);
526
  //modal - used in settings for selecting folder
527
  wp_enqueue_style('short-pixel-modal.min.css', plugins_url('/res/css/short-pixel-modal.min.css',SHORTPIXEL_PLUGIN_FILE), array(), SHORTPIXEL_IMAGE_OPTIMISER_VERSION);
530
  wp_register_style('shortpixel-admin', plugins_url('/res/css/shortpixel-admin.css', SHORTPIXEL_PLUGIN_FILE),array(), SHORTPIXEL_IMAGE_OPTIMISER_VERSION );
531
  wp_enqueue_style('shortpixel-admin');
532
  }
533
+ // }
534
+ // }
535
 
536
 
537
  wp_register_script('shortpixel' . $this->jsSuffix, plugins_url('/res/js/shortpixel' . $this->jsSuffix,SHORTPIXEL_PLUGIN_FILE), array('jquery'), SHORTPIXEL_IMAGE_OPTIMISER_VERSION, true);
596
  'confirmBulkCleanupPending' => __( "Are you sure you want to cleanup the pending metadata?", 'shortpixel-image-optimiser' ),
597
  'alertDeliverWebPAltered' => __( "Warning: Using this method alters the structure of the rendered HTML code (IMG tags get included in PICTURE tags),\nwhich in some rare cases can lead to CSS/JS inconsistencies.\n\nPlease test this functionality thoroughly after activating!\n\nIf you notice any issue, just deactivate it and the HTML will will revert to the previous state.", 'shortpixel-image-optimiser' ),
598
  'alertDeliverWebPUnaltered' => __('This option will serve both WebP and the original image using the same URL, based on the web browser capabilities, please make sure you\'re serving the images from your server and not using a CDN which caches the images.', 'shortpixel-image-optimiser' ),
599
+ 'originalImage' => __('Original image', 'shortpixel-image-optimiser' ),
600
+ 'optimizedImage' => __('Optimized image', 'shortpixel-image-optimiser' ),
601
+ 'loading' => __('Loading...', 'shortpixel-image-optimiser' ),
602
+ //'' => __('', 'shortpixel-image-optimiser' ),
603
+ );
604
  wp_localize_script( 'shortpixel' . $this->jsSuffix, '_spTr', $jsTranslation );
605
  wp_localize_script( 'shortpixel' . $this->jsSuffix, 'ShortPixelConstants', $ShortPixelConstants );
606
  wp_enqueue_script('shortpixel' . $this->jsSuffix);
653
  */
654
  function toolbar_shortpixel_processing( $wp_admin_bar ) {
655
 
656
+ if (! \wpSPIO()->env()->is_screen_to_use )
657
+ return; // not ours, don't load JS and such.
658
+
659
  $extraClasses = " shortpixel-hide";
660
  /*translators: toolbar icon tooltip*/
661
  $id = 'short-pixel-notice-toolbar';
686
 
687
  $args = array(
688
  'id' => 'shortpixel_processing',
689
+ 'title' => '<div id="' . $id . '" title="' . $tooltip . '" ><img alt="' . __('ShortPixel icon','shortpixel-image-optimiser') . '" src="'
690
  . plugins_url( 'res/img/'.$icon, SHORTPIXEL_PLUGIN_FILE ) . '" success-url="' . $successLink . '"><span class="shp-alert">!</span>'
691
  .'<div class="cssload-container"><div class="cssload-speeding-wheel"></div></div></div>',
692
  'href' => $link,
1847
  /** Manual optimization request. This is only called from the Media Library, never from the Custom media */
1848
  public function handleManualOptimization() {
1849
  $imageId = intval($_GET['image_id']);
1850
+ // $cleanup = isset($_GET['cleanup']) ? ; // seems not in use anymore at all.
1851
 
1852
+ Log::addInfo("Handle Manual Optimization #{$imageId}");
1853
 
1854
  switch(substr($imageId, 0, 2)) {
1855
  case "N-":
1898
 
1899
  $itemFile = \wpSPIO()->filesystem()->getAttachedFile($imageId);
1900
 
1901
+ /* when doing manual optimizations, reset retries every time, since you wouldn't want to deny users their button interaction. If a user should not be allowed to run this function, the button / option should not be there. */
1902
+ if ($manual)
1903
+ {
1904
+ $meta = $itemHandler->getMeta();
1905
+ $meta->setRetries(0);
1906
+ $meta->setStatus(\ShortPixelMeta::FILE_STATUS_PENDING);
1907
+ }
1908
+
1909
+
1910
  if(!$manual && 'pdf' === $itemFile->getExtension() && !$this->_settings->optimizePdfs) {
1911
  $ret = array("Status" => ShortPixelAPI::STATUS_SKIP, "Message" => $imageId);
1912
  } else {
2021
  }
2022
 
2023
  /* Gets backup folder of file
2024
+ * @param string $file Filepath - probably ( or directory )
2025
+ * @return string | boolean backupFolder or false.
2026
  */
2027
  public function getBackupFolder($file) {
2028
+ $fs = \wpSPIO()->filesystem();
2029
+ $fsFile = $fs->getFile($file);
2030
+
2031
+ $directory = $this->getBackupFolderInternal($fsFile);
2032
+ if ($directory !== false)
2033
+ return $directory->getPath();
2034
+ else
2035
+ return false;
2036
+ //if(realpath($file)) {
2037
+ //found cases when $file contains for example /wp/../wp-content - clean it up
2038
+ // if($ret) return $ret;
2039
+ // }
2040
  //another chance at glory, maybe cleanup was too much? (we tried first the cleaned up version for historical reason, don't disturb the sleeping dragon, right? :))
2041
+ //return $this->getBackupFolderInternal($file);
2042
  }
2043
 
2044
  /** Gets backup from file
2045
+ * @param FileModel $file Filename
2046
+ * @return DirectoryModel
2047
  */
2048
+ private function getBackupFolderInternal(FileModel $file) {
2049
+ // $fileExtension = strtolower(substr($file,strrpos($file,".")+1));
2050
+ $fs = \wpSPIO()->filesystem();
2051
  $SubDir = ShortPixelMetaFacade::returnSubDir($file);
2052
  $SubDirOld = ShortPixelMetaFacade::returnSubDirOld($file);
2053
+ //$basename = ShortPixelAPI::MB_basename($file);
2054
+ $basename = $file->getFileName();
2055
 
2056
+ // $backupFolder = $file->getBackUpDirectory();
2057
+
2058
+ $backupFile = $file->getBackupFile();
2059
+ if ($backupFile)
2060
+ {
2061
+ $backupFolder = $backupFile->getFileDir();
2062
+ return $backupFolder;
2063
+ }
2064
+
2065
+ // Try to unholy old solutions
2066
+ $backupFile = $fs->getFile(SHORTPIXEL_BACKUP_FOLDER . '/'. $SubDir . '/' . $basename);
2067
+ if ($backupFile->exists())
2068
+ {
2069
+ return $backupFile->getFileDir();
2070
+ }
2071
+
2072
+ $backupFile = $fs->getFile(SHORTPIXEL_BACKUP_FOLDER . '/'. $SubDirOld . '/' . $basename);
2073
+ if ($backupFile->exists())
2074
+ {
2075
+ return $backupFile->getFileDir();
2076
+ }
2077
+
2078
+ // and then this abomination.
2079
+ $backupFile = $fs->getFile(SHORTPIXEL_BACKUP_FOLDER . '/'. date("Y") . "/" . date("m") . '/' . $basename);
2080
+ if ($backupFile->exists())
2081
+ {
2082
+ return $backupFile->getFileDir();
2083
+ }
2084
+
2085
+ Log::addError('Backup Directory could not be established! ', array($file->getFullPath()) );
2086
+ return false; // $backupFile->getFileDir(); // if all else fails.
2087
+
2088
+
2089
+ /* Reference:
2090
  if ( !file_exists(SHORTPIXEL_BACKUP_FOLDER . '/' . $SubDir . ShortPixelAPI::MB_basename($file))
2091
  && !file_exists(SHORTPIXEL_BACKUP_FOLDER . '/' . date("Y") . "/" . date("m") . "/" . ShortPixelAPI::MB_basename($file)) ) {
2092
  $SubDir = $SubDirOld; //maybe the folder was saved with the old method that returned the full path if the wp-content was not inside the root of the site.
2103
  }
2104
  }
2105
  return SHORTPIXEL_BACKUP_FOLDER . '/' . $SubDir;
2106
+ */
2107
  }
2108
 
2109
  /** Gets BackupFolder. If that doesn't work, search thumbs for a backupFolder
2207
  $image = $rawMeta['file']; // relative file
2208
  $imageUrl = wp_get_attachment_url($attachmentID); // URL can be anything.
2209
 
2210
+ Log::addDebug('PHP2JPG - OriginFile -- ' . $fsFile->getFullPath() );
2211
 
2212
  $imageName = $fsFile->getFileName();
2213
 
2312
  if ($bkOrigFile && $bkOrigFile->exists())
2313
  $bkOrigFile->move($origFile);
2314
 
2315
+ Log::addDebug('Restore result - Backup original file', array($bkOrigFile, $origFile));
2316
  }
2317
  //$this->renameWithRetina($bkFile, $file);
2318
  if (! $bkFile->move($fsFile))
2386
  if($png2jpgMain) {
2387
  $crtMeta['file'] = trailingslashit(dirname($crtMeta['file'])) . $fsFile->getFileName();
2388
  update_attached_file($ID, $crtMeta['file']);
2389
+
2390
  if($png2jpgSizes && count($png2jpgSizes)) {
2391
  $crtMeta['sizes'] = $png2jpgSizes;
2392
  } else {
2570
  }
2571
 
2572
  public function handleRedo() {
2573
+ Log::addDebug("Handle Redo #{$_GET['attachment_ID']} type {$_GET['type']}");
2574
+ $attach_id = intval($_GET['attachment_ID']);
2575
+ $type = sanitize_text_field($_GET['type']);
2576
+ die(json_encode($this->redo($attach_id, $type)));
2577
  }
2578
 
2579
  public function redo($qID, $type = false) {
4013
  * @return itemHandler ItemHandler object.
4014
  */
4015
  public function onDeleteImage($post_id) {
4016
+ Log::addDebug('onDeleteImage - Image Removal Detected ' . $post_id);
4017
+ \wpSPIO()->loadModel('image');
4018
+
4019
+ $imageObj = new ImageModel();
4020
+ $imageObj->setbyPostID($post_id);
4021
+
4022
+ return $imageObj->delete();
4023
+
4024
  }
4025
 
4026
  /** Removes webp and backup from specified paths
4035
  return;
4036
  }
4037
 
 
4038
  $fs = \wpSPIO()->filesystem();
4039
 
4040
  $backupFolder = trailingslashit($this->getBackupFolder($paths[0]));
4041
+ Log::addDebug('Removing from Backup Folder - ' . $backupFolder);
4042
  foreach($paths as $path) {
4043
  $pos = strrpos($path, ".");
4044
  $pathFile = $fs->getFile($path);
4057
  $backupFile = $fs->getFile($backupFolder . $fileName);
4058
  if ($backupFile->exists())
4059
  $backupFile->delete();
4060
+
4061
  //@unlink($backupFolder . $fileName);
4062
 
4063
  $backupFile = $fs->getFile($backupFolder . preg_replace("/\." . $extension . "$/i", '@2x.' . $extension, $fileName));
4064
+ if ($backupFile->exists() && $backupFile->is_file())
4065
  $backupFile->delete();
4066
 
4067
  // @unlink($backupFolder . preg_replace("/\." . $extension . "$/i", '@2x.' . $extension, $fileName));
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: compressor, image, compression, optimize, image optimizer, image optimiser
4
  Requires at least: 3.2.0
5
  Tested up to: 5.3
6
  Requires PHP: 5.3
7
- Stable tag: 4.15.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -261,6 +261,19 @@ define("SHORTPIXEL_EXPERIMENTAL_SECURICACHE", true); // adds timestamps to URLS
261
 
262
  == Changelog ==
263
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  = 4.15.2 =
265
 
266
  Release date: 28th November 2019
4
  Requires at least: 3.2.0
5
  Tested up to: 5.3
6
  Requires PHP: 5.3
7
+ Stable tag: 4.15.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
261
 
262
  == Changelog ==
263
 
264
+ = 4.15.3 =
265
+
266
+ Release date: 20th December 2019
267
+ * Hide the "Process in front-end" option if "Optimize media on upload" unchecked
268
+ * Add ALT text for plugin images in Admin
269
+ * Moved CSS for the admin bar to the actual admin bar stylesheet, other css no longer loading on those pages
270
+ * Fixes for windows specific paths
271
+ * Fixed: warning flood when using old version of S3-offload
272
+ * Fix for frontend and error shortpixel in top toolbar
273
+ * Fixed: Pancake menu now showing proper actions ( none ) if backup is not there.
274
+ * Fixed: Windows paths in wp-short-pixel getBackupFolderInternal
275
+ * Language – 4 new strings added, 0 updated, 0 fuzzied, and 0 obsoleted
276
+
277
  = 4.15.2 =
278
 
279
  Release date: 28th November 2019
res/css/short-pixel-bar.css CHANGED
@@ -14,8 +14,9 @@ li.shortpixel-toolbar-processing > a.ab-item > div > img,
14
  #wpadminbar li.shortpixel-toolbar-processing > a.ab-item > div > img{
15
  margin-right: 2px;
16
  margin-top: 6px;
 
17
  }
18
- li.shortpixel-toolbar-processing > a.ab-item > div > span.shp-alert,
19
  #wpadminbar li.shortpixel-toolbar-processing > a.ab-item > div > span.shp-alert{
20
  display:none;
21
  }
@@ -23,14 +24,65 @@ li.shortpixel-toolbar-processing.shortpixel-alert > a.ab-item > div > span.shp-a
23
  #wpadminbar li.shortpixel-toolbar-processing.shortpixel-alert > a.ab-item > div > span.shp-alert{
24
  display: inline;
25
  font-size: 26px;
 
26
  color: red;
27
  font-weight: bold;
28
- vertical-align: top;
29
  }
30
  li.shortpixel-toolbar-processing.shortpixel-alert > a.ab-item > div,
31
  #wpadminbar li.shortpixel-toolbar-processing.shortpixel-alert > a.ab-item > div{
32
  background-image: none;
33
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  .sp-quota-exceeded-alert {
35
  background-color: #fff;
36
  border-left: 4px solid #ff0000;
@@ -66,4 +118,3 @@ li.sp-conflict-plugins-list {
66
  li.sp-conflict-plugins-list a.button {
67
  margin-left: 10px;
68
  }
69
-
14
  #wpadminbar li.shortpixel-toolbar-processing > a.ab-item > div > img{
15
  margin-right: 2px;
16
  margin-top: 6px;
17
+ vertical-align: top;
18
  }
19
+ li.shortpixel-toolbar-processing span.shp-alert,
20
  #wpadminbar li.shortpixel-toolbar-processing > a.ab-item > div > span.shp-alert{
21
  display:none;
22
  }
24
  #wpadminbar li.shortpixel-toolbar-processing.shortpixel-alert > a.ab-item > div > span.shp-alert{
25
  display: inline;
26
  font-size: 26px;
27
+ line-height: 26px;
28
  color: red;
29
  font-weight: bold;
30
+ vertical-align: middle;
31
  }
32
  li.shortpixel-toolbar-processing.shortpixel-alert > a.ab-item > div,
33
  #wpadminbar li.shortpixel-toolbar-processing.shortpixel-alert > a.ab-item > div{
34
  background-image: none;
35
  }
36
+
37
+ #wpadminbar .shortpixel-toolbar-processing .cssload-container {
38
+ width: 100%;
39
+ height: 24px;
40
+ text-align: center;
41
+ position: absolute;
42
+ top: 0px;
43
+ left: -1px;
44
+ }
45
+ #wpadminbar .shortpixel-toolbar-processing.shortpixel-quota-exceeded .cssload-container,
46
+ #wpadminbar .shortpixel-toolbar-processing.shortpixel-alert .cssload-container{
47
+ display: none;
48
+ }
49
+
50
+ #wpadminbar .shortpixel-toolbar-processing .cssload-speeding-wheel {
51
+ width: 24px;
52
+ height: 24px;
53
+ opacity: 0.7;
54
+ margin: 0 auto;
55
+ border: 4px solid rgb(28,191,203);
56
+ border-radius: 50%;
57
+ border-left-color: transparent;
58
+ animation: cssload-spin 2000ms infinite linear;
59
+ -o-animation: cssload-spin 2000ms infinite linear;
60
+ -ms-animation: cssload-spin 2000ms infinite linear;
61
+ -webkit-animation: cssload-spin 2000ms infinite linear;
62
+ -moz-animation: cssload-spin 2000ms infinite linear;
63
+ }
64
+
65
+ @keyframes cssload-spin {
66
+ 100%{ transform: rotate(360deg); transform: rotate(360deg); }
67
+ }
68
+
69
+ @-o-keyframes cssload-spin {
70
+ 100%{ -o-transform: rotate(360deg); transform: rotate(360deg); }
71
+ }
72
+
73
+ @-ms-keyframes cssload-spin {
74
+ 100%{ -ms-transform: rotate(360deg); transform: rotate(360deg); }
75
+ }
76
+
77
+ @-webkit-keyframes cssload-spin {
78
+ 100%{ -webkit-transform: rotate(360deg); transform: rotate(360deg); }
79
+ }
80
+
81
+ @-moz-keyframes cssload-spin {
82
+ 100%{ -moz-transform: rotate(360deg); transform: rotate(360deg); }
83
+ }
84
+
85
+
86
  .sp-quota-exceeded-alert {
87
  background-color: #fff;
88
  border-left: 4px solid #ff0000;
118
  li.sp-conflict-plugins-list a.button {
119
  margin-left: 10px;
120
  }
 
res/css/short-pixel-bar.min.css CHANGED
@@ -1 +1 @@
1
- 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}.short-pixel-notice-icon{float:left;margin:10px 10px 10px 0}.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}
1
+ #wpadminbar li.shortpixel-toolbar-processing>a.ab-item>div,li.shortpixel-toolbar-processing>a.ab-item>div{height:33px;margin-top:-1px;padding:0 3px}#wpadminbar li.shortpixel-toolbar-processing>a.ab-item>div>img,li.shortpixel-toolbar-processing>a.ab-item>div>img{margin-right:2px;margin-top:6px;vertical-align:top}#wpadminbar li.shortpixel-toolbar-processing>a.ab-item>div>span.shp-alert,li.shortpixel-toolbar-processing span.shp-alert{display:none}#wpadminbar li.shortpixel-toolbar-processing.shortpixel-alert>a.ab-item>div>span.shp-alert,li.shortpixel-toolbar-processing.shortpixel-alert>a.ab-item>div>span.shp-alert{display:inline;font-size:26px;line-height:26px;color:red;font-weight:700;vertical-align:middle}#wpadminbar li.shortpixel-toolbar-processing.shortpixel-alert>a.ab-item>div,li.shortpixel-toolbar-processing.shortpixel-alert>a.ab-item>div{background-image: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-alert .cssload-container,#wpadminbar .shortpixel-toolbar-processing.shortpixel-quota-exceeded .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 2s infinite linear;-o-animation:cssload-spin 2s infinite linear;-ms-animation:cssload-spin 2s infinite linear;-webkit-animation:cssload-spin 2s infinite linear;-moz-animation:cssload-spin 2s 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)}}.sp-quota-exceeded-alert{background-color:#fff;border-left:4px solid red;box-shadow:0 1px 1px 0 rgba(0,0,0,.1);padding:1px 12px}.shortpixel-clearfix{width:100%;float:left}.short-pixel-notice-icon{float:left;margin:10px 10px 10px 0}.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}
res/css/short-pixel.css CHANGED
@@ -355,7 +355,7 @@ div.shortpixel-rate-us > a:focus {
355
  padding:0px 5px;
356
  margin-bottom: 4px;
357
  height:20px;
358
- line-height:19px;
359
  float:right;
360
  }
361
 
@@ -728,51 +728,3 @@ section#tab-resources p {
728
  .sp-column-actions-template + .sp-column-info {
729
  display: none;
730
  }
731
-
732
- #wpadminbar .shortpixel-toolbar-processing .cssload-container {
733
- width: 100%;
734
- height: 24px;
735
- text-align: center;
736
- position: absolute;
737
- top: 0px;
738
- left: -1px;
739
- }
740
- #wpadminbar .shortpixel-toolbar-processing.shortpixel-quota-exceeded .cssload-container,
741
- #wpadminbar .shortpixel-toolbar-processing.shortpixel-alert .cssload-container{
742
- display: none;
743
- }
744
-
745
- #wpadminbar .shortpixel-toolbar-processing .cssload-speeding-wheel {
746
- width: 24px;
747
- height: 24px;
748
- opacity: 0.7;
749
- margin: 0 auto;
750
- border: 4px solid rgb(28,191,203);
751
- border-radius: 50%;
752
- border-left-color: transparent;
753
- animation: cssload-spin 2000ms infinite linear;
754
- -o-animation: cssload-spin 2000ms infinite linear;
755
- -ms-animation: cssload-spin 2000ms infinite linear;
756
- -webkit-animation: cssload-spin 2000ms infinite linear;
757
- -moz-animation: cssload-spin 2000ms infinite linear;
758
- }
759
-
760
- @keyframes cssload-spin {
761
- 100%{ transform: rotate(360deg); transform: rotate(360deg); }
762
- }
763
-
764
- @-o-keyframes cssload-spin {
765
- 100%{ -o-transform: rotate(360deg); transform: rotate(360deg); }
766
- }
767
-
768
- @-ms-keyframes cssload-spin {
769
- 100%{ -ms-transform: rotate(360deg); transform: rotate(360deg); }
770
- }
771
-
772
- @-webkit-keyframes cssload-spin {
773
- 100%{ -webkit-transform: rotate(360deg); transform: rotate(360deg); }
774
- }
775
-
776
- @-moz-keyframes cssload-spin {
777
- 100%{ -moz-transform: rotate(360deg); transform: rotate(360deg); }
778
- }
355
  padding:0px 5px;
356
  margin-bottom: 4px;
357
  height:20px;
358
+
359
  float:right;
360
  }
361
 
728
  .sp-column-actions-template + .sp-column-info {
729
  display: none;
730
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
res/css/short-pixel.min.css CHANGED
@@ -1 +1 @@
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;line-height:28px;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}.sp-notice img{vertical-align:bottom}@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}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}.twentytwenty-horizontal .twentytwenty-before-label:before,.twentytwenty-horizontal .twentytwenty-after-label:before{font-family:inherit;font-size:16px}.short-pixel-bulk-page p{margin:.6em 0}.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;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:19px;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{display:inline-block;padding-top:6px}.wp-core-ui .bulk-play a.button .bulk-btn-txt{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}.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;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 !important}article.sp-tabs section:first-child{z-index:1}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}#png2jpg:not(:checked) ~ #png2jpgForce,#png2jpg:not(:checked) ~ label[for=png2jpgForce]{display:none}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)}}
1
+ .reset{font-weight:400;font-style:normal}.clearfix:after,.clearfix:before{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;line-height:28px;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,.2);z-index:1}.sp-dropdown-content a{color:#000;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}.sp-notice img{vertical-align:bottom}@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}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 #fff;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:700}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:focus,div.shortpixel-rate-us>a:hover{outline:0;border-style:none}.sp-loading-small{margin-top:2px;float:left;margin-right:5px}.twentytwenty-horizontal .twentytwenty-after-label:before,.twentytwenty-horizontal .twentytwenty-before-label:before{font-family:inherit;font-size:16px}.short-pixel-bulk-page p{margin:.6em 0}.short-pixel-bulk-page form.start{display:table;content:" ";width:98%;background-color:#fff;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:700;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:700;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;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;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{display:inline-block;padding-top:6px}.wp-core-ui .bulk-play a.button .bulk-btn-txt{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}.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:700}.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:700;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:700;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:400}.bulk-slider{display:table;margin:0 auto}.bulk-slider .bulk-slide{margin:0 auto;padding-left:120px;display:inline-block;font-weight:700}.bulk-slider .img-optimized,.bulk-slider .img-original{display:inline-block;margin-right:20px;text-align:center}.bulk-slider .img-optimized div,.bulk-slider .img-original div{max-height:450px;overflow:hidden}.bulk-slider .img-optimized img,.bulk-slider .img-original 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:700}.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:700;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,.1)}article.sp-tabs section .wp-shortpixel-tab-content{visibility:hidden}article.sp-tabs section.sel-tab .wp-shortpixel-tab-content{visibility:visible!important}article.sp-tabs section:first-child{z-index:1}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}.deliverWebpAlteringTypes,.deliverWebpSettings,.deliverWebpTypes{display:none}.deliverWebpTypes .sp-notice{color:red}.deliverWebpSettings{margin:16px 0}.deliverWebpSettings input:disabled+label{color:#818181}.deliverWebpAlteringTypes,.deliverWebpTypes{margin:16px 0 16px 16px}#png2jpg:not(:checked)~#png2jpgForce,#png2jpg:not(:checked)~label[for=png2jpgForce]{display:none}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}
res/css/shortpixel-admin.css CHANGED
@@ -130,3 +130,79 @@
130
  padding: 6px 15px;
131
  height: auto;
132
  float: none; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  padding: 6px 15px;
131
  height: auto;
132
  float: none; }
133
+
134
+ body.debug-model-active {
135
+ overflow: hidden; }
136
+
137
+ .debugInfo .content.wrapper {
138
+ display: none; }
139
+ .debugInfo .content.wrapper li strong {
140
+ margin-right: 15px; }
141
+ .debugInfo .content.wrapper ul {
142
+ margin: 25px 0; }
143
+
144
+ .debug-modal {
145
+ display: none;
146
+ width: 75%;
147
+ max-width: 90%;
148
+ height: auto;
149
+ max-height: 90vh;
150
+ overflow: hidden;
151
+ border-radius: 4px;
152
+ box-shadow: -3px -3px 10px rgba(0, 0, 0, 0.5);
153
+ position: fixed;
154
+ left: 20%;
155
+ top: 10%;
156
+ z-index: 10020;
157
+ display: none;
158
+ background: #ffffff; }
159
+ .debug-modal.success {
160
+ border: 4px solid green; }
161
+ .debug-modal.error {
162
+ border: 4px solid red; }
163
+ .debug-modal.error h3 {
164
+ background-color: #ff0000; }
165
+ .debug-modal .content-area {
166
+ background-color: #fff; }
167
+ .debug-modal .modal_header {
168
+ text-align: center;
169
+ font-size: 16px;
170
+ font-weight: 700;
171
+ background-color: #f3f3f3;
172
+ border-bottom: 1px solid #ccc;
173
+ padding: 8px 5px;
174
+ cursor: move; }
175
+ .debug-modal .modal_header h3 {
176
+ margin: 0;
177
+ color: #444;
178
+ font-weight: 400;
179
+ padding: 0;
180
+ text-align: center;
181
+ text-shadow: none;
182
+ font-size: 16px; }
183
+ .debug-modal .modal_header .modal_close {
184
+ position: absolute;
185
+ right: 5px;
186
+ top: 8px;
187
+ width: 20px;
188
+ height: 20px;
189
+ cursor: pointer;
190
+ color: #444; }
191
+ .debug-modal .modal_header .modal_close:hover {
192
+ cursor: pointer;
193
+ color: #111; }
194
+ .debug-modal .content, .debug-modal .modal_content {
195
+ padding: 5px 15px 10px;
196
+ overflow-y: auto; }
197
+
198
+ .debugModal_overlay {
199
+ background: #000;
200
+ left: 0;
201
+ right: 0;
202
+ bottom: 0;
203
+ top: 0;
204
+ height: 100%;
205
+ position: fixed;
206
+ opacity: 0.7;
207
+ z-index: 10000;
208
+ display: none; }
res/js/shortpixel.js CHANGED
@@ -8,6 +8,7 @@ jQuery(document).ready(function(){ShortPixel.init();});
8
  var ShortPixel = function() {
9
 
10
  function init() {
 
11
  if (typeof ShortPixel.API_KEY !== 'undefined') return; //was initialized by the 10 sec. setTimeout, rare but who knows, might happen on very slow connections...
12
  //are we on media list?
13
  if( jQuery('table.wp-list-table.media').length > 0) {
@@ -64,7 +65,7 @@ var ShortPixel = function() {
64
  }
65
 
66
  function validateKey(button){
67
- console.log('validate');
68
  jQuery('#valid').val('validate');
69
 
70
  jQuery(button).parents('form').submit();
@@ -729,7 +730,7 @@ var ShortPixel = function() {
729
  var modalShade = jQuery('.sp-modal-shade');
730
 
731
  if(!sideBySide) {
732
- jQuery("#spCompareSlider").html('<img class="spUploadCompareOriginal"/><img class="spUploadCompareOptimized"/>');
733
  }
734
  //calculate the modal size
735
  width = Math.max(350, Math.min(800, (width < 350 ? (width + 25) * 2 : (height < 150 ? width + 25 : width))));
@@ -852,6 +853,7 @@ var ShortPixel = function() {
852
 
853
  function showToolBarAlert($status, $message, id) {
854
  var robo = jQuery("li.shortpixel-toolbar-processing");
 
855
  switch($status) {
856
  case ShortPixel.STATUS_QUOTA_EXCEEDED:
857
  if( window.location.href.search("wp-short-pixel-bulk") > 0
@@ -890,8 +892,18 @@ function showToolBarAlert($status, $message, id) {
890
  }
891
  robo.removeClass("shortpixel-hide");
892
  }
893
- function hideToolBarAlert () {
894
- jQuery("li.shortpixel-toolbar-processing.shortpixel-processing").addClass("shortpixel-hide");
 
 
 
 
 
 
 
 
 
 
895
  }
896
 
897
  function hideQuotaExceededToolBarAlert () {
@@ -933,6 +945,7 @@ function checkBulkProgress() {
933
  adminUrl = ShortPixel.convertPunycode(adminUrl);
934
  }
935
 
 
936
  if( url.search(adminUrl + "upload.php") < 0
937
  && url.search(adminUrl + "edit.php") < 0
938
  && url.search(adminUrl + "edit-tags.php") < 0
@@ -943,7 +956,7 @@ function checkBulkProgress() {
943
  ) {
944
  hideToolBarAlert();
945
  return;
946
- }
947
 
948
  //if i'm the bulk processor and i'm not the bulk page and a bulk page comes around, leave the bulk processor role
949
  if(ShortPixel.bulkProcessor == true && window.location.href.search("wp-short-pixel-bulk") < 0
@@ -1035,7 +1048,8 @@ function checkBulkProcessingCallApi(){
1035
  case ShortPixel.STATUS_EMPTY_QUEUE:
1036
  console.log(data["Message"]);
1037
  clearBulkProcessor(); //nothing to process, leave the role. Next page load will check again
1038
- hideToolBarAlert();
 
1039
  var progress = jQuery("#bulk-progress");
1040
  if(isBulkPage && progress.length && data["BulkStatus"] != '2') {
1041
  progressUpdate(100, "Bulk finished!");
@@ -1177,7 +1191,7 @@ function setCellMessage(id, message, actions){
1177
  }
1178
 
1179
  function manualOptimization(id, cleanup) {
1180
- setCellMessage(id, "<img src='" + ShortPixel.WP_PLUGIN_URL + "/res/img/loading.gif' class='sp-loading-small'>Image waiting to be processed", "");
1181
  jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");
1182
  jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-alert");
1183
  jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");
@@ -1217,7 +1231,7 @@ function manualOptimization(id, cleanup) {
1217
  }
1218
 
1219
  function reoptimize(id, type) {
1220
- setCellMessage(id, "<img src='" + ShortPixel.WP_PLUGIN_URL + "/res/img/loading.gif' class='sp-loading-small'>Image waiting to be reprocessed", "");
1221
  jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");
1222
  jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");
1223
  var data = { action : 'shortpixel_redo',
@@ -1236,7 +1250,7 @@ function reoptimize(id, type) {
1236
  }
1237
 
1238
  function optimizeThumbs(id) {
1239
- setCellMessage(id, "<img src='" + ShortPixel.WP_PLUGIN_URL + "/res/img/loading.gif' class='sp-loading-small'>" + _spTr.imageWaitOptThumbs, "");
1240
  jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");
1241
  jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");
1242
  var data = { action : 'shortpixel_optimize_thumbs',
8
  var ShortPixel = function() {
9
 
10
  function init() {
11
+
12
  if (typeof ShortPixel.API_KEY !== 'undefined') return; //was initialized by the 10 sec. setTimeout, rare but who knows, might happen on very slow connections...
13
  //are we on media list?
14
  if( jQuery('table.wp-list-table.media').length > 0) {
65
  }
66
 
67
  function validateKey(button){
68
+ // console.log('validate');
69
  jQuery('#valid').val('validate');
70
 
71
  jQuery(button).parents('form').submit();
730
  var modalShade = jQuery('.sp-modal-shade');
731
 
732
  if(!sideBySide) {
733
+ jQuery("#spCompareSlider").html('<img alt="' + _spTr.originalImage + '" class="spUploadCompareOriginal"/><img alt="' + _spTr.optimizedImage + '" class="spUploadCompareOptimized"/>');
734
  }
735
  //calculate the modal size
736
  width = Math.max(350, Math.min(800, (width < 350 ? (width + 25) * 2 : (height < 150 ? width + 25 : width))));
853
 
854
  function showToolBarAlert($status, $message, id) {
855
  var robo = jQuery("li.shortpixel-toolbar-processing");
856
+
857
  switch($status) {
858
  case ShortPixel.STATUS_QUOTA_EXCEEDED:
859
  if( window.location.href.search("wp-short-pixel-bulk") > 0
892
  }
893
  robo.removeClass("shortpixel-hide");
894
  }
895
+ function hideToolBarAlert (status) {
896
+ var $toolbar = jQuery("li.shortpixel-toolbar-processing.shortpixel-processing");
897
+
898
+ // When Queue is empty, but we have errors, don't hide the toolbar.
899
+ if (ShortPixel.STATUS_EMPTY_QUEUE == status)
900
+ {
901
+ if ($toolbar.hasClass("shortpixel-alert") || $toolbar.hasClass("shortpixel-quota-exceeded") )
902
+ {
903
+ return;
904
+ }
905
+ }
906
+ $toolbar.addClass("shortpixel-hide");
907
  }
908
 
909
  function hideQuotaExceededToolBarAlert () {
945
  adminUrl = ShortPixel.convertPunycode(adminUrl);
946
  }
947
 
948
+ /* NO. If it shouldn't go, this JS file shouldn't load.
949
  if( url.search(adminUrl + "upload.php") < 0
950
  && url.search(adminUrl + "edit.php") < 0
951
  && url.search(adminUrl + "edit-tags.php") < 0
956
  ) {
957
  hideToolBarAlert();
958
  return;
959
+ } */
960
 
961
  //if i'm the bulk processor and i'm not the bulk page and a bulk page comes around, leave the bulk processor role
962
  if(ShortPixel.bulkProcessor == true && window.location.href.search("wp-short-pixel-bulk") < 0
1048
  case ShortPixel.STATUS_EMPTY_QUEUE:
1049
  console.log(data["Message"]);
1050
  clearBulkProcessor(); //nothing to process, leave the role. Next page load will check again
1051
+
1052
+ hideToolBarAlert(data["Status"]);
1053
  var progress = jQuery("#bulk-progress");
1054
  if(isBulkPage && progress.length && data["BulkStatus"] != '2') {
1055
  progressUpdate(100, "Bulk finished!");
1191
  }
1192
 
1193
  function manualOptimization(id, cleanup) {
1194
+ setCellMessage(id, "<img src='" + ShortPixel.WP_PLUGIN_URL + "/res/img/loading.gif' alt='" + _spTr.loading + "' class='sp-loading-small'>Image waiting to be processed", "");
1195
  jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");
1196
  jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-alert");
1197
  jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");
1231
  }
1232
 
1233
  function reoptimize(id, type) {
1234
+ setCellMessage(id, "<img src='" + ShortPixel.WP_PLUGIN_URL + "/res/img/loading.gif' alt='" + _spTr.loading + "' class='sp-loading-small'>Image waiting to be reprocessed", "");
1235
  jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");
1236
  jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");
1237
  var data = { action : 'shortpixel_redo',
1250
  }
1251
 
1252
  function optimizeThumbs(id) {
1253
+ setCellMessage(id, "<img src='" + ShortPixel.WP_PLUGIN_URL + "/res/img/loading.gif' alt='" + _spTr.loading + "' class='sp-loading-small'>" + _spTr.imageWaitOptThumbs, "");
1254
  jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");
1255
  jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");
1256
  var data = { action : 'shortpixel_optimize_thumbs',
res/js/shortpixel.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(){ShortPixel.init()});var ShortPixel=function(){function N(){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>'+SPstringFormat(_spTr.changeMLToListMode,'<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 o(V){for(var W in V){ShortPixel[W]=V[W]}}function x(V){return/^\w+([\.+-]?\w+)*@\w+([\.-]?\w+)*(\.\w{1,63})+$/.test(V)}function p(){var V=jQuery("#pluginemail").val();if(ShortPixel.isEmailValid(V)){jQuery("#request_key").removeClass("disabled")}jQuery("#request_key").attr("href",jQuery("#request_key").attr("href").split("?")[0]+"?pluginemail="+V)}function a(V){console.log("validate");jQuery("#valid").val("validate");jQuery(V).parents("form").submit()}jQuery("#key").keypress(function(V){if(V.which==13){jQuery("#valid").val("validate")}});function Q(V){if(jQuery(V).is(":checked")){jQuery("#width,#height").removeAttr("disabled")}else{jQuery("#width,#height").attr("disabled","disabled")}}function k(){if(!jQuery('input[name="removeExif"]').is(":checked")&&jQuery('input[name="png2jpg"]').is(":checked")){jQuery(".exif_warning").fadeIn()}else{jQuery(".exif_warning").fadeOut()}}function e(){var V=0;if(typeof document.wp_shortpixel_options!=="undefined"){V=document.wp_shortpixel_options.compressionType}for(var W=0,X=null;W<V.length;W++){V[W].onclick=function(){if(this!==X){X=this}if(typeof ShortPixel.setupGeneralTabAlert!=="undefined"){return}alert(_spTr.alertOnlyAppliesToNewImages);ShortPixel.setupGeneralTabAlert=1}}ShortPixel.enableResize("#resize");jQuery("#resize").change(function(){Q(this)});jQuery(".resize-sizes").blur(function(aa){var ab=jQuery(aa.target);if(ShortPixel.resizeSizesAlert==ab.val()){return}ShortPixel.resizeSizesAlert=ab.val();var Z=jQuery("#min-"+ab.attr("name")).val();var Y=jQuery("#min-"+ab.attr("name")).data("nicename");if(ab.val()<Math.min(Z,1024)){if(Z>1024){alert(SPstringFormat(_spTr.pleaseDoNotSetLesser1024,Y))}else{alert(SPstringFormat(_spTr.pleaseDoNotSetLesserSize,Y,Y,Z))}aa.preventDefault();ab.focus()}else{this.defaultValue=ab.val()}});jQuery(".shortpixel-confirm").click(function(Z){var Y=confirm(Z.target.getAttribute("data-confirm"));if(!Y){Z.preventDefault();return false}return true});jQuery('input[name="removeExif"], input[name="png2jpg"]').on("change",function(){ShortPixel.checkExifWarning()});ShortPixel.checkExifWarning()}function H(){jQuery(".wp-shortpixel-options .shortpixel-key-valid").css("display","none");jQuery(".wp-shortpixel-options button#validate").css("display","inline-block")}function y(){jQuery("input.remove-folder-button").click(function(){var W=jQuery(this).data("value");var V=confirm(SPstringFormat(_spTr.areYouSureStopOptimizing,W));if(V==true){jQuery("#removeFolder").val(W);jQuery("#wp_shortpixel_options").submit()}});jQuery("input.recheck-folder-button").click(function(){var W=jQuery(this).data("value");var V=confirm(SPstringFormat(_spTr.areYouSureStopOptimizing,W));if(V==true){jQuery("#recheckFolder").val(W);jQuery("#wp_shortpixel_options").submit()}})}function P(V){var W=jQuery("#"+(V.checked?"total":"main")+"ToProcess").val();jQuery("div.bulk-play span.total").text(W);jQuery("#displayTotal").text(W)}function g(){ShortPixel.adjustSettingsTabs();ShortPixel.setupGeneralTab();jQuery(window).resize(function(){ShortPixel.adjustSettingsTabs()});jQuery("article.sp-tabs a.tab-link").click(function(W){var V=jQuery(W.target).data("id");ShortPixel.switchSettingsTab(V)});jQuery("input[type=radio][name=deliverWebpType]").change(function(){if(this.value=="deliverWebpAltered"){if(window.confirm(_spTr.alertDeliverWebPAltered)){var V=jQuery("input[type=radio][name=deliverWebpAlteringType]:checked").length;if(V==0){jQuery("#deliverWebpAlteredWP").prop("checked",true)}}else{jQuery(this).prop("checked",false)}}else{if(this.value=="deliverWebpUnaltered"){window.alert(_spTr.alertDeliverWebPUnaltered)}}})}function C(aa){var X=aa.replace("tab-",""),V="",Z=jQuery("section#"+aa);jQuery('input[name="display_part"]').val(X);var Y=window.location.href.toString();if(Y.indexOf("?")>0){var W=Y.substring(0,Y.indexOf("?"));W+="?"+jQuery.param({page:"wp-shortpixel-settings",part:X});window.history.replaceState({},document.title,W)}if(Z.length>0){jQuery("section").removeClass("sel-tab");jQuery("section .wp-shortpixel-tab-content").fadeOut(50);jQuery(Z).addClass("sel-tab");ShortPixel.adjustSettingsTabs();jQuery(Z).find(".wp-shortpixel-tab-content").fadeIn(50)}if(typeof HS!=="undefined"&&typeof HS.beacon.suggest!=="undefined"){switch(X){case"settings":V=shortpixel_suggestions_settings;break;case"adv-settings":V=shortpixel_suggestions_adv_settings;break;case"cloudflare":case"stats":V=shortpixel_suggestions_cloudflare;break;default:break}HS.beacon.suggest(V)}}function D(){var V=jQuery("section.sel-tab").height()+90;jQuery(".section-wrapper").css("height",V)}function R(){var V={action:"shortpixel_dismiss_media_alert"};jQuery.get(ShortPixel.AJAX_URL,V,function(W){V=JSON.parse(W);if(V.Status=="success"){jQuery("#short-pixel-media-alert").hide()}})}function w(){jQuery("#shortpixel-hs-button-blind").remove();jQuery("#shortpixel-hs-tools").remove();jQuery("#hs-beacon").remove();jQuery("#botbutton").remove();jQuery("#shortpixel-hs-blind").remove()}function q(){w();dismissShortPixelNotice("help")}function m(){var V={action:"shortpixel_check_quota"};jQuery.get(ShortPixel.AJAX_URL,V,function(){console.log("quota refreshed")})}function G(V){if(V.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(Z,X,W,Y,V){return(X>0?"<div class='sp-column-info'>"+_spTr.reducedBy+" <strong><span class='percent'>"+X+"%</span></strong> ":"")+(X>0&&X<5?"<br>":"")+(X<5?_spTr.bonusProcessing:"")+(W.length>0?" ("+W+")":"")+(0+Y>0?"<br>"+SPstringFormat(_spTr.plusXthumbsOpt,Y):"")+(0+V>0?"<br>"+SPstringFormat(_spTr.plusXretinasOpt,V):"")+"</div>"}function s(W,V){jQuery(W).knob({readOnly:true,width:V,height:V,fgColor:"#1CAECB",format:function(X){return X+"%"}})}function c(ac,X,aa,Z,W,ab){if(W==1){var Y=jQuery(".sp-column-actions-template").clone();if(!Y.length){return false}var V;if(X.length==0){V=["lossy","lossless"]}else{V=["lossy","glossy","lossless"].filter(function(ad){return !(ad==X)})}Y.html(Y.html().replace(/__SP_ID__/g,ac));if(ab.substr(ab.lastIndexOf(".")+1).toLowerCase()=="pdf"){jQuery(".sp-action-compare",Y).remove()}if(aa==0&&Z>0){Y.html(Y.html().replace("__SP_THUMBS_TOTAL__",Z))}else{jQuery(".sp-action-optimize-thumbs",Y).remove();jQuery(".sp-dropbtn",Y).removeClass("button-primary")}Y.html(Y.html().replace(/__SP_FIRST_TYPE__/g,V[0]));Y.html(Y.html().replace(/__SP_SECOND_TYPE__/g,V[1]));return Y.html()}return""}function j(Z,Y){Z=Z.substring(2);if(jQuery(".shortpixel-other-media").length){var X=["optimize","retry","restore","redo","quota","view"];for(var W=0,V=X.length;W<V;W++){jQuery("#"+X[W]+"_"+Z).css("display","none")}for(var W=0,V=Y.length;W<V;W++){jQuery("#"+Y[W]+"_"+Z).css("display","")}}}function l(V){ShortPixel.retries++;if(isNaN(ShortPixel.retries)){ShortPixel.retries=1}if(ShortPixel.retries<6){console.log("Invalid response from server (Error: "+V+"). 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: "+V+")","");console.log("Invalid response from server 6 times. Giving up.")}}function n(V){V.action="shortpixel_browse_content";var W="";jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:V,success:function(X){W=X},async:false});return W}function d(){var V={action:"shortpixel_get_backup_size"};var W="";jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:V,success:function(X){W=X},async:false});return W}function f(W){if(!jQuery("#tos").is(":checked")){W.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 V={action:"shortpixel_new_api_key",email:jQuery("#pluginemail").val()};jQuery.ajax({type:"POST",async:false,url:ShortPixel.AJAX_URL,data:V,success:function(X){data=JSON.parse(X);if(data.Status=="success"){W.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");W.preventDefault()}else{}}}});jQuery("#request_key").removeAttr("onclick")}else{jQuery("#pluginemail-error").css("display","");jQuery("#pluginemail-info").css("display","none");W.preventDefault()}jQuery("#request_key").removeClass("disabled");jQuery("#pluginemail_spinner").removeClass("is-active")}function S(){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 V={action:"shortpixel_propose_upgrade"};jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:V,success:function(W){jQuery("#shortPixelProposeUpgrade .sp-modal-body").removeClass("sptw-modal-spinner");jQuery("#shortPixelProposeUpgrade .sp-modal-body").html(W)}})}function L(){jQuery("#shortPixelProposeUpgradeShade").css("display","none");jQuery("#shortPixelProposeUpgrade").addClass("shortpixel-hide");if(ShortPixel.toRefresh){ShortPixel.recheckQuota()}}function z(){jQuery("#short-pixel-notice-unlisted").hide();jQuery("#optimizeUnlisted").prop("checked",true);var V={action:"shortpixel_dismiss_notice",notice_id:"unlisted",notice_data:"true"};jQuery.get(ShortPixel.AJAX_URL,V,function(W){V=JSON.parse(W);if(V.Status==ShortPixel.STATUS_SUCCESS){console.log("dismissed")}})}function r(){jQuery(".select-folder-button").click(function(){jQuery(".sp-folder-picker-shade").fadeIn(100);jQuery(".shortpixel-modal.modal-folder-picker").show();var V=jQuery(".sp-folder-picker");V.parent().css("margin-left",-V.width()/2);V.fileTree({script:ShortPixel.browseContent,multiFolder:false})});jQuery(".shortpixel-modal input.select-folder-cancel, .sp-folder-picker-shade").click(function(){jQuery(".sp-folder-picker-shade").fadeOut(100);jQuery(".shortpixel-modal.modal-folder-picker").hide()});jQuery(".shortpixel-modal input.select-folder").click(function(Y){var X=jQuery("UL.jqueryFileTree LI.directory.selected");if(jQuery(X).length==0){var X=jQuery("UL.jqueryFileTree LI.selected").parents(".directory")}var V=jQuery(X).children("a").attr("rel");if(typeof V==="undefined"){return}V=V.trim();if(V){var W=jQuery("#customFolderBase").val()+V;if(W.slice(-1)=="/"){W=W.slice(0,-1)}jQuery("#addCustomFolder").val(W);jQuery("#addCustomFolderView").val(W);jQuery(".sp-folder-picker-shade").fadeOut(100);jQuery(".shortpixel-modal.modal-folder-picker").css("display","none");jQuery("#saveAdvAddFolder").removeClass("hidden")}else{alert("Please select a folder from the list.")}})}function K(Z,Y,X){var W=jQuery(".bulk-notice-msg.bulk-lengthy");if(W.length==0){return}var V=jQuery("a",W);V.text(Y);if(X){V.attr("href",X)}else{V.attr("href",V.data("href").replace("__ID__",Z))}W.css("display","block")}function F(){jQuery(".bulk-notice-msg.bulk-lengthy").css("display","none")}function A(V){var W=jQuery(".bulk-notice-msg.bulk-"+V);if(W.length==0){return}W.css("display","block")}function T(V){jQuery(".bulk-notice-msg.bulk-"+V).css("display","none")}function v(ab,Z,aa,Y){var V=jQuery("#bulk-error-template");if(V.length==0){return}var X=V.clone();X.attr("id","bulk-error-"+ab);if(ab==-1){jQuery("span.sp-err-title",X).remove();X.addClass("bulk-error-fatal")}else{jQuery("img",X).remove();jQuery("#bulk-error-".id).remove()}jQuery("span.sp-err-content",X).html(Z);var W=jQuery("a.sp-post-link",X);if(Y){W.attr("href",Y)}else{W.attr("href",W.attr("href").replace("__ID__",ab))}W.text(aa);V.after(X);X.css("display","block")}function I(V,W){if(!confirm(_spTr["confirmBulk"+V])){W.stopPropagation();W.preventDefault();return false}return true}function B(Y){var W=jQuery(Y.target).val();var V=jQuery('input[name="random_answer"]').val();var X=jQuery('input[name="random_answer"]').data("target");if(W==V){jQuery(X).removeClass("disabled").prop("disabled",false);jQuery(X).removeAttr("aria-disabled")}else{jQuery(X).addClass("disabled").prop("disabled",true)}}function u(V){jQuery(V).parent().parent().remove()}function M(V){return V.substring(0,2)=="C-"}function O(){var V=window.location.href.split("#");window.location.href=V[0]+(V[0].indexOf("?")>0?"&":"?")+"checkquota=1"+(typeof V[1]==="undefined"?"":"#"+V[1])}function h(W){W.preventDefault();if(!this.menuCloseEvent){jQuery(window).click(function(X){if(!X.target.matches(".sp-dropbtn")){jQuery(".sp-dropdown.sp-show").removeClass("sp-show")}});this.menuCloseEvent=true}var V=W.target.parentElement.classList.contains("sp-show");jQuery(".sp-dropdown.sp-show").removeClass("sp-show");if(!V){W.target.parentElement.classList.add("sp-show")}}function U(V){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}if(this.comparerData.origUrl===false){jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:{action:"shortpixel_get_comparer_data",id:V},success:function(W){data=JSON.parse(W);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 J(X,ad,ae,Y){var ac=X;var W=(ad<150||X<350);var ab=jQuery(W?"#spUploadCompareSideBySide":"#spUploadCompare");var Z=jQuery(".sp-modal-shade");if(!W){jQuery("#spCompareSlider").html('<img class="spUploadCompareOriginal"/><img class="spUploadCompareOptimized"/>')}X=Math.max(350,Math.min(800,(X<350?(X+25)*2:(ad<150?X+25:X))));ad=Math.max(150,(W?(ac>350?2*(ad+45):ad+45):ad*X/ac));var aa="-"+Math.round(X/2);jQuery(".sp-modal-body",ab).css("width",X);jQuery(".shortpixel-slider",ab).css("width",X);ab.css("width",X);ab.css("marginLeft",aa+"px");jQuery(".sp-modal-body",ab).css("height",ad);ab.show();Z.show();if(!W){jQuery("#spCompareSlider").twentytwenty({slider_move:"mousemove"})}jQuery(".sp-close-button").on("click",ShortPixel.closeComparerPopup);jQuery(document).on("keyup.sp_modal_active",ShortPixel.closeComparerPopup);jQuery(".sp-modal-shade").on("click",ShortPixel.closeComparerPopup);var V=jQuery(".spUploadCompareOptimized",ab);jQuery(".spUploadCompareOriginal",ab).attr("src",ae);setTimeout(function(){jQuery(window).trigger("resize")},1000);V.load(function(){jQuery(window).trigger("resize")});V.attr("src",Y)}function t(V){jQuery("#spUploadCompareSideBySide").hide();jQuery("#spUploadCompare").hide();jQuery(".sp-modal-shade").hide();jQuery(document).unbind("keyup.sp_modal_active");jQuery(".sp-modal-shade").off("click");jQuery(".sp-close-button").off("click")}function E(V){var W=document.createElement("a");W.href=V;if(V.indexOf(W.protocol+"//"+W.hostname)<0){return W.href}return V.replace(W.protocol+"//"+W.hostname,W.protocol+"//"+W.hostname.split(".").map(function(X){return sp_punycode.toASCII(X)}).join("."))}return{init:N,setOptions:o,isEmailValid:x,updateSignupEmail:p,validateKey:a,enableResize:Q,setupGeneralTab:e,apiKeyChanged:H,setupAdvancedTab:y,checkThumbsUpdTotal:P,initSettings:g,switchSettingsTab:C,adjustSettingsTabs:D,onBulkThumbsCheck:G,dismissMediaAlert:R,closeHelpPane:w,dismissHelpPane:q,checkQuota:m,percentDial:s,successMsg:b,successActions:c,otherMediaUpdateActions:j,retry:l,initFolderSelector:r,browseContent:n,getBackupSize:d,newApiKey:f,proposeUpgrade:S,closeProposeUpgrade:L,includeUnlisted:z,bulkShowLengthyMsg:K,bulkHideLengthyMsg:F,bulkShowMaintenanceMsg:A,bulkHideMaintenanceMsg:T,bulkShowError:v,confirmBulkAction:I,checkRandomAnswer:B,removeBulkMsg:u,isCustomImageId:M,recheckQuota:O,openImageMenu:h,menuCloseEvent:false,loadComparer:U,displayComparerPopup:J,closeComparerPopup:t,convertPunycode:E,checkExifWarning:k,comparerData:{cssLoaded:false,jsLoaded:false,origUrl:false,optUrl:false,width:0,height:0},toRefresh:false,resizeSizesAlert:false,returnedStatusSearching:0}}();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-settings");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-settings");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 j=null;try{var j=JSON.parse(g)}catch(l){ShortPixel.retry(l.message);return}ShortPixel.retries=0;var d=j.ImageID;var k=(jQuery("div.short-pixel-bulk-page").length>0);if(j.Status&&j.Status!=ShortPixel.STATUS_SEARCHING){if(ShortPixel.returnedStatusSearching>=2){jQuery(".bulk-notice-msg.bulk-searching").hide()}ShortPixel.returnedStatusSearching=0}switch(j.Status){case ShortPixel.STATUS_NO_KEY:setCellMessage(d,j.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,j.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(j.Stop==false){setTimeout(checkBulkProgress,5000)}ShortPixel.otherMediaUpdateActions(d,["quota","view"]);break;case ShortPixel.STATUS_FAIL:setCellMessage(d,j.Message,"<a class='button button-smaller button-primary' href=\"javascript:manualOptimization('"+d+"', false)\">"+_spTr.retry+"</a>");showToolBarAlert(ShortPixel.STATUS_FAIL,j.Message,d);if(k){ShortPixel.bulkShowError(d,j.Message,j.Filename,j.CustomImageLink);if(j.BulkPercent){progressUpdate(j.BulkPercent,j.BulkMsg)}ShortPixel.otherMediaUpdateActions(d,["retry","view"])}console.log(j.Message);setTimeout(checkBulkProgress,5000);break;case ShortPixel.STATUS_EMPTY_QUEUE:console.log(j.Message);clearBulkProcessor();hideToolBarAlert();var c=jQuery("#bulk-progress");if(k&&c.length&&j.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(k){ShortPixel.bulkHideLengthyMsg();ShortPixel.bulkHideMaintenanceMsg()}var m=j.PercentImprovement;showToolBarAlert(ShortPixel.STATUS_SUCCESS,"");var b=ShortPixel.isCustomImageId(d)?"":ShortPixel.successActions(d,j.Type,j.ThumbsCount,j.ThumbsTotal,j.BackupEnabled,j.Filename);setCellMessage(d,ShortPixel.successMsg(d,m,j.Type,j.ThumbsCount,j.RetinasCount),b);if(jQuery("#post-"+d).length>0){jQuery("#post-"+d).find(".filename").text(j.Filename)}if(jQuery(".misc-pub-filename strong").length>0){jQuery(".misc-pub-filename strong").text(j.Filename)}if(ShortPixel.isCustomImageId(d)&&j.TsOptimized&&j.TsOptimized.length>0){console.log(d);jQuery(".date-"+d).text(j.TsOptimized)}var h=jQuery(["restore","view","redolossy","redoglossy","redolossless"]).not(["redo"+j.Type]).get();ShortPixel.otherMediaUpdateActions(d,h);var f=new PercentageAnimator("#sp-msg-"+d+" span.percent",m);f.animate(m);if(k&&typeof j.Thumb!=="undefined"){if(j.BulkPercent){progressUpdate(j.BulkPercent,j.BulkMsg)}if(j.Thumb.length>0){sliderUpdate(d,j.Thumb,j.BkThumb,j.PercentImprovement,j.Filename);if(typeof j.AverageCompression!=="undefined"&&0+j.AverageCompression>0){jQuery("#sp-avg-optimization").html('<input type="text" class="dial" value="'+Math.round(j.AverageCompression)+'"/>');ShortPixel.percentDial("#sp-avg-optimization .dial",60)}}}console.log("Server response: "+g);if(k&&typeof j.BulkPercent!=="undefined"){progressUpdate(j.BulkPercent,j.BulkMsg)}setTimeout(checkBulkProgress,5000);break;case ShortPixel.STATUS_SKIP:if(j.Silent!==1){ShortPixel.bulkShowError(d,j.Message,j.Filename,j.CustomImageLink)}case ShortPixel.STATUS_ERROR:if(typeof j.Message!=="undefined"){showToolBarAlert(ShortPixel.STATUS_SKIP,j.Message+" Image ID: "+d);setCellMessage(d,j.Message,"")}ShortPixel.otherMediaUpdateActions(d,["retry","view"]);case ShortPixel.STATUS_RETRY:console.log("Server response: "+g);showToolBarAlert(ShortPixel.STATUS_RETRY,"");if(k&&typeof j.BulkPercent!=="undefined"){progressUpdate(j.BulkPercent,j.BulkMsg)}if(k&&j.Count>3){ShortPixel.bulkShowLengthyMsg(d,j.Filename,j.CustomImageLink)}setTimeout(checkBulkProgress,5000);break;case ShortPixel.STATUS_SEARCHING:console.log("Server response: "+g);ShortPixel.returnedStatusSearching++;if(ShortPixel.returnedStatusSearching>=2){jQuery(".bulk-notice-msg.bulk-searching").show()}setTimeout(checkBulkProgress,2500);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 "+j.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){}}function SPstringFormat(){var b=Array.prototype.slice.call(arguments);if(b.length===0){return}var a=b.shift();for(i=0;i<b.length;i++){a=a.replace(new RegExp("\\{"+i+"\\}","gm"),b[i])}return a};
1
+ function showToolBarAlert(e,r,t){var s=jQuery("li.shortpixel-toolbar-processing");switch(e){case ShortPixel.STATUS_QUOTA_EXCEEDED:if(window.location.href.search("wp-short-pixel-bulk")>0&&0==jQuery(".sp-quota-exceeded-alert").length)return void location.reload();s.addClass("shortpixel-alert"),s.addClass("shortpixel-quota-exceeded"),jQuery("a",s).attr("href","options-general.php?page=wp-shortpixel-settings"),jQuery("a div",s).attr("title","ShortPixel quota exceeded. Click for details.");break;case ShortPixel.STATUS_SKIP:case ShortPixel.STATUS_FAIL:s.addClass("shortpixel-alert shortpixel-processing"),jQuery("a div",s).attr("title",r),void 0!==t&&jQuery("a",s).attr("href","post.php?post="+t+"&action=edit");break;case ShortPixel.STATUS_NO_KEY:s.addClass("shortpixel-alert"),s.addClass("shortpixel-quota-exceeded"),jQuery("a",s).attr("href","options-general.php?page=wp-shortpixel-settings"),jQuery("a div",s).attr("title","Get API Key");break;case ShortPixel.STATUS_SUCCESS:case ShortPixel.STATUS_RETRY:s.addClass("shortpixel-processing"),s.removeClass("shortpixel-alert"),jQuery("a",s).removeAttr("target"),jQuery("a",s).attr("href",jQuery("a img",s).attr("success-url"))}s.removeClass("shortpixel-hide")}function hideToolBarAlert(e){var r=jQuery("li.shortpixel-toolbar-processing.shortpixel-processing");ShortPixel.STATUS_EMPTY_QUEUE==e&&(r.hasClass("shortpixel-alert")||r.hasClass("shortpixel-quota-exceeded"))||r.addClass("shortpixel-hide")}function hideQuotaExceededToolBarAlert(){jQuery("li.shortpixel-toolbar-processing.shortpixel-quota-exceeded").addClass("shortpixel-hide")}function checkQuotaExceededAlert(){"undefined"!=typeof shortPixelQuotaExceeded&&(1==shortPixelQuotaExceeded?showToolBarAlert(ShortPixel.STATUS_QUOTA_EXCEEDED):hideQuotaExceededToolBarAlert())}function checkBulkProgress(){var e=function(e){return r?"/":(r=!0,e)},r=!1,t=window.location.href.toLowerCase().replace(/\/\//g,e);r=!1;var s=ShortPixel.WP_ADMIN_URL.toLowerCase().replace(/\/\//g,e);t.search(s)<0&&(t=ShortPixel.convertPunycode(t),s=ShortPixel.convertPunycode(s)),1==ShortPixel.bulkProcessor&&window.location.href.search("wp-short-pixel-bulk")<0&&void 0!==localStorage.bulkPage&&localStorage.bulkPage>0&&(ShortPixel.bulkProcessor=!1),window.location.href.search("wp-short-pixel-bulk")>=0&&(ShortPixel.bulkProcessor=!0,localStorage.bulkTime=Math.floor(Date.now()/1e3),localStorage.bulkPage=1),1==ShortPixel.bulkProcessor||void 0===localStorage.bulkTime||Math.floor(Date.now()/1e3)-localStorage.bulkTime>90?(ShortPixel.bulkProcessor=!0,localStorage.bulkPage=window.location.href.search("wp-short-pixel-bulk")>=0?1:0,localStorage.bulkTime=Math.floor(Date.now()/1e3),console.log(localStorage.bulkTime),checkBulkProcessingCallApi()):setTimeout(checkBulkProgress,5e3)}function checkBulkProcessingCallApi(){jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:{action:"shortpixel_image_processing"},success:function(e){if(e.length>0){r=null;try{var r=JSON.parse(e)}catch(e){return void ShortPixel.retry(e.message)}ShortPixel.retries=0;var t=r.ImageID,s=jQuery("div.short-pixel-bulk-page").length>0;switch(r.Status&&r.Status!=ShortPixel.STATUS_SEARCHING&&(ShortPixel.returnedStatusSearching>=2&&jQuery(".bulk-notice-msg.bulk-searching").hide(),ShortPixel.returnedStatusSearching=0),r.Status){case ShortPixel.STATUS_NO_KEY:setCellMessage(t,r.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(t,r.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),0==r.Stop&&setTimeout(checkBulkProgress,5e3),ShortPixel.otherMediaUpdateActions(t,["quota","view"]);break;case ShortPixel.STATUS_FAIL:setCellMessage(t,r.Message,"<a class='button button-smaller button-primary' href=\"javascript:manualOptimization('"+t+"', true)\">"+_spTr.retry+"</a>"),showToolBarAlert(ShortPixel.STATUS_FAIL,r.Message,t),s&&(ShortPixel.bulkShowError(t,r.Message,r.Filename,r.CustomImageLink),r.BulkPercent&&progressUpdate(r.BulkPercent,r.BulkMsg),ShortPixel.otherMediaUpdateActions(t,["retry","view"])),console.log(r.Message),setTimeout(checkBulkProgress,5e3);break;case ShortPixel.STATUS_EMPTY_QUEUE:console.log(r.Message),clearBulkProcessor(),hideToolBarAlert(r.Status);var o=jQuery("#bulk-progress");s&&o.length&&"2"!=r.BulkStatus&&(progressUpdate(100,"Bulk finished!"),jQuery("a.bulk-cancel").attr("disabled","disabled"),hideSlider(),setTimeout(function(){window.location.reload()},3e3));break;case ShortPixel.STATUS_SUCCESS:s&&(ShortPixel.bulkHideLengthyMsg(),ShortPixel.bulkHideMaintenanceMsg());var i=r.PercentImprovement;showToolBarAlert(ShortPixel.STATUS_SUCCESS,"");var a=ShortPixel.isCustomImageId(t)?"":ShortPixel.successActions(t,r.Type,r.ThumbsCount,r.ThumbsTotal,r.BackupEnabled,r.Filename);setCellMessage(t,ShortPixel.successMsg(t,i,r.Type,r.ThumbsCount,r.RetinasCount),a),jQuery("#post-"+t).length>0&&jQuery("#post-"+t).find(".filename").text(r.Filename),jQuery(".misc-pub-filename strong").length>0&&jQuery(".misc-pub-filename strong").text(r.Filename),ShortPixel.isCustomImageId(t)&&r.TsOptimized&&r.TsOptimized.length>0&&(console.log(t),jQuery(".date-"+t).text(r.TsOptimized));var l=jQuery(["restore","view","redolossy","redoglossy","redolossless"]).not(["redo"+r.Type]).get();ShortPixel.otherMediaUpdateActions(t,l);new PercentageAnimator("#sp-msg-"+t+" span.percent",i).animate(i),s&&void 0!==r.Thumb&&(r.BulkPercent&&progressUpdate(r.BulkPercent,r.BulkMsg),r.Thumb.length>0&&(sliderUpdate(t,r.Thumb,r.BkThumb,r.PercentImprovement,r.Filename),void 0!==r.AverageCompression&&0+r.AverageCompression>0&&(jQuery("#sp-avg-optimization").html('<input type="text" class="dial" value="'+Math.round(r.AverageCompression)+'"/>'),ShortPixel.percentDial("#sp-avg-optimization .dial",60)))),console.log("Server response: "+e),s&&void 0!==r.BulkPercent&&progressUpdate(r.BulkPercent,r.BulkMsg),setTimeout(checkBulkProgress,5e3);break;case ShortPixel.STATUS_SKIP:1!==r.Silent&&ShortPixel.bulkShowError(t,r.Message,r.Filename,r.CustomImageLink);case ShortPixel.STATUS_ERROR:void 0!==r.Message&&(showToolBarAlert(ShortPixel.STATUS_SKIP,r.Message+" Image ID: "+t),setCellMessage(t,r.Message,"")),ShortPixel.otherMediaUpdateActions(t,["retry","view"]);case ShortPixel.STATUS_RETRY:console.log("Server response: "+e),showToolBarAlert(ShortPixel.STATUS_RETRY,""),s&&void 0!==r.BulkPercent&&progressUpdate(r.BulkPercent,r.BulkMsg),s&&r.Count>3&&ShortPixel.bulkShowLengthyMsg(t,r.Filename,r.CustomImageLink),setTimeout(checkBulkProgress,5e3);break;case ShortPixel.STATUS_SEARCHING:console.log("Server response: "+e),ShortPixel.returnedStatusSearching++,ShortPixel.returnedStatusSearching>=2&&jQuery(".bulk-notice-msg.bulk-searching").show(),setTimeout(checkBulkProgress,2500);break;case ShortPixel.STATUS_MAINTENANCE:ShortPixel.bulkShowMaintenanceMsg("maintenance"),setTimeout(checkBulkProgress,6e4);break;case ShortPixel.STATUS_QUEUE_FULL:ShortPixel.bulkShowMaintenanceMsg("queue-full"),setTimeout(checkBulkProgress,6e4);break;default:ShortPixel.retry("Unknown status "+r.Status+". Retrying...")}}},error:function(e){ShortPixel.retry(e.statusText)}})}function clearBulkProcessor(){ShortPixel.bulkProcessor=!1,localStorage.bulkTime=0,window.location.href.search("wp-short-pixel-bulk")>=0&&(localStorage.bulkPage=0)}function setCellMessage(e,r,t){var s=jQuery("#sp-msg-"+e);s.length>0&&(s.html("<div class='sp-column-actions'>"+t+"</div><div class='sp-column-info'>"+r+"</div>"),s.css("color","")),(s=jQuery("#sp-cust-msg-"+e)).length>0&&s.html("<div class='sp-column-info'>"+r+"</div>")}function manualOptimization(e,r){setCellMessage(e,"<img src='"+ShortPixel.WP_PLUGIN_URL+"/res/img/loading.gif' alt='"+_spTr.loading+"' 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 t={action:"shortpixel_manual_optimization",image_id:e,cleanup:r};jQuery.ajax({type:"GET",url:ShortPixel.AJAX_URL,data:t,success:function(r){var t=JSON.parse(r);t.Status==ShortPixel.STATUS_SUCCESS?setTimeout(checkBulkProgress,2e3):setCellMessage(e,void 0!==t.Message?t.Message:_spTr.thisContentNotProcessable,"")},error:function(r){t.action="shortpixel_check_status",jQuery.ajax({type:"GET",url:ShortPixel.AJAX_URL,data:t,success:function(r){var t=JSON.parse(r);t.Status!==ShortPixel.STATUS_SUCCESS&&setCellMessage(e,void 0!==t.Message?t.Message:_spTr.thisContentNotProcessable,"")}})}})}function reoptimize(e,r){setCellMessage(e,"<img src='"+ShortPixel.WP_PLUGIN_URL+"/res/img/loading.gif' alt='"+_spTr.loading+"' 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 t={action:"shortpixel_redo",attachment_ID:e,type:r};jQuery.get(ShortPixel.AJAX_URL,t,function(r){(t=JSON.parse(r)).Status==ShortPixel.STATUS_SUCCESS?setTimeout(checkBulkProgress,2e3):($msg=void 0!==t.Message?t.Message:_spTr.thisContentNotProcessable,setCellMessage(e,$msg,""),showToolBarAlert(ShortPixel.STATUS_FAIL,$msg))})}function optimizeThumbs(e){setCellMessage(e,"<img src='"+ShortPixel.WP_PLUGIN_URL+"/res/img/loading.gif' alt='"+_spTr.loading+"' class='sp-loading-small'>"+_spTr.imageWaitOptThumbs,""),jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide"),jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");var r={action:"shortpixel_optimize_thumbs",attachment_ID:e};jQuery.get(ShortPixel.AJAX_URL,r,function(t){(r=JSON.parse(t)).Status==ShortPixel.STATUS_SUCCESS?setTimeout(checkBulkProgress,2e3):setCellMessage(e,void 0!==r.Message?r.Message:_spTr.thisContentNotProcessable,"")})}function dismissShortPixelNoticeExceed(e){jQuery("#wp-admin-bar-shortpixel_processing").hide();var r={action:"shortpixel_dismiss_notice",notice_id:"exceed"};jQuery.get(ShortPixel.AJAX_URL,r,function(e){(r=JSON.parse(e)).Status==ShortPixel.STATUS_SUCCESS&&console.log("dismissed")}),e.preventDefault()}function dismissShortPixelNotice(e){jQuery("#short-pixel-notice-"+e).hide();var r={action:"shortpixel_dismiss_notice",notice_id:e};jQuery.get(ShortPixel.AJAX_URL,r,function(e){(r=JSON.parse(e)).Status==ShortPixel.STATUS_SUCCESS&&console.log("dismissed")})}function PercentageAnimator(e,r){this.animationSpeed=10,this.increment=2,this.curPercentage=0,this.targetPercentage=r,this.outputSelector=e,this.animate=function(e){this.targetPercentage=e,setTimeout(PercentageTimer.bind(null,this),this.animationSpeed)}}function PercentageTimer(e){e.curPercentage-e.targetPercentage<-e.increment?e.curPercentage+=e.increment:e.curPercentage-e.targetPercentage>e.increment?e.curPercentage-=e.increment:e.curPercentage=e.targetPercentage,jQuery(e.outputSelector).text(e.curPercentage+"%"),e.curPercentage!=e.targetPercentage&&setTimeout(PercentageTimer.bind(null,e),e.animationSpeed)}function progressUpdate(e,r){var t=jQuery("#bulk-progress");t.length&&(jQuery(".progress-left",t).css("width",e+"%"),jQuery(".progress-img",t).css("left",e+"%"),e>24?(jQuery(".progress-img span",t).html(""),jQuery(".progress-left",t).html(e+"%")):(jQuery(".progress-img span",t).html(e+"%"),jQuery(".progress-left",t).html("")),jQuery(".bulk-estimate").html(r))}function sliderUpdate(e,r,t,s,o){var i=jQuery(".bulk-slider div.bulk-slide:first-child");if(0!==i.length){"empty-slide"!=i.attr("id")&&i.hide(),i.css("z-index",1e3),jQuery(".bulk-img-opt",i).attr("src",""),void 0===t&&(t=""),t.length>0&&jQuery(".bulk-img-orig",i).attr("src","");var a=i.clone();a.attr("id","slide-"+e),jQuery(".bulk-img-opt",a).attr("src",r),t.length>0?(jQuery(".img-original",a).css("display","inline-block"),jQuery(".bulk-img-orig",a).attr("src",t)):jQuery(".img-original",a).css("display","none"),jQuery(".bulk-opt-percent",a).html('<input type="text" class="dial" value="'+s+'"/>'),jQuery(".bulk-slider").append(a),ShortPixel.percentDial("#"+a.attr("id")+" .dial",100),jQuery(".bulk-slider-container span.filename").html("&nbsp;&nbsp;"+o),"empty-slide"==i.attr("id")?(i.remove(),jQuery(".bulk-slider-container").css("display","block")):i.animate({left:i.width()+i.position().left},"slow","swing",function(){i.remove(),a.fadeIn("slow")})}}function hideSlider(){jQuery(".bulk-slider-container").css("display","none")}function showStats(){jQuery(".bulk-stats").length}function SPstringFormat(){var e=Array.prototype.slice.call(arguments);if(0!==e.length){var r=e.shift();for(i=0;i<e.length;i++)r=r.replace(new RegExp("\\{"+i+"\\}","gm"),e[i]);return r}}jQuery(document).ready(function(){ShortPixel.init()});var ShortPixel=function(){function e(e){jQuery(e).is(":checked")?jQuery("#width,#height").removeAttr("disabled"):jQuery("#width,#height").attr("disabled","disabled")}function r(){jQuery("#shortpixel-hs-button-blind").remove(),jQuery("#shortpixel-hs-tools").remove(),jQuery("#hs-beacon").remove(),jQuery("#botbutton").remove(),jQuery("#shortpixel-hs-blind").remove()}return jQuery("#key").keypress(function(e){13==e.which&&jQuery("#valid").val("validate")}),{init:function(){void 0===ShortPixel.API_KEY&&(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]),jQuery("#backup-folder-size").length&&jQuery("#backup-folder-size").html(ShortPixel.getBackupSize()),"todo"==ShortPixel.MEDIA_ALERT&&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>'+SPstringFormat(_spTr.changeMLToListMode,'<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(){1==ShortPixel.bulkProcessor&&clearBulkProcessor()}),checkQuotaExceededAlert(),checkBulkProgress())},setOptions:function(e){for(var r in e)ShortPixel[r]=e[r]},isEmailValid:function(e){return/^\w+([\.+-]?\w+)*@\w+([\.-]?\w+)*(\.\w{1,63})+$/.test(e)},updateSignupEmail:function(){var e=jQuery("#pluginemail").val();ShortPixel.isEmailValid(e)&&jQuery("#request_key").removeClass("disabled"),jQuery("#request_key").attr("href",jQuery("#request_key").attr("href").split("?")[0]+"?pluginemail="+e)},validateKey:function(e){jQuery("#valid").val("validate"),jQuery(e).parents("form").submit()},enableResize:e,setupGeneralTab:function(){var r=0;void 0!==document.wp_shortpixel_options&&(r=document.wp_shortpixel_options.compressionType);for(var t=0,s=null;t<r.length;t++)r[t].onclick=function(){this!==s&&(s=this),void 0===ShortPixel.setupGeneralTabAlert&&(alert(_spTr.alertOnlyAppliesToNewImages),ShortPixel.setupGeneralTabAlert=1)};ShortPixel.enableResize("#resize"),jQuery("#resize").change(function(){e(this)}),jQuery(".resize-sizes").blur(function(e){var r=jQuery(e.target);if(ShortPixel.resizeSizesAlert!=r.val()){ShortPixel.resizeSizesAlert=r.val();var t=jQuery("#min-"+r.attr("name")).val(),s=jQuery("#min-"+r.attr("name")).data("nicename");r.val()<Math.min(t,1024)?(t>1024?alert(SPstringFormat(_spTr.pleaseDoNotSetLesser1024,s)):alert(SPstringFormat(_spTr.pleaseDoNotSetLesserSize,s,s,t)),e.preventDefault(),r.focus()):this.defaultValue=r.val()}}),jQuery(".shortpixel-confirm").click(function(e){return!!confirm(e.target.getAttribute("data-confirm"))||(e.preventDefault(),!1)}),jQuery('input[name="removeExif"], input[name="png2jpg"]').on("change",function(){ShortPixel.checkExifWarning()}),ShortPixel.checkExifWarning()},apiKeyChanged:function(){jQuery(".wp-shortpixel-options .shortpixel-key-valid").css("display","none"),jQuery(".wp-shortpixel-options button#validate").css("display","inline-block")},setupAdvancedTab:function(){jQuery("input.remove-folder-button").click(function(){var e=jQuery(this).data("value");1==confirm(SPstringFormat(_spTr.areYouSureStopOptimizing,e))&&(jQuery("#removeFolder").val(e),jQuery("#wp_shortpixel_options").submit())}),jQuery("input.recheck-folder-button").click(function(){var e=jQuery(this).data("value");1==confirm(SPstringFormat(_spTr.areYouSureStopOptimizing,e))&&(jQuery("#recheckFolder").val(e),jQuery("#wp_shortpixel_options").submit())})},checkThumbsUpdTotal:function(e){var r=jQuery("#"+(e.checked?"total":"main")+"ToProcess").val();jQuery("div.bulk-play span.total").text(r),jQuery("#displayTotal").text(r)},initSettings:function(){ShortPixel.adjustSettingsTabs(),ShortPixel.setupGeneralTab(),jQuery(window).resize(function(){ShortPixel.adjustSettingsTabs()}),jQuery("article.sp-tabs a.tab-link").click(function(e){var r=jQuery(e.target).data("id");ShortPixel.switchSettingsTab(r)}),jQuery("input[type=radio][name=deliverWebpType]").change(function(){"deliverWebpAltered"==this.value?window.confirm(_spTr.alertDeliverWebPAltered)?0==jQuery("input[type=radio][name=deliverWebpAlteringType]:checked").length&&jQuery("#deliverWebpAlteredWP").prop("checked",!0):jQuery(this).prop("checked",!1):"deliverWebpUnaltered"==this.value&&window.alert(_spTr.alertDeliverWebPUnaltered)})},switchSettingsTab:function(e){var r=e.replace("tab-",""),t="",s=jQuery("section#"+e);jQuery('input[name="display_part"]').val(r);var o=window.location.href.toString();if(o.indexOf("?")>0){var i=o.substring(0,o.indexOf("?"));i+="?"+jQuery.param({page:"wp-shortpixel-settings",part:r}),window.history.replaceState({},document.title,i)}if(s.length>0&&(jQuery("section").removeClass("sel-tab"),jQuery("section .wp-shortpixel-tab-content").fadeOut(50),jQuery(s).addClass("sel-tab"),ShortPixel.adjustSettingsTabs(),jQuery(s).find(".wp-shortpixel-tab-content").fadeIn(50)),"undefined"!=typeof HS&&void 0!==HS.beacon.suggest){switch(r){case"settings":t=shortpixel_suggestions_settings;break;case"adv-settings":t=shortpixel_suggestions_adv_settings;break;case"cloudflare":case"stats":t=shortpixel_suggestions_cloudflare}HS.beacon.suggest(t)}},adjustSettingsTabs:function(){var e=jQuery("section.sel-tab").height()+90;jQuery(".section-wrapper").css("height",e)},onBulkThumbsCheck:function(e){e.checked?(jQuery("#with-thumbs").css("display","inherit"),jQuery("#without-thumbs").css("display","none")):(jQuery("#without-thumbs").css("display","inherit"),jQuery("#with-thumbs").css("display","none"))},dismissMediaAlert:function(){var e={action:"shortpixel_dismiss_media_alert"};jQuery.get(ShortPixel.AJAX_URL,e,function(r){"success"==(e=JSON.parse(r)).Status&&jQuery("#short-pixel-media-alert").hide()})},closeHelpPane:r,dismissHelpPane:function(){r(),dismissShortPixelNotice("help")},checkQuota:function(){jQuery.get(ShortPixel.AJAX_URL,{action:"shortpixel_check_quota"},function(){console.log("quota refreshed")})},percentDial:function(e,r){jQuery(e).knob({readOnly:!0,width:r,height:r,fgColor:"#1CAECB",format:function(e){return e+"%"}})},successMsg:function(e,r,t,s,o){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:"")+(t.length>0?" ("+t+")":"")+(0+s>0?"<br>"+SPstringFormat(_spTr.plusXthumbsOpt,s):"")+(0+o>0?"<br>"+SPstringFormat(_spTr.plusXretinasOpt,o):"")+"</div>"},successActions:function(e,r,t,s,o,i){if(1==o){var a=jQuery(".sp-column-actions-template").clone();if(!a.length)return!1;var l;return l=0==r.length?["lossy","lossless"]:["lossy","glossy","lossless"].filter(function(e){return!(e==r)}),a.html(a.html().replace(/__SP_ID__/g,e)),"pdf"==i.substr(i.lastIndexOf(".")+1).toLowerCase()&&jQuery(".sp-action-compare",a).remove(),0==t&&s>0?a.html(a.html().replace("__SP_THUMBS_TOTAL__",s)):(jQuery(".sp-action-optimize-thumbs",a).remove(),jQuery(".sp-dropbtn",a).removeClass("button-primary")),a.html(a.html().replace(/__SP_FIRST_TYPE__/g,l[0])),a.html(a.html().replace(/__SP_SECOND_TYPE__/g,l[1])),a.html()}return""},otherMediaUpdateActions:function(e,r){if(e=e.substring(2),jQuery(".shortpixel-other-media").length){for(var t=["optimize","retry","restore","redo","quota","view"],s=0,o=t.length;s<o;s++)jQuery("#"+t[s]+"_"+e).css("display","none");for(var s=0,o=r.length;s<o;s++)jQuery("#"+r[s]+"_"+e).css("display","")}},retry:function(e){ShortPixel.retries++,isNaN(ShortPixel.retries)&&(ShortPixel.retries=1),ShortPixel.retries<6?(console.log("Invalid response from server (Error: "+e+"). Retrying pass "+(ShortPixel.retries+1)+"..."),setTimeout(checkBulkProgress,5e3)):(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: "+e+")",""),console.log("Invalid response from server 6 times. Giving up."))},initFolderSelector:function(){jQuery(".select-folder-button").click(function(){jQuery(".sp-folder-picker-shade").fadeIn(100),jQuery(".shortpixel-modal.modal-folder-picker").show();var e=jQuery(".sp-folder-picker");e.parent().css("margin-left",-e.width()/2),e.fileTree({script:ShortPixel.browseContent,multiFolder:!1})}),jQuery(".shortpixel-modal input.select-folder-cancel, .sp-folder-picker-shade").click(function(){jQuery(".sp-folder-picker-shade").fadeOut(100),jQuery(".shortpixel-modal.modal-folder-picker").hide()}),jQuery(".shortpixel-modal input.select-folder").click(function(e){if(r=jQuery("UL.jqueryFileTree LI.directory.selected"),0==jQuery(r).length)var r=jQuery("UL.jqueryFileTree LI.selected").parents(".directory");var t=jQuery(r).children("a").attr("rel");if(void 0!==t)if(t=t.trim()){var s=jQuery("#customFolderBase").val()+t;"/"==s.slice(-1)&&(s=s.slice(0,-1)),jQuery("#addCustomFolder").val(s),jQuery("#addCustomFolderView").val(s),jQuery(".sp-folder-picker-shade").fadeOut(100),jQuery(".shortpixel-modal.modal-folder-picker").css("display","none"),jQuery("#saveAdvAddFolder").removeClass("hidden")}else alert("Please select a folder from the list.")})},browseContent:function(e){e.action="shortpixel_browse_content";var r="";return jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:e,success:function(e){r=e},async:!1}),r},getBackupSize:function(){var e="";return jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:{action:"shortpixel_get_backup_size"},success:function(r){e=r},async:!1}),e},newApiKey:function(e){if(!jQuery("#tos").is(":checked"))return e.preventDefault(),jQuery("#tos-robo").fadeIn(400,function(){jQuery("#tos-hand").fadeIn()}),void jQuery("#tos").click(function(){jQuery("#tos-robo").css("display","none"),jQuery("#tos-hand").css("display","none")});if(jQuery("#request_key").addClass("disabled"),jQuery("#pluginemail_spinner").addClass("is-active"),ShortPixel.updateSignupEmail(),ShortPixel.isEmailValid(jQuery("#pluginemail").val())){jQuery("#pluginemail-error").css("display","none");var r={action:"shortpixel_new_api_key",email:jQuery("#pluginemail").val()};jQuery.ajax({type:"POST",async:!1,url:ShortPixel.AJAX_URL,data:r,success:function(r){data=JSON.parse(r),"success"==data.Status?(e.preventDefault(),window.location.reload()):"invalid"==data.Status&&(jQuery("#pluginemail-error").html("<b>"+data.Details+"</b>"),jQuery("#pluginemail-error").css("display",""),jQuery("#pluginemail-info").css("display","none"),e.preventDefault())}}),jQuery("#request_key").removeAttr("onclick")}else jQuery("#pluginemail-error").css("display",""),jQuery("#pluginemail-info").css("display","none"),e.preventDefault();jQuery("#request_key").removeClass("disabled"),jQuery("#pluginemail_spinner").removeClass("is-active")},proposeUpgrade:function(){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"),jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:{action:"shortpixel_propose_upgrade"},success:function(e){jQuery("#shortPixelProposeUpgrade .sp-modal-body").removeClass("sptw-modal-spinner"),jQuery("#shortPixelProposeUpgrade .sp-modal-body").html(e)}})},closeProposeUpgrade:function(){jQuery("#shortPixelProposeUpgradeShade").css("display","none"),jQuery("#shortPixelProposeUpgrade").addClass("shortpixel-hide"),ShortPixel.toRefresh&&ShortPixel.recheckQuota()},includeUnlisted:function(){jQuery("#short-pixel-notice-unlisted").hide(),jQuery("#optimizeUnlisted").prop("checked",!0);var e={action:"shortpixel_dismiss_notice",notice_id:"unlisted",notice_data:"true"};jQuery.get(ShortPixel.AJAX_URL,e,function(r){(e=JSON.parse(r)).Status==ShortPixel.STATUS_SUCCESS&&console.log("dismissed")})},bulkShowLengthyMsg:function(e,r,t){var s=jQuery(".bulk-notice-msg.bulk-lengthy");if(0!=s.length){var o=jQuery("a",s);o.text(r),t?o.attr("href",t):o.attr("href",o.data("href").replace("__ID__",e)),s.css("display","block")}},bulkHideLengthyMsg:function(){jQuery(".bulk-notice-msg.bulk-lengthy").css("display","none")},bulkShowMaintenanceMsg:function(e){var r=jQuery(".bulk-notice-msg.bulk-"+e);0!=r.length&&r.css("display","block")},bulkHideMaintenanceMsg:function(e){jQuery(".bulk-notice-msg.bulk-"+e).css("display","none")},bulkShowError:function(e,r,t,s){var o=jQuery("#bulk-error-template");if(0!=o.length){var i=o.clone();i.attr("id","bulk-error-"+e),-1==e?(jQuery("span.sp-err-title",i).remove(),i.addClass("bulk-error-fatal")):(jQuery("img",i).remove(),jQuery("#bulk-error-".id).remove()),jQuery("span.sp-err-content",i).html(r);var a=jQuery("a.sp-post-link",i);s?a.attr("href",s):a.attr("href",a.attr("href").replace("__ID__",e)),a.text(t),o.after(i),i.css("display","block")}},confirmBulkAction:function(e,r){return!!confirm(_spTr["confirmBulk"+e])||(r.stopPropagation(),r.preventDefault(),!1)},checkRandomAnswer:function(e){var r=jQuery(e.target).val(),t=jQuery('input[name="random_answer"]').val(),s=jQuery('input[name="random_answer"]').data("target");r==t?(jQuery(s).removeClass("disabled").prop("disabled",!1),jQuery(s).removeAttr("aria-disabled")):jQuery(s).addClass("disabled").prop("disabled",!0)},removeBulkMsg:function(e){jQuery(e).parent().parent().remove()},isCustomImageId:function(e){return"C-"==e.substring(0,2)},recheckQuota:function(){var e=window.location.href.split("#");window.location.href=e[0]+(e[0].indexOf("?")>0?"&":"?")+"checkquota=1"+(void 0===e[1]?"":"#"+e[1])},openImageMenu:function(e){e.preventDefault(),this.menuCloseEvent||(jQuery(window).click(function(e){e.target.matches(".sp-dropbtn")||jQuery(".sp-dropdown.sp-show").removeClass("sp-show")}),this.menuCloseEvent=!0);var r=e.target.parentElement.classList.contains("sp-show");jQuery(".sp-dropdown.sp-show").removeClass("sp-show"),r||e.target.parentElement.classList.add("sp-show")},menuCloseEvent:!1,loadComparer:function(e){this.comparerData.origUrl=!1,!1===this.comparerData.cssLoaded&&(jQuery("<link>").appendTo("head").attr({type:"text/css",rel:"stylesheet",href:this.WP_PLUGIN_URL+"/res/css/twentytwenty.min.css"}),this.comparerData.cssLoaded=2),!1===this.comparerData.jsLoaded&&(jQuery.getScript(this.WP_PLUGIN_URL+"/res/js/jquery.twentytwenty.min.js",function(){ShortPixel.comparerData.jsLoaded=2,ShortPixel.comparerData.origUrl.length>0&&ShortPixel.displayComparerPopup(ShortPixel.comparerData.width,ShortPixel.comparerData.height,ShortPixel.comparerData.origUrl,ShortPixel.comparerData.optUrl)}),this.comparerData.jsLoaded=1),!1===this.comparerData.origUrl&&(jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:{action:"shortpixel_get_comparer_data",id:e},success:function(e){data=JSON.parse(e),jQuery.extend(ShortPixel.comparerData,data),2==ShortPixel.comparerData.jsLoaded&&ShortPixel.displayComparerPopup(ShortPixel.comparerData.width,ShortPixel.comparerData.height,ShortPixel.comparerData.origUrl,ShortPixel.comparerData.optUrl)}}),this.comparerData.origUrl="")},displayComparerPopup:function(e,r,t,s){var o=e,i=r<150||e<350,a=jQuery(i?"#spUploadCompareSideBySide":"#spUploadCompare"),l=jQuery(".sp-modal-shade");i||jQuery("#spCompareSlider").html('<img alt="'+_spTr.originalImage+'" class="spUploadCompareOriginal"/><img alt="'+_spTr.optimizedImage+'" class="spUploadCompareOptimized"/>'),e=Math.max(350,Math.min(800,e<350?2*(e+25):r<150?e+25:e)),r=Math.max(150,i?o>350?2*(r+45):r+45:r*e/o);var n="-"+Math.round(e/2);jQuery(".sp-modal-body",a).css("width",e),jQuery(".shortpixel-slider",a).css("width",e),a.css("width",e),a.css("marginLeft",n+"px"),jQuery(".sp-modal-body",a).css("height",r),a.show(),l.show(),i||jQuery("#spCompareSlider").twentytwenty({slider_move:"mousemove"}),jQuery(".sp-close-button").on("click",ShortPixel.closeComparerPopup),jQuery(document).on("keyup.sp_modal_active",ShortPixel.closeComparerPopup),jQuery(".sp-modal-shade").on("click",ShortPixel.closeComparerPopup);var u=jQuery(".spUploadCompareOptimized",a);jQuery(".spUploadCompareOriginal",a).attr("src",t),setTimeout(function(){jQuery(window).trigger("resize")},1e3),u.load(function(){jQuery(window).trigger("resize")}),u.attr("src",s)},closeComparerPopup:function(e){jQuery("#spUploadCompareSideBySide").hide(),jQuery("#spUploadCompare").hide(),jQuery(".sp-modal-shade").hide(),jQuery(document).unbind("keyup.sp_modal_active"),jQuery(".sp-modal-shade").off("click"),jQuery(".sp-close-button").off("click")},convertPunycode:function(e){var r=document.createElement("a");return r.href=e,e.indexOf(r.protocol+"//"+r.hostname)<0?r.href:e.replace(r.protocol+"//"+r.hostname,r.protocol+"//"+r.hostname.split(".").map(function(e){return sp_punycode.toASCII(e)}).join("."))},checkExifWarning:function(){!jQuery('input[name="removeExif"]').is(":checked")&&jQuery('input[name="png2jpg"]').is(":checked")?jQuery(".exif_warning").fadeIn():jQuery(".exif_warning").fadeOut()},comparerData:{cssLoaded:!1,jsLoaded:!1,origUrl:!1,optUrl:!1,width:0,height:0},toRefresh:!1,resizeSizesAlert:!1,returnedStatusSearching:0}}();
res/scss/shortpixel-admin.scss CHANGED
@@ -5,3 +5,4 @@
5
  @import 'view/settings-advanced';
6
  @import 'view/settings';
7
  @import 'view/edit-media';
 
5
  @import 'view/settings-advanced';
6
  @import 'view/settings';
7
  @import 'view/edit-media';
8
+ @import 'view/debug';
shortpixel-plugin.php CHANGED
@@ -23,7 +23,7 @@ class ShortPixelPlugin
23
  protected $shortPixel; // shortpixel megaclass
24
  protected $settings; // settings object.
25
 
26
- protected $admin_pages; // admin page hooks.
27
 
28
  public function __construct()
29
  {
@@ -47,6 +47,7 @@ class ShortPixelPlugin
47
  $this->is_noheaders = true;
48
  }
49
 
 
50
  // @todo Transitionary init for the time being, since plugin init functionality is still split between.
51
  global $shortPixelPluginInstance;
52
  $shortPixelPluginInstance = new \wpShortPixel();
@@ -79,6 +80,11 @@ class ShortPixelPlugin
79
  }
80
  }
81
  }
 
 
 
 
 
82
  }
83
 
84
  /** Function to get plugin settings
@@ -108,7 +114,9 @@ class ShortPixelPlugin
108
  return new \ShortPixel\FileSystemController();
109
  }
110
 
111
- /** Create instance. This should not be needed to call anywhere else than main plugin file **/
 
 
112
  public static function getInstance()
113
  {
114
  if (is_null(self::$instance))
@@ -192,9 +200,13 @@ class ShortPixelPlugin
192
  wp_register_style('shortpixel-admin', plugins_url('/res/css/shortpixel-admin.css', SHORTPIXEL_PLUGIN_FILE),array(), SHORTPIXEL_IMAGE_OPTIMISER_VERSION );
193
 
194
  wp_register_style('shortpixel', plugins_url('/res/css/short-pixel.min.css',SHORTPIXEL_PLUGIN_FILE), array(), SHORTPIXEL_IMAGE_OPTIMISER_VERSION);
 
195
  //modal - used in settings for selecting folder
196
  wp_register_style('shortpixel-modal', plugins_url('/res/css/short-pixel-modal.min.css',SHORTPIXEL_PLUGIN_FILE), array(), SHORTPIXEL_IMAGE_OPTIMISER_VERSION);
197
 
 
 
 
198
  }
199
 
200
  public function admin_notices()
@@ -262,6 +274,11 @@ class ShortPixelPlugin
262
  Log::addDebug('Request', $_REQUEST);
263
  $controller = false;
264
 
 
 
 
 
 
265
  switch($plugin_page)
266
  {
267
  case 'wp-shortpixel-settings':
@@ -383,9 +400,15 @@ class ShortPixelPlugin
383
  public static function uninstallPlugin()
384
  {
385
  $settings = new \WPShortPixelSettings();
 
 
386
  if($settings->removeSettingsOnDeletePlugin == 1) {
387
  \WPShortPixelSettings::debugResetOptions();
388
- insert_with_markers( get_home_path() . '.htaccess', 'ShortPixelWebp', '');
 
 
 
 
389
  }
390
  }
391
 
23
  protected $shortPixel; // shortpixel megaclass
24
  protected $settings; // settings object.
25
 
26
+ protected $admin_pages = array(); // admin page hooks.
27
 
28
  public function __construct()
29
  {
47
  $this->is_noheaders = true;
48
  }
49
 
50
+
51
  // @todo Transitionary init for the time being, since plugin init functionality is still split between.
52
  global $shortPixelPluginInstance;
53
  $shortPixelPluginInstance = new \wpShortPixel();
80
  }
81
  }
82
  }
83
+ elseif($this->settings()->frontBootstrap && $this->env()->is_front)
84
+ {
85
+ // if automedialibrary is off, but we do want to auto-optimize on the front, still load the hook.
86
+ add_filter( 'wp_generate_attachment_metadata', array($admin,'handleImageUploadHook'), 10, 2 );
87
+ }
88
  }
89
 
90
  /** Function to get plugin settings
114
  return new \ShortPixel\FileSystemController();
115
  }
116
 
117
+ /** Create instance. This should not be needed to call anywhere else than main plugin file
118
+ * This should not be called *after* plugins_loaded action
119
+ **/
120
  public static function getInstance()
121
  {
122
  if (is_null(self::$instance))
200
  wp_register_style('shortpixel-admin', plugins_url('/res/css/shortpixel-admin.css', SHORTPIXEL_PLUGIN_FILE),array(), SHORTPIXEL_IMAGE_OPTIMISER_VERSION );
201
 
202
  wp_register_style('shortpixel', plugins_url('/res/css/short-pixel.min.css',SHORTPIXEL_PLUGIN_FILE), array(), SHORTPIXEL_IMAGE_OPTIMISER_VERSION);
203
+
204
  //modal - used in settings for selecting folder
205
  wp_register_style('shortpixel-modal', plugins_url('/res/css/short-pixel-modal.min.css',SHORTPIXEL_PLUGIN_FILE), array(), SHORTPIXEL_IMAGE_OPTIMISER_VERSION);
206
 
207
+
208
+ wp_register_script('shortpixel-debug', plugins_url('/res/js/debug.js',SHORTPIXEL_PLUGIN_FILE), array('jquery', 'jquery-ui-draggable'), SHORTPIXEL_IMAGE_OPTIMISER_VERSION);
209
+
210
  }
211
 
212
  public function admin_notices()
274
  Log::addDebug('Request', $_REQUEST);
275
  $controller = false;
276
 
277
+ if ($this->env()->is_debug)
278
+ {
279
+ $this->load_script('shortpixel-debug');
280
+ }
281
+
282
  switch($plugin_page)
283
  {
284
  case 'wp-shortpixel-settings':
400
  public static function uninstallPlugin()
401
  {
402
  $settings = new \WPShortPixelSettings();
403
+ $env = \wpSPIO()->env();
404
+
405
  if($settings->removeSettingsOnDeletePlugin == 1) {
406
  \WPShortPixelSettings::debugResetOptions();
407
+ if (! $env->is_nginx)
408
+ insert_with_markers( get_home_path() . '.htaccess', 'ShortPixelWebp', '');
409
+
410
+ $spMetaDao = new \ShortPixelCustomMetaDao(new \WpShortPixelDb());
411
+ $spMetaDao->dropTables();
412
  }
413
  }
414
 
shortpixel_api.php CHANGED
@@ -247,7 +247,7 @@ class ShortPixelAPI {
247
  $compressionType = $meta->getCompressionType() !== null ? $meta->getCompressionType() : $this->_settings->compressionType;
248
  $response = $this->doRequests($URLs, true, $itemHandler, $compressionType);//send requests to API
249
 
250
-
251
  //die($response['body']);
252
 
253
  if($response['response']['code'] != 200) {//response <> 200 -> there was an error apparently?
@@ -518,14 +518,21 @@ class ShortPixelAPI {
518
 
519
  private function createArchiveTempFolder($archiveBasename) {
520
  $archiveTempDir = get_temp_dir() . '/' . $archiveBasename;
521
- if(file_exists($archiveTempDir) && is_dir($archiveTempDir) && (time() - filemtime($archiveTempDir) < max(30, SHORTPIXEL_MAX_EXECUTION_TIME) + 10)) {
 
 
 
522
  Log::addWarn("CONFLICT. Folder already exists and is modified in the last minute. Current IP:" . $_SERVER['REMOTE_ADDR']);
523
  return array("Status" => self::STATUS_RETRY, "Code" => 1, "Message" => "Pending");
524
  }
525
- if( !file_exists($archiveTempDir) && !@mkdir($archiveTempDir) ) {
 
 
 
 
526
  return array("Status" => self::STATUS_ERROR, "Code" => self::ERR_SAVE, "Message" => "Could not create temporary folder.");
527
  }
528
- return array("Status" => self::STATUS_SUCCESS, "Dir" => $archiveTempDir);
529
  }
530
 
531
  private function downloadArchive($archive, $compressionType, $first = true) {
247
  $compressionType = $meta->getCompressionType() !== null ? $meta->getCompressionType() : $this->_settings->compressionType;
248
  $response = $this->doRequests($URLs, true, $itemHandler, $compressionType);//send requests to API
249
 
250
+
251
  //die($response['body']);
252
 
253
  if($response['response']['code'] != 200) {//response <> 200 -> there was an error apparently?
518
 
519
  private function createArchiveTempFolder($archiveBasename) {
520
  $archiveTempDir = get_temp_dir() . '/' . $archiveBasename;
521
+ $fs = \wpSPIO()->filesystem();
522
+ $tempDir = $fs->getDirectory($archiveTempDir);
523
+
524
+ if( $tempDir->exists() && (time() - filemtime($archiveTempDir) < max(30, SHORTPIXEL_MAX_EXECUTION_TIME) + 10)) {
525
  Log::addWarn("CONFLICT. Folder already exists and is modified in the last minute. Current IP:" . $_SERVER['REMOTE_ADDR']);
526
  return array("Status" => self::STATUS_RETRY, "Code" => 1, "Message" => "Pending");
527
  }
528
+
529
+ // try to create temporary folder
530
+ $tempDir->check();
531
+
532
+ if( ! $tempDir->exists() ) {
533
  return array("Status" => self::STATUS_ERROR, "Code" => self::ERR_SAVE, "Message" => "Could not create temporary folder.");
534
  }
535
+ return array("Status" => self::STATUS_SUCCESS, "Dir" => $tempDir);
536
  }
537
 
538
  private function downloadArchive($archive, $compressionType, $first = true) {
wp-shortpixel.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: ShortPixel Image Optimizer
4
  * Plugin URI: https://shortpixel.com/
5
  * Description: ShortPixel optimizes images automatically, while guarding the quality of your images. Check your <a href="options-general.php?page=wp-shortpixel-settings" target="_blank">Settings &gt; ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
6
- * Version: 4.15.2
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  * Text Domain: shortpixel-image-optimiser
@@ -19,7 +19,7 @@ define('SHORTPIXEL_PLUGIN_DIR', __DIR__);
19
 
20
  //define('SHORTPIXEL_AFFILIATE_CODE', '');
21
 
22
- define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.15.2");
23
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
24
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
25
  define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');
@@ -86,12 +86,14 @@ require_once(SHORTPIXEL_PLUGIN_DIR . '/class/controller/controller.php');
86
  require_once(SHORTPIXEL_PLUGIN_DIR . '/class/shortpixel-model.php');
87
  require_once(SHORTPIXEL_PLUGIN_DIR . '/shortpixel-plugin.php'); // loads runtime and needed classes.
88
 
 
89
  if (! defined('SHORTPIXEL_DEBUG'))
90
  {
91
  define('SHORTPIXEL_DEBUG', false);
92
  }
93
  $log = ShortPixel\ShortPixelLogger\ShortPixelLogger::getInstance();
94
- $log->setLogPath(SHORTPIXEL_BACKUP_FOLDER . "/shortpixel_log");
 
95
 
96
  // Pre-Runtime Checks
97
  // @todo Better solution for pre-runtime inclusions of externals.
3
  * Plugin Name: ShortPixel Image Optimizer
4
  * Plugin URI: https://shortpixel.com/
5
  * Description: ShortPixel optimizes images automatically, while guarding the quality of your images. Check your <a href="options-general.php?page=wp-shortpixel-settings" target="_blank">Settings &gt; ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
6
+ * Version: 4.15.3
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  * Text Domain: shortpixel-image-optimiser
19
 
20
  //define('SHORTPIXEL_AFFILIATE_CODE', '');
21
 
22
+ define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.15.3");
23
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
24
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
25
  define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');
86
  require_once(SHORTPIXEL_PLUGIN_DIR . '/class/shortpixel-model.php');
87
  require_once(SHORTPIXEL_PLUGIN_DIR . '/shortpixel-plugin.php'); // loads runtime and needed classes.
88
 
89
+
90
  if (! defined('SHORTPIXEL_DEBUG'))
91
  {
92
  define('SHORTPIXEL_DEBUG', false);
93
  }
94
  $log = ShortPixel\ShortPixelLogger\ShortPixelLogger::getInstance();
95
+ if (ShortPixel\ShortPixelLogger\ShortPixelLogger::debugIsActive())
96
+ $log->setLogPath(SHORTPIXEL_BACKUP_FOLDER . "/shortpixel_log");
97
 
98
  // Pre-Runtime Checks
99
  // @todo Better solution for pre-runtime inclusions of externals.