Version Description
Release date: 14th February 2020 * Fix non-dismissable alerts. * Reference to the Website Speed Optimization service. * Fixed: deleteItemCache in wrong place ( before save ) thus resetting data * Fixed: NextGen integration * Language 3 new strings added, 0 updated, 0 fuzzied, and 0 obsoleted
Download this release
Release Info
Developer | ShortPixel |
Plugin | ShortPixel Image Optimizer |
Version | 4.16.1 |
Comparing to | |
See all releases |
Code changes from version 4.16.0 to 4.16.1
- build/shortpixel/notices/src/NoticeController.php +0 -1
- build/shortpixel/notices/src/NoticeModel.php +11 -0
- class/controller/adminnotices_controller.php +13 -0
- class/controller/settings.php +15 -29
- class/db/shortpixel-custom-meta-dao.php +10 -9
- class/db/shortpixel-meta-facade.php +6 -3
- class/external/nextgen.php +197 -22
- class/model/environment_model.php +12 -12
- class/view/settings/part-advanced.php +17 -10
- class/view/shortpixel-list-table.php +10 -5
- class/view/shortpixel_view.php +25 -7
- class/wp-short-pixel.php +29 -106
- readme.txt +10 -1
- res/css/shortpixel-admin.css +3 -0
- res/img/robo-winky.png +0 -0
- res/img/robo-winky@2x.png +0 -0
- res/js/shortpixel.js +5 -3
- res/js/shortpixel.min.js +1 -1
- res/scss/view/_settings-advanced.scss +10 -0
- shortpixel-plugin.php +0 -2
- shortpixel_api.php +1 -0
- wp-shortpixel-req.php +1 -1
- wp-shortpixel.php +2 -2
build/shortpixel/notices/src/NoticeController.php
CHANGED
@@ -256,7 +256,6 @@ class NoticeController //extends ShortPixelController
|
|
256 |
$noticeController = self::getInstance();
|
257 |
$notice = $noticeController->addNotice($message, NoticeModel::NOTICE_WARNING, $unique);
|
258 |
return $notice;
|
259 |
-
|
260 |
}
|
261 |
|
262 |
public static function addSuccess($message, $unique = false)
|
256 |
$noticeController = self::getInstance();
|
257 |
$notice = $noticeController->addNotice($message, NoticeModel::NOTICE_WARNING, $unique);
|
258 |
return $notice;
|
|
|
259 |
}
|
260 |
|
261 |
public static function addSuccess($message, $unique = false)
|
build/shortpixel/notices/src/NoticeModel.php
CHANGED
@@ -72,6 +72,17 @@ class NoticeModel //extends ShortPixelModel
|
|
72 |
$this->suppress_until = time() + $this->suppress_period;
|
73 |
}
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
/** Set a notice persistent. Meaning it shows every page load until dismissed.
|
76 |
* @param $key Unique Key of this message. Required
|
77 |
* @param $suppress When dismissed do not show this message again for X amount of time. When -1 it will just be dropped from the Notices and not suppressed
|
72 |
$this->suppress_until = time() + $this->suppress_period;
|
73 |
}
|
74 |
|
75 |
+
public function unDismiss()
|
76 |
+
{
|
77 |
+
$this->is_dismissed = false;
|
78 |
+
}
|
79 |
+
|
80 |
+
public function setDismissedUntil($timestamp)
|
81 |
+
{
|
82 |
+
$this->suppress_until = $timestamp;
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
/** Set a notice persistent. Meaning it shows every page load until dismissed.
|
87 |
* @param $key Unique Key of this message. Required
|
88 |
* @param $suppress When dismissed do not show this message again for X amount of time. When -1 it will just be dropped from the Notices and not suppressed
|
class/controller/adminnotices_controller.php
CHANGED
@@ -18,6 +18,7 @@ class adminNoticesController extends ShortPixelController
|
|
18 |
const MSG_UNLISTED_FOUND = 'Error102'; // SPIO found unlisted images, but this setting is not on
|
19 |
|
20 |
//const MSG_NO_
|
|
|
21 |
const MSG_UPGRADE_MONTH = 'UpgradeNotice200'; // When processing more than the subscription allows on average..
|
22 |
const MSG_UPGRADE_BULK = 'UpgradeNotice201'; // when there is no enough for a bulk run.
|
23 |
|
@@ -55,6 +56,17 @@ class adminNoticesController extends ShortPixelController
|
|
55 |
{
|
56 |
Notices::removeNoticeByID(self::MSG_UPGRADE_MONTH);
|
57 |
Notices::removeNoticeByID(self::MSG_UPGRADE_BULK);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
59 |
|
60 |
/* General function to check on Hook for admin notices if there is something to show globally */
|
@@ -235,6 +247,7 @@ class adminNoticesController extends ShortPixelController
|
|
235 |
|
236 |
$message = $this->getQuotaExceededMessage($quotaData);
|
237 |
$notice = Notices::addError($message);
|
|
|
238 |
}
|
239 |
|
240 |
}
|
18 |
const MSG_UNLISTED_FOUND = 'Error102'; // SPIO found unlisted images, but this setting is not on
|
19 |
|
20 |
//const MSG_NO_
|
21 |
+
const MSG_QUOTA_REACHED = 'QuotaReached100';
|
22 |
const MSG_UPGRADE_MONTH = 'UpgradeNotice200'; // When processing more than the subscription allows on average..
|
23 |
const MSG_UPGRADE_BULK = 'UpgradeNotice201'; // when there is no enough for a bulk run.
|
24 |
|
56 |
{
|
57 |
Notices::removeNoticeByID(self::MSG_UPGRADE_MONTH);
|
58 |
Notices::removeNoticeByID(self::MSG_UPGRADE_BULK);
|
59 |
+
Notices::removeNoticeBYID(self::MSG_QUOTA_REACHED);
|
60 |
+
}
|
61 |
+
|
62 |
+
/** ReInstates A Persistent Notice manually */
|
63 |
+
public static function reInstateQuotaExceeded()
|
64 |
+
{
|
65 |
+
$noticeControl = Notices::getInstance();
|
66 |
+
$notice = $noticeControl->getNoticeByID(self::MSG_QUOTA_REACHED);
|
67 |
+
$notice->unDismiss();
|
68 |
+
|
69 |
+
$noticeControl->update();
|
70 |
}
|
71 |
|
72 |
/* General function to check on Hook for admin notices if there is something to show globally */
|
247 |
|
248 |
$message = $this->getQuotaExceededMessage($quotaData);
|
249 |
$notice = Notices::addError($message);
|
250 |
+
Notices::makePersistent($notice, self::MSG_QUOTA_REACHED, WEEK_IN_SECONDS);
|
251 |
}
|
252 |
|
253 |
}
|
class/controller/settings.php
CHANGED
@@ -90,16 +90,9 @@ class SettingsController extends shortPixelController
|
|
90 |
$this->keyModel->resetTried();
|
91 |
$this->keyModel->checkKey($this->postData['apiKey']);
|
92 |
}
|
93 |
-
/*if (isset($this->postData['verifiedKey']) && $this->postData['verifiedKey'])
|
94 |
-
{
|
95 |
-
$this->model->apiKey = $this->postData['apiKey'];
|
96 |
-
$this->model->verifiedKey = $this->postData['verifiedKey'];
|
97 |
-
} */
|
98 |
}
|
99 |
|
100 |
$this->doRedirect();
|
101 |
-
//exit();
|
102 |
-
|
103 |
}
|
104 |
|
105 |
public function action_debug_medialibrary()
|
@@ -195,10 +188,8 @@ class SettingsController extends shortPixelController
|
|
195 |
$this->has_nextgen = $env->has_nextgen;
|
196 |
|
197 |
$this->display_part = isset($_GET['part']) ? sanitize_text_field($_GET['part']) : 'settings';
|
198 |
-
|
199 |
}
|
200 |
|
201 |
-
|
202 |
/* Temporary function to check if HTaccess is writable.
|
203 |
* HTaccess is writable if it exists *and* is_writable, or can be written if directory is writable.
|
204 |
* @todo Should be replaced when File / Folder model are complete. Function check should go there.
|
@@ -276,12 +267,21 @@ class SettingsController extends shortPixelController
|
|
276 |
|
277 |
if ($this->has_nextgen)
|
278 |
{
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
}
|
|
|
285 |
}
|
286 |
return $customFolders;
|
287 |
}
|
@@ -487,19 +487,5 @@ class SettingsController extends shortPixelController
|
|
487 |
exit();
|
488 |
}
|
489 |
|
490 |
-
|
491 |
-
protected function NoticeApiKeyLength($key)
|
492 |
-
{
|
493 |
-
$KeyLength = strlen($key);
|
494 |
-
|
495 |
-
$notice = sprintf(__("The key you provided has %s characters. The API key should have 20 characters, letters and numbers only.",'shortpixel-image-optimiser'), $KeyLength)
|
496 |
-
. "<BR> <b>"
|
497 |
-
. __('Please check that the API key is the same as the one you received in your confirmation email.','shortpixel-image-optimiser')
|
498 |
-
. "</b><BR> "
|
499 |
-
. __('If this problem persists, please contact us at ','shortpixel-image-optimiser')
|
500 |
-
. "<a href='mailto:help@shortpixel.com?Subject=API Key issues' target='_top'>help@shortpixel.com</a>"
|
501 |
-
. __(' or ','shortpixel-image-optimiser')
|
502 |
-
. "<a href='https://shortpixel.com/contact' target='_blank'>" . __('here','shortpixel-image-optimiser') . "</a>.";
|
503 |
-
Notice::addError($notice);
|
504 |
-
} */
|
505 |
}
|
90 |
$this->keyModel->resetTried();
|
91 |
$this->keyModel->checkKey($this->postData['apiKey']);
|
92 |
}
|
|
|
|
|
|
|
|
|
|
|
93 |
}
|
94 |
|
95 |
$this->doRedirect();
|
|
|
|
|
96 |
}
|
97 |
|
98 |
public function action_debug_medialibrary()
|
188 |
$this->has_nextgen = $env->has_nextgen;
|
189 |
|
190 |
$this->display_part = isset($_GET['part']) ? sanitize_text_field($_GET['part']) : 'settings';
|
|
|
191 |
}
|
192 |
|
|
|
193 |
/* Temporary function to check if HTaccess is writable.
|
194 |
* HTaccess is writable if it exists *and* is_writable, or can be written if directory is writable.
|
195 |
* @todo Should be replaced when File / Folder model are complete. Function check should go there.
|
267 |
|
268 |
if ($this->has_nextgen)
|
269 |
{
|
270 |
+
// $ngg = array_map(array('ShortPixelNextGenAdapter','pathToAbsolute'), \ShortPixelNextGenAdapter::getGalleries());
|
271 |
+
$ng = NextGen::getInstance();
|
272 |
+
$folders = $ng->getGalleries();
|
273 |
+
$foldersArray = array();
|
274 |
+
foreach($folders as $dirObj)
|
275 |
+
{
|
276 |
+
$foldersArray[] = $dirObj->getPath();
|
277 |
+
}
|
278 |
+
|
279 |
+
foreach($customFolders as $id => $folder)
|
280 |
+
{
|
281 |
+
if(in_array($folder->getPath(), $foldersArray )) {
|
282 |
+
$folder->setType("nextgen");
|
283 |
}
|
284 |
+
}
|
285 |
}
|
286 |
return $customFolders;
|
287 |
}
|
487 |
exit();
|
488 |
}
|
489 |
|
490 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
491 |
}
|
class/db/shortpixel-custom-meta-dao.php
CHANGED
@@ -65,12 +65,12 @@ class ShortPixelCustomMetaDao {
|
|
65 |
path_md5 char(32),
|
66 |
compressed_size int(10) NOT NULL DEFAULT 0,
|
67 |
compression_type tinyint,
|
68 |
-
keep_exif tinyint,
|
69 |
-
cmyk2rgb tinyint,
|
70 |
resize tinyint,
|
71 |
resize_width smallint,
|
72 |
resize_height smallint,
|
73 |
-
backup tinyint,
|
74 |
status SMALLINT NOT NULL DEFAULT 0,
|
75 |
retries tinyint NOT NULL DEFAULT 0,
|
76 |
message varchar(255),
|
@@ -132,7 +132,7 @@ class ShortPixelCustomMetaDao {
|
|
132 |
$rows = $this->db->query($sql);
|
133 |
$folders = array();
|
134 |
foreach($rows as $row) {
|
135 |
-
$folders[] = new ShortPixelFolder($row, $this->excludePatterns);
|
136 |
}
|
137 |
return $folders;
|
138 |
}
|
@@ -272,7 +272,7 @@ class ShortPixelCustomMetaDao {
|
|
272 |
Log::addWarn('FolderObj from database is not there, while folder seems ok ' . $folder->getPath() );
|
273 |
return false;
|
274 |
}
|
275 |
-
|
276 |
Log::addDebug('Doing Refresh Folder for (DirectoryModel / ShortpixelFolder) ', array($folder->getPath(), $folderObj->getPath()) );
|
277 |
|
278 |
$fs = \wpSPIO()->fileSystem();
|
@@ -334,7 +334,6 @@ class ShortPixelCustomMetaDao {
|
|
334 |
$folder->setId($fld->getId());
|
335 |
}
|
336 |
}
|
337 |
-
//var_dump($allFolders);
|
338 |
return sprintf(__('Folder already included in %s.','shortpixel-image-optimiser'),$parent);
|
339 |
}
|
340 |
} else {
|
@@ -376,24 +375,26 @@ class ShortPixelCustomMetaDao {
|
|
376 |
$i = 0;
|
377 |
$count = 0;
|
378 |
$placeholders = array();
|
|
|
|
|
379 |
foreach($files as $file) {
|
380 |
$filepath = $file->getFullPath();
|
381 |
$filename = $file->getFileName();
|
382 |
|
383 |
-
array_push($values, $folderId, $filepath, $filename, md5($filepath),
|
384 |
$placeholders[] = $format;
|
385 |
|
386 |
-
|
387 |
if($i % 500 == 499) {
|
388 |
$query = $sql;
|
389 |
$query .= implode(', ', $placeholders);
|
390 |
$this->db->query( $this->db->prepare("$query ", $values));
|
391 |
|
392 |
$values = array();
|
|
|
393 |
}
|
394 |
$i++;
|
395 |
}
|
396 |
-
if($values) {
|
397 |
$query = $sql;
|
398 |
$query .= implode(', ', $placeholders);
|
399 |
$result = $wpdb->query( $wpdb->prepare("$query ", $values) );
|
65 |
path_md5 char(32),
|
66 |
compressed_size int(10) NOT NULL DEFAULT 0,
|
67 |
compression_type tinyint,
|
68 |
+
keep_exif tinyint DEFAULT 0,
|
69 |
+
cmyk2rgb tinyint DEFAULT 0,
|
70 |
resize tinyint,
|
71 |
resize_width smallint,
|
72 |
resize_height smallint,
|
73 |
+
backup tinyint DEFAULT 0,
|
74 |
status SMALLINT NOT NULL DEFAULT 0,
|
75 |
retries tinyint NOT NULL DEFAULT 0,
|
76 |
message varchar(255),
|
132 |
$rows = $this->db->query($sql);
|
133 |
$folders = array();
|
134 |
foreach($rows as $row) {
|
135 |
+
$folders[$row->id] = new ShortPixelFolder($row, $this->excludePatterns);
|
136 |
}
|
137 |
return $folders;
|
138 |
}
|
272 |
Log::addWarn('FolderObj from database is not there, while folder seems ok ' . $folder->getPath() );
|
273 |
return false;
|
274 |
}
|
275 |
+
|
276 |
Log::addDebug('Doing Refresh Folder for (DirectoryModel / ShortpixelFolder) ', array($folder->getPath(), $folderObj->getPath()) );
|
277 |
|
278 |
$fs = \wpSPIO()->fileSystem();
|
334 |
$folder->setId($fld->getId());
|
335 |
}
|
336 |
}
|
|
|
337 |
return sprintf(__('Folder already included in %s.','shortpixel-image-optimiser'),$parent);
|
338 |
}
|
339 |
} else {
|
375 |
$i = 0;
|
376 |
$count = 0;
|
377 |
$placeholders = array();
|
378 |
+
$status = (\wpSPIO()->settings()->autoMediaLibrary == 1) ? ShortPixelMeta::FILE_STATUS_PENDING : ShortPixelMeta::FILE_STATUS_UNPROCESSED;
|
379 |
+
|
380 |
foreach($files as $file) {
|
381 |
$filepath = $file->getFullPath();
|
382 |
$filename = $file->getFileName();
|
383 |
|
384 |
+
array_push($values, $folderId, $filepath, $filename, md5($filepath), $status);
|
385 |
$placeholders[] = $format;
|
386 |
|
|
|
387 |
if($i % 500 == 499) {
|
388 |
$query = $sql;
|
389 |
$query .= implode(', ', $placeholders);
|
390 |
$this->db->query( $this->db->prepare("$query ", $values));
|
391 |
|
392 |
$values = array();
|
393 |
+
$placeholders = array();
|
394 |
}
|
395 |
$i++;
|
396 |
}
|
397 |
+
if(count($values) > 0) {
|
398 |
$query = $sql;
|
399 |
$query .= implode(', ', $placeholders);
|
400 |
$result = $wpdb->query( $wpdb->prepare("$query ", $values) );
|
class/db/shortpixel-meta-facade.php
CHANGED
@@ -109,15 +109,14 @@ class ShortPixelMetaFacade {
|
|
109 |
// Update MetaData of Image.
|
110 |
public function updateMeta($newMeta = null, $replaceThumbs = false) {
|
111 |
|
112 |
-
$this->deleteItemCache();
|
113 |
-
|
114 |
if($newMeta) {
|
115 |
$this->meta = $newMeta;
|
116 |
}
|
117 |
if($this->type == self::CUSTOM_TYPE) {
|
118 |
$this->spMetaDao->update($this->meta);
|
119 |
if($this->meta->getExtMetaId()) {
|
120 |
-
|
|
|
121 |
}
|
122 |
}
|
123 |
elseif($this->type == ShortPixelMetaFacade::MEDIA_LIBRARY_TYPE) {
|
@@ -223,6 +222,8 @@ class ShortPixelMetaFacade {
|
|
223 |
}
|
224 |
} // duplicates loop
|
225 |
}
|
|
|
|
|
226 |
}
|
227 |
|
228 |
|
@@ -896,6 +897,7 @@ class ShortPixelMetaFacade {
|
|
896 |
return array_unique($duplicates);
|
897 |
}
|
898 |
|
|
|
899 |
public static function pathToWebPath($path) {
|
900 |
//$upl = wp_upload_dir();
|
901 |
//return str_replace($upl["basedir"], $upl["baseurl"], $path);
|
@@ -910,6 +912,7 @@ class ShortPixelMetaFacade {
|
|
910 |
return self::filenameToRootRelative($path);
|
911 |
}
|
912 |
|
|
|
913 |
public static function filenameToRootRelative($path) {
|
914 |
return self::replaceHomePath($path, "");
|
915 |
}
|
109 |
// Update MetaData of Image.
|
110 |
public function updateMeta($newMeta = null, $replaceThumbs = false) {
|
111 |
|
|
|
|
|
112 |
if($newMeta) {
|
113 |
$this->meta = $newMeta;
|
114 |
}
|
115 |
if($this->type == self::CUSTOM_TYPE) {
|
116 |
$this->spMetaDao->update($this->meta);
|
117 |
if($this->meta->getExtMetaId()) {
|
118 |
+
$ng = \ShortPixel\NextGen::getInstance();
|
119 |
+
$ng->updateImageSize($this->meta->getExtMetaId(), $this->meta->getPath());
|
120 |
}
|
121 |
}
|
122 |
elseif($this->type == ShortPixelMetaFacade::MEDIA_LIBRARY_TYPE) {
|
222 |
}
|
223 |
} // duplicates loop
|
224 |
}
|
225 |
+
|
226 |
+
$this->deleteItemCache();
|
227 |
}
|
228 |
|
229 |
|
897 |
return array_unique($duplicates);
|
898 |
}
|
899 |
|
900 |
+
/* @todo . Was only in use by now defunct shortpixel-list-table */
|
901 |
public static function pathToWebPath($path) {
|
902 |
//$upl = wp_upload_dir();
|
903 |
//return str_replace($upl["basedir"], $upl["baseurl"], $path);
|
912 |
return self::filenameToRootRelative($path);
|
913 |
}
|
914 |
|
915 |
+
|
916 |
public static function filenameToRootRelative($path) {
|
917 |
return self::replaceHomePath($path, "");
|
918 |
}
|
class/external/nextgen.php
CHANGED
@@ -4,31 +4,66 @@ use ShortPixel\Notices\NoticeController as Notice;
|
|
4 |
|
5 |
class NextGen
|
6 |
{
|
7 |
-
protected $instance;
|
|
|
|
|
|
|
8 |
|
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
|
16 |
{
|
17 |
-
$
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
21 |
|
22 |
-
return $use_screens;
|
23 |
}
|
24 |
|
|
|
25 |
public static function getInstance()
|
26 |
{
|
27 |
if (is_null(self::$instance))
|
28 |
-
self::$instance = new
|
29 |
|
30 |
return self::$instance;
|
31 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
/** Enables nextGen, add galleries to custom folders
|
33 |
* @param boolean $silent Throw a notice or not. This seems to be based if nextgen was already activated previously or not.
|
34 |
*/
|
@@ -40,24 +75,47 @@ class NextGen
|
|
40 |
|
41 |
}
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
/** Adds nextGen galleries to custom table
|
44 |
* Note - this function does *Not* check if nextgen is enabled, not if checks custom Tables. Use nextgenEnabled for this.
|
45 |
* Enabled checks are not an external class issue, so must be done before calling.
|
46 |
*/
|
47 |
public function addNextGenGalleriesToCustom($silent = true) {
|
48 |
$shortPixel = \wpSPIO()->getShortPixel();
|
49 |
-
|
|
|
50 |
$folderMsg = "";
|
51 |
-
|
52 |
//add the NextGen galleries to custom folders
|
53 |
-
$ngGalleries =
|
|
|
|
|
54 |
$meta = $shortPixel->getSpMetaDao();
|
55 |
foreach($ngGalleries as $gallery) {
|
56 |
-
$msg = $meta->newFolderFromPath($gallery,
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
61 |
//$this->_settings->hasCustomFolders = time();
|
62 |
}
|
63 |
|
@@ -68,20 +126,137 @@ class NextGen
|
|
68 |
$settings->hasCustomFolders = time();
|
69 |
|
70 |
}
|
71 |
-
if (! $silent)
|
72 |
{
|
73 |
Notice::addNormal($folderMsg);
|
74 |
}
|
75 |
|
76 |
}
|
77 |
|
78 |
-
|
79 |
-
public function add_image($image)
|
80 |
{
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
} // class .
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
|
87 |
-
$ng =
|
4 |
|
5 |
class NextGen
|
6 |
{
|
7 |
+
protected static $instance;
|
8 |
+
protected $view;
|
9 |
+
|
10 |
+
// ngg_created_new_gallery
|
11 |
|
12 |
public function __construct()
|
13 |
{
|
|
|
14 |
add_filter('shortpixel/init/optimize_on_screens', array($this, 'add_screen_loads'));
|
15 |
+
$this->view = new nextGenView();
|
16 |
+
|
17 |
+
|
18 |
+
add_action('plugins_loaded', array($this, 'hooks'));
|
19 |
}
|
20 |
|
21 |
+
public function hooks()
|
22 |
{
|
23 |
+
if ($this->optimizeNextGen()) // if optimization is on, hook.
|
24 |
+
{
|
25 |
+
add_action('ngg_update_addgallery_page', array( &$this, 'addNextGenGalleriesToCustom'));
|
26 |
+
add_action('ngg_added_new_image', array($this,'handleImageUpload'));
|
27 |
+
}
|
28 |
|
|
|
29 |
}
|
30 |
|
31 |
+
// Use GetInstance, don't use the construct.
|
32 |
public static function getInstance()
|
33 |
{
|
34 |
if (is_null(self::$instance))
|
35 |
+
self::$instance = new NextGen();
|
36 |
|
37 |
return self::$instance;
|
38 |
}
|
39 |
+
|
40 |
+
public function has_nextgen()
|
41 |
+
{
|
42 |
+
if (defined('NGG_PLUGIN'))
|
43 |
+
return true;
|
44 |
+
else
|
45 |
+
return false;
|
46 |
+
}
|
47 |
+
|
48 |
+
public function optimizeNextGen()
|
49 |
+
{
|
50 |
+
if (\wpSPIO()->settings()->includeNextGen == 1)
|
51 |
+
return true;
|
52 |
+
else
|
53 |
+
return false;
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
public function add_screen_loads($use_screens)
|
58 |
+
{
|
59 |
+
|
60 |
+
$use_screens[] = 'toplevel_page_nextgen-gallery'; // toplevel
|
61 |
+
$use_screens[] = 'gallery_page_ngg_addgallery'; // add gallery
|
62 |
+
$use_screens[] = 'nggallery-manage-gallery'; // manage gallery
|
63 |
+
$use_screens[] = 'gallery_page_nggallery-manage-album'; // manage album
|
64 |
+
|
65 |
+
return $use_screens;
|
66 |
+
}
|
67 |
/** Enables nextGen, add galleries to custom folders
|
68 |
* @param boolean $silent Throw a notice or not. This seems to be based if nextgen was already activated previously or not.
|
69 |
*/
|
75 |
|
76 |
}
|
77 |
|
78 |
+
/* @return DirectoryModel */
|
79 |
+
public function getGalleries()
|
80 |
+
{
|
81 |
+
global $wpdb;
|
82 |
+
$fs = \wpSPIO()->filesystem();
|
83 |
+
$homepath = $fs->getWPFileBase();
|
84 |
+
$result = $wpdb->get_results("SELECT path FROM {$wpdb->prefix}ngg_gallery");
|
85 |
+
|
86 |
+
$galleries = array();
|
87 |
+
|
88 |
+
foreach($result as $row)
|
89 |
+
{
|
90 |
+
$directory = $fs->getDirectory($homepath->getPath() . $row->path);
|
91 |
+
if ($directory->exists())
|
92 |
+
$galleries[] = $directory;
|
93 |
+
}
|
94 |
+
|
95 |
+
return $galleries;
|
96 |
+
}
|
97 |
+
|
98 |
/** Adds nextGen galleries to custom table
|
99 |
* Note - this function does *Not* check if nextgen is enabled, not if checks custom Tables. Use nextgenEnabled for this.
|
100 |
* Enabled checks are not an external class issue, so must be done before calling.
|
101 |
*/
|
102 |
public function addNextGenGalleriesToCustom($silent = true) {
|
103 |
$shortPixel = \wpSPIO()->getShortPixel();
|
104 |
+
$fs = \wpSPIO()->filesystem();
|
105 |
+
$homepath = $fs->getWPFileBase();
|
106 |
$folderMsg = "";
|
|
|
107 |
//add the NextGen galleries to custom folders
|
108 |
+
$ngGalleries = $this->getGalleries();
|
109 |
+
|
110 |
+
|
111 |
$meta = $shortPixel->getSpMetaDao();
|
112 |
foreach($ngGalleries as $gallery) {
|
113 |
+
$msg = $meta->newFolderFromPath($gallery, $homepath->getPath(), \WPShortPixel::getCustomFolderBase());
|
114 |
+
// if($msg) { //try again with ABSPATH as maybe WP is in a subdir
|
115 |
+
// $msg = $meta->newFolderFromPath($gallery, ABSPATH, \WPShortPixel::getCustomFolderBase());
|
116 |
+
// }
|
117 |
+
if ($msg)
|
118 |
+
$folderMsg .= $msg . '(' . $gallery . ') <br>';
|
119 |
//$this->_settings->hasCustomFolders = time();
|
120 |
}
|
121 |
|
126 |
$settings->hasCustomFolders = time();
|
127 |
|
128 |
}
|
129 |
+
if (! $silent && (strlen(trim($folderMsg)) > 0 && $folderMsg !== false))
|
130 |
{
|
131 |
Notice::addNormal($folderMsg);
|
132 |
}
|
133 |
|
134 |
}
|
135 |
|
136 |
+
public function handleImageUpload($image)
|
|
|
137 |
{
|
138 |
+
$shortPixel = \wpSPIO()->getShortPixel();
|
139 |
+
$metadao = $shortPixel->getSpMetaDao();
|
140 |
+
|
141 |
+
if (\wpSPIO()->settings()->includeNextGen == 1) {
|
142 |
+
$imageFsPath = $this->getImageAbspath($image);
|
143 |
+
$customFolders = $metadao->getFolders();
|
144 |
+
|
145 |
+
$folderId = -1;
|
146 |
+
foreach ($customFolders as $folder) {
|
147 |
+
if (strpos($imageFsPath, $folder->getPath()) === 0) {
|
148 |
+
$folderId = $folder->getId();
|
149 |
+
break;
|
150 |
+
}
|
151 |
+
}
|
152 |
+
if ($folderId == -1) { //if not found, create
|
153 |
+
$galleryPath = dirname($imageFsPath);
|
154 |
+
$folder = new \ShortPixelFolder(array("path" => $galleryPath), $this->_settings->excludePatterns);
|
155 |
+
$folderMsg = $metadao->saveFolder($folder);
|
156 |
+
$folderId = $folder->getId();
|
157 |
+
//self::log("NG Image Upload: created folder from path $galleryPath : Folder info: " . json_encode($folder));
|
158 |
+
}
|
159 |
+
|
160 |
+
return $shortPixel->addPathToCustomFolder($imageFsPath, $folderId, $image->pid);
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
public function updateImageSize($nggId, $path) {
|
165 |
+
|
166 |
+
$mapper = \C_Image_Mapper::get_instance();
|
167 |
+
$image = $mapper->find($nggId);
|
168 |
+
|
169 |
+
$dimensions = getimagesize($this->getImageAbspath($image));
|
170 |
+
$size_meta = array('width' => $dimensions[0], 'height' => $dimensions[1]);
|
171 |
+
$image->meta_data = array_merge($image->meta_data, $size_meta);
|
172 |
+
$image->meta_data['full'] = $size_meta;
|
173 |
+
$mapper->save($image);
|
174 |
}
|
175 |
+
|
176 |
+
public function getImageAbspath($image) {
|
177 |
+
$storage = \C_Gallery_Storage::get_instance();
|
178 |
+
return $storage->get_image_abspath($image);
|
179 |
+
}
|
180 |
+
|
181 |
} // class .
|
182 |
|
183 |
+
class nextGenView
|
184 |
+
{
|
185 |
+
protected $nggColumnIndex = 0;
|
186 |
+
|
187 |
+
public function __construct()
|
188 |
+
{
|
189 |
+
$this->hooks();
|
190 |
+
}
|
191 |
+
|
192 |
+
protected function hooks()
|
193 |
+
{
|
194 |
+
add_filter( 'ngg_manage_images_columns', array( $this, 'nggColumns' ) );
|
195 |
+
add_filter( 'ngg_manage_images_number_of_columns', array( $this, 'nggCountColumns' ) );
|
196 |
+
add_filter( 'ngg_manage_images_column_7_header', array( $this, 'nggColumnHeader' ) );
|
197 |
+
add_filter( 'ngg_manage_images_column_7_content', array( $this, 'nggColumnContent' ) );
|
198 |
+
}
|
199 |
+
|
200 |
+
// @todo move NGG specific function to own integration
|
201 |
+
public function nggColumns( $defaults ) {
|
202 |
+
$this->nggColumnIndex = count($defaults) + 1;
|
203 |
+
add_filter( 'ngg_manage_images_column_' . $this->nggColumnIndex . '_header', array( &$this, 'nggColumnHeader' ) );
|
204 |
+
add_filter( 'ngg_manage_images_column_' . $this->nggColumnIndex . '_content', array( &$this, 'nggColumnContent' ), 10, 2 );
|
205 |
+
$defaults['wp-shortPixelNgg'] = 'ShortPixel Compression';
|
206 |
+
return $defaults;
|
207 |
+
}
|
208 |
+
|
209 |
+
public function nggCountColumns( $count ) {
|
210 |
+
return $count + 1;
|
211 |
+
}
|
212 |
+
|
213 |
+
public function nggColumnHeader( $default ) {
|
214 |
+
return __('ShortPixel Compression','shortpixel-image-optimiser');
|
215 |
+
}
|
216 |
+
|
217 |
+
public function nggColumnContent( $unknown, $picture ) {
|
218 |
+
$shortPixel = \wpSPIO()->getShortPixel();
|
219 |
+
$metadao = $shortPixel->getSpMetaDao();
|
220 |
+
$view = new \ShortPixelView($shortPixel);
|
221 |
+
|
222 |
+
$meta = $metadao->getMetaForPath($picture->imagePath);
|
223 |
+
if($meta) {
|
224 |
+
switch($meta->getStatus()) {
|
225 |
+
case "0": echo("<div id='sp-msg-C-{$meta->getId()}' class='column-wp-shortPixel' style='color: #000'>Waiting</div>"); break;
|
226 |
+
case "1": echo("<div id='sp-msg-C-{$meta->getId()}' class='column-wp-shortPixel' style='color: #000'>Pending</div>"); break;
|
227 |
+
case "2": $view->renderCustomColumn("C-" . $meta->getId(), array(
|
228 |
+
'showActions' => false && current_user_can( 'manage_options' ),
|
229 |
+
'status' => 'imgOptimized',
|
230 |
+
'type' => \ShortPixelAPI::getCompressionTypeName($meta->getCompressionType()),
|
231 |
+
'percent' => $meta->getImprovementPercent(),
|
232 |
+
'bonus' => $meta->getImprovementPercent() < 5,
|
233 |
+
'thumbsOpt' => 0,
|
234 |
+
'thumbsOptList' => array(),
|
235 |
+
'thumbsTotal' => 0,
|
236 |
+
'retinasOpt' => 0,
|
237 |
+
'backup' => true,
|
238 |
+
'excludeSizes' => \wpSPIO()->settings()->excludeSizes,
|
239 |
+
'thumbsToOptimize' => array(),
|
240 |
+
'invType' => array(),
|
241 |
+
|
242 |
+
));
|
243 |
+
break;
|
244 |
+
}
|
245 |
+
} else {
|
246 |
+
$view->renderCustomColumn($meta ? "C-" . $meta->getId() : "N-" . $picture->pid, array(
|
247 |
+
'showActions' => false && current_user_can( 'manage_options' ),
|
248 |
+
'status' => 'optimizeNow',
|
249 |
+
'thumbsOpt' => 0,
|
250 |
+
'thumbsOptList' => array(),
|
251 |
+
'thumbsTotal' => 0,
|
252 |
+
'retinasOpt' => 0,
|
253 |
+
'message' => "Not optimized"
|
254 |
+
));
|
255 |
+
}
|
256 |
+
// return var_dump($meta);
|
257 |
+
}
|
258 |
+
|
259 |
+
} // class
|
260 |
|
261 |
|
262 |
+
$ng = NextGen::getInstance();
|
class/model/environment_model.php
CHANGED
@@ -41,8 +41,8 @@ class EnvironmentModel extends ShortPixelModel
|
|
41 |
{
|
42 |
$this->setServer();
|
43 |
$this->setWordPress();
|
44 |
-
$this
|
45 |
-
$this
|
46 |
}
|
47 |
|
48 |
public static function getInstance()
|
@@ -50,8 +50,8 @@ class EnvironmentModel extends ShortPixelModel
|
|
50 |
if (is_null(self::$instance))
|
51 |
self::$instance = new EnvironmentModel();
|
52 |
|
53 |
-
if (! self::$instance->screen_is_set)
|
54 |
-
self::$instance->setScreen();
|
55 |
|
56 |
return self::$instance;
|
57 |
}
|
@@ -92,15 +92,16 @@ class EnvironmentModel extends ShortPixelModel
|
|
92 |
|
93 |
}
|
94 |
|
95 |
-
public function setScreen()
|
96 |
{
|
97 |
-
if (! function_exists('get_current_screen')) // way too early.
|
98 |
return false;
|
99 |
|
100 |
$screen = get_current_screen();
|
|
|
101 |
|
102 |
-
if (is_null($screen)) //
|
103 |
-
return false;
|
104 |
|
105 |
// WordPress pages where we'll be active on.
|
106 |
// https://codex.wordpress.org/Plugin_API/Admin_Screen_Reference
|
@@ -142,14 +143,13 @@ class EnvironmentModel extends ShortPixelModel
|
|
142 |
$this->is_bulk_page = true;
|
143 |
}
|
144 |
|
145 |
-
|
146 |
-
|
147 |
$this->screen_is_set = true;
|
148 |
}
|
149 |
|
150 |
-
|
151 |
{
|
152 |
-
$
|
|
|
153 |
|
154 |
}
|
155 |
}
|
41 |
{
|
42 |
$this->setServer();
|
43 |
$this->setWordPress();
|
44 |
+
add_action('plugins_loaded', array($this, 'setIntegrations') ); // not set on construct.
|
45 |
+
add_action('current_screen', array($this, 'setScreen') ); // Not set on construct
|
46 |
}
|
47 |
|
48 |
public static function getInstance()
|
50 |
if (is_null(self::$instance))
|
51 |
self::$instance = new EnvironmentModel();
|
52 |
|
53 |
+
/*if (! self::$instance->screen_is_set)
|
54 |
+
self::$instance->setScreen(); */
|
55 |
|
56 |
return self::$instance;
|
57 |
}
|
92 |
|
93 |
}
|
94 |
|
95 |
+
public function setScreen($screen)
|
96 |
{
|
97 |
+
/*if (! function_exists('get_current_screen')) // way too early.
|
98 |
return false;
|
99 |
|
100 |
$screen = get_current_screen();
|
101 |
+
*/
|
102 |
|
103 |
+
/*if (is_null($screen)) //
|
104 |
+
return false; */
|
105 |
|
106 |
// WordPress pages where we'll be active on.
|
107 |
// https://codex.wordpress.org/Plugin_API/Admin_Screen_Reference
|
143 |
$this->is_bulk_page = true;
|
144 |
}
|
145 |
|
|
|
|
|
146 |
$this->screen_is_set = true;
|
147 |
}
|
148 |
|
149 |
+
public function setIntegrations()
|
150 |
{
|
151 |
+
$ng = NextGen::getInstance();
|
152 |
+
$this->has_nextgen = $ng->has_nextgen();
|
153 |
|
154 |
}
|
155 |
}
|
class/view/settings/part-advanced.php
CHANGED
@@ -53,17 +53,19 @@ namespace ShortPixel;
|
|
53 |
<?php if($view->customFolders) { ?>
|
54 |
<table class="shortpixel-folders-list">
|
55 |
<tr style="font-weight: bold;">
|
56 |
-
<
|
57 |
-
<
|
58 |
-
<
|
59 |
-
<
|
60 |
-
<td
|
61 |
</tr>
|
62 |
-
<?php foreach($view->customFolders as $folder) {
|
63 |
-
$
|
64 |
-
|
|
|
65 |
$stat = $this->shortPixel->getSpMetaDao()->getFolderOptimizationStatus($folder->getId());
|
66 |
$cnt = $folder->getFileCount();
|
|
|
67 |
$st = ($cnt == 0
|
68 |
? __("Empty",'shortpixel-image-optimiser')
|
69 |
: ($stat->Total == $stat->Optimized
|
@@ -74,19 +76,22 @@ namespace ShortPixel;
|
|
74 |
|
75 |
$action = ($st == __("Optimized",'shortpixel-image-optimiser') || $st == __("Empty",'shortpixel-image-optimiser') ? __("Stop monitoring",'shortpixel-image-optimiser') : __("Stop optimizing",'shortpixel-image-optimiser'));
|
76 |
|
|
|
|
|
|
|
77 |
$fullStat = $st == __("Empty",'shortpixel-image-optimiser') ? "" : __("Optimized",'shortpixel-image-optimiser') . ": " . $stat->Optimized . ", "
|
78 |
. __("Pending",'shortpixel-image-optimiser') . ": " . $stat->Pending . ", " . __("Waiting",'shortpixel-image-optimiser') . ": " . $stat->Waiting . ", "
|
79 |
. __("Failed",'shortpixel-image-optimiser') . ": " . $stat->Failed;
|
80 |
?>
|
81 |
<tr>
|
82 |
-
<td>
|
83 |
<?php echo($folder->getPath()); ?>
|
84 |
</td>
|
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> <?php } echo($
|
90 |
|
91 |
</td>
|
92 |
<td>
|
@@ -96,7 +101,9 @@ namespace ShortPixel;
|
|
96 |
<?php echo($folder->getTsUpdated()); ?>
|
97 |
</td>
|
98 |
<td>
|
|
|
99 |
<input type="button" class="button remove-folder-button" data-value="<?php echo($folder->getPath()); ?>" title="<?php echo($action . " " . $folder->getPath()); ?>" value="<?php echo $action;?>">
|
|
|
100 |
<input type="button" style="display:none;" class="button button-alert recheck-folder-button" data-value="<?php echo($folder->getPath()); ?>"
|
101 |
title="<?php _e('Full folder refresh, check each file of the folder if it changed since it was optimized. Might take up to 1 min. for big folders.','shortpixel-image-optimiser');?>"
|
102 |
value="<?php _e('Refresh','shortpixel-image-optimiser');?>">
|
53 |
<?php if($view->customFolders) { ?>
|
54 |
<table class="shortpixel-folders-list">
|
55 |
<tr style="font-weight: bold;">
|
56 |
+
<th><?php _e('Folder name','shortpixel-image-optimiser');?></th>
|
57 |
+
<th><?php _e('Type & Status','shortpixel-image-optimiser');?></th>
|
58 |
+
<th><?php _e('Files','shortpixel-image-optimiser');?></th>
|
59 |
+
<th><?php _e('Last change','shortpixel-image-optimiser');?></th>
|
60 |
+
<td> </td>
|
61 |
</tr>
|
62 |
+
<?php foreach($view->customFolders as $folder_id => $folder) {
|
63 |
+
$folder_type = $folder->getType();
|
64 |
+
|
65 |
+
$type_display = ($folder_type) ? ucfirst($folder_type) . "<br>" : "";
|
66 |
$stat = $this->shortPixel->getSpMetaDao()->getFolderOptimizationStatus($folder->getId());
|
67 |
$cnt = $folder->getFileCount();
|
68 |
+
|
69 |
$st = ($cnt == 0
|
70 |
? __("Empty",'shortpixel-image-optimiser')
|
71 |
: ($stat->Total == $stat->Optimized
|
76 |
|
77 |
$action = ($st == __("Optimized",'shortpixel-image-optimiser') || $st == __("Empty",'shortpixel-image-optimiser') ? __("Stop monitoring",'shortpixel-image-optimiser') : __("Stop optimizing",'shortpixel-image-optimiser'));
|
78 |
|
79 |
+
if ($folder_type == 'nextgen' && $view->data->includeNextGen == 1)
|
80 |
+
$action = false;
|
81 |
+
|
82 |
$fullStat = $st == __("Empty",'shortpixel-image-optimiser') ? "" : __("Optimized",'shortpixel-image-optimiser') . ": " . $stat->Optimized . ", "
|
83 |
. __("Pending",'shortpixel-image-optimiser') . ": " . $stat->Pending . ", " . __("Waiting",'shortpixel-image-optimiser') . ": " . $stat->Waiting . ", "
|
84 |
. __("Failed",'shortpixel-image-optimiser') . ": " . $stat->Failed;
|
85 |
?>
|
86 |
<tr>
|
87 |
+
<td class='folder folder-<?php echo $folder_id ?>'>
|
88 |
<?php echo($folder->getPath()); ?>
|
89 |
</td>
|
90 |
<td>
|
91 |
<?php if(!($st == "Empty")) { ?>
|
92 |
<a href="javascript:none();" title="<?php echo $fullStat; ?>" style="text-decoration: none;">
|
93 |
<img alt='Info icon' src='<?php echo( wpSPIO()->plugin_url('res/img/info-icon.png' ));?>' style="margin-bottom: -2px;"/>
|
94 |
+
</a> <?php } echo($type_display.$st.$err); ?>
|
95 |
|
96 |
</td>
|
97 |
<td>
|
101 |
<?php echo($folder->getTsUpdated()); ?>
|
102 |
</td>
|
103 |
<td>
|
104 |
+
<?php if ($action): ?>
|
105 |
<input type="button" class="button remove-folder-button" data-value="<?php echo($folder->getPath()); ?>" title="<?php echo($action . " " . $folder->getPath()); ?>" value="<?php echo $action;?>">
|
106 |
+
<?php endif; ?>
|
107 |
<input type="button" style="display:none;" class="button button-alert recheck-folder-button" data-value="<?php echo($folder->getPath()); ?>"
|
108 |
title="<?php _e('Full folder refresh, check each file of the folder if it changed since it was optimized. Might take up to 1 min. for big folders.','shortpixel-image-optimiser');?>"
|
109 |
value="<?php _e('Refresh','shortpixel-image-optimiser');?>">
|
class/view/shortpixel-list-table.php
CHANGED
@@ -176,7 +176,7 @@ class ShortPixelListTable extends WP_List_Table {
|
|
176 |
|
177 |
return __($item->compression_type == 2 ? 'Glossy' : ($item->compression_type == 1 ? 'Lossy' : 'Lossless'),'shortpixel-image-optimiser')
|
178 |
. ($item->keep_exif == 0 ? "": ", " . __('Keep EXIF','shortpixel-image-optimiser'))
|
179 |
-
. ($item->cmyk2rgb == 1 ? "": ", " . __('Preserve CMYK','shortpixel-image-optimiser'));
|
180 |
case 'media_type':
|
181 |
return $item->$column_name;
|
182 |
case 'date':
|
@@ -199,7 +199,7 @@ class ShortPixelListTable extends WP_List_Table {
|
|
199 |
}
|
200 |
|
201 |
public function no_items() {
|
202 |
-
echo(__('No images
|
203 |
}
|
204 |
|
205 |
/**
|
@@ -282,7 +282,7 @@ class ShortPixelListTable extends WP_List_Table {
|
|
282 |
switch($this->current_action()) {
|
283 |
case 'optimize':
|
284 |
if (!wp_verify_nonce($nonce, 'sp_optimize_image')) {
|
285 |
-
|
286 |
} else {
|
287 |
$this->action_optimize_image(absint($_GET['image']));
|
288 |
wp_redirect($redirect_url);
|
@@ -291,7 +291,7 @@ class ShortPixelListTable extends WP_List_Table {
|
|
291 |
break;
|
292 |
case 'restore':
|
293 |
if (!wp_verify_nonce($nonce, 'sp_restore_image')) {
|
294 |
-
|
295 |
} else {
|
296 |
if($this->action_restore_image(absint($_GET['image'])))
|
297 |
{
|
@@ -303,7 +303,7 @@ class ShortPixelListTable extends WP_List_Table {
|
|
303 |
break;
|
304 |
case 'redo':
|
305 |
if (!wp_verify_nonce($nonce, 'sp_redo_image')) {
|
306 |
-
|
307 |
} else {
|
308 |
$this->action_redo_image(absint($_GET['image']), sanitize_text_field($_GET['type']));
|
309 |
wp_redirect($redirect_url);
|
@@ -328,6 +328,11 @@ class ShortPixelListTable extends WP_List_Table {
|
|
328 |
}
|
329 |
}
|
330 |
|
|
|
|
|
|
|
|
|
|
|
331 |
protected function row_actions($actions, $always_visible = false, $id = false, $actionsEnabled = false ) {
|
332 |
if($id === false) {
|
333 |
return parent::row_actions($actions, $always_visible);
|
176 |
|
177 |
return __($item->compression_type == 2 ? 'Glossy' : ($item->compression_type == 1 ? 'Lossy' : 'Lossless'),'shortpixel-image-optimiser')
|
178 |
. ($item->keep_exif == 0 ? "": ", " . __('Keep EXIF','shortpixel-image-optimiser'))
|
179 |
+
. ($item->cmyk2rgb == 1 || is_null($item->cmyk2rgb) ? "": ", " . __('Preserve CMYK','shortpixel-image-optimiser'));
|
180 |
case 'media_type':
|
181 |
return $item->$column_name;
|
182 |
case 'date':
|
199 |
}
|
200 |
|
201 |
public function no_items() {
|
202 |
+
echo(__('No images available. Go to <a href="options-general.php?page=wp-shortpixel-settings&part=adv-settings">Advanced Settings</a> to configure additional folders to be optimized.','shortpixel-image-optimiser'));
|
203 |
}
|
204 |
|
205 |
/**
|
282 |
switch($this->current_action()) {
|
283 |
case 'optimize':
|
284 |
if (!wp_verify_nonce($nonce, 'sp_optimize_image')) {
|
285 |
+
$this->badNonceDie();
|
286 |
} else {
|
287 |
$this->action_optimize_image(absint($_GET['image']));
|
288 |
wp_redirect($redirect_url);
|
291 |
break;
|
292 |
case 'restore':
|
293 |
if (!wp_verify_nonce($nonce, 'sp_restore_image')) {
|
294 |
+
$this->badNonceDie();
|
295 |
} else {
|
296 |
if($this->action_restore_image(absint($_GET['image'])))
|
297 |
{
|
303 |
break;
|
304 |
case 'redo':
|
305 |
if (!wp_verify_nonce($nonce, 'sp_redo_image')) {
|
306 |
+
$this->badNonceDie();
|
307 |
} else {
|
308 |
$this->action_redo_image(absint($_GET['image']), sanitize_text_field($_GET['type']));
|
309 |
wp_redirect($redirect_url);
|
328 |
}
|
329 |
}
|
330 |
|
331 |
+
protected function badNonceDie()
|
332 |
+
{
|
333 |
+
die('Error. Nonce not verified. Do not call this function directly');
|
334 |
+
}
|
335 |
+
|
336 |
protected function row_actions($actions, $always_visible = false, $id = false, $actionsEnabled = false ) {
|
337 |
if($id === false) {
|
338 |
return parent::row_actions($actions, $always_visible);
|
class/view/shortpixel_view.php
CHANGED
@@ -607,16 +607,34 @@ class ShortPixelView {
|
|
607 |
<h1><?php _e('Bulk Image Optimization by ShortPixel','shortpixel-image-optimiser');?></h1>
|
608 |
<?php $this->displayBulkProgressBar(true, $percent, $message, $remainingQuota, $averageCompression, $type);?>
|
609 |
|
610 |
-
<!-- Partners:
|
611 |
-
<?php
|
|
|
|
|
|
|
612 |
<div id="short-pixel-notice-squirrly" class="sp-notice sp-notice-info bulk-progress bulk-progress-partners sp-floating-block sp-full-width">
|
613 |
-
<div style="float:right"><a href="javascript:dismissShortPixelNotice('squirrly')"><?php _e('Dismiss','shortpixel-image-optimiser')
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
|
|
|
|
|
|
618 |
</div>
|
619 |
<?php } ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
620 |
|
621 |
<div class="sp-floating-block sp-notice bulk-notices-parent">
|
622 |
<div class="bulk-notice-container">
|
607 |
<h1><?php _e('Bulk Image Optimization by ShortPixel','shortpixel-image-optimiser');?></h1>
|
608 |
<?php $this->displayBulkProgressBar(true, $percent, $message, $remainingQuota, $averageCompression, $type);?>
|
609 |
|
610 |
+
<!-- Partners: WSO Website Speed Optimization -->
|
611 |
+
<?php
|
612 |
+
if(!isset($dismissed['squirrly'])) // keep the same dismiss option
|
613 |
+
{
|
614 |
+
?>
|
615 |
<div id="short-pixel-notice-squirrly" class="sp-notice sp-notice-info bulk-progress bulk-progress-partners sp-floating-block sp-full-width">
|
616 |
+
<div style="float:right"><a href="javascript:dismissShortPixelNotice('squirrly')"><?php _e('Dismiss','shortpixel-image-optimiser'); ?></a></div>
|
617 |
+
<div style="display: flex; align-items: center;">
|
618 |
+
<span class='icon' style="margin-right: 25px;"><img src="<?php echo(wpSPIO()->plugin_url('res/img/robo-winky.png' ));?>" ></span>
|
619 |
+
<span class='content'>
|
620 |
+
<p><?php _e('After you optimized all your images your site speed might still be improved. Allow ShortPixel Specialists to tell you how.', 'shortpixel-image-optimiser'); ?><p>
|
621 |
+
<p style='font-size: 16px;'><a href="https://shortpixel.com/lp/wso/" target="_blank" style='font-weight: 700;'><?php _e('Get Your Site Assessment','shortpixel-image-optimiser'); ?></a></p>
|
622 |
+
</span>
|
623 |
+
</div>
|
624 |
</div>
|
625 |
<?php } ?>
|
626 |
+
<?php
|
627 |
+
// deactivated for the moment, because of the WSO notice above
|
628 |
+
if(false && !isset($dismissed['squirrly']) && $quotaData['APICallsQuotaOneTimeNumeric']<10000 && $quotaData['APICallsQuotaNumeric']<5000) { ?>
|
629 |
+
<!-- Partners: SQUIRLY -->
|
630 |
+
<div id="short-pixel-notice-squirrly" class="sp-notice sp-notice-info bulk-progress bulk-progress-partners sp-floating-block sp-full-width">
|
631 |
+
<div style="float:right"><a href="javascript:dismissShortPixelNotice('squirrly')"><?php _e('Dismiss','shortpixel-image-optimiser');?></a></div>
|
632 |
+
<a href="https://my.squirrly.co/go120073/squirrly.co/short-pixel-seo" target="_blank">
|
633 |
+
<img src="<?php echo(wpSPIO()->plugin_url('res/img/squirrly.png' ));?>" height="50">
|
634 |
+
<div><?php _e('While you wait for your images to optimize, check out Squirrly, a great plugin for further boosting your SEO.','shortpixel-image-optimiser');?></div>
|
635 |
+
</a>
|
636 |
+
</div>
|
637 |
+
<?php } ?>
|
638 |
|
639 |
<div class="sp-floating-block sp-notice bulk-notices-parent">
|
640 |
<div class="bulk-notice-container">
|
class/wp-short-pixel.php
CHANGED
@@ -16,7 +16,7 @@ class WPShortPixel {
|
|
16 |
private $view = null;
|
17 |
private $thumbnailsRegenerating = array();
|
18 |
|
19 |
-
private $hasNextGen = false;
|
20 |
private $spMetaDao = null;
|
21 |
|
22 |
private $jsSuffix = '.min.js';
|
@@ -42,7 +42,7 @@ class WPShortPixel {
|
|
42 |
$this->_settings = new WPShortPixelSettings();
|
43 |
$this->_apiInterface = new ShortPixelAPI($this->_settings);
|
44 |
// $this->cloudflareApi = new ShortPixelCloudFlareApi($this->_settings->cloudflareEmail, $this->_settings->cloudflareAuthKey, $this->_settings->cloudflareZoneID);
|
45 |
-
|
46 |
$this->spMetaDao = new ShortPixelCustomMetaDao(new WpShortPixelDb(), $this->_settings->excludePatterns);
|
47 |
$this->prioQ = (! defined('SHORTPIXEL_NOFLOCK')) ? new ShortPixelQueue($this, $this->_settings) : new ShortPixelQueueDB($this, $this->_settings);
|
48 |
$this->view = new ShortPixelView($this);
|
@@ -103,16 +103,6 @@ class WPShortPixel {
|
|
103 |
|
104 |
add_action('mime_types', array($this, 'addWebpMime'));
|
105 |
|
106 |
-
//for NextGen
|
107 |
-
if($this->_settings->hasCustomFolders) {
|
108 |
-
add_filter( 'ngg_manage_images_columns', array( &$this, 'nggColumns' ) );
|
109 |
-
add_filter( 'ngg_manage_images_number_of_columns', array( &$this, 'nggCountColumns' ) );
|
110 |
-
add_filter( 'ngg_manage_images_column_7_header', array( &$this, 'nggColumnHeader' ) );
|
111 |
-
add_filter( 'ngg_manage_images_column_7_content', array( &$this, 'nggColumnContent' ) );
|
112 |
-
// hook on the NextGen gallery list update
|
113 |
-
add_action('ngg_update_addgallery_page', array( &$this, 'addNextGenGalleriesToCustom'));
|
114 |
-
}
|
115 |
-
|
116 |
// integration with WP/LR Sync plugin
|
117 |
add_action( 'wplr_update_media', array( &$this, 'onWpLrUpdateMedia' ), 10, 2);
|
118 |
|
@@ -168,7 +158,7 @@ class WPShortPixel {
|
|
168 |
//dismiss notices
|
169 |
|
170 |
// deprecated - dismissAdminNotice should not be called no longer.
|
171 |
-
|
172 |
add_action( 'wp_ajax_shortpixel_dismiss_media_alert', array($this, 'dismissMediaAlert'));
|
173 |
add_action( 'wp_ajax_shortpixel_dismissFileError', array($this, 'dismissFileError'));
|
174 |
|
@@ -311,7 +301,7 @@ class WPShortPixel {
|
|
311 |
} */
|
312 |
}
|
313 |
|
314 |
-
/* Deprecated in favor of NoticeController.
|
315 |
public function dismissAdminNotice() {
|
316 |
$noticeId = preg_replace('|[^a-z0-9]|i', '', $_GET['notice_id']);
|
317 |
$dismissed = $this->_settings->dismissedNotices ? $this->_settings->dismissedNotices : array();
|
@@ -323,9 +313,6 @@ class WPShortPixel {
|
|
323 |
die(json_encode(array("Status" => 'success', "Message" => 'Notice ID: ' . $noticeId . ' dismissed')));
|
324 |
}
|
325 |
|
326 |
-
|
327 |
-
*/
|
328 |
-
|
329 |
// This probably displays an alert when requesting the user to switch from grid to list in media library
|
330 |
public function dismissMediaAlert() {
|
331 |
$this->_settings->mediaAlert = 1;
|
@@ -829,7 +816,7 @@ class WPShortPixel {
|
|
829 |
* this is hooked onto the NextGen upload
|
830 |
* @param type $image
|
831 |
*/
|
832 |
-
|
833 |
{
|
834 |
if ($this->_settings->includeNextGen == 1) {
|
835 |
$imageFsPath = ShortPixelNextGenAdapter::getImageAbspath($image);
|
@@ -853,9 +840,9 @@ class WPShortPixel {
|
|
853 |
|
854 |
return $this->addPathToCustomFolder($imageFsPath, $folderId, $image->pid);
|
855 |
}
|
856 |
-
}
|
857 |
|
858 |
-
|
859 |
//prevent adding it multiple times if the action is called repeatedly (Gravity Forms does that)
|
860 |
$existing = $this->spMetaDao->getMetaForPath($imageFsPath);
|
861 |
if($existing) {
|
@@ -1280,14 +1267,12 @@ class WPShortPixel {
|
|
1280 |
}
|
1281 |
|
1282 |
$customIds = $this->spMetaDao->getPendingMetas( SHORTPIXEL_PRESEND_ITEMS - count($ids));
|
|
|
1283 |
if(is_array($customIds)) {
|
1284 |
$ids = array_merge($ids, array_map(array('ShortPixelMetaFacade', 'getNewFromRow'), $customIds));
|
1285 |
}
|
1286 |
}
|
1287 |
-
//var_dump($ids);
|
1288 |
-
//die("za stop 2");
|
1289 |
|
1290 |
-
//self::log("HIP: 1 Ids: ".json_encode($ids));
|
1291 |
if(count($ids)) {$idl='';foreach($ids as $i){$idl.=$i->getId().' ';}
|
1292 |
Log::addInfo("HIP: 1 Selected IDs: $idl");}
|
1293 |
|
@@ -1306,6 +1291,7 @@ class WPShortPixel {
|
|
1306 |
$itemHandler = $ids[$i];
|
1307 |
$firstUrlAndPaths = $URLsAndPATHs;
|
1308 |
}
|
|
|
1309 |
} catch(Exception $e) { // Exception("Post metadata is corrupt (No attachment URL)") or Exception("Image files are missing.")
|
1310 |
if($tmpMeta->getStatus() != 2) {
|
1311 |
$crtItemHandler->incrementRetries(1, ($e->getCode() < 0 ? $e->getCode() : ShortPixelAPI::ERR_FILE_NOT_FOUND), $e->getMessage());
|
@@ -1493,6 +1479,13 @@ class WPShortPixel {
|
|
1493 |
//put this one in the failed images list - to show the user at the end
|
1494 |
$prio = $this->prioQ->addToFailed($itemHandler->getQueuedId());
|
1495 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1496 |
self::log("HIP RES: skipping $itemId");
|
1497 |
$this->advanceBulk($meta->getId());
|
1498 |
if($itemHandler->getType() == ShortPixelMetaFacade::CUSTOM_TYPE) {
|
@@ -1901,13 +1894,14 @@ class WPShortPixel {
|
|
1901 |
* @param int $ID image_id
|
1902 |
* @param string $result - Error String
|
1903 |
*/
|
|
|
1904 |
public function handleError($ID, $result)
|
1905 |
{
|
1906 |
$meta = wp_get_attachment_metadata($ID);
|
1907 |
$meta['ShortPixelImprovement'] = $result;
|
1908 |
//wp_update_attachment_metadata($ID, $meta);
|
1909 |
update_post_meta($ID, '_wp_attachment_metadata', $meta);
|
1910 |
-
}
|
1911 |
|
1912 |
/* Gets backup folder of file. This backup must exist already, or false is given.
|
1913 |
* @param string $file Filepath - probably ( or directory )
|
@@ -2762,6 +2756,7 @@ class WPShortPixel {
|
|
2762 |
/** View for Custom media
|
2763 |
* @todo Move this to own view.
|
2764 |
*/
|
|
|
2765 |
public function listCustomMedia() {
|
2766 |
if( ! class_exists( 'ShortPixelListTable' ) ) {
|
2767 |
require_once('view/shortpixel-list-table.php');
|
@@ -2775,7 +2770,7 @@ class WPShortPixel {
|
|
2775 |
$this->prioQ->push(ShortPixelMetaFacade::queuedId(ShortPixelMetaFacade::CUSTOM_TYPE, $_REQUEST['image']));
|
2776 |
}
|
2777 |
|
2778 |
-
$customMediaListTable = new ShortPixelListTable($this, $this->spMetaDao,
|
2779 |
$items = $customMediaListTable->prepare_items();
|
2780 |
if ( isset($_GET['noheader']) ) {
|
2781 |
require_once(ABSPATH . 'wp-admin/admin-header.php');
|
@@ -2821,25 +2816,26 @@ class WPShortPixel {
|
|
2821 |
</div> <?php
|
2822 |
}
|
2823 |
|
|
|
2824 |
/** Front End function that controls bulk processes.
|
2825 |
* TODO This is a Bulk controller
|
2826 |
*/
|
2827 |
public function bulkProcess() {
|
2828 |
global $wpdb;
|
2829 |
|
2830 |
-
|
2831 |
if( $this->_settings->verifiedKey == false ) {//invalid API Key
|
2832 |
//ShortPixelView::displayActivationNotice();
|
2833 |
return;
|
2834 |
}
|
2835 |
|
2836 |
$quotaData = $this->checkQuotaAndAlert(null, isset($_GET['checkquota']), 0);
|
2837 |
-
|
|
|
|
|
2838 |
//return;
|
2839 |
//}
|
2840 |
|
2841 |
|
2842 |
-
|
2843 |
if(isset($_POST['bulkProcessPause']))
|
2844 |
{//pause an ongoing bulk processing, it might be needed sometimes
|
2845 |
$this->prioQ->pauseBulk();
|
@@ -3191,6 +3187,8 @@ class WPShortPixel {
|
|
3191 |
if($validityData['APIKeyValid']) {
|
3192 |
$this->_settings->apiKey = $key;
|
3193 |
$this->_settings->verifiedKey = true;
|
|
|
|
|
3194 |
}
|
3195 |
}
|
3196 |
die(json_encode($body));
|
@@ -3394,32 +3392,6 @@ class WPShortPixel {
|
|
3394 |
}
|
3395 |
}
|
3396 |
|
3397 |
-
|
3398 |
-
|
3399 |
-
/** Adds NextGenGalleries to Custom Images Library
|
3400 |
-
* @param boolean $silent Will not return messages if silent
|
3401 |
-
* @return array Array for information
|
3402 |
-
* @todo Move to a integration class || This can be removed after nextgen.php in externals is released.
|
3403 |
-
*/
|
3404 |
-
public function addNextGenGalleriesToCustom($silent) {
|
3405 |
-
$customFolders = array();
|
3406 |
-
$folderMsg = "";
|
3407 |
-
if($this->_settings->includeNextGen) {
|
3408 |
-
//add the NextGen galleries to custom folders
|
3409 |
-
$ngGalleries = ShortPixelNextGenAdapter::getGalleries();
|
3410 |
-
foreach($ngGalleries as $gallery) {
|
3411 |
-
$msg = $this->spMetaDao->newFolderFromPath($gallery, get_home_path(), self::getCustomFolderBase());
|
3412 |
-
if($msg) { //try again with ABSPATH as maybe WP is in a subdir
|
3413 |
-
$msg = $this->spMetaDao->newFolderFromPath($gallery, ABSPATH, self::getCustomFolderBase());
|
3414 |
-
}
|
3415 |
-
$folderMsg .= $msg;
|
3416 |
-
$this->_settings->hasCustomFolders = time();
|
3417 |
-
}
|
3418 |
-
$customFolders = $this->spMetaDao->getFolders();
|
3419 |
-
}
|
3420 |
-
return array("message" => $silent? "" : $folderMsg, "customFolders" => $customFolders);
|
3421 |
-
}
|
3422 |
-
|
3423 |
/** Gets the average compression
|
3424 |
* @return int Average compressions percentage
|
3425 |
* @todo Move to utility (?)
|
@@ -3986,57 +3958,8 @@ class WPShortPixel {
|
|
3986 |
return $defaults;
|
3987 |
}
|
3988 |
|
3989 |
-
// @todo move NGG specific function to own integration
|
3990 |
-
public function nggColumns( $defaults ) {
|
3991 |
-
$this->nggColumnIndex = count($defaults) + 1;
|
3992 |
-
add_filter( 'ngg_manage_images_column_' . $this->nggColumnIndex . '_header', array( &$this, 'nggColumnHeader' ) );
|
3993 |
-
add_filter( 'ngg_manage_images_column_' . $this->nggColumnIndex . '_content', array( &$this, 'nggColumnContent' ), 10, 2 );
|
3994 |
-
$defaults['wp-shortPixelNgg'] = 'ShortPixel Compression';
|
3995 |
-
return $defaults;
|
3996 |
-
}
|
3997 |
-
|
3998 |
-
public function nggCountColumns( $count ) {
|
3999 |
-
return $count + 1;
|
4000 |
-
}
|
4001 |
|
4002 |
-
public function nggColumnHeader( $default ) {
|
4003 |
-
return __('ShortPixel Compression','shortpixel-image-optimiser');
|
4004 |
-
}
|
4005 |
|
4006 |
-
public function nggColumnContent( $unknown, $picture ) {
|
4007 |
-
|
4008 |
-
$meta = $this->spMetaDao->getMetaForPath($picture->imagePath);
|
4009 |
-
if($meta) {
|
4010 |
-
switch($meta->getStatus()) {
|
4011 |
-
case "0": echo("<div id='sp-msg-C-{$meta->getId()}' class='column-wp-shortPixel' style='color: #928B1E'>Waiting</div>"); break;
|
4012 |
-
case "1": echo("<div id='sp-msg-C-{$meta->getId()}' class='column-wp-shortPixel' style='color: #1919E2'>Pending</div>"); break;
|
4013 |
-
case "2": $this->view->renderCustomColumn("C-" . $meta->getId(), array(
|
4014 |
-
'showActions' => false && current_user_can( 'manage_options' ),
|
4015 |
-
'status' => 'imgOptimized',
|
4016 |
-
'type' => ShortPixelAPI::getCompressionTypeName($meta->getCompressionType()),
|
4017 |
-
'percent' => $meta->getImprovementPercent(),
|
4018 |
-
'bonus' => $meta->getImprovementPercent() < 5,
|
4019 |
-
'thumbsOpt' => 0,
|
4020 |
-
'thumbsOptList' => array(),
|
4021 |
-
'thumbsTotal' => 0,
|
4022 |
-
'retinasOpt' => 0,
|
4023 |
-
'backup' => true
|
4024 |
-
));
|
4025 |
-
break;
|
4026 |
-
}
|
4027 |
-
} else {
|
4028 |
-
$this->view->renderCustomColumn($meta ? "C-" . $meta->getId() : "N-" . $picture->pid, array(
|
4029 |
-
'showActions' => false && current_user_can( 'manage_options' ),
|
4030 |
-
'status' => 'optimizeNow',
|
4031 |
-
'thumbsOpt' => 0,
|
4032 |
-
'thumbsOptList' => array(),
|
4033 |
-
'thumbsTotal' => 0,
|
4034 |
-
'retinasOpt' => 0,
|
4035 |
-
'message' => "Not optimized"
|
4036 |
-
));
|
4037 |
-
}
|
4038 |
-
// return var_dump($meta);
|
4039 |
-
}
|
4040 |
|
4041 |
public function generatePluginLinks($links) {
|
4042 |
$in = '<a href="options-general.php?page=wp-shortpixel-settings">Settings</a>';
|
@@ -4548,15 +4471,15 @@ class WPShortPixel {
|
|
4548 |
// : (defined("SHORTPIXEL_AFFILIATE_CODE") && strlen(SHORTPIXEL_AFFILIATE_CODE) ? "/affiliate/" . SHORTPIXEL_AFFILIATE_CODE : "");
|
4549 |
return "";
|
4550 |
}
|
|
|
|
|
4551 |
public function getVerifiedKey() {
|
4552 |
return $this->_settings->verifiedKey;
|
4553 |
}
|
4554 |
public function getCompressionType() {
|
4555 |
return $this->_settings->compressionType;
|
4556 |
}
|
4557 |
-
|
4558 |
-
return $this->hasNextGen;
|
4559 |
-
}
|
4560 |
|
4561 |
public function getSpMetaDao() {
|
4562 |
return $this->spMetaDao;
|
16 |
private $view = null;
|
17 |
private $thumbnailsRegenerating = array();
|
18 |
|
19 |
+
// private $hasNextGen = false;
|
20 |
private $spMetaDao = null;
|
21 |
|
22 |
private $jsSuffix = '.min.js';
|
42 |
$this->_settings = new WPShortPixelSettings();
|
43 |
$this->_apiInterface = new ShortPixelAPI($this->_settings);
|
44 |
// $this->cloudflareApi = new ShortPixelCloudFlareApi($this->_settings->cloudflareEmail, $this->_settings->cloudflareAuthKey, $this->_settings->cloudflareZoneID);
|
45 |
+
// $this->hasNextGen = wpSPIO()->env()->has_nextgen; //ShortPixelNextGenAdapter::hasNextGen();
|
46 |
$this->spMetaDao = new ShortPixelCustomMetaDao(new WpShortPixelDb(), $this->_settings->excludePatterns);
|
47 |
$this->prioQ = (! defined('SHORTPIXEL_NOFLOCK')) ? new ShortPixelQueue($this, $this->_settings) : new ShortPixelQueueDB($this, $this->_settings);
|
48 |
$this->view = new ShortPixelView($this);
|
103 |
|
104 |
add_action('mime_types', array($this, 'addWebpMime'));
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
// integration with WP/LR Sync plugin
|
107 |
add_action( 'wplr_update_media', array( &$this, 'onWpLrUpdateMedia' ), 10, 2);
|
108 |
|
158 |
//dismiss notices
|
159 |
|
160 |
// deprecated - dismissAdminNotice should not be called no longer.
|
161 |
+
add_action( 'wp_ajax_shortpixel_dismiss_notice', array(&$this, 'dismissAdminNotice'));
|
162 |
add_action( 'wp_ajax_shortpixel_dismiss_media_alert', array($this, 'dismissMediaAlert'));
|
163 |
add_action( 'wp_ajax_shortpixel_dismissFileError', array($this, 'dismissFileError'));
|
164 |
|
301 |
} */
|
302 |
}
|
303 |
|
304 |
+
/* Deprecated in favor of NoticeController. @todo Must go, sadly still in use. */
|
305 |
public function dismissAdminNotice() {
|
306 |
$noticeId = preg_replace('|[^a-z0-9]|i', '', $_GET['notice_id']);
|
307 |
$dismissed = $this->_settings->dismissedNotices ? $this->_settings->dismissedNotices : array();
|
313 |
die(json_encode(array("Status" => 'success', "Message" => 'Notice ID: ' . $noticeId . ' dismissed')));
|
314 |
}
|
315 |
|
|
|
|
|
|
|
316 |
// This probably displays an alert when requesting the user to switch from grid to list in media library
|
317 |
public function dismissMediaAlert() {
|
318 |
$this->_settings->mediaAlert = 1;
|
816 |
* this is hooked onto the NextGen upload
|
817 |
* @param type $image
|
818 |
*/
|
819 |
+
/* public function handleNextGenImageUpload($image)
|
820 |
{
|
821 |
if ($this->_settings->includeNextGen == 1) {
|
822 |
$imageFsPath = ShortPixelNextGenAdapter::getImageAbspath($image);
|
840 |
|
841 |
return $this->addPathToCustomFolder($imageFsPath, $folderId, $image->pid);
|
842 |
}
|
843 |
+
} */
|
844 |
|
845 |
+
public function addPathToCustomFolder($imageFsPath, $folderId, $pid) {
|
846 |
//prevent adding it multiple times if the action is called repeatedly (Gravity Forms does that)
|
847 |
$existing = $this->spMetaDao->getMetaForPath($imageFsPath);
|
848 |
if($existing) {
|
1267 |
}
|
1268 |
|
1269 |
$customIds = $this->spMetaDao->getPendingMetas( SHORTPIXEL_PRESEND_ITEMS - count($ids));
|
1270 |
+
|
1271 |
if(is_array($customIds)) {
|
1272 |
$ids = array_merge($ids, array_map(array('ShortPixelMetaFacade', 'getNewFromRow'), $customIds));
|
1273 |
}
|
1274 |
}
|
|
|
|
|
1275 |
|
|
|
1276 |
if(count($ids)) {$idl='';foreach($ids as $i){$idl.=$i->getId().' ';}
|
1277 |
Log::addInfo("HIP: 1 Selected IDs: $idl");}
|
1278 |
|
1291 |
$itemHandler = $ids[$i];
|
1292 |
$firstUrlAndPaths = $URLsAndPATHs;
|
1293 |
}
|
1294 |
+
/* @todo This catch will never hit. See sendToProcessing. Any ApiRequest is caught this. This was added because in other places errors would occur */
|
1295 |
} catch(Exception $e) { // Exception("Post metadata is corrupt (No attachment URL)") or Exception("Image files are missing.")
|
1296 |
if($tmpMeta->getStatus() != 2) {
|
1297 |
$crtItemHandler->incrementRetries(1, ($e->getCode() < 0 ? $e->getCode() : ShortPixelAPI::ERR_FILE_NOT_FOUND), $e->getMessage());
|
1479 |
//put this one in the failed images list - to show the user at the end
|
1480 |
$prio = $this->prioQ->addToFailed($itemHandler->getQueuedId());
|
1481 |
}
|
1482 |
+
//** @todo Provisory code, testing */
|
1483 |
+
if(isset($result['Code'])) {
|
1484 |
+
$itemHandler->incrementRetries(1, $result['Code'], $result["Message"]);
|
1485 |
+
} else {
|
1486 |
+
$itemHandler->incrementRetries(1, ShortPixelAPI::ERR_UNKNOWN, "Connection error (" . $result["Message"] . ")" );
|
1487 |
+
}
|
1488 |
+
|
1489 |
self::log("HIP RES: skipping $itemId");
|
1490 |
$this->advanceBulk($meta->getId());
|
1491 |
if($itemHandler->getType() == ShortPixelMetaFacade::CUSTOM_TYPE) {
|
1894 |
* @param int $ID image_id
|
1895 |
* @param string $result - Error String
|
1896 |
*/
|
1897 |
+
/* Seems not in use
|
1898 |
public function handleError($ID, $result)
|
1899 |
{
|
1900 |
$meta = wp_get_attachment_metadata($ID);
|
1901 |
$meta['ShortPixelImprovement'] = $result;
|
1902 |
//wp_update_attachment_metadata($ID, $meta);
|
1903 |
update_post_meta($ID, '_wp_attachment_metadata', $meta);
|
1904 |
+
} */
|
1905 |
|
1906 |
/* Gets backup folder of file. This backup must exist already, or false is given.
|
1907 |
* @param string $file Filepath - probably ( or directory )
|
2756 |
/** View for Custom media
|
2757 |
* @todo Move this to own view.
|
2758 |
*/
|
2759 |
+
/* Gone! @todo Must go when new ListCMedia is done */
|
2760 |
public function listCustomMedia() {
|
2761 |
if( ! class_exists( 'ShortPixelListTable' ) ) {
|
2762 |
require_once('view/shortpixel-list-table.php');
|
2770 |
$this->prioQ->push(ShortPixelMetaFacade::queuedId(ShortPixelMetaFacade::CUSTOM_TYPE, $_REQUEST['image']));
|
2771 |
}
|
2772 |
|
2773 |
+
$customMediaListTable = new ShortPixelListTable($this, $this->spMetaDao, \wpSPIO()->env()->has_nextgen);
|
2774 |
$items = $customMediaListTable->prepare_items();
|
2775 |
if ( isset($_GET['noheader']) ) {
|
2776 |
require_once(ABSPATH . 'wp-admin/admin-header.php');
|
2816 |
</div> <?php
|
2817 |
}
|
2818 |
|
2819 |
+
|
2820 |
/** Front End function that controls bulk processes.
|
2821 |
* TODO This is a Bulk controller
|
2822 |
*/
|
2823 |
public function bulkProcess() {
|
2824 |
global $wpdb;
|
2825 |
|
|
|
2826 |
if( $this->_settings->verifiedKey == false ) {//invalid API Key
|
2827 |
//ShortPixelView::displayActivationNotice();
|
2828 |
return;
|
2829 |
}
|
2830 |
|
2831 |
$quotaData = $this->checkQuotaAndAlert(null, isset($_GET['checkquota']), 0);
|
2832 |
+
if($this->_settings->quotaExceeded == 1) {
|
2833 |
+
\ShortPixel\adminNoticesController::reInstateQuotaExceeded();
|
2834 |
+
}
|
2835 |
//return;
|
2836 |
//}
|
2837 |
|
2838 |
|
|
|
2839 |
if(isset($_POST['bulkProcessPause']))
|
2840 |
{//pause an ongoing bulk processing, it might be needed sometimes
|
2841 |
$this->prioQ->pauseBulk();
|
3187 |
if($validityData['APIKeyValid']) {
|
3188 |
$this->_settings->apiKey = $key;
|
3189 |
$this->_settings->verifiedKey = true;
|
3190 |
+
\ShortPixel\adminNoticesController::resetAPINotices();
|
3191 |
+
Notices::addSuccess(__('Great, you successfully claimed your API Key! Please take a few moments to review the plugin settings below before starting to optimize your images.','shortpixel-image-optimiser'));
|
3192 |
}
|
3193 |
}
|
3194 |
die(json_encode($body));
|
3392 |
}
|
3393 |
}
|
3394 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3395 |
/** Gets the average compression
|
3396 |
* @return int Average compressions percentage
|
3397 |
* @todo Move to utility (?)
|
3958 |
return $defaults;
|
3959 |
}
|
3960 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3961 |
|
|
|
|
|
|
|
3962 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3963 |
|
3964 |
public function generatePluginLinks($links) {
|
3965 |
$in = '<a href="options-general.php?page=wp-shortpixel-settings">Settings</a>';
|
4471 |
// : (defined("SHORTPIXEL_AFFILIATE_CODE") && strlen(SHORTPIXEL_AFFILIATE_CODE) ? "/affiliate/" . SHORTPIXEL_AFFILIATE_CODE : "");
|
4472 |
return "";
|
4473 |
}
|
4474 |
+
|
4475 |
+
/** @todo Deprecate in favor of apikeyModel */
|
4476 |
public function getVerifiedKey() {
|
4477 |
return $this->_settings->verifiedKey;
|
4478 |
}
|
4479 |
public function getCompressionType() {
|
4480 |
return $this->_settings->compressionType;
|
4481 |
}
|
4482 |
+
|
|
|
|
|
4483 |
|
4484 |
public function getSpMetaDao() {
|
4485 |
return $this->spMetaDao;
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: compressor, image, compression, optimize, image optimizer, image optimiser
|
|
4 |
Requires at least: 3.2.0
|
5 |
Tested up to: 5.3
|
6 |
Requires PHP: 5.3
|
7 |
-
Stable tag: 4.16.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -264,9 +264,18 @@ define('SHORTPIXEL_CFZONE', 'The Zone ID from the domain settings in Cloudflare'
|
|
264 |
|
265 |
== Changelog ==
|
266 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
|
268 |
= 4.16.0 =
|
269 |
|
|
|
270 |
* New - Token support for Cloudflare via config constant or settings.
|
271 |
* Backup setting - add orange warning when backups are off.
|
272 |
* Button to dismiss the top bar notification of missing files.
|
4 |
Requires at least: 3.2.0
|
5 |
Tested up to: 5.3
|
6 |
Requires PHP: 5.3
|
7 |
+
Stable tag: 4.16.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
264 |
|
265 |
== Changelog ==
|
266 |
|
267 |
+
= 4.16.1 =
|
268 |
+
|
269 |
+
Release date: 14th February 2020
|
270 |
+
* Fix non-dismissable alerts.
|
271 |
+
* Reference to the Website Speed Optimization service.
|
272 |
+
* Fixed: deleteItemCache in wrong place ( before save ) thus resetting data
|
273 |
+
* Fixed: NextGen integration
|
274 |
+
* Language – 3 new strings added, 0 updated, 0 fuzzied, and 0 obsoleted
|
275 |
|
276 |
= 4.16.0 =
|
277 |
|
278 |
+
Release date: 4th February 2020
|
279 |
* New - Token support for Cloudflare via config constant or settings.
|
280 |
* Backup setting - add orange warning when backups are off.
|
281 |
* Button to dismiss the top bar notification of missing files.
|
res/css/shortpixel-admin.css
CHANGED
@@ -36,6 +36,9 @@
|
|
36 |
max-width: 70%; }
|
37 |
#shortpixel-settings-tabs #tab-adv-settings .addCustomFolder input[name="saveAdv"] {
|
38 |
margin-left: 8px; }
|
|
|
|
|
|
|
39 |
|
40 |
.cf_switch label {
|
41 |
width: 100%;
|
36 |
max-width: 70%; }
|
37 |
#shortpixel-settings-tabs #tab-adv-settings .addCustomFolder input[name="saveAdv"] {
|
38 |
margin-left: 8px; }
|
39 |
+
#shortpixel-settings-tabs #tab-adv-settings .shortpixel-folders-list th {
|
40 |
+
width: auto;
|
41 |
+
padding: 12px 16px 12px 12px; }
|
42 |
|
43 |
.cf_switch label {
|
44 |
width: 100%;
|
res/img/robo-winky.png
ADDED
Binary file
|
res/img/robo-winky@2x.png
ADDED
Binary file
|
res/js/shortpixel.js
CHANGED
@@ -680,6 +680,7 @@ var ShortPixel = function() {
|
|
680 |
|
681 |
function recheckQuota() {
|
682 |
var parts = window.location.href.split('#');
|
|
|
683 |
window.location.href=parts[0]+(parts[0].indexOf('?')>0?'&':'?')+'checkquota=1' + (typeof parts[1] === 'undefined' ? '' : '#' + parts[1]);
|
684 |
}
|
685 |
|
@@ -876,7 +877,7 @@ function showToolBarAlert($status, $message, id) {
|
|
876 |
case ShortPixel.STATUS_QUOTA_EXCEEDED:
|
877 |
if( window.location.href.search("wp-short-pixel-bulk") > 0
|
878 |
&& jQuery(".sp-quota-exceeded-alert").length == 0) { //if we're in bulk and the alert is not displayed reload to see all options
|
879 |
-
|
880 |
return;
|
881 |
}
|
882 |
robo.addClass("shortpixel-alert");
|
@@ -1074,6 +1075,7 @@ function checkBulkProcessingCallApi(){
|
|
1074 |
jQuery("a.bulk-cancel").attr("disabled", "disabled");
|
1075 |
hideSlider();
|
1076 |
//showStats();
|
|
|
1077 |
setTimeout(function(){
|
1078 |
window.location.reload();
|
1079 |
}, 3000);
|
@@ -1297,7 +1299,7 @@ function dismissShortPixelNoticeExceed(e) {
|
|
1297 |
e.preventDefault();
|
1298 |
} */
|
1299 |
|
1300 |
-
/*
|
1301 |
function dismissShortPixelNotice(id) {
|
1302 |
jQuery("#short-pixel-notice-" + id).hide();
|
1303 |
var data = { action : 'shortpixel_dismiss_notice',
|
@@ -1308,7 +1310,7 @@ function dismissShortPixelNotice(id) {
|
|
1308 |
console.log("dismissed");
|
1309 |
}
|
1310 |
});
|
1311 |
-
}
|
1312 |
|
1313 |
function dismissFileError() {
|
1314 |
jQuery('.shortpixel-alert').hide();
|
680 |
|
681 |
function recheckQuota() {
|
682 |
var parts = window.location.href.split('#');
|
683 |
+
|
684 |
window.location.href=parts[0]+(parts[0].indexOf('?')>0?'&':'?')+'checkquota=1' + (typeof parts[1] === 'undefined' ? '' : '#' + parts[1]);
|
685 |
}
|
686 |
|
877 |
case ShortPixel.STATUS_QUOTA_EXCEEDED:
|
878 |
if( window.location.href.search("wp-short-pixel-bulk") > 0
|
879 |
&& jQuery(".sp-quota-exceeded-alert").length == 0) { //if we're in bulk and the alert is not displayed reload to see all options
|
880 |
+
// location.reload();
|
881 |
return;
|
882 |
}
|
883 |
robo.addClass("shortpixel-alert");
|
1075 |
jQuery("a.bulk-cancel").attr("disabled", "disabled");
|
1076 |
hideSlider();
|
1077 |
//showStats();
|
1078 |
+
|
1079 |
setTimeout(function(){
|
1080 |
window.location.reload();
|
1081 |
}, 3000);
|
1299 |
e.preventDefault();
|
1300 |
} */
|
1301 |
|
1302 |
+
/* @todo Must go, still in use in some parts */
|
1303 |
function dismissShortPixelNotice(id) {
|
1304 |
jQuery("#short-pixel-notice-" + id).hide();
|
1305 |
var data = { action : 'shortpixel_dismiss_notice',
|
1310 |
console.log("dismissed");
|
1311 |
}
|
1312 |
});
|
1313 |
+
}
|
1314 |
|
1315 |
function dismissFileError() {
|
1316 |
jQuery('.shortpixel-alert').hide();
|
res/js/shortpixel.min.js
CHANGED
@@ -1 +1 @@
|
|
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 dismissFileError(){jQuery(".shortpixel-alert").hide();var e={action:"shortpixel_dismissFileError"};jQuery.get(ShortPixel.AJAX_URL,e,function(r){(e=JSON.parse(r)).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(" "+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(),jQuery('input[name="backupImages"]').on("change",function(){ShortPixel.checkBackUpWarning()}),ShortPixel.checkBackUpWarning()},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()},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()},checkBackUpWarning:function(){jQuery('input[name="backupImages"]').is(":checked")?jQuery(".backup_warning").fadeOut():jQuery(".backup_warning").fadeIn()},comparerData:{cssLoaded:!1,jsLoaded:!1,origUrl:!1,optUrl:!1,width:0,height:0},toRefresh:!1,resizeSizesAlert:!1,returnedStatusSearching:0}}();
|
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;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 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 dismissFileError(){jQuery(".shortpixel-alert").hide();var e={action:"shortpixel_dismissFileError"};jQuery.get(ShortPixel.AJAX_URL,e,function(r){(e=JSON.parse(r)).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(" "+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(),jQuery('input[name="backupImages"]').on("change",function(){ShortPixel.checkBackUpWarning()}),ShortPixel.checkBackUpWarning()},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()},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()},checkBackUpWarning:function(){jQuery('input[name="backupImages"]').is(":checked")?jQuery(".backup_warning").fadeOut():jQuery(".backup_warning").fadeIn()},comparerData:{cssLoaded:!1,jsLoaded:!1,origUrl:!1,optUrl:!1,width:0,height:0},toRefresh:!1,resizeSizesAlert:!1,returnedStatusSearching:0}}();
|
res/scss/view/_settings-advanced.scss
CHANGED
@@ -21,6 +21,16 @@
|
|
21 |
}
|
22 |
}
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
|
26 |
}
|
21 |
}
|
22 |
}
|
23 |
|
24 |
+
// additional media table
|
25 |
+
.shortpixel-folders-list
|
26 |
+
{
|
27 |
+
th {
|
28 |
+
width: auto;
|
29 |
+
padding: 12px 16px 12px 12px;
|
30 |
+
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
|
35 |
|
36 |
}
|
shortpixel-plugin.php
CHANGED
@@ -32,7 +32,6 @@ class ShortPixelPlugin
|
|
32 |
|
33 |
$this->initRuntime(); // require controllers, and other needed classes
|
34 |
$this->initHooks();
|
35 |
-
|
36 |
add_action('plugins_loaded', array($this, 'init'), 5); // early as possible init.
|
37 |
}
|
38 |
|
@@ -47,7 +46,6 @@ class ShortPixelPlugin
|
|
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();
|
32 |
|
33 |
$this->initRuntime(); // require controllers, and other needed classes
|
34 |
$this->initHooks();
|
|
|
35 |
add_action('plugins_loaded', array($this, 'init'), 5); // early as possible init.
|
36 |
}
|
37 |
|
46 |
$this->is_noheaders = true;
|
47 |
}
|
48 |
|
|
|
49 |
// @todo Transitionary init for the time being, since plugin init functionality is still split between.
|
50 |
global $shortPixelPluginInstance;
|
51 |
$shortPixelPluginInstance = new \wpShortPixel();
|
shortpixel_api.php
CHANGED
@@ -809,6 +809,7 @@ class ShortPixelAPI {
|
|
809 |
$meta->setCompressionType($compressionType);
|
810 |
$meta->setCompressedSize(@filesize($meta->getPath()));
|
811 |
$meta->setKeepExif($this->_settings->keepExif);
|
|
|
812 |
$meta->setTsOptimized(date("Y-m-d H:i:s"));
|
813 |
$meta->setThumbsOptList(is_array($meta->getThumbsOptList()) ? array_unique(array_merge($meta->getThumbsOptList(), $thumbsOptList)) : $thumbsOptList);
|
814 |
$meta->setThumbsOpt(($meta->getThumbsTodo() || $this->_settings->processThumbnails) ? count($meta->getThumbsOptList()) : 0);
|
809 |
$meta->setCompressionType($compressionType);
|
810 |
$meta->setCompressedSize(@filesize($meta->getPath()));
|
811 |
$meta->setKeepExif($this->_settings->keepExif);
|
812 |
+
$meta->setCmyk2rgb($this->_settings->CMYKtoRGBconversion);
|
813 |
$meta->setTsOptimized(date("Y-m-d H:i:s"));
|
814 |
$meta->setThumbsOptList(is_array($meta->getThumbsOptList()) ? array_unique(array_merge($meta->getThumbsOptList(), $thumbsOptList)) : $thumbsOptList);
|
815 |
$meta->setThumbsOpt(($meta->getThumbsTodo() || $this->_settings->processThumbnails) ? count($meta->getThumbsOptList()) : 0);
|
wp-shortpixel-req.php
CHANGED
@@ -54,7 +54,7 @@ require_once('class/model/sp-file-rights-exception.php');
|
|
54 |
require_once('class/db/shortpixel-db.php');
|
55 |
require_once('class/db/wp-shortpixel-db.php');
|
56 |
require_once('class/db/shortpixel-custom-meta-dao.php');
|
57 |
-
|
58 |
require_once('class/db/wp-shortpixel-media-library-adapter.php');
|
59 |
require_once('class/db/shortpixel-meta-facade.php');
|
60 |
//view
|
54 |
require_once('class/db/shortpixel-db.php');
|
55 |
require_once('class/db/wp-shortpixel-db.php');
|
56 |
require_once('class/db/shortpixel-custom-meta-dao.php');
|
57 |
+
|
58 |
require_once('class/db/wp-shortpixel-media-library-adapter.php');
|
59 |
require_once('class/db/shortpixel-meta-facade.php');
|
60 |
//view
|
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 > ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
|
6 |
-
* Version: 4.16.
|
7 |
* Author: ShortPixel
|
8 |
* Author URI: https://shortpixel.com
|
9 |
* Text Domain: shortpixel-image-optimiser
|
@@ -19,7 +19,7 @@ define('SHORTPIXEL_PLUGIN_DIR', __DIR__);
|
|
19 |
|
20 |
//define('SHORTPIXEL_AFFILIATE_CODE', '');
|
21 |
|
22 |
-
define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.16.
|
23 |
define('SHORTPIXEL_MAX_TIMEOUT', 10);
|
24 |
define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
|
25 |
define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');
|
3 |
* Plugin Name: ShortPixel Image Optimizer
|
4 |
* Plugin URI: https://shortpixel.com/
|
5 |
* Description: ShortPixel optimizes images automatically, while guarding the quality of your images. Check your <a href="options-general.php?page=wp-shortpixel-settings" target="_blank">Settings > ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
|
6 |
+
* Version: 4.16.1
|
7 |
* Author: ShortPixel
|
8 |
* Author URI: https://shortpixel.com
|
9 |
* Text Domain: shortpixel-image-optimiser
|
19 |
|
20 |
//define('SHORTPIXEL_AFFILIATE_CODE', '');
|
21 |
|
22 |
+
define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.16.1");
|
23 |
define('SHORTPIXEL_MAX_TIMEOUT', 10);
|
24 |
define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
|
25 |
define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');
|