Version Description
Release date: 12th February 2019
- solved conflicting WebP file names when image.jpg and image.png exist in the same folder - use image.jpg.webp filename.
- fixed .htaccess rules for some Apache versions which seemingly don't honour the RewriteRule backreferences in the RewriteCond's (Apache bug?)
- remove the WebP .htaccess rules on plugin deactivation and add them back on plugin activation
- fixed alt attribute for
Download this release
Release Info
Developer | ShortPixel |
Plugin | ShortPixel Image Optimizer |
Version | 4.12.7 |
Comparing to | |
See all releases |
Code changes from version 4.12.6 to 4.12.7
- class/db/wp-shortpixel-media-library-adapter.php +1 -5
- class/front/img-to-picture-webp.php +74 -51
- class/shortpixel_queue.php +3 -0
- class/view/shortpixel_view.php +2 -1
- class/wp-short-pixel.php +37 -13
- class/wp-shortpixel-settings.php +1 -1
- readme.txt +10 -1
- res/css/sp-file-tree.min.css +1 -1
- res/css/twentytwenty.min.css +1 -2
- res/img/.htaccess +27 -5
- res/img/test.jpg.webp +0 -0
- res/img/test.webp +0 -0
- res/js/jquery.knob.min.js +0 -1
- res/js/jquery.tooltip.min.js +0 -1
- res/js/jquery.twentytwenty.min.js +1 -1
- res/js/shortpixel.js +2 -1
- res/js/shortpixel.min.js +1 -1
- res/js/sp-file-tree.min.js +0 -1
- shortpixel_api.php +75 -71
- wp-shortpixel.php +8 -3
class/db/wp-shortpixel-media-library-adapter.php
CHANGED
@@ -287,11 +287,7 @@ class WpShortPixelMediaLbraryAdapter {
|
|
287 |
$thumbs[]= $th;
|
288 |
}
|
289 |
}
|
290 |
-
|
291 |
-
if( defined('SHORTPIXEL_CUSTOM_THUMB_SUFFIX') || defined('SHORTPIXEL_CUSTOM_THUMB_SUFFIXES') ){
|
292 |
-
$thumbsCandidates = @glob($base . "-*." . $ext);
|
293 |
-
if(is_array($thumbsCandidates)) {
|
294 |
-
$thumbs = array();
|
295 |
$suffixes = defined('SHORTPIXEL_CUSTOM_THUMB_SUFFIXES') ? explode(',', SHORTPIXEL_CUSTOM_THUMB_SUFFIXES) : array();
|
296 |
if( defined('SHORTPIXEL_CUSTOM_THUMB_SUFFIX') ){
|
297 |
$suffixes[] = SHORTPIXEL_CUSTOM_THUMB_SUFFIX;
|
287 |
$thumbs[]= $th;
|
288 |
}
|
289 |
}
|
290 |
+
if( defined('SHORTPIXEL_CUSTOM_THUMB_SUFFIX') || defined('SHORTPIXEL_CUSTOM_THUMB_SUFFIXES') ){
|
|
|
|
|
|
|
|
|
291 |
$suffixes = defined('SHORTPIXEL_CUSTOM_THUMB_SUFFIXES') ? explode(',', SHORTPIXEL_CUSTOM_THUMB_SUFFIXES) : array();
|
292 |
if( defined('SHORTPIXEL_CUSTOM_THUMB_SUFFIX') ){
|
293 |
$suffixes[] = SHORTPIXEL_CUSTOM_THUMB_SUFFIX;
|
class/front/img-to-picture-webp.php
CHANGED
@@ -4,10 +4,10 @@
|
|
4 |
* thanks to the Responsify WP plugin for some of the code
|
5 |
*/
|
6 |
|
7 |
-
class ShortPixelImgToPictureWebp
|
8 |
-
|
9 |
-
public static function lazyGet($img, $type)
|
10 |
-
|
11 |
return array(
|
12 |
'value' =>
|
13 |
(isset($img['data-lazy-' . $type]) && strlen($img['data-lazy-' . $type])) ?
|
@@ -21,17 +21,23 @@ class ShortPixelImgToPictureWebp {
|
|
21 |
: (isset($img[$type]) && strlen($img[$type]) ? '' : false))
|
22 |
);
|
23 |
}
|
24 |
-
|
25 |
-
public static function convert($content)
|
|
|
26 |
// Don't do anything with the RSS feed.
|
27 |
-
if (
|
|
|
|
|
28 |
|
29 |
return preg_replace_callback('/<img[^>]*>/', array('ShortPixelImgToPictureWebp', 'convertImage'), $content);
|
30 |
}
|
31 |
|
32 |
-
public static function convertImage($match)
|
|
|
33 |
// Do nothing with images that have the 'sp-no-webp' class.
|
34 |
-
if (
|
|
|
|
|
35 |
|
36 |
$img = self::get_attributes($match[0]);
|
37 |
|
@@ -47,6 +53,8 @@ class ShortPixelImgToPictureWebp {
|
|
47 |
$sizes = $sizesInfo['value'];
|
48 |
$sizesPrefix = $sizesInfo['prefix'];
|
49 |
|
|
|
|
|
50 |
//check if there are webps
|
51 |
/*$id = $thisClass::url_to_attachment_id( $src );
|
52 |
if(!$id) {
|
@@ -56,18 +64,18 @@ class ShortPixelImgToPictureWebp {
|
|
56 |
*/
|
57 |
$updir = wp_upload_dir();
|
58 |
$proto = explode("://", $src);
|
59 |
-
if(count($proto) > 1) {
|
60 |
//check that baseurl uses the same http/https proto and if not, change
|
61 |
$proto = $proto[0];
|
62 |
-
if(strpos($updir['baseurl'], $proto."://") === false) {
|
63 |
$base = explode("://", $updir['baseurl']);
|
64 |
-
if(count($base) > 1) {
|
65 |
$updir['baseurl'] = $proto . "://" . $base[1];
|
66 |
}
|
67 |
}
|
68 |
}
|
69 |
$imageBase = str_replace($updir['baseurl'], SHORTPIXEL_UPLOADS_BASE, $src);
|
70 |
-
if($imageBase == $src) {
|
71 |
return $match[0];
|
72 |
}
|
73 |
$imageBase = dirname($imageBase) . '/';
|
@@ -76,22 +84,28 @@ class ShortPixelImgToPictureWebp {
|
|
76 |
unset($img['src']);
|
77 |
unset($img['data-src']);
|
78 |
unset($img['data-lazy-src']);
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
$srcsetWebP = '';
|
83 |
-
if($srcset) {
|
84 |
$defs = explode(",", $srcset);
|
85 |
-
foreach($defs as $item) {
|
86 |
$parts = preg_split('/\s+/', trim($item));
|
87 |
|
88 |
//echo(" file: " . $parts[0] . " ext: " . pathinfo($parts[0], PATHINFO_EXTENSION) . " basename: " . wp_basename($parts[0], '.' . pathinfo($parts[0], PATHINFO_EXTENSION)));
|
89 |
|
90 |
-
$
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
$srcsetWebP .= (strlen($srcsetWebP) ? ',': '')
|
93 |
-
|
94 |
-
|
95 |
}
|
96 |
}
|
97 |
//$srcsetWebP = preg_replace('/\.[a-zA-Z0-9]+\s+/', '.webp ', $srcset);
|
@@ -100,12 +114,20 @@ class ShortPixelImgToPictureWebp {
|
|
100 |
|
101 |
// die(var_dump($match));
|
102 |
|
103 |
-
$
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
106 |
}
|
107 |
}
|
108 |
-
|
|
|
|
|
|
|
109 |
|
110 |
//add the exclude class so if this content is processed again in other filter, the img is not converted again in picture
|
111 |
$img['class'] = (isset($img['class']) ? $img['class'] . " " : "") . "sp-no-webp";
|
@@ -113,32 +135,33 @@ class ShortPixelImgToPictureWebp {
|
|
113 |
return '<picture ' . self::create_attributes($img) . '>'
|
114 |
.'<source ' . $srcsetPrefix . 'srcset="' . $srcsetWebP . '"' . ($sizes ? ' ' . $sizesPrefix . 'sizes="' . $sizes . '"' : '') . ' type="image/webp">'
|
115 |
.'<source ' . $srcsetPrefix . 'srcset="' . $srcset . '"' . ($sizes ? ' ' . $sizesPrefix . 'sizes="' . $sizes . '"' : '') . '>'
|
116 |
-
.'<img ' . $srcPrefix . 'src="' . $src . '" ' . self::create_attributes($img) .
|
|
|
117 |
.'</picture>';
|
118 |
}
|
119 |
-
|
120 |
-
public static function get_attributes(
|
121 |
{
|
122 |
-
if(function_exists("mb_convert_encoding")) {
|
123 |
$image_node = mb_convert_encoding($image_node, 'HTML-ENTITIES', 'UTF-8');
|
124 |
}
|
125 |
$dom = new DOMDocument();
|
126 |
@$dom->loadHTML($image_node);
|
127 |
$image = $dom->getElementsByTagName('img')->item(0);
|
128 |
$attributes = array();
|
129 |
-
foreach (
|
130 |
-
|
131 |
}
|
132 |
return $attributes;
|
133 |
}
|
134 |
-
|
135 |
/**
|
136 |
* Makes a string with all attributes.
|
137 |
*
|
138 |
* @param $attribute_array
|
139 |
* @return string
|
140 |
*/
|
141 |
-
public static function create_attributes(
|
142 |
{
|
143 |
$attributes = '';
|
144 |
foreach ($attribute_array as $attribute => $value) {
|
@@ -147,38 +170,38 @@ class ShortPixelImgToPictureWebp {
|
|
147 |
// Removes the extra space after the last attribute
|
148 |
return substr($attributes, 0, -1);
|
149 |
}
|
150 |
-
|
151 |
/**
|
152 |
* @param $image_url
|
153 |
* @return array
|
154 |
*/
|
155 |
-
public static function url_to_attachment_id
|
|
|
156 |
// Thx to https://github.com/kylereicks/picturefill.js.wp/blob/master/inc/class-model-picturefill-wp.php
|
157 |
global $wpdb;
|
158 |
$original_image_url = $image_url;
|
159 |
$image_url = preg_replace('/^(.+?)(-\d+x\d+)?\.(jpg|jpeg|png|gif)((?:\?|#).+)?$/i', '$1.$3', $image_url);
|
160 |
$prefix = $wpdb->prefix;
|
161 |
-
$attachment_id = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $prefix . "posts" . " WHERE guid='%s';", $image_url
|
162 |
-
|
163 |
//try the other proto (https - http) if full urls are used
|
164 |
-
if (
|
165 |
-
$image_url_other_proto = strpos($image_url, 'https') === 0 ?
|
166 |
str_replace('https://', 'http://', $image_url) :
|
167 |
str_replace('http://', 'https://', $image_url);
|
168 |
-
$attachment_id = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $prefix . "posts" . " WHERE guid='%s';", $image_url_other_proto
|
169 |
-
}
|
170 |
-
|
171 |
//try using only path
|
172 |
-
if (empty($attachment_id)
|
173 |
$image_path = parse_url($image_url, PHP_URL_PATH); //some sites have different domains in posts guid (site changes, etc.)
|
174 |
-
$attachment_id = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $prefix . "posts" . " WHERE guid like'%%%s';", $image_path
|
175 |
-
}
|
176 |
-
|
177 |
//try using the initial URL
|
178 |
-
if (
|
179 |
-
$attachment_id = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $prefix . "posts" . " WHERE guid='%s';", $original_image_url
|
180 |
}
|
181 |
return !empty($attachment_id) ? $attachment_id[0] : false;
|
182 |
}
|
183 |
-
|
184 |
-
}
|
4 |
* thanks to the Responsify WP plugin for some of the code
|
5 |
*/
|
6 |
|
7 |
+
class ShortPixelImgToPictureWebp
|
8 |
+
{
|
9 |
+
public static function lazyGet($img, $type)
|
10 |
+
{
|
11 |
return array(
|
12 |
'value' =>
|
13 |
(isset($img['data-lazy-' . $type]) && strlen($img['data-lazy-' . $type])) ?
|
21 |
: (isset($img[$type]) && strlen($img[$type]) ? '' : false))
|
22 |
);
|
23 |
}
|
24 |
+
|
25 |
+
public static function convert($content)
|
26 |
+
{
|
27 |
// Don't do anything with the RSS feed.
|
28 |
+
if (is_feed() || is_admin()) {
|
29 |
+
return $content;
|
30 |
+
}
|
31 |
|
32 |
return preg_replace_callback('/<img[^>]*>/', array('ShortPixelImgToPictureWebp', 'convertImage'), $content);
|
33 |
}
|
34 |
|
35 |
+
public static function convertImage($match)
|
36 |
+
{
|
37 |
// Do nothing with images that have the 'sp-no-webp' class.
|
38 |
+
if (strpos($match[0], 'sp-no-webp')) {
|
39 |
+
return $match[0];
|
40 |
+
}
|
41 |
|
42 |
$img = self::get_attributes($match[0]);
|
43 |
|
53 |
$sizes = $sizesInfo['value'];
|
54 |
$sizesPrefix = $sizesInfo['prefix'];
|
55 |
|
56 |
+
$altAttr = isset($img['alt']) && strlen($img['alt']) ? ' alt="' . $img['alt'] . '"' : '';
|
57 |
+
|
58 |
//check if there are webps
|
59 |
/*$id = $thisClass::url_to_attachment_id( $src );
|
60 |
if(!$id) {
|
64 |
*/
|
65 |
$updir = wp_upload_dir();
|
66 |
$proto = explode("://", $src);
|
67 |
+
if (count($proto) > 1) {
|
68 |
//check that baseurl uses the same http/https proto and if not, change
|
69 |
$proto = $proto[0];
|
70 |
+
if (strpos($updir['baseurl'], $proto."://") === false) {
|
71 |
$base = explode("://", $updir['baseurl']);
|
72 |
+
if (count($base) > 1) {
|
73 |
$updir['baseurl'] = $proto . "://" . $base[1];
|
74 |
}
|
75 |
}
|
76 |
}
|
77 |
$imageBase = str_replace($updir['baseurl'], SHORTPIXEL_UPLOADS_BASE, $src);
|
78 |
+
if ($imageBase == $src) {
|
79 |
return $match[0];
|
80 |
}
|
81 |
$imageBase = dirname($imageBase) . '/';
|
84 |
unset($img['src']);
|
85 |
unset($img['data-src']);
|
86 |
unset($img['data-lazy-src']);
|
87 |
+
unset($img['srcset']);
|
88 |
+
unset($img['sizes']);
|
89 |
+
unset($img['alt']);
|
90 |
$srcsetWebP = '';
|
91 |
+
if ($srcset) {
|
92 |
$defs = explode(",", $srcset);
|
93 |
+
foreach ($defs as $item) {
|
94 |
$parts = preg_split('/\s+/', trim($item));
|
95 |
|
96 |
//echo(" file: " . $parts[0] . " ext: " . pathinfo($parts[0], PATHINFO_EXTENSION) . " basename: " . wp_basename($parts[0], '.' . pathinfo($parts[0], PATHINFO_EXTENSION)));
|
97 |
|
98 |
+
$fileWebPCompat = $imageBase . wp_basename($parts[0], '.' . pathinfo($parts[0], PATHINFO_EXTENSION)) . '.webp';
|
99 |
+
$fileWebP = $imageBase . wp_basename($parts[0]) . '.webp';
|
100 |
+
if (file_exists($fileWebP)) {
|
101 |
+
$srcsetWebP .= (strlen($srcsetWebP) ? ',': '')
|
102 |
+
. $parts[0].'.webp'
|
103 |
+
. (isset($parts[1]) ? ' ' . $parts[1] : '');
|
104 |
+
}
|
105 |
+
if (file_exists($fileWebPCompat)) {
|
106 |
$srcsetWebP .= (strlen($srcsetWebP) ? ',': '')
|
107 |
+
.preg_replace('/\.[a-zA-Z0-9]+$/', '.webp', $parts[0])
|
108 |
+
.(isset($parts[1]) ? ' ' . $parts[1] : '');
|
109 |
}
|
110 |
}
|
111 |
//$srcsetWebP = preg_replace('/\.[a-zA-Z0-9]+\s+/', '.webp ', $srcset);
|
114 |
|
115 |
// die(var_dump($match));
|
116 |
|
117 |
+
$fileWebPCompat = $imageBase . wp_basename($srcset, '.' . pathinfo($srcset, PATHINFO_EXTENSION)) . '.webp';
|
118 |
+
$fileWebP = $imageBase . wp_basename($srcset) . '.webp';
|
119 |
+
if (file_exists($fileWebP)) {
|
120 |
+
$srcsetWebP = $srcset.".webp";
|
121 |
+
} else {
|
122 |
+
if (file_exists($fileWebPCompat)) {
|
123 |
+
$srcsetWebP = preg_replace('/\.[a-zA-Z0-9]+$/', '.webp', $srcset);
|
124 |
+
}
|
125 |
}
|
126 |
}
|
127 |
+
//return($match[0]. "<!-- srcsetTZF:".$srcsetWebP." -->");
|
128 |
+
if (!strlen($srcsetWebP)) {
|
129 |
+
return $match[0];
|
130 |
+
}
|
131 |
|
132 |
//add the exclude class so if this content is processed again in other filter, the img is not converted again in picture
|
133 |
$img['class'] = (isset($img['class']) ? $img['class'] . " " : "") . "sp-no-webp";
|
135 |
return '<picture ' . self::create_attributes($img) . '>'
|
136 |
.'<source ' . $srcsetPrefix . 'srcset="' . $srcsetWebP . '"' . ($sizes ? ' ' . $sizesPrefix . 'sizes="' . $sizes . '"' : '') . ' type="image/webp">'
|
137 |
.'<source ' . $srcsetPrefix . 'srcset="' . $srcset . '"' . ($sizes ? ' ' . $sizesPrefix . 'sizes="' . $sizes . '"' : '') . '>'
|
138 |
+
.'<img ' . $srcPrefix . 'src="' . $src . '" ' . self::create_attributes($img) . $altAttr
|
139 |
+
. (strlen($srcset) ? ' srcset="' . $srcset . '"': '') . (strlen($sizes) ? ' sizes="' . $sizes . '"': '') . '>'
|
140 |
.'</picture>';
|
141 |
}
|
142 |
+
|
143 |
+
public static function get_attributes($image_node)
|
144 |
{
|
145 |
+
if (function_exists("mb_convert_encoding")) {
|
146 |
$image_node = mb_convert_encoding($image_node, 'HTML-ENTITIES', 'UTF-8');
|
147 |
}
|
148 |
$dom = new DOMDocument();
|
149 |
@$dom->loadHTML($image_node);
|
150 |
$image = $dom->getElementsByTagName('img')->item(0);
|
151 |
$attributes = array();
|
152 |
+
foreach ($image->attributes as $attr) {
|
153 |
+
$attributes[$attr->nodeName] = $attr->nodeValue;
|
154 |
}
|
155 |
return $attributes;
|
156 |
}
|
157 |
+
|
158 |
/**
|
159 |
* Makes a string with all attributes.
|
160 |
*
|
161 |
* @param $attribute_array
|
162 |
* @return string
|
163 |
*/
|
164 |
+
public static function create_attributes($attribute_array)
|
165 |
{
|
166 |
$attributes = '';
|
167 |
foreach ($attribute_array as $attribute => $value) {
|
170 |
// Removes the extra space after the last attribute
|
171 |
return substr($attributes, 0, -1);
|
172 |
}
|
173 |
+
|
174 |
/**
|
175 |
* @param $image_url
|
176 |
* @return array
|
177 |
*/
|
178 |
+
public static function url_to_attachment_id($image_url)
|
179 |
+
{
|
180 |
// Thx to https://github.com/kylereicks/picturefill.js.wp/blob/master/inc/class-model-picturefill-wp.php
|
181 |
global $wpdb;
|
182 |
$original_image_url = $image_url;
|
183 |
$image_url = preg_replace('/^(.+?)(-\d+x\d+)?\.(jpg|jpeg|png|gif)((?:\?|#).+)?$/i', '$1.$3', $image_url);
|
184 |
$prefix = $wpdb->prefix;
|
185 |
+
$attachment_id = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $prefix . "posts" . " WHERE guid='%s';", $image_url));
|
186 |
+
|
187 |
//try the other proto (https - http) if full urls are used
|
188 |
+
if (empty($attachment_id) && strpos($image_url, 'http://') === 0) {
|
189 |
+
$image_url_other_proto = strpos($image_url, 'https') === 0 ?
|
190 |
str_replace('https://', 'http://', $image_url) :
|
191 |
str_replace('http://', 'https://', $image_url);
|
192 |
+
$attachment_id = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $prefix . "posts" . " WHERE guid='%s';", $image_url_other_proto));
|
193 |
+
}
|
194 |
+
|
195 |
//try using only path
|
196 |
+
if (empty($attachment_id)) {
|
197 |
$image_path = parse_url($image_url, PHP_URL_PATH); //some sites have different domains in posts guid (site changes, etc.)
|
198 |
+
$attachment_id = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $prefix . "posts" . " WHERE guid like'%%%s';", $image_path));
|
199 |
+
}
|
200 |
+
|
201 |
//try using the initial URL
|
202 |
+
if (empty($attachment_id)) {
|
203 |
+
$attachment_id = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $prefix . "posts" . " WHERE guid='%s';", $original_image_url));
|
204 |
}
|
205 |
return !empty($attachment_id) ? $attachment_id[0] : false;
|
206 |
}
|
207 |
+
}
|
|
class/shortpixel_queue.php
CHANGED
@@ -324,6 +324,9 @@ class ShortPixelQueue {
|
|
324 |
}
|
325 |
|
326 |
public function getBulkToProcess() {
|
|
|
|
|
|
|
327 |
return $this->settings->bulkCount - $this->settings->bulkAlreadyDoneCount;
|
328 |
}
|
329 |
|
324 |
}
|
325 |
|
326 |
public function getBulkToProcess() {
|
327 |
+
//check numeric as per https://secure.helpscout.net/conversation/764815647/12934?folderId=1117588
|
328 |
+
if(!is_numeric($this->settings->bulkCount)) $this->settings->bulkCount = 0;
|
329 |
+
if(!is_numeric($this->settings->bulkAlreadyDoneCount)) $this->settings->bulkAlreadyDoneCount = 0;
|
330 |
return $this->settings->bulkCount - $this->settings->bulkAlreadyDoneCount;
|
331 |
}
|
332 |
|
class/view/shortpixel_view.php
CHANGED
@@ -1255,7 +1255,8 @@ class ShortPixelView {
|
|
1255 |
</p>
|
1256 |
<?php } ?>
|
1257 |
<p class="settings-info">
|
1258 |
-
<?php _e('Each <img> will be replaced with a <picture> tag that will also provide the WebP image as a choice for browsers that support it. Also loads the picturefill.js for browsers that don\'t support the <picture> tag. You don\'t need to activate this if you\'re using the Cache Enabler plugin because your WebP images are already handled by this plugin. <strong>Please make a test before using this option</strong>, as if the styles that your theme is using rely on the position of your <img> tag, you might experience display problems.','shortpixel-image-optimiser')
|
|
|
1259 |
</p>
|
1260 |
<ul class="deliverWebpAlteringTypes">
|
1261 |
<li>
|
1255 |
</p>
|
1256 |
<?php } ?>
|
1257 |
<p class="settings-info">
|
1258 |
+
<?php _e('Each <img> will be replaced with a <picture> tag that will also provide the WebP image as a choice for browsers that support it. Also loads the picturefill.js for browsers that don\'t support the <picture> tag. You don\'t need to activate this if you\'re using the Cache Enabler plugin because your WebP images are already handled by this plugin. <strong>Please make a test before using this option</strong>, as if the styles that your theme is using rely on the position of your <img> tag, you might experience display problems.','shortpixel-image-optimiser'); ?>
|
1259 |
+
<strong><?php _e('You can revert anytime to the previous state by just deactivating the option.','shortpixel-image-optimiser'); ?></strong>
|
1260 |
</p>
|
1261 |
<ul class="deliverWebpAlteringTypes">
|
1262 |
<li>
|
class/wp-short-pixel.php
CHANGED
@@ -181,6 +181,9 @@ class WPShortPixel {
|
|
181 |
$spMetaDao = new ShortPixelCustomMetaDao(new WpShortPixelDb(), $settings->excludePatterns);
|
182 |
$spMetaDao->dropTables();
|
183 |
}
|
|
|
|
|
|
|
184 |
WPShortPixelSettings::onActivate();
|
185 |
}
|
186 |
|
@@ -189,6 +192,7 @@ class WPShortPixel {
|
|
189 |
ShortPixelQueue::resetBulk();
|
190 |
ShortPixelQueue::resetPrio();
|
191 |
WPShortPixelSettings::onDeactivate();
|
|
|
192 |
@unlink(SHORTPIXEL_BACKUP_FOLDER . "/shortpixel_log");
|
193 |
}
|
194 |
|
@@ -530,7 +534,7 @@ class WPShortPixel {
|
|
530 |
'confirmBulkRestore' => __( "Are you sure you want to restore from backup all the images in your Media Library optimized with ShortPixel?", 'shortpixel-image-optimiser' ),
|
531 |
'confirmBulkCleanup' => __( "Are you sure you want to cleanup the ShortPixel metadata info for the images in your Media Library optimized with ShortPixel? This will make ShortPixel 'forget' that it optimized them and will optimize them again if you re-run the Bulk Optimization process.", 'shortpixel-image-optimiser' ),
|
532 |
'confirmBulkCleanupPending' => __( "Are you sure you want to cleanup the pending metadata?", 'shortpixel-image-optimiser' ),
|
533 |
-
'alertDeliverWebPAltered' => __( "Warning: Using this method alters the structure of the HTML code (IMG tags get included in PICTURE tags),\nwhich can lead to CSS/JS inconsistencies
|
534 |
'alertDeliverWebPUnaltered' => __('This option will serve both WebP and the original image using the same URL, based on the web browser capabilities, please make sure you\'re serving the images from your server and not using a CDN which caches the images.', 'shortpixel-image-optimiser' ),
|
535 |
);
|
536 |
wp_localize_script( 'shortpixel' . $this->jsSuffix, '_spTr', $jsTranslation );
|
@@ -1267,7 +1271,11 @@ class WPShortPixel {
|
|
1267 |
}
|
1268 |
|
1269 |
if(strlen($thumb) && $this->_settings->backupImages && $this->_settings->processThumbnails) {
|
1270 |
-
|
|
|
|
|
|
|
|
|
1271 |
//$urlBkPath = $this->_apiInterface->returnSubDir(get_attached_file($ID));
|
1272 |
$urlBkPath = ShortPixelMetaFacade::returnSubDir($meta->getPath(), ShortPixelMetaFacade::MEDIA_LIBRARY_TYPE);
|
1273 |
$bkThumb = $backupUrl . $urlBkPath . $thumb;
|
@@ -1840,8 +1848,10 @@ class WPShortPixel {
|
|
1840 |
@unlink($unlink);
|
1841 |
}
|
1842 |
//try also the .webp
|
1843 |
-
$
|
|
|
1844 |
WPShortPixel::log("PNG2JPG unlink $unlinkWebp");
|
|
|
1845 |
@unlink($unlinkWebp);
|
1846 |
}
|
1847 |
} catch(Exception $e) {
|
@@ -2565,25 +2575,39 @@ class WPShortPixel {
|
|
2565 |
return $customFolders;
|
2566 |
}
|
2567 |
|
2568 |
-
protected function alterHtaccess( $clear = false ){
|
2569 |
if ( $clear ) {
|
2570 |
insert_with_markers( get_home_path() . '.htaccess', 'ShortPixelWebp', '');
|
2571 |
} else {
|
2572 |
insert_with_markers( get_home_path() . '.htaccess', 'ShortPixelWebp', '
|
2573 |
<IfModule mod_rewrite.c>
|
2574 |
RewriteEngine On
|
|
|
|
|
2575 |
# Does browser explicitly support webp?
|
2576 |
RewriteCond %{HTTP_USER_AGENT} Chrome [OR]
|
2577 |
# OR Is request from Page Speed
|
2578 |
RewriteCond %{HTTP_USER_AGENT} "Google Page Speed Insights" [OR]
|
2579 |
# OR does this browser explicitly support webp
|
2580 |
-
RewriteCond %{HTTP_ACCEPT} image/webp
|
2581 |
-
|
2582 |
-
|
2583 |
-
|
|
|
|
|
|
|
2584 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2585 |
# THEN send the webp image and set the env var webp
|
2586 |
RewriteRule (.+)\.(?:jpe?g|png)$ $1.webp [NC,T=image/webp,E=webp,L]
|
|
|
2587 |
</IfModule>
|
2588 |
<IfModule mod_headers.c>
|
2589 |
# If REDIRECT_webp env var exists, append Accept to the Vary header
|
@@ -2786,10 +2810,10 @@ Header append Vary Accept env=REDIRECT_webp
|
|
2786 |
switch( $_POST['deliverWebpType'] ) {
|
2787 |
case 'deliverWebpUnaltered':
|
2788 |
$this->_settings->deliverWebp = 3;
|
2789 |
-
if(!$isNginx)
|
2790 |
break;
|
2791 |
case 'deliverWebpAltered':
|
2792 |
-
|
2793 |
if( isset( $_POST['deliverWebpAlteringType'] ) ){
|
2794 |
switch ($_POST['deliverWebpAlteringType']) {
|
2795 |
case 'deliverWebpAlteredWP':
|
@@ -2804,11 +2828,11 @@ Header append Vary Accept env=REDIRECT_webp
|
|
2804 |
}
|
2805 |
}
|
2806 |
} else {
|
2807 |
-
if(!$isNginx)
|
2808 |
$this->_settings->deliverWebp = 0;
|
2809 |
}
|
2810 |
} else {
|
2811 |
-
if(!$isNginx)
|
2812 |
$this->_settings->deliverWebp = 0;
|
2813 |
}
|
2814 |
|
@@ -3122,7 +3146,7 @@ Header append Vary Accept env=REDIRECT_webp
|
|
3122 |
$file = get_attached_file($id);
|
3123 |
$data = ShortPixelMetaFacade::sanitizeMeta(wp_get_attachment_metadata($id));
|
3124 |
|
3125 |
-
if($extended && isset($
|
3126 |
var_dump(wp_get_attachment_url($id));
|
3127 |
echo('<br><br>' . json_encode(ShortPixelMetaFacade::getWPMLDuplicates($id)));
|
3128 |
echo('<br><br>' . json_encode($data));
|
181 |
$spMetaDao = new ShortPixelCustomMetaDao(new WpShortPixelDb(), $settings->excludePatterns);
|
182 |
$spMetaDao->dropTables();
|
183 |
}
|
184 |
+
if(WPShortPixelSettings::getOpt('deliverWebp') == 3) {
|
185 |
+
self::alterHtaccess(); //add the htaccess lines
|
186 |
+
}
|
187 |
WPShortPixelSettings::onActivate();
|
188 |
}
|
189 |
|
192 |
ShortPixelQueue::resetBulk();
|
193 |
ShortPixelQueue::resetPrio();
|
194 |
WPShortPixelSettings::onDeactivate();
|
195 |
+
self::alterHtaccess(true);
|
196 |
@unlink(SHORTPIXEL_BACKUP_FOLDER . "/shortpixel_log");
|
197 |
}
|
198 |
|
534 |
'confirmBulkRestore' => __( "Are you sure you want to restore from backup all the images in your Media Library optimized with ShortPixel?", 'shortpixel-image-optimiser' ),
|
535 |
'confirmBulkCleanup' => __( "Are you sure you want to cleanup the ShortPixel metadata info for the images in your Media Library optimized with ShortPixel? This will make ShortPixel 'forget' that it optimized them and will optimize them again if you re-run the Bulk Optimization process.", 'shortpixel-image-optimiser' ),
|
536 |
'confirmBulkCleanupPending' => __( "Are you sure you want to cleanup the pending metadata?", 'shortpixel-image-optimiser' ),
|
537 |
+
'alertDeliverWebPAltered' => __( "Warning: Using this method alters the structure of the rendered HTML code (IMG tags get included in PICTURE tags),\nwhich in some rare cases can lead to CSS/JS inconsistencies.\n\nPlease test this functionality thoroughly after activating!\n\nIf you notice any issue, just deactivate it and the HTML will will revert to the previous state.", 'shortpixel-image-optimiser' ),
|
538 |
'alertDeliverWebPUnaltered' => __('This option will serve both WebP and the original image using the same URL, based on the web browser capabilities, please make sure you\'re serving the images from your server and not using a CDN which caches the images.', 'shortpixel-image-optimiser' ),
|
539 |
);
|
540 |
wp_localize_script( 'shortpixel' . $this->jsSuffix, '_spTr', $jsTranslation );
|
1271 |
}
|
1272 |
|
1273 |
if(strlen($thumb) && $this->_settings->backupImages && $this->_settings->processThumbnails) {
|
1274 |
+
//$backupUrl = SHORTPIXEL_UPLOADS_URL . "/" . SHORTPIXEL_BACKUP . "/";
|
1275 |
+
// use the same method as in getComparerData (HelpScout case 771014296). Former method above.
|
1276 |
+
//$backupUrl = content_url() . "/" . SHORTPIXEL_UPLOADS_NAME . "/" . SHORTPIXEL_BACKUP . "/";
|
1277 |
+
//or even better:
|
1278 |
+
$backupUrl = SHORTPIXEL_BACKUP_URL . "/";
|
1279 |
//$urlBkPath = $this->_apiInterface->returnSubDir(get_attached_file($ID));
|
1280 |
$urlBkPath = ShortPixelMetaFacade::returnSubDir($meta->getPath(), ShortPixelMetaFacade::MEDIA_LIBRARY_TYPE);
|
1281 |
$bkThumb = $backupUrl . $urlBkPath . $thumb;
|
1848 |
@unlink($unlink);
|
1849 |
}
|
1850 |
//try also the .webp
|
1851 |
+
$unlinkWebpSymlink = trailingslashit(dirname($unlink)) . wp_basename($unlink, '.' . pathinfo($unlink, PATHINFO_EXTENSION)) . '.webp';
|
1852 |
+
$unlinkWebp = $unlink . '.webp';
|
1853 |
WPShortPixel::log("PNG2JPG unlink $unlinkWebp");
|
1854 |
+
@unlink($unlinkWebpSymlink);
|
1855 |
@unlink($unlinkWebp);
|
1856 |
}
|
1857 |
} catch(Exception $e) {
|
2575 |
return $customFolders;
|
2576 |
}
|
2577 |
|
2578 |
+
protected static function alterHtaccess( $clear = false ){
|
2579 |
if ( $clear ) {
|
2580 |
insert_with_markers( get_home_path() . '.htaccess', 'ShortPixelWebp', '');
|
2581 |
} else {
|
2582 |
insert_with_markers( get_home_path() . '.htaccess', 'ShortPixelWebp', '
|
2583 |
<IfModule mod_rewrite.c>
|
2584 |
RewriteEngine On
|
2585 |
+
|
2586 |
+
##### TRY FIRST the file appended with .webp (ex. test.jpg.webp) #####
|
2587 |
# Does browser explicitly support webp?
|
2588 |
RewriteCond %{HTTP_USER_AGENT} Chrome [OR]
|
2589 |
# OR Is request from Page Speed
|
2590 |
RewriteCond %{HTTP_USER_AGENT} "Google Page Speed Insights" [OR]
|
2591 |
# OR does this browser explicitly support webp
|
2592 |
+
RewriteCond %{HTTP_ACCEPT} image/webp
|
2593 |
+
# AND is the request a jpg or png?
|
2594 |
+
RewriteCond %{REQUEST_URI} ^(.+)\.(?:jpe?g|png)$
|
2595 |
+
# AND does a .ext.webp image exist?
|
2596 |
+
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.webp -f
|
2597 |
+
# THEN send the webp image and set the env var webp
|
2598 |
+
RewriteRule ^(.+)$ $1.webp [NC,T=image/webp,E=webp,L]
|
2599 |
|
2600 |
+
##### IF NOT, try the file with replaced extension (test.webp) #####
|
2601 |
+
RewriteCond %{HTTP_USER_AGENT} Chrome [OR]
|
2602 |
+
RewriteCond %{HTTP_USER_AGENT} "Google Page Speed Insights" [OR]
|
2603 |
+
RewriteCond %{HTTP_ACCEPT} image/webp
|
2604 |
+
# AND is the request a jpg or png? (also grab the basepath %1 to match in the next rule)
|
2605 |
+
RewriteCond %{REQUEST_URI} ^(.+)\.(?:jpe?g|png)$
|
2606 |
+
# AND does a .ext.webp image exist?
|
2607 |
+
RewriteCond %{DOCUMENT_ROOT}/%1.webp -f
|
2608 |
# THEN send the webp image and set the env var webp
|
2609 |
RewriteRule (.+)\.(?:jpe?g|png)$ $1.webp [NC,T=image/webp,E=webp,L]
|
2610 |
+
|
2611 |
</IfModule>
|
2612 |
<IfModule mod_headers.c>
|
2613 |
# If REDIRECT_webp env var exists, append Accept to the Vary header
|
2810 |
switch( $_POST['deliverWebpType'] ) {
|
2811 |
case 'deliverWebpUnaltered':
|
2812 |
$this->_settings->deliverWebp = 3;
|
2813 |
+
if(!$isNginx) self::alterHtaccess();
|
2814 |
break;
|
2815 |
case 'deliverWebpAltered':
|
2816 |
+
self::alterHtaccess(true);
|
2817 |
if( isset( $_POST['deliverWebpAlteringType'] ) ){
|
2818 |
switch ($_POST['deliverWebpAlteringType']) {
|
2819 |
case 'deliverWebpAlteredWP':
|
2828 |
}
|
2829 |
}
|
2830 |
} else {
|
2831 |
+
if(!$isNginx) self::alterHtaccess(true);
|
2832 |
$this->_settings->deliverWebp = 0;
|
2833 |
}
|
2834 |
} else {
|
2835 |
+
if(!$isNginx) self::alterHtaccess(true);
|
2836 |
$this->_settings->deliverWebp = 0;
|
2837 |
}
|
2838 |
|
3146 |
$file = get_attached_file($id);
|
3147 |
$data = ShortPixelMetaFacade::sanitizeMeta(wp_get_attachment_metadata($id));
|
3148 |
|
3149 |
+
if($extended && isset($_GET['SHORTPIXEL_DEBUG'])) {
|
3150 |
var_dump(wp_get_attachment_url($id));
|
3151 |
echo('<br><br>' . json_encode(ShortPixelMetaFacade::getWPMLDuplicates($id)));
|
3152 |
echo('<br><br>' . json_encode($data));
|
class/wp-shortpixel-settings.php
CHANGED
@@ -26,7 +26,7 @@ class WPShortPixelSettings {
|
|
26 |
'keepExif' => array('key' => 'wp-short-pixel-keep-exif', 'default' => 0, 'group' => 'options'),
|
27 |
'CMYKtoRGBconversion' => array('key' => 'wp-short-pixel_cmyk2rgb', 'default' => 1, 'group' => 'options'),
|
28 |
'createWebp' => array('key' => 'wp-short-create-webp', 'default' => null, 'group' => 'options'),
|
29 |
-
'deliverWebp' => array('key' => 'wp-short-pixel-create-webp-markup', 'default' =>
|
30 |
'optimizeRetina' => array('key' => 'wp-short-pixel-optimize-retina', 'default' => 1, 'group' => 'options'),
|
31 |
'optimizeUnlisted' => array('key' => 'wp-short-pixel-optimize-unlisted', 'default' => 0, 'group' => 'options'),
|
32 |
'backupImages' => array('key' => 'wp-short-backup_images', 'default' => 1, 'group' => 'options'),
|
26 |
'keepExif' => array('key' => 'wp-short-pixel-keep-exif', 'default' => 0, 'group' => 'options'),
|
27 |
'CMYKtoRGBconversion' => array('key' => 'wp-short-pixel_cmyk2rgb', 'default' => 1, 'group' => 'options'),
|
28 |
'createWebp' => array('key' => 'wp-short-create-webp', 'default' => null, 'group' => 'options'),
|
29 |
+
'deliverWebp' => array('key' => 'wp-short-pixel-create-webp-markup', 'default' => 0, 'group' => 'options'),
|
30 |
'optimizeRetina' => array('key' => 'wp-short-pixel-optimize-retina', 'default' => 1, 'group' => 'options'),
|
31 |
'optimizeUnlisted' => array('key' => 'wp-short-pixel-optimize-unlisted', 'default' => 0, 'group' => 'options'),
|
32 |
'backupImages' => array('key' => 'wp-short-backup_images', 'default' => 1, 'group' => 'options'),
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: compressor, image, compression, optimize, image optimizer, image optimiser
|
|
4 |
Requires at least: 3.2.0
|
5 |
Tested up to: 5.0
|
6 |
Requires PHP: 5.2
|
7 |
-
Stable tag: 4.12.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -241,6 +241,15 @@ The ShortPixel Image Optimiser plugin calls the following actions and filters:
|
|
241 |
|
242 |
== Changelog ==
|
243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
= 4.12.6 =
|
245 |
|
246 |
Release date: 27th January 2019
|
4 |
Requires at least: 3.2.0
|
5 |
Tested up to: 5.0
|
6 |
Requires PHP: 5.2
|
7 |
+
Stable tag: 4.12.7
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
241 |
|
242 |
== Changelog ==
|
243 |
|
244 |
+
= 4.12.7 =
|
245 |
+
|
246 |
+
Release date: 12th February 2019
|
247 |
+
|
248 |
+
* solved conflicting WebP file names when image.jpg and image.png exist in the same folder - use image.jpg.webp filename.
|
249 |
+
* fixed .htaccess rules for some Apache versions which seemingly don't honour the RewriteRule backreferences in the RewriteCond's (Apache bug?)
|
250 |
+
* remove the WebP .htaccess rules on plugin deactivation and add them back on plugin activation
|
251 |
+
* fixed alt attribute for <picture> tags - now it is included properly only on the enclosed <img> tag.
|
252 |
+
|
253 |
= 4.12.6 =
|
254 |
|
255 |
Release date: 27th January 2019
|
res/css/sp-file-tree.min.css
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
|
2 |
-
div.sp-folder-picker{margin:20px 0;border:1px solid #888;max-height:400px;overflow:auto}UL.jqueryFileTree LI.directory.selected{background-color:#209fd2}UL.jqueryFileTree{font-family:Verdana,sans-serif;font-size:11px;line-height:18px;padding:0;margin:0;display:none}UL.jqueryFileTree LI{list-style:none;padding:0;padding-left:20px;margin:0;white-space:nowrap}UL.jqueryFileTree LI.directory{background:url(../img/file-tree/directory.png) left top no-repeat}UL.jqueryFileTree LI.directory-locked{background:url(../img/file-tree/directory-lock.png) left top no-repeat}UL.jqueryFileTree LI.expanded{background:url(../img/file-tree/folder_open.png) left top no-repeat}UL.jqueryFileTree LI.file{background:url(../img/file-tree/file.png) left top no-repeat}UL.jqueryFileTree LI.file-locked{background:url(../img/file-tree/file-lock.png) left top no-repeat!important}UL.jqueryFileTree LI.wait{background:url(../img/file-tree/spinner.gif) left top no-repeat}UL.jqueryFileTree LI.selected>a{font-weight:bold}UL.jqueryFileTree LI.ext_3gp{background:url(../img/file-tree/film.png) left top no-repeat}UL.jqueryFileTree LI.ext_afp{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_afpa{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_asp{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_aspx{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_avi{background:url(../img/file-tree/film.png) left top no-repeat}UL.jqueryFileTree LI.ext_bat{background:url(../img/file-tree/application.png) left top no-repeat}UL.jqueryFileTree LI.ext_bmp{background:url(../img/file-tree/picture.png) left top no-repeat}UL.jqueryFileTree LI.ext_c{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_cfm{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_cgi{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_com{background:url(../img/file-tree/application.png) left top no-repeat}UL.jqueryFileTree LI.ext_cpp{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_css{background:url(../img/file-tree/css.png) left top no-repeat}UL.jqueryFileTree LI.ext_doc{background:url(../img/file-tree/doc.png) left top no-repeat}UL.jqueryFileTree LI.ext_exe{background:url(../img/file-tree/application.png) left top no-repeat}UL.jqueryFileTree LI.ext_gif{background:url(../img/file-tree/picture.png) left top no-repeat}UL.jqueryFileTree LI.ext_fla{background:url(../img/file-tree/flash.png) left top no-repeat}UL.jqueryFileTree LI.ext_h{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_htm{background:url(../img/file-tree/html.png) left top no-repeat}UL.jqueryFileTree LI.ext_html{background:url(../img/file-tree/html.png) left top no-repeat}UL.jqueryFileTree LI.ext_jar{background:url(../img/file-tree/java.png) left top no-repeat}UL.jqueryFileTree LI.ext_jpg{background:url(../img/file-tree/picture.png) left top no-repeat}UL.jqueryFileTree LI.ext_jpeg{background:url(../img/file-tree/picture.png) left top no-repeat}UL.jqueryFileTree LI.ext_js{background:url(../img/file-tree/script.png) left top no-repeat}UL.jqueryFileTree LI.ext_lasso{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_log{background:url(../img/file-tree/txt.png) left top no-repeat}UL.jqueryFileTree LI.ext_m4p{background:url(../img/file-tree/music.png) left top no-repeat}UL.jqueryFileTree LI.ext_mov{background:url(../img/file-tree/film.png) left top no-repeat}UL.jqueryFileTree LI.ext_mp3{background:url(../img/file-tree/music.png) left top no-repeat}UL.jqueryFileTree LI.ext_mp4{background:url(../img/file-tree/film.png) left top no-repeat}UL.jqueryFileTree LI.ext_mpg{background:url(../img/file-tree/film.png) left top no-repeat}UL.jqueryFileTree LI.ext_mpeg{background:url(../img/file-tree/film.png) left top no-repeat}UL.jqueryFileTree LI.ext_ogg{background:url(../img/file-tree/music.png) left top no-repeat}UL.jqueryFileTree LI.ext_ogv{background:url(../img/file-tree/film.png) left top no-repeat}UL.jqueryFileTree LI.ext_pcx{background:url(../img/file-tree/picture.png) left top no-repeat}UL.jqueryFileTree LI.ext_pdf{background:url(../img/file-tree/pdf.png) left top no-repeat}UL.jqueryFileTree LI.ext_php{background:url(../img/file-tree/php.png) left top no-repeat}UL.jqueryFileTree LI.ext_png{background:url(../img/file-tree/picture.png) left top no-repeat}UL.jqueryFileTree LI.ext_ppt{background:url(../img/file-tree/ppt.png) left top no-repeat}UL.jqueryFileTree LI.ext_psd{background:url(../img/file-tree/psd.png) left top no-repeat}UL.jqueryFileTree LI.ext_pl{background:url(../img/file-tree/script.png) left top no-repeat}UL.jqueryFileTree LI.ext_py{background:url(../img/file-tree/script.png) left top no-repeat}UL.jqueryFileTree LI.ext_rb{background:url(../img/file-tree/ruby.png) left top no-repeat}UL.jqueryFileTree LI.ext_rbx{background:url(../img/file-tree/ruby.png) left top no-repeat}UL.jqueryFileTree LI.ext_rhtml{background:url(../img/file-tree/ruby.png) left top no-repeat}UL.jqueryFileTree LI.ext_rpm{background:url(../img/file-tree/linux.png) left top no-repeat}UL.jqueryFileTree LI.ext_ruby{background:url(../img/file-tree/ruby.png) left top no-repeat}UL.jqueryFileTree LI.ext_sql{background:url(../img/file-tree/db.png) left top no-repeat}UL.jqueryFileTree LI.ext_swf{background:url(../img/file-tree/flash.png) left top no-repeat}UL.jqueryFileTree LI.ext_tif{background:url(../img/file-tree/picture.png) left top no-repeat}UL.jqueryFileTree LI.ext_tiff{background:url(../img/file-tree/picture.png) left top no-repeat}UL.jqueryFileTree LI.ext_txt{background:url(../img/file-tree/txt.png) left top no-repeat}UL.jqueryFileTree LI.ext_vb{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_wav{background:url(../img/file-tree/music.png) left top no-repeat}UL.jqueryFileTree LI.ext_webm{background:url(../img/file-tree/film.png) left top no-repeat}UL.jqueryFileTree LI.ext_wmv{background:url(../img/file-tree/film.png) left top no-repeat}UL.jqueryFileTree LI.ext_xls{background:url(../img/file-tree/xls.png) left top no-repeat}UL.jqueryFileTree LI.ext_xml{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_zip{background:url(../img/file-tree/zip.png) left top no-repeat}UL.jqueryFileTree A{color:#333;text-decoration:none;display:inline-block;padding:0 2px;cursor:pointer}UL.jqueryFileTree A:hover{background:#BDF}
|
1 |
|
2 |
+
div.sp-folder-picker{margin:20px 0;border:1px solid #888;max-height:400px;overflow:auto}UL.jqueryFileTree LI.directory.selected{background-color:#209fd2}UL.jqueryFileTree{font-family:Verdana,sans-serif;font-size:11px;line-height:18px;padding:0;margin:0;display:none}UL.jqueryFileTree LI{list-style:none;padding:0;padding-left:20px;margin:0;white-space:nowrap}UL.jqueryFileTree LI.directory{background:url(../img/file-tree/directory.png) left top no-repeat}UL.jqueryFileTree LI.directory-locked{background:url(../img/file-tree/directory-lock.png) left top no-repeat}UL.jqueryFileTree LI.expanded{background:url(../img/file-tree/folder_open.png) left top no-repeat}UL.jqueryFileTree LI.file{background:url(../img/file-tree/file.png) left top no-repeat}UL.jqueryFileTree LI.file-locked{background:url(../img/file-tree/file-lock.png) left top no-repeat !important}UL.jqueryFileTree LI.wait{background:url(../img/file-tree/spinner.gif) left top no-repeat}UL.jqueryFileTree LI.selected>a{font-weight:bold}UL.jqueryFileTree LI.ext_3gp{background:url(../img/file-tree/film.png) left top no-repeat}UL.jqueryFileTree LI.ext_afp{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_afpa{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_asp{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_aspx{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_avi{background:url(../img/file-tree/film.png) left top no-repeat}UL.jqueryFileTree LI.ext_bat{background:url(../img/file-tree/application.png) left top no-repeat}UL.jqueryFileTree LI.ext_bmp{background:url(../img/file-tree/picture.png) left top no-repeat}UL.jqueryFileTree LI.ext_c{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_cfm{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_cgi{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_com{background:url(../img/file-tree/application.png) left top no-repeat}UL.jqueryFileTree LI.ext_cpp{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_css{background:url(../img/file-tree/css.png) left top no-repeat}UL.jqueryFileTree LI.ext_doc{background:url(../img/file-tree/doc.png) left top no-repeat}UL.jqueryFileTree LI.ext_exe{background:url(../img/file-tree/application.png) left top no-repeat}UL.jqueryFileTree LI.ext_gif{background:url(../img/file-tree/picture.png) left top no-repeat}UL.jqueryFileTree LI.ext_fla{background:url(../img/file-tree/flash.png) left top no-repeat}UL.jqueryFileTree LI.ext_h{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_htm{background:url(../img/file-tree/html.png) left top no-repeat}UL.jqueryFileTree LI.ext_html{background:url(../img/file-tree/html.png) left top no-repeat}UL.jqueryFileTree LI.ext_jar{background:url(../img/file-tree/java.png) left top no-repeat}UL.jqueryFileTree LI.ext_jpg{background:url(../img/file-tree/picture.png) left top no-repeat}UL.jqueryFileTree LI.ext_jpeg{background:url(../img/file-tree/picture.png) left top no-repeat}UL.jqueryFileTree LI.ext_js{background:url(../img/file-tree/script.png) left top no-repeat}UL.jqueryFileTree LI.ext_lasso{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_log{background:url(../img/file-tree/txt.png) left top no-repeat}UL.jqueryFileTree LI.ext_m4p{background:url(../img/file-tree/music.png) left top no-repeat}UL.jqueryFileTree LI.ext_mov{background:url(../img/file-tree/film.png) left top no-repeat}UL.jqueryFileTree LI.ext_mp3{background:url(../img/file-tree/music.png) left top no-repeat}UL.jqueryFileTree LI.ext_mp4{background:url(../img/file-tree/film.png) left top no-repeat}UL.jqueryFileTree LI.ext_mpg{background:url(../img/file-tree/film.png) left top no-repeat}UL.jqueryFileTree LI.ext_mpeg{background:url(../img/file-tree/film.png) left top no-repeat}UL.jqueryFileTree LI.ext_ogg{background:url(../img/file-tree/music.png) left top no-repeat}UL.jqueryFileTree LI.ext_ogv{background:url(../img/file-tree/film.png) left top no-repeat}UL.jqueryFileTree LI.ext_pcx{background:url(../img/file-tree/picture.png) left top no-repeat}UL.jqueryFileTree LI.ext_pdf{background:url(../img/file-tree/pdf.png) left top no-repeat}UL.jqueryFileTree LI.ext_php{background:url(../img/file-tree/php.png) left top no-repeat}UL.jqueryFileTree LI.ext_png{background:url(../img/file-tree/picture.png) left top no-repeat}UL.jqueryFileTree LI.ext_ppt{background:url(../img/file-tree/ppt.png) left top no-repeat}UL.jqueryFileTree LI.ext_psd{background:url(../img/file-tree/psd.png) left top no-repeat}UL.jqueryFileTree LI.ext_pl{background:url(../img/file-tree/script.png) left top no-repeat}UL.jqueryFileTree LI.ext_py{background:url(../img/file-tree/script.png) left top no-repeat}UL.jqueryFileTree LI.ext_rb{background:url(../img/file-tree/ruby.png) left top no-repeat}UL.jqueryFileTree LI.ext_rbx{background:url(../img/file-tree/ruby.png) left top no-repeat}UL.jqueryFileTree LI.ext_rhtml{background:url(../img/file-tree/ruby.png) left top no-repeat}UL.jqueryFileTree LI.ext_rpm{background:url(../img/file-tree/linux.png) left top no-repeat}UL.jqueryFileTree LI.ext_ruby{background:url(../img/file-tree/ruby.png) left top no-repeat}UL.jqueryFileTree LI.ext_sql{background:url(../img/file-tree/db.png) left top no-repeat}UL.jqueryFileTree LI.ext_swf{background:url(../img/file-tree/flash.png) left top no-repeat}UL.jqueryFileTree LI.ext_tif{background:url(../img/file-tree/picture.png) left top no-repeat}UL.jqueryFileTree LI.ext_tiff{background:url(../img/file-tree/picture.png) left top no-repeat}UL.jqueryFileTree LI.ext_txt{background:url(../img/file-tree/txt.png) left top no-repeat}UL.jqueryFileTree LI.ext_vb{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_wav{background:url(../img/file-tree/music.png) left top no-repeat}UL.jqueryFileTree LI.ext_webm{background:url(../img/file-tree/film.png) left top no-repeat}UL.jqueryFileTree LI.ext_wmv{background:url(../img/file-tree/film.png) left top no-repeat}UL.jqueryFileTree LI.ext_xls{background:url(../img/file-tree/xls.png) left top no-repeat}UL.jqueryFileTree LI.ext_xml{background:url(../img/file-tree/code.png) left top no-repeat}UL.jqueryFileTree LI.ext_zip{background:url(../img/file-tree/zip.png) left top no-repeat}UL.jqueryFileTree A{color:#333;text-decoration:none;display:inline-block;padding:0 2px;cursor:pointer}UL.jqueryFileTree A:hover{background:#BDF}
|
res/css/twentytwenty.min.css
CHANGED
@@ -1,2 +1 @@
|
|
1 |
-
|
2 |
-
.twentytwenty-horizontal .twentytwenty-handle:before,.twentytwenty-horizontal .twentytwenty-handle:after,.twentytwenty-vertical .twentytwenty-handle:before,.twentytwenty-vertical .twentytwenty-handle:after{content:" ";display:block;background:white;position:absolute;z-index:30;-webkit-box-shadow:0 0 12px rgba(51,51,51,0.5);-moz-box-shadow:0 0 12px rgba(51,51,51,0.5);box-shadow:0 0 12px rgba(51,51,51,0.5)}.twentytwenty-horizontal .twentytwenty-handle:before,.twentytwenty-horizontal .twentytwenty-handle:after{width:3px;height:9999px;left:50%;margin-left:-1.5px}.twentytwenty-vertical .twentytwenty-handle:before,.twentytwenty-vertical .twentytwenty-handle:after{width:9999px;height:3px;top:50%;margin-top:-1.5px}.twentytwenty-before-label,.twentytwenty-after-label,.twentytwenty-overlay{position:absolute;top:0;width:100%;height:100%}.twentytwenty-before-label,.twentytwenty-after-label,.twentytwenty-overlay{-webkit-transition-duration:.5s;-moz-transition-duration:.5s;transition-duration:.5s}.twentytwenty-before-label,.twentytwenty-after-label{-webkit-transition-property:opacity;-moz-transition-property:opacity;transition-property:opacity}.twentytwenty-before-label:before,.twentytwenty-after-label:before{color:white;font-size:13px;letter-spacing:.1em}.twentytwenty-before-label:before{background:rgba(82,82,82,0.9) none repeat scroll 0 0}.twentytwenty-after-label:before{background:rgba(28,190,203,0.9) none repeat scroll 0 0}.twentytwenty-before-label:before,.twentytwenty-after-label:before{position:absolute;line-height:38px;padding:0 20px;-webkit-border-radius:2px;-moz-border-radius:2px;font-family:montserratbold;font-weight:bold}.twentytwenty-horizontal .twentytwenty-before-label:before,.twentytwenty-horizontal .twentytwenty-after-label:before{top:20px}.twentytwenty-vertical .twentytwenty-before-label:before,.twentytwenty-vertical .twentytwenty-after-label:before{left:50%;margin-left:-45px;text-align:center;width:90px}.twentytwenty-left-arrow,.twentytwenty-right-arrow,.twentytwenty-up-arrow,.twentytwenty-down-arrow{width:0;height:0;border:6px inset transparent;position:absolute}.twentytwenty-left-arrow,.twentytwenty-right-arrow{top:50%;margin-top:-6px}.twentytwenty-up-arrow,.twentytwenty-down-arrow{left:50%;margin-left:-6px}.twentytwenty-container{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;z-index:0;overflow:hidden;position:relative;-webkit-user-select:none;-moz-user-select:none}.twentytwenty-container img{max-width:100%;position:absolute;top:0;display:block}.twentytwenty-container.active .twentytwenty-overlay,.twentytwenty-container.active :hover.twentytwenty-overlay{background:rgba(0,0,0,0)}.twentytwenty-container.active .twentytwenty-overlay .twentytwenty-before-label,.twentytwenty-container.active .twentytwenty-overlay .twentytwenty-after-label,.twentytwenty-container.active :hover.twentytwenty-overlay .twentytwenty-before-label,.twentytwenty-container.active :hover.twentytwenty-overlay .twentytwenty-after-label{opacity:0}.twentytwenty-container *{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}.twentytwenty-before-label{opacity:.7}.twentytwenty-before-label:before{content:"ORIGINAL"}.twentytwenty-after-label{opacity:.7}.twentytwenty-after-label:before{content:"SHORTPIXEL"}.twentytwenty-horizontal .twentytwenty-before-label:before{left:20px}.twentytwenty-horizontal .twentytwenty-after-label:before{right:20px}.twentytwenty-vertical .twentytwenty-before-label:before{top:10px}.twentytwenty-vertical .twentytwenty-after-label:before{bottom:10px}.twentytwenty-overlay{-webkit-transition-property:background;-moz-transition-property:background;transition-property:background;background:rgba(0,0,0,0);z-index:25}.twentytwenty-overlay:hover{background:rgba(0,0,0,0)}.twentytwenty-overlay:hover .twentytwenty-after-label{opacity:1}.twentytwenty-overlay:hover .twentytwenty-before-label{opacity:1}.twentytwenty-before{z-index:20}.twentytwenty-after{z-index:10}.twentytwenty-handle{height:38px;width:38px;position:absolute;left:50%;top:50%;margin-left:-22px;margin-top:-22px;border:3px solid white;-webkit-border-radius:1000px;-moz-border-radius:1000px;border-radius:1000px;-webkit-box-shadow:0 0 12px rgba(51,51,51,0.5);-moz-box-shadow:0 0 12px rgba(51,51,51,0.5);box-shadow:0 0 12px rgba(51,51,51,0.5);z-index:40;cursor:pointer}.twentytwenty-horizontal .twentytwenty-handle:before{bottom:50%;margin-bottom:22px;-webkit-box-shadow:0 3px 0 white,0px 0 12px rgba(51,51,51,0.5);-moz-box-shadow:0 3px 0 white,0px 0 12px rgba(51,51,51,0.5);box-shadow:0 3px 0 white,0px 0 12px rgba(51,51,51,0.5)}.twentytwenty-horizontal .twentytwenty-handle:after{top:50%;margin-top:22px;-webkit-box-shadow:0 -3px 0 white,0px 0 12px rgba(51,51,51,0.5);-moz-box-shadow:0 -3px 0 white,0px 0 12px rgba(51,51,51,0.5);box-shadow:0 -3px 0 white,0px 0 12px rgba(51,51,51,0.5)}.twentytwenty-vertical .twentytwenty-handle:before{left:50%;margin-left:22px;-webkit-box-shadow:3px 0 0 white,0px 0 12px rgba(51,51,51,0.5);-moz-box-shadow:3px 0 0 white,0px 0 12px rgba(51,51,51,0.5);box-shadow:3px 0 0 white,0px 0 12px rgba(51,51,51,0.5)}.twentytwenty-vertical .twentytwenty-handle:after{right:50%;margin-right:22px;-webkit-box-shadow:-3px 0 0 white,0px 0 12px rgba(51,51,51,0.5);-moz-box-shadow:-3px 0 0 white,0px 0 12px rgba(51,51,51,0.5);box-shadow:-3px 0 0 white,0px 0 12px rgba(51,51,51,0.5)}.twentytwenty-left-arrow{border-right:6px solid white;left:50%;margin-left:-17px}.twentytwenty-right-arrow{border-left:6px solid white;right:50%;margin-right:-17px}.twentytwenty-up-arrow{border-bottom:6px solid white;top:50%;margin-top:-17px}.twentytwenty-down-arrow{border-top:6px solid white;bottom:50%;margin-bottom:-17px}
|
1 |
+
.twentytwenty-horizontal .twentytwenty-handle:before,.twentytwenty-horizontal .twentytwenty-handle:after,.twentytwenty-vertical .twentytwenty-handle:before,.twentytwenty-vertical .twentytwenty-handle:after{content:" ";display:block;background:white;position:absolute;z-index:30;-webkit-box-shadow:0 0 12px rgba(51,51,51,0.5);-moz-box-shadow:0 0 12px rgba(51,51,51,0.5);box-shadow:0 0 12px rgba(51,51,51,0.5)}.twentytwenty-horizontal .twentytwenty-handle:before,.twentytwenty-horizontal .twentytwenty-handle:after{width:3px;height:9999px;left:50%;margin-left:-1.5px}.twentytwenty-vertical .twentytwenty-handle:before,.twentytwenty-vertical .twentytwenty-handle:after{width:9999px;height:3px;top:50%;margin-top:-1.5px}.twentytwenty-before-label,.twentytwenty-after-label,.twentytwenty-overlay{position:absolute;top:0;width:100%;height:100%}.twentytwenty-before-label,.twentytwenty-after-label,.twentytwenty-overlay{-webkit-transition-duration:.5s;-moz-transition-duration:.5s;transition-duration:.5s}.twentytwenty-before-label,.twentytwenty-after-label{-webkit-transition-property:opacity;-moz-transition-property:opacity;transition-property:opacity}.twentytwenty-before-label:before,.twentytwenty-after-label:before{color:white;font-size:13px;letter-spacing:.1em}.twentytwenty-before-label:before{background:rgba(82,82,82,0.9) none repeat scroll 0 0}.twentytwenty-after-label:before{background:rgba(28,190,203,0.9) none repeat scroll 0 0}.twentytwenty-before-label:before,.twentytwenty-after-label:before{position:absolute;line-height:38px;padding:0 20px;-webkit-border-radius:2px;-moz-border-radius:2px;font-family:montserratbold;font-weight:bold}.twentytwenty-horizontal .twentytwenty-before-label:before,.twentytwenty-horizontal .twentytwenty-after-label:before{top:20px}.twentytwenty-vertical .twentytwenty-before-label:before,.twentytwenty-vertical .twentytwenty-after-label:before{left:50%;margin-left:-45px;text-align:center;width:90px}.twentytwenty-left-arrow,.twentytwenty-right-arrow,.twentytwenty-up-arrow,.twentytwenty-down-arrow{width:0;height:0;border:6px inset transparent;position:absolute}.twentytwenty-left-arrow,.twentytwenty-right-arrow{top:50%;margin-top:-6px}.twentytwenty-up-arrow,.twentytwenty-down-arrow{left:50%;margin-left:-6px}.twentytwenty-container{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;z-index:0;overflow:hidden;position:relative;-webkit-user-select:none;-moz-user-select:none}.twentytwenty-container img{max-width:100%;position:absolute;top:0;display:block}.twentytwenty-container.active .twentytwenty-overlay,.twentytwenty-container.active :hover.twentytwenty-overlay{background:rgba(0,0,0,0)}.twentytwenty-container.active .twentytwenty-overlay .twentytwenty-before-label,.twentytwenty-container.active .twentytwenty-overlay .twentytwenty-after-label,.twentytwenty-container.active :hover.twentytwenty-overlay .twentytwenty-before-label,.twentytwenty-container.active :hover.twentytwenty-overlay .twentytwenty-after-label{opacity:0}.twentytwenty-container *{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}.twentytwenty-before-label{opacity:.7}.twentytwenty-before-label:before{content:"ORIGINAL"}.twentytwenty-after-label{opacity:.7}.twentytwenty-after-label:before{content:"SHORTPIXEL"}.twentytwenty-horizontal .twentytwenty-before-label:before{left:20px}.twentytwenty-horizontal .twentytwenty-after-label:before{right:20px}.twentytwenty-vertical .twentytwenty-before-label:before{top:10px}.twentytwenty-vertical .twentytwenty-after-label:before{bottom:10px}.twentytwenty-overlay{-webkit-transition-property:background;-moz-transition-property:background;transition-property:background;background:rgba(0,0,0,0);z-index:25}.twentytwenty-overlay:hover{background:rgba(0,0,0,0)}.twentytwenty-overlay:hover .twentytwenty-after-label{opacity:1}.twentytwenty-overlay:hover .twentytwenty-before-label{opacity:1}.twentytwenty-before{z-index:20}.twentytwenty-after{z-index:10}.twentytwenty-handle{height:38px;width:38px;position:absolute;left:50%;top:50%;margin-left:-22px;margin-top:-22px;border:3px solid white;-webkit-border-radius:1000px;-moz-border-radius:1000px;border-radius:1000px;-webkit-box-shadow:0 0 12px rgba(51,51,51,0.5);-moz-box-shadow:0 0 12px rgba(51,51,51,0.5);box-shadow:0 0 12px rgba(51,51,51,0.5);z-index:40;cursor:pointer}.twentytwenty-horizontal .twentytwenty-handle:before{bottom:50%;margin-bottom:22px;-webkit-box-shadow:0 3px 0 white,0 0 12px rgba(51,51,51,0.5);-moz-box-shadow:0 3px 0 white,0 0 12px rgba(51,51,51,0.5);box-shadow:0 3px 0 white,0 0 12px rgba(51,51,51,0.5)}.twentytwenty-horizontal .twentytwenty-handle:after{top:50%;margin-top:22px;-webkit-box-shadow:0 -3px 0 white,0 0 12px rgba(51,51,51,0.5);-moz-box-shadow:0 -3px 0 white,0 0 12px rgba(51,51,51,0.5);box-shadow:0 -3px 0 white,0 0 12px rgba(51,51,51,0.5)}.twentytwenty-vertical .twentytwenty-handle:before{left:50%;margin-left:22px;-webkit-box-shadow:3px 0 0 white,0 0 12px rgba(51,51,51,0.5);-moz-box-shadow:3px 0 0 white,0 0 12px rgba(51,51,51,0.5);box-shadow:3px 0 0 white,0 0 12px rgba(51,51,51,0.5)}.twentytwenty-vertical .twentytwenty-handle:after{right:50%;margin-right:22px;-webkit-box-shadow:-3px 0 0 white,0 0 12px rgba(51,51,51,0.5);-moz-box-shadow:-3px 0 0 white,0 0 12px rgba(51,51,51,0.5);box-shadow:-3px 0 0 white,0 0 12px rgba(51,51,51,0.5)}.twentytwenty-left-arrow{border-right:6px solid white;left:50%;margin-left:-17px}.twentytwenty-right-arrow{border-left:6px solid white;right:50%;margin-right:-17px}.twentytwenty-up-arrow{border-bottom:6px solid white;top:50%;margin-top:-17px}.twentytwenty-down-arrow{border-top:6px solid white;bottom:50%;margin-bottom:-17px}
|
|
res/img/.htaccess
CHANGED
@@ -1,15 +1,37 @@
|
|
1 |
<IfModule mod_rewrite.c>
|
2 |
RewriteEngine On
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
RewriteCond %{HTTP_ACCEPT} image/webp
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
|
|
8 |
<IfModule mod_headers.c>
|
9 |
-
|
|
|
10 |
</IfModule>
|
11 |
|
12 |
<IfModule mod_mime.c>
|
13 |
AddType image/webp .webp
|
14 |
</IfModule>
|
15 |
-
|
1 |
<IfModule mod_rewrite.c>
|
2 |
RewriteEngine On
|
3 |
+
|
4 |
+
##### TRY FIRST the file appended with .webp (ex. test.jpg.webp) #####
|
5 |
+
# Does browser explicitly support webp?
|
6 |
+
RewriteCond %{HTTP_USER_AGENT} Chrome [OR]
|
7 |
+
# OR Is request from Page Speed
|
8 |
+
RewriteCond %{HTTP_USER_AGENT} "Google Page Speed Insights" [OR]
|
9 |
+
# OR does this browser explicitly support webp
|
10 |
RewriteCond %{HTTP_ACCEPT} image/webp
|
11 |
+
# AND is the request a jpg or png?
|
12 |
+
RewriteCond %{REQUEST_URI} ^(.+)\.(?:jpe?g|png)$
|
13 |
+
# AND does a .ext.webp image exist?
|
14 |
+
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.webp -f
|
15 |
+
# THEN send the webp image and set the env var webp
|
16 |
+
RewriteRule ^(.+)$ $1.webp [NC,T=image/webp,E=webp,L]
|
17 |
+
|
18 |
+
##### IF NOT, try the file with replaced extension (test.webp) #####
|
19 |
+
RewriteCond %{HTTP_USER_AGENT} Chrome [OR]
|
20 |
+
RewriteCond %{HTTP_USER_AGENT} "Google Page Speed Insights" [OR]
|
21 |
+
RewriteCond %{HTTP_ACCEPT} image/webp
|
22 |
+
# AND is the request a jpg or png? (also grab the basepath %1 to match in the next rule)
|
23 |
+
RewriteCond %{REQUEST_URI} ^(.+)\.(?:jpe?g|png)$
|
24 |
+
# AND does a .ext.webp image exist?
|
25 |
+
RewriteCond %{DOCUMENT_ROOT}/%1.webp -f
|
26 |
+
# THEN send the webp image and set the env var webp
|
27 |
+
RewriteRule (.+)\.(?:jpe?g|png)$ $1.webp [NC,T=image/webp,E=webp,L]
|
28 |
|
29 |
+
</IfModule>
|
30 |
<IfModule mod_headers.c>
|
31 |
+
# If REDIRECT_webp env var exists, append Accept to the Vary header
|
32 |
+
Header append Vary Accept env=REDIRECT_webp
|
33 |
</IfModule>
|
34 |
|
35 |
<IfModule mod_mime.c>
|
36 |
AddType image/webp .webp
|
37 |
</IfModule>
|
|
res/img/test.jpg.webp
ADDED
Binary file
|
res/img/test.webp
CHANGED
Binary file
|
res/js/jquery.knob.min.js
CHANGED
@@ -1,3 +1,2 @@
|
|
1 |
-
|
2 |
/*!jQuery Knob*/
|
3 |
(function(a){if(typeof exports==="object"){module.exports=a(require("jquery"))}else{if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{a(jQuery)}}}(function(d){var b={},a=Math.max,c=Math.min;b.c={};b.c.d=d(document);b.c.t=function(f){return f.originalEvent.touches.length-1};b.o=function(){var e=this;this.o=null;this.$=null;this.i=null;this.g=null;this.v=null;this.cv=null;this.x=0;this.y=0;this.w=0;this.h=0;this.$c=null;this.c=null;this.t=0;this.isInit=false;this.fgColor=null;this.pColor=null;this.dH=null;this.cH=null;this.eH=null;this.rH=null;this.scale=1;this.relative=false;this.relativeWidth=false;this.relativeHeight=false;this.$div=null;this.run=function(){var f=function(i,h){var g;for(g in h){e.o[g]=h[g]}e._carve().init();e._configure()._draw()};if(this.$.data("kontroled")){return}this.$.data("kontroled",true);this.extend();this.o=d.extend({min:this.$.data("min")!==undefined?this.$.data("min"):0,max:this.$.data("max")!==undefined?this.$.data("max"):100,stopper:true,readOnly:this.$.data("readonly")||(this.$.attr("readonly")==="readonly"),cursor:this.$.data("cursor")===true&&30||this.$.data("cursor")||0,thickness:this.$.data("thickness")&&Math.max(Math.min(this.$.data("thickness"),1),0.01)||0.35,lineCap:this.$.data("linecap")||"butt",width:this.$.data("width")||200,height:this.$.data("height")||200,displayInput:this.$.data("displayinput")==null||this.$.data("displayinput"),displayPrevious:this.$.data("displayprevious"),fgColor:this.$.data("fgcolor")||"#87CEEB",inputColor:this.$.data("inputcolor"),font:this.$.data("font")||"Arial",fontWeight:this.$.data("font-weight")||"bold",inline:false,step:this.$.data("step")||1,rotation:this.$.data("rotation"),draw:null,change:null,cancel:null,release:null,format:function(g){return g},parse:function(g){return parseFloat(g)}},this.o);this.o.flip=this.o.rotation==="anticlockwise"||this.o.rotation==="acw";if(!this.o.inputColor){this.o.inputColor=this.o.fgColor}if(this.$.is("fieldset")){this.v={};this.i=this.$.find("input");this.i.each(function(g){var h=d(this);e.i[g]=h;e.v[g]=e.o.parse(h.val());h.bind("change blur",function(){var i={};i[g]=h.val();e.val(e._validate(i))})});this.$.find("legend").remove()}else{this.i=this.$;this.v=this.o.parse(this.$.val());this.v===""&&(this.v=this.o.min);this.$.bind("change blur",function(){e.val(e._validate(e.o.parse(e.$.val())))})}!this.o.displayInput&&this.$.hide();this.$c=d(document.createElement("canvas")).attr({width:this.o.width,height:this.o.height});this.$div=d('<div style="'+(this.o.inline?"display:inline;":"")+"width:"+this.o.width+"px;height:"+this.o.height+'px;"></div>');this.$.wrap(this.$div).before(this.$c);this.$div=this.$.parent();if(typeof G_vmlCanvasManager!=="undefined"){G_vmlCanvasManager.initElement(this.$c[0])}this.c=this.$c[0].getContext?this.$c[0].getContext("2d"):null;if(!this.c){throw {name:"CanvasNotSupportedException",message:"Canvas not supported. Please use excanvas on IE8.0.",toString:function(){return this.name+": "+this.message}}}this.scale=(window.devicePixelRatio||1)/(this.c.webkitBackingStorePixelRatio||this.c.mozBackingStorePixelRatio||this.c.msBackingStorePixelRatio||this.c.oBackingStorePixelRatio||this.c.backingStorePixelRatio||1);this.relativeWidth=this.o.width%1!==0&&this.o.width.indexOf("%");this.relativeHeight=this.o.height%1!==0&&this.o.height.indexOf("%");this.relative=this.relativeWidth||this.relativeHeight;this._carve();if(this.v instanceof Object){this.cv={};this.copy(this.v,this.cv)}else{this.cv=this.v}this.$.bind("configure",f).parent().bind("configure",f);this._listen()._configure()._xy().init();this.isInit=true;this.$.val(this.o.format(this.v));this._draw();return this};this._carve=function(){if(this.relative){var f=this.relativeWidth?this.$div.parent().width()*parseInt(this.o.width)/100:this.$div.parent().width(),g=this.relativeHeight?this.$div.parent().height()*parseInt(this.o.height)/100:this.$div.parent().height();this.w=this.h=Math.min(f,g)}else{this.w=this.o.width;this.h=this.o.height}this.$div.css({width:this.w+"px",height:this.h+"px"});this.$c.attr({width:this.w,height:this.h});if(this.scale!==1){this.$c[0].width=this.$c[0].width*this.scale;this.$c[0].height=this.$c[0].height*this.scale;this.$c.width(this.w);this.$c.height(this.h)}return this};this._draw=function(){var f=true;e.g=e.c;e.clear();e.dH&&(f=e.dH());f!==false&&e.draw()};this._touch=function(f){var g=function(i){var h=e.xy2val(i.originalEvent.touches[e.t].pageX,i.originalEvent.touches[e.t].pageY);if(h==e.cv){return}if(e.cH&&e.cH(h)===false){return}e.change(e._validate(h));e._draw()};this.t=b.c.t(f);g(f);b.c.d.bind("touchmove.k",g).bind("touchend.k",function(){b.c.d.unbind("touchmove.k touchend.k");e.val(e.cv)});return this};this._mouse=function(g){var f=function(i){var h=e.xy2val(i.pageX,i.pageY);if(h==e.cv){return}if(e.cH&&(e.cH(h)===false)){return}e.change(e._validate(h));e._draw()};f(g);b.c.d.bind("mousemove.k",f).bind("keyup.k",function(h){if(h.keyCode===27){b.c.d.unbind("mouseup.k mousemove.k keyup.k");if(e.eH&&e.eH()===false){return}e.cancel()}}).bind("mouseup.k",function(h){b.c.d.unbind("mousemove.k mouseup.k keyup.k");e.val(e.cv)});return this};this._xy=function(){var f=this.$c.offset();this.x=f.left;this.y=f.top;return this};this._listen=function(){if(!this.o.readOnly){this.$c.bind("mousedown",function(f){f.preventDefault();e._xy()._mouse(f)}).bind("touchstart",function(f){f.preventDefault();e._xy()._touch(f)});this.listen()}else{this.$.attr("readonly","readonly")}if(this.relative){d(window).resize(function(){e._carve().init();e._draw()})}return this};this._configure=function(){if(this.o.draw){this.dH=this.o.draw}if(this.o.change){this.cH=this.o.change}if(this.o.cancel){this.eH=this.o.cancel}if(this.o.release){this.rH=this.o.release}if(this.o.displayPrevious){this.pColor=this.h2rgba(this.o.fgColor,"0.4");this.fgColor=this.h2rgba(this.o.fgColor,"0.6")}else{this.fgColor=this.o.fgColor}return this};this._clear=function(){this.$c[0].width=this.$c[0].width};this._validate=function(f){var g=(~~(((f<0)?-0.5:0.5)+(f/this.o.step)))*this.o.step;return Math.round(g*100)/100};this.listen=function(){};this.extend=function(){};this.init=function(){};this.change=function(f){};this.val=function(f){};this.xy2val=function(f,g){};this.draw=function(){};this.clear=function(){this._clear()};this.h2rgba=function(i,f){var g;i=i.substring(1,7);g=[parseInt(i.substring(0,2),16),parseInt(i.substring(2,4),16),parseInt(i.substring(4,6),16)];return"rgba("+g[0]+","+g[1]+","+g[2]+","+f+")"};this.copy=function(j,h){for(var g in j){h[g]=j[g]}}};b.Dial=function(){b.o.call(this);this.startAngle=null;this.xy=null;this.radius=null;this.lineWidth=null;this.cursorExt=null;this.w2=null;this.PI2=2*Math.PI;this.extend=function(){this.o=d.extend({bgColor:this.$.data("bgcolor")||"#EEEEEE",angleOffset:this.$.data("angleoffset")||0,angleArc:this.$.data("anglearc")||360,inline:true},this.o)};this.val=function(e,f){if(null!=e){e=this.o.parse(e);if(f!==false&&e!=this.v&&this.rH&&this.rH(e)===false){return}this.cv=this.o.stopper?a(c(e,this.o.max),this.o.min):e;this.v=this.cv;this.$.val(this.o.format(this.v));this._draw()}else{return this.v}};this.xy2val=function(e,h){var f,g;f=Math.atan2(e-(this.x+this.w2),-(h-this.y-this.w2))-this.angleOffset;if(this.o.flip){f=this.angleArc-f-this.PI2}if(this.angleArc!=this.PI2&&(f<0)&&(f>-0.5)){f=0}else{if(f<0){f+=this.PI2}}g=(f*(this.o.max-this.o.min)/this.angleArc)+this.o.min;this.o.stopper&&(g=a(c(g,this.o.max),this.o.min));return g};this.listen=function(){var h=this,g,f,l=function(q){q.preventDefault();var p=q.originalEvent,n=p.detail||p.wheelDeltaX,m=p.detail||p.wheelDeltaY,o=h._validate(h.o.parse(h.$.val()))+(n>0||m>0?h.o.step:n<0||m<0?-h.o.step:0);o=a(c(o,h.o.max),h.o.min);h.val(o,false);if(h.rH){clearTimeout(g);g=setTimeout(function(){h.rH(o);g=null},100);if(!f){f=setTimeout(function(){if(g){h.rH(o)}f=null},200)}}},j,k,e=1,i={37:-h.o.step,38:h.o.step,39:h.o.step,40:-h.o.step};this.$.bind("keydown",function(o){var n=o.keyCode;if(n>=96&&n<=105){n=o.keyCode=n-48}j=parseInt(String.fromCharCode(n));if(isNaN(j)){(n!==13)&&n!==8&&n!==9&&n!==189&&(n!==190||h.$.val().match(/\./))&&o.preventDefault();if(d.inArray(n,[37,38,39,40])>-1){o.preventDefault();var m=h.o.parse(h.$.val())+i[n]*e;h.o.stopper&&(m=a(c(m,h.o.max),h.o.min));h.change(h._validate(m));h._draw();k=window.setTimeout(function(){e*=2},30)}}}).bind("keyup",function(m){if(isNaN(j)){if(k){window.clearTimeout(k);k=null;e=1;h.val(h.$.val())}}else{(h.$.val()>h.o.max&&h.$.val(h.o.max))||(h.$.val()<h.o.min&&h.$.val(h.o.min))}});this.$c.bind("mousewheel DOMMouseScroll",l);this.$.bind("mousewheel DOMMouseScroll",l)};this.init=function(){if(this.v<this.o.min||this.v>this.o.max){this.v=this.o.min}this.$.val(this.v);this.w2=this.w/2;this.cursorExt=this.o.cursor/100;this.xy=this.w2*this.scale;this.lineWidth=this.xy*this.o.thickness;this.lineCap=this.o.lineCap;this.radius=this.xy-this.lineWidth/2;this.o.angleOffset&&(this.o.angleOffset=isNaN(this.o.angleOffset)?0:this.o.angleOffset);this.o.angleArc&&(this.o.angleArc=isNaN(this.o.angleArc)?this.PI2:this.o.angleArc);this.angleOffset=this.o.angleOffset*Math.PI/180;this.angleArc=this.o.angleArc*Math.PI/180;this.startAngle=1.5*Math.PI+this.angleOffset;this.endAngle=1.5*Math.PI+this.angleOffset+this.angleArc;var e=a(String(Math.abs(this.o.max)).length,String(Math.abs(this.o.min)).length,2)+2;this.o.displayInput&&this.i.css({width:((this.w/2+4)>>0)+"px",height:((this.w/3)>>0)+"px",position:"absolute","vertical-align":"middle","margin-top":((this.w/3)>>0)+"px","margin-left":"-"+((this.w*3/4+2)>>0)+"px",border:0,background:"none",font:this.o.fontWeight+" "+((this.w/e)>>0)+"px "+this.o.font,"text-align":"center",color:this.o.inputColor||this.o.fgColor,padding:"0px","-webkit-appearance":"none"})||this.i.css({width:"0px",visibility:"hidden"})};this.change=function(e){this.cv=e;this.$.val(this.o.format(e))};this.angle=function(e){return(e-this.o.min)*this.angleArc/(this.o.max-this.o.min)};this.arc=function(f){var e,g;f=this.angle(f);if(this.o.flip){e=this.endAngle+0.00001;g=e-f-0.00001}else{e=this.startAngle-0.00001;g=e+f+0.00001}this.o.cursor&&(e=g-this.cursorExt)&&(g=g+this.cursorExt);return{s:e,e:g,d:this.o.flip&&!this.o.cursor}};this.draw=function(){var h=this.g,e=this.arc(this.cv),f,g=1;h.lineWidth=this.lineWidth;h.lineCap=this.lineCap;if(this.o.bgColor!=="none"){h.beginPath();h.strokeStyle=this.o.bgColor;h.arc(this.xy,this.xy,this.radius,this.endAngle-0.00001,this.startAngle+0.00001,true);h.stroke()}if(this.o.displayPrevious){f=this.arc(this.v);h.beginPath();h.strokeStyle=this.pColor;h.arc(this.xy,this.xy,this.radius,f.s,f.e,f.d);h.stroke();g=this.cv==this.v}h.beginPath();h.strokeStyle=g?this.o.fgColor:this.fgColor;h.arc(this.xy,this.xy,this.radius,e.s,e.e,e.d);h.stroke()};this.cancel=function(){this.val(this.v)}};d.fn.dial=d.fn.knob=function(e){return this.each(function(){var f=new b.Dial();f.o=e;f.$=d(this);f.run()}).parent()}}));
|
|
|
1 |
/*!jQuery Knob*/
|
2 |
(function(a){if(typeof exports==="object"){module.exports=a(require("jquery"))}else{if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{a(jQuery)}}}(function(d){var b={},a=Math.max,c=Math.min;b.c={};b.c.d=d(document);b.c.t=function(f){return f.originalEvent.touches.length-1};b.o=function(){var e=this;this.o=null;this.$=null;this.i=null;this.g=null;this.v=null;this.cv=null;this.x=0;this.y=0;this.w=0;this.h=0;this.$c=null;this.c=null;this.t=0;this.isInit=false;this.fgColor=null;this.pColor=null;this.dH=null;this.cH=null;this.eH=null;this.rH=null;this.scale=1;this.relative=false;this.relativeWidth=false;this.relativeHeight=false;this.$div=null;this.run=function(){var f=function(i,h){var g;for(g in h){e.o[g]=h[g]}e._carve().init();e._configure()._draw()};if(this.$.data("kontroled")){return}this.$.data("kontroled",true);this.extend();this.o=d.extend({min:this.$.data("min")!==undefined?this.$.data("min"):0,max:this.$.data("max")!==undefined?this.$.data("max"):100,stopper:true,readOnly:this.$.data("readonly")||(this.$.attr("readonly")==="readonly"),cursor:this.$.data("cursor")===true&&30||this.$.data("cursor")||0,thickness:this.$.data("thickness")&&Math.max(Math.min(this.$.data("thickness"),1),0.01)||0.35,lineCap:this.$.data("linecap")||"butt",width:this.$.data("width")||200,height:this.$.data("height")||200,displayInput:this.$.data("displayinput")==null||this.$.data("displayinput"),displayPrevious:this.$.data("displayprevious"),fgColor:this.$.data("fgcolor")||"#87CEEB",inputColor:this.$.data("inputcolor"),font:this.$.data("font")||"Arial",fontWeight:this.$.data("font-weight")||"bold",inline:false,step:this.$.data("step")||1,rotation:this.$.data("rotation"),draw:null,change:null,cancel:null,release:null,format:function(g){return g},parse:function(g){return parseFloat(g)}},this.o);this.o.flip=this.o.rotation==="anticlockwise"||this.o.rotation==="acw";if(!this.o.inputColor){this.o.inputColor=this.o.fgColor}if(this.$.is("fieldset")){this.v={};this.i=this.$.find("input");this.i.each(function(g){var h=d(this);e.i[g]=h;e.v[g]=e.o.parse(h.val());h.bind("change blur",function(){var i={};i[g]=h.val();e.val(e._validate(i))})});this.$.find("legend").remove()}else{this.i=this.$;this.v=this.o.parse(this.$.val());this.v===""&&(this.v=this.o.min);this.$.bind("change blur",function(){e.val(e._validate(e.o.parse(e.$.val())))})}!this.o.displayInput&&this.$.hide();this.$c=d(document.createElement("canvas")).attr({width:this.o.width,height:this.o.height});this.$div=d('<div style="'+(this.o.inline?"display:inline;":"")+"width:"+this.o.width+"px;height:"+this.o.height+'px;"></div>');this.$.wrap(this.$div).before(this.$c);this.$div=this.$.parent();if(typeof G_vmlCanvasManager!=="undefined"){G_vmlCanvasManager.initElement(this.$c[0])}this.c=this.$c[0].getContext?this.$c[0].getContext("2d"):null;if(!this.c){throw {name:"CanvasNotSupportedException",message:"Canvas not supported. Please use excanvas on IE8.0.",toString:function(){return this.name+": "+this.message}}}this.scale=(window.devicePixelRatio||1)/(this.c.webkitBackingStorePixelRatio||this.c.mozBackingStorePixelRatio||this.c.msBackingStorePixelRatio||this.c.oBackingStorePixelRatio||this.c.backingStorePixelRatio||1);this.relativeWidth=this.o.width%1!==0&&this.o.width.indexOf("%");this.relativeHeight=this.o.height%1!==0&&this.o.height.indexOf("%");this.relative=this.relativeWidth||this.relativeHeight;this._carve();if(this.v instanceof Object){this.cv={};this.copy(this.v,this.cv)}else{this.cv=this.v}this.$.bind("configure",f).parent().bind("configure",f);this._listen()._configure()._xy().init();this.isInit=true;this.$.val(this.o.format(this.v));this._draw();return this};this._carve=function(){if(this.relative){var f=this.relativeWidth?this.$div.parent().width()*parseInt(this.o.width)/100:this.$div.parent().width(),g=this.relativeHeight?this.$div.parent().height()*parseInt(this.o.height)/100:this.$div.parent().height();this.w=this.h=Math.min(f,g)}else{this.w=this.o.width;this.h=this.o.height}this.$div.css({width:this.w+"px",height:this.h+"px"});this.$c.attr({width:this.w,height:this.h});if(this.scale!==1){this.$c[0].width=this.$c[0].width*this.scale;this.$c[0].height=this.$c[0].height*this.scale;this.$c.width(this.w);this.$c.height(this.h)}return this};this._draw=function(){var f=true;e.g=e.c;e.clear();e.dH&&(f=e.dH());f!==false&&e.draw()};this._touch=function(f){var g=function(i){var h=e.xy2val(i.originalEvent.touches[e.t].pageX,i.originalEvent.touches[e.t].pageY);if(h==e.cv){return}if(e.cH&&e.cH(h)===false){return}e.change(e._validate(h));e._draw()};this.t=b.c.t(f);g(f);b.c.d.bind("touchmove.k",g).bind("touchend.k",function(){b.c.d.unbind("touchmove.k touchend.k");e.val(e.cv)});return this};this._mouse=function(g){var f=function(i){var h=e.xy2val(i.pageX,i.pageY);if(h==e.cv){return}if(e.cH&&(e.cH(h)===false)){return}e.change(e._validate(h));e._draw()};f(g);b.c.d.bind("mousemove.k",f).bind("keyup.k",function(h){if(h.keyCode===27){b.c.d.unbind("mouseup.k mousemove.k keyup.k");if(e.eH&&e.eH()===false){return}e.cancel()}}).bind("mouseup.k",function(h){b.c.d.unbind("mousemove.k mouseup.k keyup.k");e.val(e.cv)});return this};this._xy=function(){var f=this.$c.offset();this.x=f.left;this.y=f.top;return this};this._listen=function(){if(!this.o.readOnly){this.$c.bind("mousedown",function(f){f.preventDefault();e._xy()._mouse(f)}).bind("touchstart",function(f){f.preventDefault();e._xy()._touch(f)});this.listen()}else{this.$.attr("readonly","readonly")}if(this.relative){d(window).resize(function(){e._carve().init();e._draw()})}return this};this._configure=function(){if(this.o.draw){this.dH=this.o.draw}if(this.o.change){this.cH=this.o.change}if(this.o.cancel){this.eH=this.o.cancel}if(this.o.release){this.rH=this.o.release}if(this.o.displayPrevious){this.pColor=this.h2rgba(this.o.fgColor,"0.4");this.fgColor=this.h2rgba(this.o.fgColor,"0.6")}else{this.fgColor=this.o.fgColor}return this};this._clear=function(){this.$c[0].width=this.$c[0].width};this._validate=function(f){var g=(~~(((f<0)?-0.5:0.5)+(f/this.o.step)))*this.o.step;return Math.round(g*100)/100};this.listen=function(){};this.extend=function(){};this.init=function(){};this.change=function(f){};this.val=function(f){};this.xy2val=function(f,g){};this.draw=function(){};this.clear=function(){this._clear()};this.h2rgba=function(i,f){var g;i=i.substring(1,7);g=[parseInt(i.substring(0,2),16),parseInt(i.substring(2,4),16),parseInt(i.substring(4,6),16)];return"rgba("+g[0]+","+g[1]+","+g[2]+","+f+")"};this.copy=function(j,h){for(var g in j){h[g]=j[g]}}};b.Dial=function(){b.o.call(this);this.startAngle=null;this.xy=null;this.radius=null;this.lineWidth=null;this.cursorExt=null;this.w2=null;this.PI2=2*Math.PI;this.extend=function(){this.o=d.extend({bgColor:this.$.data("bgcolor")||"#EEEEEE",angleOffset:this.$.data("angleoffset")||0,angleArc:this.$.data("anglearc")||360,inline:true},this.o)};this.val=function(e,f){if(null!=e){e=this.o.parse(e);if(f!==false&&e!=this.v&&this.rH&&this.rH(e)===false){return}this.cv=this.o.stopper?a(c(e,this.o.max),this.o.min):e;this.v=this.cv;this.$.val(this.o.format(this.v));this._draw()}else{return this.v}};this.xy2val=function(e,h){var f,g;f=Math.atan2(e-(this.x+this.w2),-(h-this.y-this.w2))-this.angleOffset;if(this.o.flip){f=this.angleArc-f-this.PI2}if(this.angleArc!=this.PI2&&(f<0)&&(f>-0.5)){f=0}else{if(f<0){f+=this.PI2}}g=(f*(this.o.max-this.o.min)/this.angleArc)+this.o.min;this.o.stopper&&(g=a(c(g,this.o.max),this.o.min));return g};this.listen=function(){var h=this,g,f,l=function(q){q.preventDefault();var p=q.originalEvent,n=p.detail||p.wheelDeltaX,m=p.detail||p.wheelDeltaY,o=h._validate(h.o.parse(h.$.val()))+(n>0||m>0?h.o.step:n<0||m<0?-h.o.step:0);o=a(c(o,h.o.max),h.o.min);h.val(o,false);if(h.rH){clearTimeout(g);g=setTimeout(function(){h.rH(o);g=null},100);if(!f){f=setTimeout(function(){if(g){h.rH(o)}f=null},200)}}},j,k,e=1,i={37:-h.o.step,38:h.o.step,39:h.o.step,40:-h.o.step};this.$.bind("keydown",function(o){var n=o.keyCode;if(n>=96&&n<=105){n=o.keyCode=n-48}j=parseInt(String.fromCharCode(n));if(isNaN(j)){(n!==13)&&n!==8&&n!==9&&n!==189&&(n!==190||h.$.val().match(/\./))&&o.preventDefault();if(d.inArray(n,[37,38,39,40])>-1){o.preventDefault();var m=h.o.parse(h.$.val())+i[n]*e;h.o.stopper&&(m=a(c(m,h.o.max),h.o.min));h.change(h._validate(m));h._draw();k=window.setTimeout(function(){e*=2},30)}}}).bind("keyup",function(m){if(isNaN(j)){if(k){window.clearTimeout(k);k=null;e=1;h.val(h.$.val())}}else{(h.$.val()>h.o.max&&h.$.val(h.o.max))||(h.$.val()<h.o.min&&h.$.val(h.o.min))}});this.$c.bind("mousewheel DOMMouseScroll",l);this.$.bind("mousewheel DOMMouseScroll",l)};this.init=function(){if(this.v<this.o.min||this.v>this.o.max){this.v=this.o.min}this.$.val(this.v);this.w2=this.w/2;this.cursorExt=this.o.cursor/100;this.xy=this.w2*this.scale;this.lineWidth=this.xy*this.o.thickness;this.lineCap=this.o.lineCap;this.radius=this.xy-this.lineWidth/2;this.o.angleOffset&&(this.o.angleOffset=isNaN(this.o.angleOffset)?0:this.o.angleOffset);this.o.angleArc&&(this.o.angleArc=isNaN(this.o.angleArc)?this.PI2:this.o.angleArc);this.angleOffset=this.o.angleOffset*Math.PI/180;this.angleArc=this.o.angleArc*Math.PI/180;this.startAngle=1.5*Math.PI+this.angleOffset;this.endAngle=1.5*Math.PI+this.angleOffset+this.angleArc;var e=a(String(Math.abs(this.o.max)).length,String(Math.abs(this.o.min)).length,2)+2;this.o.displayInput&&this.i.css({width:((this.w/2+4)>>0)+"px",height:((this.w/3)>>0)+"px",position:"absolute","vertical-align":"middle","margin-top":((this.w/3)>>0)+"px","margin-left":"-"+((this.w*3/4+2)>>0)+"px",border:0,background:"none",font:this.o.fontWeight+" "+((this.w/e)>>0)+"px "+this.o.font,"text-align":"center",color:this.o.inputColor||this.o.fgColor,padding:"0px","-webkit-appearance":"none"})||this.i.css({width:"0px",visibility:"hidden"})};this.change=function(e){this.cv=e;this.$.val(this.o.format(e))};this.angle=function(e){return(e-this.o.min)*this.angleArc/(this.o.max-this.o.min)};this.arc=function(f){var e,g;f=this.angle(f);if(this.o.flip){e=this.endAngle+0.00001;g=e-f-0.00001}else{e=this.startAngle-0.00001;g=e+f+0.00001}this.o.cursor&&(e=g-this.cursorExt)&&(g=g+this.cursorExt);return{s:e,e:g,d:this.o.flip&&!this.o.cursor}};this.draw=function(){var h=this.g,e=this.arc(this.cv),f,g=1;h.lineWidth=this.lineWidth;h.lineCap=this.lineCap;if(this.o.bgColor!=="none"){h.beginPath();h.strokeStyle=this.o.bgColor;h.arc(this.xy,this.xy,this.radius,this.endAngle-0.00001,this.startAngle+0.00001,true);h.stroke()}if(this.o.displayPrevious){f=this.arc(this.v);h.beginPath();h.strokeStyle=this.pColor;h.arc(this.xy,this.xy,this.radius,f.s,f.e,f.d);h.stroke();g=this.cv==this.v}h.beginPath();h.strokeStyle=g?this.o.fgColor:this.fgColor;h.arc(this.xy,this.xy,this.radius,e.s,e.e,e.d);h.stroke()};this.cancel=function(){this.val(this.v)}};d.fn.dial=d.fn.knob=function(e){return this.each(function(){var f=new b.Dial();f.o=e;f.$=d(this);f.run()}).parent()}}));
|
res/js/jquery.tooltip.min.js
CHANGED
@@ -1,2 +1 @@
|
|
1 |
-
|
2 |
(function(a){a.fn.spTooltip=function(d){a.fn.spTooltip.defaultsSettings={attributeName:"title",borderColor:"#ccc",borderSize:"1",cancelClick:0,followMouse:1,height:"auto",hoverIntent:{sensitivity:7,interval:100,timeout:0},loader:0,loaderHeight:0,loaderImagePath:"",loaderWidth:0,positionTop:12,positionLeft:12,width:"auto",titleAttributeContent:"",tooltipBGColor:"#fff",tooltipBGImage:"none",tooltipHTTPType:"get",tooltipPadding:10,tooltipSource:"attribute",tooltipSourceID:"",tooltipSourceURL:"",tooltipID:"tooltip"};var e=a.extend({},a.fn.spTooltip.defaultsSettings,d||{});var g=function(k){var h=0;var l=0;if(!k){var k=window.event}if(k.pageX||k.pageY){h=k.pageX;l=k.pageY}else{if(k.clientX||k.clientY){h=k.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;l=k.clientY+document.body.scrollTop+document.documentElement.scrollTop}}var j={x:h+e.positionLeft,y:l+e.positionTop,w:a("#"+e.tooltipID).width(),h:a("#"+e.tooltipID).height()};var i={x:a(window).scrollLeft(),y:a(window).scrollTop(),w:a(window).width()-20,h:a(window).height()-20};if(j.y+j.h>i.y+i.h&&j.x+j.w>i.x+i.w){j.x=(j.x-j.w)-45;j.y=(j.y-j.h)-45}else{if(j.x+j.w>i.x+i.w){j.x=j.x-(((j.x+j.w)-(i.x+i.w))+20)}else{if(j.y+j.h>i.y+i.h){j.y=j.y-(((j.y+j.h)-(i.y+i.h))+20)}}}a("#"+e.tooltipID).css({left:j.x+"px",top:j.y+"px"})};var f=function(){a("#tooltipLoader").remove();a("#"+e.tooltipID+" #tooltipContent").show();if(a.browser.version=="6.0"){a("#"+e.tooltipID).append('<iframe id="tooltipIE6FixIframe" style="width:'+(a("#"+e.tooltipID).width()+parseFloat(e.borderSize)+parseFloat(e.borderSize)+20)+"px;height:"+(a("#"+e.tooltipID).height()+parseFloat(e.borderSize)+parseFloat(e.borderSize)+20)+"px;position:absolute;top:-"+e.borderSize+"px;left:-"+e.borderSize+'px;filter:alpha(opacity=0);"src="blank.html"></iframe>')}};var b=function(h){a("#"+e.tooltipID).fadeOut("fast").trigger("unload").remove();if(a(h).filter("[title]")){a(h).attr("title",e.titleAttributeContent)}};var c=function(h){var i={};h.replace(/b([^&=]*)=([^&=]*)b/g,function(j,k,l){if(typeof i[k]!="undefined"){i[k]+=","+l}else{i[k]=l}});return i};return this.each(function(i){if(e.cancelClick){a(this).bind("click",function(){return false})}if(a.fn.hoverIntent){a(this).hoverIntent({sensitivity:e.hoverIntent.sensitivity,interval:e.hoverIntent.interval,over:h,timeout:e.hoverIntent.timeout,out:j})}else{a(this).hover(h,j)}function h(n){a("body").append('<div id="'+e.tooltipID+'" style="background-repeat:no-repeat;background-image:url('+e.tooltipBGImage+");padding:"+e.tooltipPadding+"px;display:none;height:"+e.height+";width:"+e.width+";background-color:"+e.tooltipBGColor+";border:"+e.borderSize+"px solid "+e.borderColor+'; position:absolute;z-index:100000000000;"><div id="tooltipContent" style="display:none;"></div></div>');var l=a("#"+e.tooltipID);var o=a("#"+e.tooltipID+" #tooltipContent");if(e.loader&&e.loaderImagePath!=""){l.append('<div id="tooltipLoader" style="width:'+e.loaderWidth+"px;height:"+e.loaderHeight+'px;"><img src="'+e.loaderImagePath+'" /></div>')}if(a(this).attr("title")){e.titleAttributeContent=a(this).attr("title");a(this).attr("title","")}if(a(this).is("input")){a(this).focus(function(){b(this)})}n.preventDefault();g(n);l.show();e.tooltipSourceID=a(this).attr("href")||e.tooltipSourceID;e.tooltipSourceURL=a(this).attr("href")||e.tooltipSourceURL;switch(e.tooltipSource){case"attribute":o.text(e.titleAttributeContent);f();break;case"inline":o.html(a(e.tooltipSourceID).children());l.unload(function(){a(e.tooltipSourceID).html(o.children())});f();break;case"ajax":if(e.tooltipHTTPType=="post"){var m,k;if(e.tooltipSourceURL.indexOf("?")!==-1){m=e.windowSourceURL.substr(0,e.windowSourceURL.indexOf("?"));k=c(e.tooltipSourceURL)}else{m=e.tooltipSourceURL;k={}}o.load(m,k,function(){f()})}else{if(e.tooltipSourceURL.indexOf("?")==-1){e.tooltipSourceURL+="?"}o.load(e.tooltipSourceURL+"&random="+(new Date().getTime()),function(){f()})}break}return false}function j(k){b(this);return false}if(e.followMouse){a(this).bind("mousemove",function(k){g(k);return false})}})}})(jQuery);
|
|
|
1 |
(function(a){a.fn.spTooltip=function(d){a.fn.spTooltip.defaultsSettings={attributeName:"title",borderColor:"#ccc",borderSize:"1",cancelClick:0,followMouse:1,height:"auto",hoverIntent:{sensitivity:7,interval:100,timeout:0},loader:0,loaderHeight:0,loaderImagePath:"",loaderWidth:0,positionTop:12,positionLeft:12,width:"auto",titleAttributeContent:"",tooltipBGColor:"#fff",tooltipBGImage:"none",tooltipHTTPType:"get",tooltipPadding:10,tooltipSource:"attribute",tooltipSourceID:"",tooltipSourceURL:"",tooltipID:"tooltip"};var e=a.extend({},a.fn.spTooltip.defaultsSettings,d||{});var g=function(k){var h=0;var l=0;if(!k){var k=window.event}if(k.pageX||k.pageY){h=k.pageX;l=k.pageY}else{if(k.clientX||k.clientY){h=k.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;l=k.clientY+document.body.scrollTop+document.documentElement.scrollTop}}var j={x:h+e.positionLeft,y:l+e.positionTop,w:a("#"+e.tooltipID).width(),h:a("#"+e.tooltipID).height()};var i={x:a(window).scrollLeft(),y:a(window).scrollTop(),w:a(window).width()-20,h:a(window).height()-20};if(j.y+j.h>i.y+i.h&&j.x+j.w>i.x+i.w){j.x=(j.x-j.w)-45;j.y=(j.y-j.h)-45}else{if(j.x+j.w>i.x+i.w){j.x=j.x-(((j.x+j.w)-(i.x+i.w))+20)}else{if(j.y+j.h>i.y+i.h){j.y=j.y-(((j.y+j.h)-(i.y+i.h))+20)}}}a("#"+e.tooltipID).css({left:j.x+"px",top:j.y+"px"})};var f=function(){a("#tooltipLoader").remove();a("#"+e.tooltipID+" #tooltipContent").show();if(a.browser.version=="6.0"){a("#"+e.tooltipID).append('<iframe id="tooltipIE6FixIframe" style="width:'+(a("#"+e.tooltipID).width()+parseFloat(e.borderSize)+parseFloat(e.borderSize)+20)+"px;height:"+(a("#"+e.tooltipID).height()+parseFloat(e.borderSize)+parseFloat(e.borderSize)+20)+"px;position:absolute;top:-"+e.borderSize+"px;left:-"+e.borderSize+'px;filter:alpha(opacity=0);"src="blank.html"></iframe>')}};var b=function(h){a("#"+e.tooltipID).fadeOut("fast").trigger("unload").remove();if(a(h).filter("[title]")){a(h).attr("title",e.titleAttributeContent)}};var c=function(h){var i={};h.replace(/b([^&=]*)=([^&=]*)b/g,function(j,k,l){if(typeof i[k]!="undefined"){i[k]+=","+l}else{i[k]=l}});return i};return this.each(function(i){if(e.cancelClick){a(this).bind("click",function(){return false})}if(a.fn.hoverIntent){a(this).hoverIntent({sensitivity:e.hoverIntent.sensitivity,interval:e.hoverIntent.interval,over:h,timeout:e.hoverIntent.timeout,out:j})}else{a(this).hover(h,j)}function h(n){a("body").append('<div id="'+e.tooltipID+'" style="background-repeat:no-repeat;background-image:url('+e.tooltipBGImage+");padding:"+e.tooltipPadding+"px;display:none;height:"+e.height+";width:"+e.width+";background-color:"+e.tooltipBGColor+";border:"+e.borderSize+"px solid "+e.borderColor+'; position:absolute;z-index:100000000000;"><div id="tooltipContent" style="display:none;"></div></div>');var l=a("#"+e.tooltipID);var o=a("#"+e.tooltipID+" #tooltipContent");if(e.loader&&e.loaderImagePath!=""){l.append('<div id="tooltipLoader" style="width:'+e.loaderWidth+"px;height:"+e.loaderHeight+'px;"><img src="'+e.loaderImagePath+'" /></div>')}if(a(this).attr("title")){e.titleAttributeContent=a(this).attr("title");a(this).attr("title","")}if(a(this).is("input")){a(this).focus(function(){b(this)})}n.preventDefault();g(n);l.show();e.tooltipSourceID=a(this).attr("href")||e.tooltipSourceID;e.tooltipSourceURL=a(this).attr("href")||e.tooltipSourceURL;switch(e.tooltipSource){case"attribute":o.text(e.titleAttributeContent);f();break;case"inline":o.html(a(e.tooltipSourceID).children());l.unload(function(){a(e.tooltipSourceID).html(o.children())});f();break;case"ajax":if(e.tooltipHTTPType=="post"){var m,k;if(e.tooltipSourceURL.indexOf("?")!==-1){m=e.windowSourceURL.substr(0,e.windowSourceURL.indexOf("?"));k=c(e.tooltipSourceURL)}else{m=e.tooltipSourceURL;k={}}o.load(m,k,function(){f()})}else{if(e.tooltipSourceURL.indexOf("?")==-1){e.tooltipSourceURL+="?"}o.load(e.tooltipSourceURL+"&random="+(new Date().getTime()),function(){f()})}break}return false}function j(k){b(this);return false}if(e.followMouse){a(this).bind("mousemove",function(k){g(k);return false})}})}})(jQuery);
|
res/js/jquery.twentytwenty.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(function(a){a.fn.twentytwenty=function(b){var b=a.extend({default_offset_pct:0.5,orientation:"horizontal",slider_move:"drag"},b);return this.each(function(){var h=b.default_offset_pct;var e=a(this);var c=b.orientation;var q=(c==="vertical")?"down":"left";var d=(c==="vertical")?"up":"right";e.wrap("<div class='twentytwenty-wrapper twentytwenty-"+c+"'></div>");e.append("<div class='twentytwenty-overlay'></div>");var r=e.find("img:first");var o=e.find("img:last");e.append("<div class='twentytwenty-handle'></div>");var f=e.find(".twentytwenty-handle");f.append("<span class='twentytwenty-"+q+"-arrow'></span>");f.append("<span class='twentytwenty-"+d+"-arrow'></span>");e.addClass("twentytwenty-container");r.addClass("twentytwenty-before");o.addClass("twentytwenty-after");var j=e.find(".twentytwenty-overlay");j.append("<div class='twentytwenty-before-label'></div>");j.append("<div class='twentytwenty-after-label'></div>");var l=e.find("div.twentytwenty-before-label");var k=e.find("div.twentytwenty-after-label");var i=function(t){var s=r.width();var u=r.height();return{w:s+"px",h:u+"px",cw:(t*s)+"px",ch:(t*u)+"px"}};var g=function(s){if(c==="vertical"){r.css("clip","rect(0,"+s.w+","+s.ch+",0)")}else{r.css("clip","rect(0,"+s.cw+","+s.h+",0)");l.css("clip","rect(0,"+s.cw+","+s.h+",0)");k.css("clip","rect(0,"+s.w+","+s.h+","+s.cw+")")}e.css("height",s.h)};var n=function(s){var t=i(s);f.css((c==="vertical")?"top":"left",(c==="vertical")?t.ch:t.cw);g(t)};a(window).on("resize.twentytwenty",function(s){n(h)});var m=0;var p=0;if(b.slider_move=="drag"){f.on("movestart",function(s){if(((s.distX>s.distY&&s.distX<-s.distY)||(s.distX<s.distY&&s.distX>-s.distY))&&c!=="vertical"){s.preventDefault()}else{if(((s.distX<s.distY&&s.distX<-s.distY)||(s.distX>s.distY&&s.distX>-s.distY))&&c==="vertical"){s.preventDefault()}}e.addClass("active");m=e.offset().left;offsetY=e.offset().top;p=r.width();imgHeight=r.height()});f.on("moveend",function(s){e.removeClass("active")});f.on("move",function(s){if(e.hasClass("active")){h=(c==="vertical")?(s.pageY-offsetY)/imgHeight:(s.pageX-m)/p;if(h<0){h=0}if(h>1){h=1}n(h)}})}else{e.mousemove(function(s){h=(c==="vertical")?(s.pageY-e.offset().top)/r.height():(s.pageX-e.offset().left)/r.width();if(h<0){h=0}if(h>1){h=1}n(h)})}e.find("img").on("mousedown",function(s){s.preventDefault()});a(window).trigger("resize.twentytwenty")})}})(jQuery);
|
1 |
+
(function(a){a.fn.twentytwenty=function(b){var b=a.extend({default_offset_pct:0.5,orientation:"horizontal",slider_move:"drag"},b);return this.each(function(){var h=b.default_offset_pct;var e=a(this);var c=b.orientation;var q=(c==="vertical")?"down":"left";var d=(c==="vertical")?"up":"right";e.wrap("<div class='twentytwenty-wrapper twentytwenty-"+c+"'></div>");e.append("<div class='twentytwenty-overlay'></div>");var r=e.find("img:first");var o=e.find("img:last");e.append("<div class='twentytwenty-handle'></div>");var f=e.find(".twentytwenty-handle");f.append("<span class='twentytwenty-"+q+"-arrow'></span>");f.append("<span class='twentytwenty-"+d+"-arrow'></span>");e.addClass("twentytwenty-container");r.addClass("twentytwenty-before");o.addClass("twentytwenty-after");var j=e.find(".twentytwenty-overlay");j.append("<div class='twentytwenty-before-label'></div>");j.append("<div class='twentytwenty-after-label'></div>");var l=e.find("div.twentytwenty-before-label");var k=e.find("div.twentytwenty-after-label");var i=function(t){var s=r.width();var u=r.height();return{w:s+"px",h:u+"px",cw:(t*s)+"px",ch:(t*u)+"px"}};var g=function(s){if(c==="vertical"){r.css("clip","rect(0,"+s.w+","+s.ch+",0)")}else{r.css("clip","rect(0,"+s.cw+","+s.h+",0)");l.css("clip","rect(0,"+s.cw+","+s.h+",0)");k.css("clip","rect(0,"+s.w+","+s.h+","+s.cw+")")}e.css("height",s.h)};var n=function(s){var t=i(s);f.css((c==="vertical")?"top":"left",(c==="vertical")?t.ch:t.cw);g(t)};a(window).on("resize.twentytwenty",function(s){n(h)});var m=0;var p=0;if(b.slider_move=="drag"){f.on("movestart",function(s){if(((s.distX>s.distY&&s.distX<-s.distY)||(s.distX<s.distY&&s.distX>-s.distY))&&c!=="vertical"){s.preventDefault()}else{if(((s.distX<s.distY&&s.distX<-s.distY)||(s.distX>s.distY&&s.distX>-s.distY))&&c==="vertical"){s.preventDefault()}}e.addClass("active");m=e.offset().left;offsetY=e.offset().top;p=r.width();imgHeight=r.height()});f.on("moveend",function(s){e.removeClass("active")});f.on("move",function(s){if(e.hasClass("active")){h=(c==="vertical")?(s.pageY-offsetY)/imgHeight:(s.pageX-m)/p;if(h<0){h=0}if(h>1){h=1}n(h)}})}else{e.mousemove(function(s){h=(c==="vertical")?(s.pageY-e.offset().top)/r.height():(s.pageX-e.offset().left)/r.width();if(h<0){h=0}if(h>1){h=1}n(h)})}e.find("img").on("mousedown",function(s){s.preventDefault()});a(window).trigger("resize.twentytwenty")})}})(jQuery);
|
res/js/shortpixel.js
CHANGED
@@ -558,7 +558,8 @@ var ShortPixel = function() {
|
|
558 |
}
|
559 |
|
560 |
function recheckQuota() {
|
561 |
-
|
|
|
562 |
}
|
563 |
|
564 |
function openImageMenu(e) {
|
558 |
}
|
559 |
|
560 |
function recheckQuota() {
|
561 |
+
var parts = window.location.href.split('#');
|
562 |
+
window.location.href=parts[0]+(parts[0].indexOf('?')>0?'&':'?')+'checkquota=1' + (typeof parts[1] === 'undefined' ? '' : '#' + parts[1]);
|
563 |
}
|
564 |
|
565 |
function openImageMenu(e) {
|
res/js/shortpixel.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(document).ready(function(){ShortPixel.init()});var ShortPixel=function(){function I(){if(typeof ShortPixel.API_KEY!=="undefined"){return}if(jQuery("table.wp-list-table.media").length>0){jQuery('select[name^="action"] option:last-child').before('<option value="short-pixel-bulk">'+_spTr.optimizeWithSP+'</option><option value="short-pixel-bulk-lossy"> → '+_spTr.redoLossy+'</option><option value="short-pixel-bulk-glossy"> → '+_spTr.redoGlossy+'</option><option value="short-pixel-bulk-lossless"> → '+_spTr.redoLossless+'</option><option value="short-pixel-bulk-restore"> → '+_spTr.restoreOriginal+"</option>")}ShortPixel.setOptions(ShortPixelConstants[0]);if(jQuery("#backup-folder-size").length){jQuery("#backup-folder-size").html(ShortPixel.getBackupSize())}if(ShortPixel.MEDIA_ALERT=="todo"&&jQuery("div.media-frame.mode-grid").length>0){jQuery("div.media-frame.mode-grid").before('<div id="short-pixel-media-alert" class="notice notice-warning"><p>'+_spTr.changeMLToListMode.format('<a href="upload.php?mode=list" class="view-list"><span class="screen-reader-text">'," </span>",'</a><a class="alignright" href="javascript:ShortPixel.dismissMediaAlert();">',"</a>")+"</p></div>")}jQuery(window).on("beforeunload",function(){if(ShortPixel.bulkProcessor==true){clearBulkProcessor()}});checkQuotaExceededAlert();checkBulkProgress()}function m(Q){for(var R in Q){ShortPixel[R]=Q[R]}}function t(Q){return/^\w+([\.+-]?\w+)*@\w+([\.-]?\w+)*(\.\w{1,63})+$/.test(Q)}function n(){var Q=jQuery("#pluginemail").val();if(ShortPixel.isEmailValid(Q)){jQuery("#request_key").removeClass("disabled")}jQuery("#request_key").attr("href",jQuery("#request_key").attr("href").split("?")[0]+"?pluginemail="+Q)}function a(){jQuery("#valid").val("validate");jQuery("#wp_shortpixel_options").submit()}jQuery("#key").keypress(function(Q){if(Q.which==13){jQuery("#valid").val("validate")}});function L(Q){if(jQuery(Q).is(":checked")){jQuery("#width,#height").removeAttr("disabled")}else{jQuery("#width,#height").attr("disabled","disabled")}}function e(Q,S,U){for(var R=0,T=null;R<Q.length;R++){Q[R].onclick=function(){if(this!==T){T=this}if(typeof ShortPixel.setupGeneralTabAlert!=="undefined"){return}alert(_spTr.alertOnlyAppliesToNewImages);ShortPixel.setupGeneralTabAlert=1}}ShortPixel.enableResize("#resize");jQuery("#resize").change(function(){L(this)});jQuery(".resize-sizes").blur(function(W){var X=jQuery(this);if(ShortPixel.resizeSizesAlert==X.val()){return}ShortPixel.resizeSizesAlert=X.val();var V=jQuery("#min-"+X.attr("name")).val();if(X.val()<Math.min(V,1024)){if(V>1024){alert(_spTr.pleaseDoNotSetLesser1024.format(X.attr("name")))}else{alert(_spTr.pleaseDoNotSetLesserSize.format(X.attr("name"),X.attr("name"),V))}W.preventDefault();X.focus()}else{this.defaultValue=X.val()}});jQuery(".shortpixel-confirm").click(function(W){var V=confirm(W.target.getAttribute("data-confirm"));if(!V){W.preventDefault();return false}return true})}function C(){jQuery(".wp-shortpixel-options .shortpixel-key-valid").css("display","none");jQuery(".wp-shortpixel-options button#validate").css("display","inline-block")}function u(){jQuery("input.remove-folder-button").click(function(){var R=jQuery(this).data("value");var Q=confirm(_spTr.areYouSureStopOptimizing.format(R));if(Q==true){jQuery("#removeFolder").val(R);jQuery("#wp_shortpixel_options").submit()}});jQuery("input.recheck-folder-button").click(function(){var R=jQuery(this).data("value");var Q=confirm(_spTr.areYouSureStopOptimizing.format(R));if(Q==true){jQuery("#recheckFolder").val(R);jQuery("#wp_shortpixel_options").submit()}})}function K(Q){var R=jQuery("#"+(Q.checked?"total":"main")+"ToProcess").val();jQuery("div.bulk-play span.total").text(R);jQuery("#displayTotal").text(R)}function g(){ShortPixel.adjustSettingsTabs();jQuery(window).resize(function(){ShortPixel.adjustSettingsTabs()});if(window.location.hash){var Q=("tab-"+window.location.hash.substring(window.location.hash.indexOf("#")+1)).replace(/\//,"");if(jQuery("section#"+Q).length){ShortPixel.switchSettingsTab(Q)}}jQuery("article.sp-tabs a.tab-link").click(function(){var R=jQuery(this).data("id");ShortPixel.switchSettingsTab(R)});jQuery("input[type=radio][name=deliverWebpType]").change(function(){if(this.value=="deliverWebpAltered"){if(window.confirm(_spTr.alertDeliverWebPAltered)){var R=jQuery("input[type=radio][name=deliverWebpAlteringType]:checked").length;if(R==0){jQuery("#deliverWebpAlteredWP").prop("checked",true)}}else{jQuery(this).prop("checked",false)}}else{if(this.value=="deliverWebpUnaltered"){window.alert(_spTr.alertDeliverWebPUnaltered)}}})}function x(U){var S=U.replace("tab-",""),Q="",T=jQuery("section#"+U),R=location.href.replace(location.hash,"")+"#"+S;if(history.pushState){history.pushState(null,null,R)}else{location.hash=R}if(T.length>0){jQuery("section").removeClass("sel-tab");jQuery("section#"+U).addClass("sel-tab")}if(typeof HS.beacon.suggest!=="undefined"){switch(S){case"settings":Q=shortpixel_suggestions_settings;break;case"adv-settings":Q=shortpixel_suggestions_adv_settings;break;case"cloudflare":case"stats":Q=shortpixel_suggestions_cloudflare;break;default:break}HS.beacon.suggest(Q)}}function y(){var Q=jQuery("section#tab-settings .wp-shortpixel-options").height()+90;Q=Math.max(Q,jQuery("section#tab-adv-settings .wp-shortpixel-options").height()+20);Q=Math.max(Q,jQuery("section#tab-resources .area1").height()+60);jQuery("#shortpixel-settings-tabs").css("height",Q)}function M(){var Q={action:"shortpixel_dismiss_media_alert"};jQuery.get(ShortPixel.AJAX_URL,Q,function(R){Q=JSON.parse(R);if(Q.Status=="success"){jQuery("#short-pixel-media-alert").hide();console.log("dismissed")}})}function k(){var Q={action:"shortpixel_check_quota"};jQuery.get(ShortPixel.AJAX_URL,Q,function(){console.log("quota refreshed")})}function B(Q){if(Q.checked){jQuery("#with-thumbs").css("display","inherit");jQuery("#without-thumbs").css("display","none")}else{jQuery("#without-thumbs").css("display","inherit");jQuery("#with-thumbs").css("display","none")}}function b(U,S,R,T,Q){return(S>0?"<div class='sp-column-info'>"+_spTr.reducedBy+" <strong><span class='percent'>"+S+"%</span></strong> ":"")+(S>0&&S<5?"<br>":"")+(S<5?_spTr.bonusProcessing:"")+(R.length>0?" ("+R+")":"")+(0+T>0?"<br>"+_spTr.plusXthumbsOpt.format(T):"")+(0+Q>0?"<br>"+_spTr.plusXretinasOpt.format(Q):"")+"</div>"}function p(R,Q){jQuery(R).knob({readOnly:true,width:Q,height:Q,fgColor:"#1CAECB",format:function(S){return S+"%"}})}function c(X,S,V,U,R,W){if(R==1){var T=jQuery(".sp-column-actions-template").clone();if(!T.length){return false}var Q;if(S.length==0){Q=["lossy","lossless"]}else{Q=["lossy","glossy","lossless"].filter(function(Y){return !(Y==S)})}T.html(T.html().replace(/__SP_ID__/g,X));if(W.substr(W.lastIndexOf(".")+1).toLowerCase()=="pdf"){jQuery(".sp-action-compare",T).remove()}if(V==0&&U>0){T.html(T.html().replace("__SP_THUMBS_TOTAL__",U))}else{jQuery(".sp-action-optimize-thumbs",T).remove();jQuery(".sp-dropbtn",T).removeClass("button-primary")}T.html(T.html().replace(/__SP_FIRST_TYPE__/g,Q[0]));T.html(T.html().replace(/__SP_SECOND_TYPE__/g,Q[1]));return T.html()}return""}function i(U,T){U=U.substring(2);if(jQuery(".shortpixel-other-media").length){var S=["optimize","retry","restore","redo","quota","view"];for(var R=0,Q=S.length;R<Q;R++){jQuery("#"+S[R]+"_"+U).css("display","none")}for(var R=0,Q=T.length;R<Q;R++){jQuery("#"+T[R]+"_"+U).css("display","")}}}function j(Q){ShortPixel.retries++;if(isNaN(ShortPixel.retries)){ShortPixel.retries=1}if(ShortPixel.retries<6){console.log("Invalid response from server (Error: "+Q+"). Retrying pass "+(ShortPixel.retries+1)+"...");setTimeout(checkBulkProgress,5000)}else{ShortPixel.bulkShowError(-1,"Invalid response from server received 6 times. Please retry later by reloading this page, or <a href='https://shortpixel.com/contact' target='_blank'>contact support</a>. (Error: "+Q+")","");console.log("Invalid response from server 6 times. Giving up.")}}function l(Q){Q.action="shortpixel_browse_content";var R="";jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:Q,success:function(S){R=S},async:false});return R}function d(){var Q={action:"shortpixel_get_backup_size"};var R="";jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:Q,success:function(S){R=S},async:false});return R}function f(R){if(!jQuery("#tos").is(":checked")){R.preventDefault();jQuery("#tos-robo").fadeIn(400,function(){jQuery("#tos-hand").fadeIn()});jQuery("#tos").click(function(){jQuery("#tos-robo").css("display","none");jQuery("#tos-hand").css("display","none")});return}jQuery("#request_key").addClass("disabled");jQuery("#pluginemail_spinner").addClass("is-active");ShortPixel.updateSignupEmail();if(ShortPixel.isEmailValid(jQuery("#pluginemail").val())){jQuery("#pluginemail-error").css("display","none");var Q={action:"shortpixel_new_api_key",email:jQuery("#pluginemail").val()};jQuery.ajax({type:"POST",async:false,url:ShortPixel.AJAX_URL,data:Q,success:function(S){data=JSON.parse(S);if(data.Status=="success"){R.preventDefault();window.location.reload()}else{if(data.Status=="invalid"){jQuery("#pluginemail-error").html("<b>"+data.Details+"</b>");jQuery("#pluginemail-error").css("display","");jQuery("#pluginemail-info").css("display","none");R.preventDefault()}else{}}}});jQuery("#request_key").removeAttr("onclick")}else{jQuery("#pluginemail-error").css("display","");jQuery("#pluginemail-info").css("display","none");R.preventDefault()}jQuery("#request_key").removeClass("disabled");jQuery("#pluginemail_spinner").removeClass("is-active")}function N(){jQuery("#shortPixelProposeUpgrade .sp-modal-body").addClass("sptw-modal-spinner");jQuery("#shortPixelProposeUpgrade .sp-modal-body").html("");jQuery("#shortPixelProposeUpgradeShade").css("display","block");jQuery("#shortPixelProposeUpgrade").removeClass("shortpixel-hide");var Q={action:"shortpixel_propose_upgrade"};jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:Q,success:function(R){jQuery("#shortPixelProposeUpgrade .sp-modal-body").removeClass("sptw-modal-spinner");jQuery("#shortPixelProposeUpgrade .sp-modal-body").html(R)}})}function G(){jQuery("#shortPixelProposeUpgradeShade").css("display","none");jQuery("#shortPixelProposeUpgrade").addClass("shortpixel-hide");if(ShortPixel.toRefresh){ShortPixel.recheckQuota()}}function v(){jQuery("#short-pixel-notice-unlisted").hide();jQuery("#optimizeUnlisted").prop("checked",true);var Q={action:"shortpixel_dismiss_notice",notice_id:"unlisted",notice_data:"true"};jQuery.get(ShortPixel.AJAX_URL,Q,function(R){Q=JSON.parse(R);if(Q.Status==ShortPixel.STATUS_SUCCESS){console.log("dismissed")}})}function o(){jQuery(".select-folder-button").click(function(){jQuery(".sp-folder-picker-shade").css("display","block");jQuery(".sp-folder-picker").fileTree({script:ShortPixel.browseContent,multiFolder:false})});jQuery(".shortpixel-modal input.select-folder-cancel").click(function(){jQuery(".sp-folder-picker-shade").css("display","none")});jQuery(".shortpixel-modal input.select-folder").click(function(){var Q=jQuery("UL.jqueryFileTree LI.directory.selected A").attr("rel").trim();if(Q){var R=jQuery("#customFolderBase").val()+Q;if(R.slice(-1)=="/"){R=R.slice(0,-1)}jQuery("#addCustomFolder").val(R);jQuery("#addCustomFolderView").val(R);jQuery(".sp-folder-picker-shade").css("display","none")}else{alert("Please select a folder from the list.")}})}function F(U,T,S){var R=jQuery(".bulk-notice-msg.bulk-lengthy");if(R.length==0){return}var Q=jQuery("a",R);Q.text(T);if(S){Q.attr("href",S)}else{Q.attr("href",Q.data("href").replace("__ID__",U))}R.css("display","block")}function A(){jQuery(".bulk-notice-msg.bulk-lengthy").css("display","none")}function w(Q){var R=jQuery(".bulk-notice-msg.bulk-"+Q);if(R.length==0){return}R.css("display","block")}function O(Q){jQuery(".bulk-notice-msg.bulk-"+Q).css("display","none")}function s(W,U,V,T){var Q=jQuery("#bulk-error-template");if(Q.length==0){return}var S=Q.clone();S.attr("id","bulk-error-"+W);if(W==-1){jQuery("span.sp-err-title",S).remove();S.addClass("bulk-error-fatal")}else{jQuery("img",S).remove();jQuery("#bulk-error-".id).remove()}jQuery("span.sp-err-content",S).html(U);var R=jQuery("a.sp-post-link",S);if(T){R.attr("href",T)}else{R.attr("href",R.attr("href").replace("__ID__",W))}R.text(V);Q.after(S);S.css("display","block")}function D(Q,R){if(!confirm(_spTr["confirmBulk"+Q])){R.stopPropagation();R.preventDefault();return false}return true}function r(Q){jQuery(Q).parent().parent().remove()}function H(Q){return Q.substring(0,2)=="C-"}function J(){window.location.href=window.location.href+(window.location.href.indexOf("?")>0?"&":"?")+"checkquota=1"}function h(R){R.preventDefault();if(!this.menuCloseEvent){jQuery(window).click(function(S){if(!S.target.matches(".sp-dropbtn")){jQuery(".sp-dropdown.sp-show").removeClass("sp-show")}});this.menuCloseEvent=true}var Q=R.target.parentElement.classList.contains("sp-show");jQuery(".sp-dropdown.sp-show").removeClass("sp-show");if(!Q){R.target.parentElement.classList.add("sp-show")}}function P(Q){this.comparerData.origUrl=false;if(this.comparerData.cssLoaded===false){jQuery("<link>").appendTo("head").attr({type:"text/css",rel:"stylesheet",href:this.WP_PLUGIN_URL+"/res/css/twentytwenty.min.css"});this.comparerData.cssLoaded=2}if(this.comparerData.jsLoaded===false){jQuery.getScript(this.WP_PLUGIN_URL+"/res/js/jquery.twentytwenty.min.js",function(){ShortPixel.comparerData.jsLoaded=2;if(ShortPixel.comparerData.origUrl.length>0){ShortPixel.displayComparerPopup(ShortPixel.comparerData.width,ShortPixel.comparerData.height,ShortPixel.comparerData.origUrl,ShortPixel.comparerData.optUrl)}});this.comparerData.jsLoaded=1;jQuery(".sp-close-button").click(ShortPixel.closeComparerPopup)}if(this.comparerData.origUrl===false){jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:{action:"shortpixel_get_comparer_data",id:Q},success:function(R){data=JSON.parse(R);jQuery.extend(ShortPixel.comparerData,data);if(ShortPixel.comparerData.jsLoaded==2){ShortPixel.displayComparerPopup(ShortPixel.comparerData.width,ShortPixel.comparerData.height,ShortPixel.comparerData.origUrl,ShortPixel.comparerData.optUrl)}}});this.comparerData.origUrl=""}}function E(U,S,R,T){var X=U;var W=(S<150||U<350);var V=jQuery(W?"#spUploadCompareSideBySide":"#spUploadCompare");if(!W){jQuery("#spCompareSlider").html('<img class="spUploadCompareOriginal"/><img class="spUploadCompareOptimized"/>')}U=Math.max(350,Math.min(800,(U<350?(U+25)*2:(S<150?U+25:U))));S=Math.max(150,(W?(X>350?2*(S+45):S+45):S*U/X));jQuery(".sp-modal-body",V).css("width",U);jQuery(".shortpixel-slider",V).css("width",U);V.css("width",U);jQuery(".sp-modal-body",V).css("height",S);V.css("display","block");V.parent().css("display","block");if(!W){jQuery("#spCompareSlider").twentytwenty({slider_move:"mousemove"})}jQuery(document).on("keyup.sp_modal_active",ShortPixel.closeComparerPopup);var Q=jQuery(".spUploadCompareOptimized",V);jQuery(".spUploadCompareOriginal",V).attr("src",R);setTimeout(function(){jQuery(window).trigger("resize")},1000);Q.load(function(){jQuery(window).trigger("resize")});Q.attr("src",T)}function q(Q){jQuery("#spUploadCompareSideBySide").parent().css("display","none");jQuery("#spUploadCompareSideBySide").css("display","none");jQuery("#spUploadCompare").css("display","none");jQuery(document).unbind("keyup.sp_modal_active")}function z(Q){var R=document.createElement("a");R.href=Q;if(Q.indexOf(R.protocol+"//"+R.hostname)<0){return R.href}return Q.replace(R.protocol+"//"+R.hostname,R.protocol+"//"+R.hostname.split(".").map(function(S){return sp_punycode.toASCII(S)}).join("."))}return{init:I,setOptions:m,isEmailValid:t,updateSignupEmail:n,validateKey:a,enableResize:L,setupGeneralTab:e,apiKeyChanged:C,setupAdvancedTab:u,checkThumbsUpdTotal:K,initSettings:g,switchSettingsTab:x,adjustSettingsTabs:y,onBulkThumbsCheck:B,dismissMediaAlert:M,checkQuota:k,percentDial:p,successMsg:b,successActions:c,otherMediaUpdateActions:i,retry:j,initFolderSelector:o,browseContent:l,getBackupSize:d,newApiKey:f,proposeUpgrade:N,closeProposeUpgrade:G,includeUnlisted:v,bulkShowLengthyMsg:F,bulkHideLengthyMsg:A,bulkShowMaintenanceMsg:w,bulkHideMaintenanceMsg:O,bulkShowError:s,confirmBulkAction:D,removeBulkMsg:r,isCustomImageId:H,recheckQuota:J,openImageMenu:h,menuCloseEvent:false,loadComparer:P,displayComparerPopup:E,closeComparerPopup:q,convertPunycode:z,comparerData:{cssLoaded:false,jsLoaded:false,origUrl:false,optUrl:false,width:0,height:0},toRefresh:false,resizeSizesAlert:false}}();function showToolBarAlert(c,b,d){var a=jQuery("li.shortpixel-toolbar-processing");switch(c){case ShortPixel.STATUS_QUOTA_EXCEEDED:if(window.location.href.search("wp-short-pixel-bulk")>0&&jQuery(".sp-quota-exceeded-alert").length==0){location.reload();return}a.addClass("shortpixel-alert");a.addClass("shortpixel-quota-exceeded");jQuery("a",a).attr("href","options-general.php?page=wp-shortpixel");jQuery("a div",a).attr("title","ShortPixel quota exceeded. Click for details.");break;case ShortPixel.STATUS_SKIP:case ShortPixel.STATUS_FAIL:a.addClass("shortpixel-alert shortpixel-processing");jQuery("a div",a).attr("title",b);if(typeof d!=="undefined"){jQuery("a",a).attr("href","post.php?post="+d+"&action=edit")}break;case ShortPixel.STATUS_NO_KEY:a.addClass("shortpixel-alert");a.addClass("shortpixel-quota-exceeded");jQuery("a",a).attr("href","options-general.php?page=wp-shortpixel");jQuery("a div",a).attr("title","Get API Key");break;case ShortPixel.STATUS_SUCCESS:case ShortPixel.STATUS_RETRY:a.addClass("shortpixel-processing");a.removeClass("shortpixel-alert");jQuery("a",a).removeAttr("target");jQuery("a",a).attr("href",jQuery("a img",a).attr("success-url"))}a.removeClass("shortpixel-hide")}function hideToolBarAlert(){jQuery("li.shortpixel-toolbar-processing.shortpixel-processing").addClass("shortpixel-hide")}function hideQuotaExceededToolBarAlert(){jQuery("li.shortpixel-toolbar-processing.shortpixel-quota-exceeded").addClass("shortpixel-hide")}function checkQuotaExceededAlert(){if(typeof shortPixelQuotaExceeded!="undefined"){if(shortPixelQuotaExceeded==1){showToolBarAlert(ShortPixel.STATUS_QUOTA_EXCEEDED)}else{hideQuotaExceededToolBarAlert()}}}function checkBulkProgress(){var b=function(e){if(!d){d=true;return e}return"/"};var d=false;var a=window.location.href.toLowerCase().replace(/\/\//g,b);d=false;var c=ShortPixel.WP_ADMIN_URL.toLowerCase().replace(/\/\//g,b);if(a.search(c)<0){a=ShortPixel.convertPunycode(a);c=ShortPixel.convertPunycode(c)}if(a.search(c+"upload.php")<0&&a.search(c+"edit.php")<0&&a.search(c+"edit-tags.php")<0&&a.search(c+"post-new.php")<0&&a.search(c+"post.php")<0&&a.search("page=nggallery-manage-gallery")<0&&(ShortPixel.FRONT_BOOTSTRAP==0||a.search(c)==0)){hideToolBarAlert();return}if(ShortPixel.bulkProcessor==true&&window.location.href.search("wp-short-pixel-bulk")<0&&typeof localStorage.bulkPage!=="undefined"&&localStorage.bulkPage>0){ShortPixel.bulkProcessor=false}if(window.location.href.search("wp-short-pixel-bulk")>=0){ShortPixel.bulkProcessor=true;localStorage.bulkTime=Math.floor(Date.now()/1000);localStorage.bulkPage=1}if(ShortPixel.bulkProcessor==true||typeof localStorage.bulkTime=="undefined"||Math.floor(Date.now()/1000)-localStorage.bulkTime>90){ShortPixel.bulkProcessor=true;localStorage.bulkPage=(window.location.href.search("wp-short-pixel-bulk")>=0?1:0);localStorage.bulkTime=Math.floor(Date.now()/1000);console.log(localStorage.bulkTime);checkBulkProcessingCallApi()}else{setTimeout(checkBulkProgress,5000)}}function checkBulkProcessingCallApi(){var a={action:"shortpixel_image_processing"};jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:a,success:function(g){if(g.length>0){var i=null;try{var i=JSON.parse(g)}catch(k){ShortPixel.retry(k.message);return}ShortPixel.retries=0;var d=i.ImageID;var j=(jQuery("div.short-pixel-bulk-page").length>0);switch(i.Status){case ShortPixel.STATUS_NO_KEY:setCellMessage(d,i.Message,"<a class='button button-smaller button-primary' href=\"https://shortpixel.com/wp-apikey"+ShortPixel.AFFILIATE+'" target="_blank">'+_spTr.getApiKey+"</a>");showToolBarAlert(ShortPixel.STATUS_NO_KEY);break;case ShortPixel.STATUS_QUOTA_EXCEEDED:setCellMessage(d,i.Message,"<a class='button button-smaller button-primary' href=\"https://shortpixel.com/login/"+ShortPixel.API_KEY+'" target="_blank">'+_spTr.extendQuota+"</a><a class='button button-smaller' href='admin.php?action=shortpixel_check_quota'>"+_spTr.check__Quota+"</a>");showToolBarAlert(ShortPixel.STATUS_QUOTA_EXCEEDED);if(i.Stop==false){setTimeout(checkBulkProgress,5000)}ShortPixel.otherMediaUpdateActions(d,["quota","view"]);break;case ShortPixel.STATUS_FAIL:setCellMessage(d,i.Message,"<a class='button button-smaller button-primary' href=\"javascript:manualOptimization('"+d+"', false)\">"+_spTr.retry+"</a>");showToolBarAlert(ShortPixel.STATUS_FAIL,i.Message,d);if(j){ShortPixel.bulkShowError(d,i.Message,i.Filename,i.CustomImageLink);if(i.BulkPercent){progressUpdate(i.BulkPercent,i.BulkMsg)}ShortPixel.otherMediaUpdateActions(d,["retry","view"])}console.log(i.Message);setTimeout(checkBulkProgress,5000);break;case ShortPixel.STATUS_EMPTY_QUEUE:console.log(i.Message);clearBulkProcessor();hideToolBarAlert();var c=jQuery("#bulk-progress");if(j&&c.length&&i.BulkStatus!="2"){progressUpdate(100,"Bulk finished!");jQuery("a.bulk-cancel").attr("disabled","disabled");hideSlider();setTimeout(function(){window.location.reload()},3000)}break;case ShortPixel.STATUS_SUCCESS:if(j){ShortPixel.bulkHideLengthyMsg();ShortPixel.bulkHideMaintenanceMsg()}var l=i.PercentImprovement;showToolBarAlert(ShortPixel.STATUS_SUCCESS,"");var b=ShortPixel.isCustomImageId(d)?"":ShortPixel.successActions(d,i.Type,i.ThumbsCount,i.ThumbsTotal,i.BackupEnabled,i.Filename);setCellMessage(d,ShortPixel.successMsg(d,l,i.Type,i.ThumbsCount,i.RetinasCount),b);var h=jQuery(["restore","view","redolossy","redoglossy","redolossless"]).not(["redo"+i.Type]).get();ShortPixel.otherMediaUpdateActions(d,h);var f=new PercentageAnimator("#sp-msg-"+d+" span.percent",l);f.animate(l);if(j&&typeof i.Thumb!=="undefined"){if(i.BulkPercent){progressUpdate(i.BulkPercent,i.BulkMsg)}if(i.Thumb.length>0){sliderUpdate(d,i.Thumb,i.BkThumb,i.PercentImprovement,i.Filename);if(typeof i.AverageCompression!=="undefined"&&0+i.AverageCompression>0){jQuery("#sp-avg-optimization").html('<input type="text" class="dial" value="'+Math.round(i.AverageCompression)+'"/>');ShortPixel.percentDial("#sp-avg-optimization .dial",60)}}}console.log("Server response: "+g);if(j&&typeof i.BulkPercent!=="undefined"){progressUpdate(i.BulkPercent,i.BulkMsg)}setTimeout(checkBulkProgress,5000);break;case ShortPixel.STATUS_SKIP:if(i.Silent!==1){ShortPixel.bulkShowError(d,i.Message,i.Filename,i.CustomImageLink)}case ShortPixel.STATUS_ERROR:if(typeof i.Message!=="undefined"){showToolBarAlert(ShortPixel.STATUS_SKIP,i.Message+" Image ID: "+d);setCellMessage(d,i.Message,"")}ShortPixel.otherMediaUpdateActions(d,["retry","view"]);case ShortPixel.STATUS_RETRY:console.log("Server response: "+g);showToolBarAlert(ShortPixel.STATUS_RETRY,"");if(j&&typeof i.BulkPercent!=="undefined"){progressUpdate(i.BulkPercent,i.BulkMsg)}if(j&&i.Count>3){ShortPixel.bulkShowLengthyMsg(d,i.Filename,i.CustomImageLink)}setTimeout(checkBulkProgress,5000);break;case ShortPixel.STATUS_MAINTENANCE:ShortPixel.bulkShowMaintenanceMsg("maintenance");setTimeout(checkBulkProgress,60000);break;case ShortPixel.STATUS_QUEUE_FULL:ShortPixel.bulkShowMaintenanceMsg("queue-full");setTimeout(checkBulkProgress,60000);break;default:ShortPixel.retry("Unknown status "+i.Status+". Retrying...");break}}},error:function(b){ShortPixel.retry(b.statusText)}})}function clearBulkProcessor(){ShortPixel.bulkProcessor=false;localStorage.bulkTime=0;if(window.location.href.search("wp-short-pixel-bulk")>=0){localStorage.bulkPage=0}}function setCellMessage(d,a,c){var b=jQuery("#sp-msg-"+d);if(b.length>0){b.html("<div class='sp-column-actions'>"+c+"</div><div class='sp-column-info'>"+a+"</div>");b.css("color","")}b=jQuery("#sp-cust-msg-"+d);if(b.length>0){b.html("<div class='sp-column-info'>"+a+"</div>")}}function manualOptimization(c,a){setCellMessage(c,"<img src='"+ShortPixel.WP_PLUGIN_URL+"/res/img/loading.gif' class='sp-loading-small'>Image waiting to be processed","");jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-alert");jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");var b={action:"shortpixel_manual_optimization",image_id:c,cleanup:a};jQuery.ajax({type:"GET",url:ShortPixel.AJAX_URL,data:b,success:function(d){var e=JSON.parse(d);if(e.Status==ShortPixel.STATUS_SUCCESS){setTimeout(checkBulkProgress,2000)}else{setCellMessage(c,typeof e.Message!=="undefined"?e.Message:_spTr.thisContentNotProcessable,"")}},error:function(d){b.action="shortpixel_check_status";jQuery.ajax({type:"GET",url:ShortPixel.AJAX_URL,data:b,success:function(e){var f=JSON.parse(e);if(f.Status!==ShortPixel.STATUS_SUCCESS){setCellMessage(c,typeof f.Message!=="undefined"?f.Message:_spTr.thisContentNotProcessable,"")}}})}})}function reoptimize(c,a){setCellMessage(c,"<img src='"+ShortPixel.WP_PLUGIN_URL+"/res/img/loading.gif' class='sp-loading-small'>Image waiting to be reprocessed","");jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");var b={action:"shortpixel_redo",attachment_ID:c,type:a};jQuery.get(ShortPixel.AJAX_URL,b,function(d){b=JSON.parse(d);if(b.Status==ShortPixel.STATUS_SUCCESS){setTimeout(checkBulkProgress,2000)}else{$msg=typeof b.Message!=="undefined"?b.Message:_spTr.thisContentNotProcessable;setCellMessage(c,$msg,"");showToolBarAlert(ShortPixel.STATUS_FAIL,$msg)}})}function optimizeThumbs(b){setCellMessage(b,"<img src='"+ShortPixel.WP_PLUGIN_URL+"/res/img/loading.gif' class='sp-loading-small'>"+_spTr.imageWaitOptThumbs,"");jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");var a={action:"shortpixel_optimize_thumbs",attachment_ID:b};jQuery.get(ShortPixel.AJAX_URL,a,function(c){a=JSON.parse(c);if(a.Status==ShortPixel.STATUS_SUCCESS){setTimeout(checkBulkProgress,2000)}else{setCellMessage(b,typeof a.Message!=="undefined"?a.Message:_spTr.thisContentNotProcessable,"")}})}function dismissShortPixelNoticeExceed(b){jQuery("#wp-admin-bar-shortpixel_processing").hide();var a={action:"shortpixel_dismiss_notice",notice_id:"exceed"};jQuery.get(ShortPixel.AJAX_URL,a,function(c){a=JSON.parse(c);if(a.Status==ShortPixel.STATUS_SUCCESS){console.log("dismissed")}});b.preventDefault()}function dismissShortPixelNotice(b){jQuery("#short-pixel-notice-"+b).hide();var a={action:"shortpixel_dismiss_notice",notice_id:b};jQuery.get(ShortPixel.AJAX_URL,a,function(c){a=JSON.parse(c);if(a.Status==ShortPixel.STATUS_SUCCESS){console.log("dismissed")}})}function PercentageAnimator(b,a){this.animationSpeed=10;this.increment=2;this.curPercentage=0;this.targetPercentage=a;this.outputSelector=b;this.animate=function(c){this.targetPercentage=c;setTimeout(PercentageTimer.bind(null,this),this.animationSpeed)}}function PercentageTimer(a){if(a.curPercentage-a.targetPercentage<-a.increment){a.curPercentage+=a.increment}else{if(a.curPercentage-a.targetPercentage>a.increment){a.curPercentage-=a.increment}else{a.curPercentage=a.targetPercentage}}jQuery(a.outputSelector).text(a.curPercentage+"%");if(a.curPercentage!=a.targetPercentage){setTimeout(PercentageTimer.bind(null,a),a.animationSpeed)}}function progressUpdate(c,b){var a=jQuery("#bulk-progress");if(a.length){jQuery(".progress-left",a).css("width",c+"%");jQuery(".progress-img",a).css("left",c+"%");if(c>24){jQuery(".progress-img span",a).html("");jQuery(".progress-left",a).html(c+"%")}else{jQuery(".progress-img span",a).html(c+"%");jQuery(".progress-left",a).html("")}jQuery(".bulk-estimate").html(b)}}function sliderUpdate(g,c,d,e,b){var f=jQuery(".bulk-slider div.bulk-slide:first-child");if(f.length===0){return}if(f.attr("id")!="empty-slide"){f.hide()}f.css("z-index",1000);jQuery(".bulk-img-opt",f).attr("src","");if(typeof d==="undefined"){d=""}if(d.length>0){jQuery(".bulk-img-orig",f).attr("src","")}var a=f.clone();a.attr("id","slide-"+g);jQuery(".bulk-img-opt",a).attr("src",c);if(d.length>0){jQuery(".img-original",a).css("display","inline-block");jQuery(".bulk-img-orig",a).attr("src",d)}else{jQuery(".img-original",a).css("display","none")}jQuery(".bulk-opt-percent",a).html('<input type="text" class="dial" value="'+e+'"/>');jQuery(".bulk-slider").append(a);ShortPixel.percentDial("#"+a.attr("id")+" .dial",100);jQuery(".bulk-slider-container span.filename").html(" "+b);if(f.attr("id")=="empty-slide"){f.remove();jQuery(".bulk-slider-container").css("display","block")}else{f.animate({left:f.width()+f.position().left},"slow","swing",function(){f.remove();a.fadeIn("slow")})}}function hideSlider(){jQuery(".bulk-slider-container").css("display","none")}function showStats(){var a=jQuery(".bulk-stats");if(a.length>0){}}if(!(typeof String.prototype.format=="function")){String.prototype.format=function(){var b=this,a=arguments.length;while(a--){b=b.replace(new RegExp("\\{"+a+"\\}","gm"),arguments[a])}return b}};
|
1 |
+
jQuery(document).ready(function(){ShortPixel.init()});var ShortPixel=function(){function I(){if(typeof ShortPixel.API_KEY!=="undefined"){return}if(jQuery("table.wp-list-table.media").length>0){jQuery('select[name^="action"] option:last-child').before('<option value="short-pixel-bulk">'+_spTr.optimizeWithSP+'</option><option value="short-pixel-bulk-lossy"> → '+_spTr.redoLossy+'</option><option value="short-pixel-bulk-glossy"> → '+_spTr.redoGlossy+'</option><option value="short-pixel-bulk-lossless"> → '+_spTr.redoLossless+'</option><option value="short-pixel-bulk-restore"> → '+_spTr.restoreOriginal+"</option>")}ShortPixel.setOptions(ShortPixelConstants[0]);if(jQuery("#backup-folder-size").length){jQuery("#backup-folder-size").html(ShortPixel.getBackupSize())}if(ShortPixel.MEDIA_ALERT=="todo"&&jQuery("div.media-frame.mode-grid").length>0){jQuery("div.media-frame.mode-grid").before('<div id="short-pixel-media-alert" class="notice notice-warning"><p>'+_spTr.changeMLToListMode.format('<a href="upload.php?mode=list" class="view-list"><span class="screen-reader-text">'," </span>",'</a><a class="alignright" href="javascript:ShortPixel.dismissMediaAlert();">',"</a>")+"</p></div>")}jQuery(window).on("beforeunload",function(){if(ShortPixel.bulkProcessor==true){clearBulkProcessor()}});checkQuotaExceededAlert();checkBulkProgress()}function m(Q){for(var R in Q){ShortPixel[R]=Q[R]}}function t(Q){return/^\w+([\.+-]?\w+)*@\w+([\.-]?\w+)*(\.\w{1,63})+$/.test(Q)}function n(){var Q=jQuery("#pluginemail").val();if(ShortPixel.isEmailValid(Q)){jQuery("#request_key").removeClass("disabled")}jQuery("#request_key").attr("href",jQuery("#request_key").attr("href").split("?")[0]+"?pluginemail="+Q)}function a(){jQuery("#valid").val("validate");jQuery("#wp_shortpixel_options").submit()}jQuery("#key").keypress(function(Q){if(Q.which==13){jQuery("#valid").val("validate")}});function L(Q){if(jQuery(Q).is(":checked")){jQuery("#width,#height").removeAttr("disabled")}else{jQuery("#width,#height").attr("disabled","disabled")}}function e(Q,S,U){for(var R=0,T=null;R<Q.length;R++){Q[R].onclick=function(){if(this!==T){T=this}if(typeof ShortPixel.setupGeneralTabAlert!=="undefined"){return}alert(_spTr.alertOnlyAppliesToNewImages);ShortPixel.setupGeneralTabAlert=1}}ShortPixel.enableResize("#resize");jQuery("#resize").change(function(){L(this)});jQuery(".resize-sizes").blur(function(W){var X=jQuery(this);if(ShortPixel.resizeSizesAlert==X.val()){return}ShortPixel.resizeSizesAlert=X.val();var V=jQuery("#min-"+X.attr("name")).val();if(X.val()<Math.min(V,1024)){if(V>1024){alert(_spTr.pleaseDoNotSetLesser1024.format(X.attr("name")))}else{alert(_spTr.pleaseDoNotSetLesserSize.format(X.attr("name"),X.attr("name"),V))}W.preventDefault();X.focus()}else{this.defaultValue=X.val()}});jQuery(".shortpixel-confirm").click(function(W){var V=confirm(W.target.getAttribute("data-confirm"));if(!V){W.preventDefault();return false}return true})}function C(){jQuery(".wp-shortpixel-options .shortpixel-key-valid").css("display","none");jQuery(".wp-shortpixel-options button#validate").css("display","inline-block")}function u(){jQuery("input.remove-folder-button").click(function(){var R=jQuery(this).data("value");var Q=confirm(_spTr.areYouSureStopOptimizing.format(R));if(Q==true){jQuery("#removeFolder").val(R);jQuery("#wp_shortpixel_options").submit()}});jQuery("input.recheck-folder-button").click(function(){var R=jQuery(this).data("value");var Q=confirm(_spTr.areYouSureStopOptimizing.format(R));if(Q==true){jQuery("#recheckFolder").val(R);jQuery("#wp_shortpixel_options").submit()}})}function K(Q){var R=jQuery("#"+(Q.checked?"total":"main")+"ToProcess").val();jQuery("div.bulk-play span.total").text(R);jQuery("#displayTotal").text(R)}function g(){ShortPixel.adjustSettingsTabs();jQuery(window).resize(function(){ShortPixel.adjustSettingsTabs()});if(window.location.hash){var Q=("tab-"+window.location.hash.substring(window.location.hash.indexOf("#")+1)).replace(/\//,"");if(jQuery("section#"+Q).length){ShortPixel.switchSettingsTab(Q)}}jQuery("article.sp-tabs a.tab-link").click(function(){var R=jQuery(this).data("id");ShortPixel.switchSettingsTab(R)});jQuery("input[type=radio][name=deliverWebpType]").change(function(){if(this.value=="deliverWebpAltered"){if(window.confirm(_spTr.alertDeliverWebPAltered)){var R=jQuery("input[type=radio][name=deliverWebpAlteringType]:checked").length;if(R==0){jQuery("#deliverWebpAlteredWP").prop("checked",true)}}else{jQuery(this).prop("checked",false)}}else{if(this.value=="deliverWebpUnaltered"){window.alert(_spTr.alertDeliverWebPUnaltered)}}})}function x(U){var S=U.replace("tab-",""),Q="",T=jQuery("section#"+U),R=location.href.replace(location.hash,"")+"#"+S;if(history.pushState){history.pushState(null,null,R)}else{location.hash=R}if(T.length>0){jQuery("section").removeClass("sel-tab");jQuery("section#"+U).addClass("sel-tab")}if(typeof HS.beacon.suggest!=="undefined"){switch(S){case"settings":Q=shortpixel_suggestions_settings;break;case"adv-settings":Q=shortpixel_suggestions_adv_settings;break;case"cloudflare":case"stats":Q=shortpixel_suggestions_cloudflare;break;default:break}HS.beacon.suggest(Q)}}function y(){var Q=jQuery("section#tab-settings .wp-shortpixel-options").height()+90;Q=Math.max(Q,jQuery("section#tab-adv-settings .wp-shortpixel-options").height()+20);Q=Math.max(Q,jQuery("section#tab-resources .area1").height()+60);jQuery("#shortpixel-settings-tabs").css("height",Q)}function M(){var Q={action:"shortpixel_dismiss_media_alert"};jQuery.get(ShortPixel.AJAX_URL,Q,function(R){Q=JSON.parse(R);if(Q.Status=="success"){jQuery("#short-pixel-media-alert").hide();console.log("dismissed")}})}function k(){var Q={action:"shortpixel_check_quota"};jQuery.get(ShortPixel.AJAX_URL,Q,function(){console.log("quota refreshed")})}function B(Q){if(Q.checked){jQuery("#with-thumbs").css("display","inherit");jQuery("#without-thumbs").css("display","none")}else{jQuery("#without-thumbs").css("display","inherit");jQuery("#with-thumbs").css("display","none")}}function b(U,S,R,T,Q){return(S>0?"<div class='sp-column-info'>"+_spTr.reducedBy+" <strong><span class='percent'>"+S+"%</span></strong> ":"")+(S>0&&S<5?"<br>":"")+(S<5?_spTr.bonusProcessing:"")+(R.length>0?" ("+R+")":"")+(0+T>0?"<br>"+_spTr.plusXthumbsOpt.format(T):"")+(0+Q>0?"<br>"+_spTr.plusXretinasOpt.format(Q):"")+"</div>"}function p(R,Q){jQuery(R).knob({readOnly:true,width:Q,height:Q,fgColor:"#1CAECB",format:function(S){return S+"%"}})}function c(X,S,V,U,R,W){if(R==1){var T=jQuery(".sp-column-actions-template").clone();if(!T.length){return false}var Q;if(S.length==0){Q=["lossy","lossless"]}else{Q=["lossy","glossy","lossless"].filter(function(Y){return !(Y==S)})}T.html(T.html().replace(/__SP_ID__/g,X));if(W.substr(W.lastIndexOf(".")+1).toLowerCase()=="pdf"){jQuery(".sp-action-compare",T).remove()}if(V==0&&U>0){T.html(T.html().replace("__SP_THUMBS_TOTAL__",U))}else{jQuery(".sp-action-optimize-thumbs",T).remove();jQuery(".sp-dropbtn",T).removeClass("button-primary")}T.html(T.html().replace(/__SP_FIRST_TYPE__/g,Q[0]));T.html(T.html().replace(/__SP_SECOND_TYPE__/g,Q[1]));return T.html()}return""}function i(U,T){U=U.substring(2);if(jQuery(".shortpixel-other-media").length){var S=["optimize","retry","restore","redo","quota","view"];for(var R=0,Q=S.length;R<Q;R++){jQuery("#"+S[R]+"_"+U).css("display","none")}for(var R=0,Q=T.length;R<Q;R++){jQuery("#"+T[R]+"_"+U).css("display","")}}}function j(Q){ShortPixel.retries++;if(isNaN(ShortPixel.retries)){ShortPixel.retries=1}if(ShortPixel.retries<6){console.log("Invalid response from server (Error: "+Q+"). Retrying pass "+(ShortPixel.retries+1)+"...");setTimeout(checkBulkProgress,5000)}else{ShortPixel.bulkShowError(-1,"Invalid response from server received 6 times. Please retry later by reloading this page, or <a href='https://shortpixel.com/contact' target='_blank'>contact support</a>. (Error: "+Q+")","");console.log("Invalid response from server 6 times. Giving up.")}}function l(Q){Q.action="shortpixel_browse_content";var R="";jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:Q,success:function(S){R=S},async:false});return R}function d(){var Q={action:"shortpixel_get_backup_size"};var R="";jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:Q,success:function(S){R=S},async:false});return R}function f(R){if(!jQuery("#tos").is(":checked")){R.preventDefault();jQuery("#tos-robo").fadeIn(400,function(){jQuery("#tos-hand").fadeIn()});jQuery("#tos").click(function(){jQuery("#tos-robo").css("display","none");jQuery("#tos-hand").css("display","none")});return}jQuery("#request_key").addClass("disabled");jQuery("#pluginemail_spinner").addClass("is-active");ShortPixel.updateSignupEmail();if(ShortPixel.isEmailValid(jQuery("#pluginemail").val())){jQuery("#pluginemail-error").css("display","none");var Q={action:"shortpixel_new_api_key",email:jQuery("#pluginemail").val()};jQuery.ajax({type:"POST",async:false,url:ShortPixel.AJAX_URL,data:Q,success:function(S){data=JSON.parse(S);if(data.Status=="success"){R.preventDefault();window.location.reload()}else{if(data.Status=="invalid"){jQuery("#pluginemail-error").html("<b>"+data.Details+"</b>");jQuery("#pluginemail-error").css("display","");jQuery("#pluginemail-info").css("display","none");R.preventDefault()}else{}}}});jQuery("#request_key").removeAttr("onclick")}else{jQuery("#pluginemail-error").css("display","");jQuery("#pluginemail-info").css("display","none");R.preventDefault()}jQuery("#request_key").removeClass("disabled");jQuery("#pluginemail_spinner").removeClass("is-active")}function N(){jQuery("#shortPixelProposeUpgrade .sp-modal-body").addClass("sptw-modal-spinner");jQuery("#shortPixelProposeUpgrade .sp-modal-body").html("");jQuery("#shortPixelProposeUpgradeShade").css("display","block");jQuery("#shortPixelProposeUpgrade").removeClass("shortpixel-hide");var Q={action:"shortpixel_propose_upgrade"};jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:Q,success:function(R){jQuery("#shortPixelProposeUpgrade .sp-modal-body").removeClass("sptw-modal-spinner");jQuery("#shortPixelProposeUpgrade .sp-modal-body").html(R)}})}function G(){jQuery("#shortPixelProposeUpgradeShade").css("display","none");jQuery("#shortPixelProposeUpgrade").addClass("shortpixel-hide");if(ShortPixel.toRefresh){ShortPixel.recheckQuota()}}function v(){jQuery("#short-pixel-notice-unlisted").hide();jQuery("#optimizeUnlisted").prop("checked",true);var Q={action:"shortpixel_dismiss_notice",notice_id:"unlisted",notice_data:"true"};jQuery.get(ShortPixel.AJAX_URL,Q,function(R){Q=JSON.parse(R);if(Q.Status==ShortPixel.STATUS_SUCCESS){console.log("dismissed")}})}function o(){jQuery(".select-folder-button").click(function(){jQuery(".sp-folder-picker-shade").css("display","block");jQuery(".sp-folder-picker").fileTree({script:ShortPixel.browseContent,multiFolder:false})});jQuery(".shortpixel-modal input.select-folder-cancel").click(function(){jQuery(".sp-folder-picker-shade").css("display","none")});jQuery(".shortpixel-modal input.select-folder").click(function(){var Q=jQuery("UL.jqueryFileTree LI.directory.selected A").attr("rel").trim();if(Q){var R=jQuery("#customFolderBase").val()+Q;if(R.slice(-1)=="/"){R=R.slice(0,-1)}jQuery("#addCustomFolder").val(R);jQuery("#addCustomFolderView").val(R);jQuery(".sp-folder-picker-shade").css("display","none")}else{alert("Please select a folder from the list.")}})}function F(U,T,S){var R=jQuery(".bulk-notice-msg.bulk-lengthy");if(R.length==0){return}var Q=jQuery("a",R);Q.text(T);if(S){Q.attr("href",S)}else{Q.attr("href",Q.data("href").replace("__ID__",U))}R.css("display","block")}function A(){jQuery(".bulk-notice-msg.bulk-lengthy").css("display","none")}function w(Q){var R=jQuery(".bulk-notice-msg.bulk-"+Q);if(R.length==0){return}R.css("display","block")}function O(Q){jQuery(".bulk-notice-msg.bulk-"+Q).css("display","none")}function s(W,U,V,T){var Q=jQuery("#bulk-error-template");if(Q.length==0){return}var S=Q.clone();S.attr("id","bulk-error-"+W);if(W==-1){jQuery("span.sp-err-title",S).remove();S.addClass("bulk-error-fatal")}else{jQuery("img",S).remove();jQuery("#bulk-error-".id).remove()}jQuery("span.sp-err-content",S).html(U);var R=jQuery("a.sp-post-link",S);if(T){R.attr("href",T)}else{R.attr("href",R.attr("href").replace("__ID__",W))}R.text(V);Q.after(S);S.css("display","block")}function D(Q,R){if(!confirm(_spTr["confirmBulk"+Q])){R.stopPropagation();R.preventDefault();return false}return true}function r(Q){jQuery(Q).parent().parent().remove()}function H(Q){return Q.substring(0,2)=="C-"}function J(){var Q=window.location.href.split("#");window.location.href=Q[0]+(Q[0].indexOf("?")>0?"&":"?")+"checkquota=1"+(typeof Q[1]==="undefined"?"":"#"+Q[1])}function h(R){R.preventDefault();if(!this.menuCloseEvent){jQuery(window).click(function(S){if(!S.target.matches(".sp-dropbtn")){jQuery(".sp-dropdown.sp-show").removeClass("sp-show")}});this.menuCloseEvent=true}var Q=R.target.parentElement.classList.contains("sp-show");jQuery(".sp-dropdown.sp-show").removeClass("sp-show");if(!Q){R.target.parentElement.classList.add("sp-show")}}function P(Q){this.comparerData.origUrl=false;if(this.comparerData.cssLoaded===false){jQuery("<link>").appendTo("head").attr({type:"text/css",rel:"stylesheet",href:this.WP_PLUGIN_URL+"/res/css/twentytwenty.min.css"});this.comparerData.cssLoaded=2}if(this.comparerData.jsLoaded===false){jQuery.getScript(this.WP_PLUGIN_URL+"/res/js/jquery.twentytwenty.min.js",function(){ShortPixel.comparerData.jsLoaded=2;if(ShortPixel.comparerData.origUrl.length>0){ShortPixel.displayComparerPopup(ShortPixel.comparerData.width,ShortPixel.comparerData.height,ShortPixel.comparerData.origUrl,ShortPixel.comparerData.optUrl)}});this.comparerData.jsLoaded=1;jQuery(".sp-close-button").click(ShortPixel.closeComparerPopup)}if(this.comparerData.origUrl===false){jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:{action:"shortpixel_get_comparer_data",id:Q},success:function(R){data=JSON.parse(R);jQuery.extend(ShortPixel.comparerData,data);if(ShortPixel.comparerData.jsLoaded==2){ShortPixel.displayComparerPopup(ShortPixel.comparerData.width,ShortPixel.comparerData.height,ShortPixel.comparerData.origUrl,ShortPixel.comparerData.optUrl)}}});this.comparerData.origUrl=""}}function E(U,S,R,T){var X=U;var W=(S<150||U<350);var V=jQuery(W?"#spUploadCompareSideBySide":"#spUploadCompare");if(!W){jQuery("#spCompareSlider").html('<img class="spUploadCompareOriginal"/><img class="spUploadCompareOptimized"/>')}U=Math.max(350,Math.min(800,(U<350?(U+25)*2:(S<150?U+25:U))));S=Math.max(150,(W?(X>350?2*(S+45):S+45):S*U/X));jQuery(".sp-modal-body",V).css("width",U);jQuery(".shortpixel-slider",V).css("width",U);V.css("width",U);jQuery(".sp-modal-body",V).css("height",S);V.css("display","block");V.parent().css("display","block");if(!W){jQuery("#spCompareSlider").twentytwenty({slider_move:"mousemove"})}jQuery(document).on("keyup.sp_modal_active",ShortPixel.closeComparerPopup);var Q=jQuery(".spUploadCompareOptimized",V);jQuery(".spUploadCompareOriginal",V).attr("src",R);setTimeout(function(){jQuery(window).trigger("resize")},1000);Q.load(function(){jQuery(window).trigger("resize")});Q.attr("src",T)}function q(Q){jQuery("#spUploadCompareSideBySide").parent().css("display","none");jQuery("#spUploadCompareSideBySide").css("display","none");jQuery("#spUploadCompare").css("display","none");jQuery(document).unbind("keyup.sp_modal_active")}function z(Q){var R=document.createElement("a");R.href=Q;if(Q.indexOf(R.protocol+"//"+R.hostname)<0){return R.href}return Q.replace(R.protocol+"//"+R.hostname,R.protocol+"//"+R.hostname.split(".").map(function(S){return sp_punycode.toASCII(S)}).join("."))}return{init:I,setOptions:m,isEmailValid:t,updateSignupEmail:n,validateKey:a,enableResize:L,setupGeneralTab:e,apiKeyChanged:C,setupAdvancedTab:u,checkThumbsUpdTotal:K,initSettings:g,switchSettingsTab:x,adjustSettingsTabs:y,onBulkThumbsCheck:B,dismissMediaAlert:M,checkQuota:k,percentDial:p,successMsg:b,successActions:c,otherMediaUpdateActions:i,retry:j,initFolderSelector:o,browseContent:l,getBackupSize:d,newApiKey:f,proposeUpgrade:N,closeProposeUpgrade:G,includeUnlisted:v,bulkShowLengthyMsg:F,bulkHideLengthyMsg:A,bulkShowMaintenanceMsg:w,bulkHideMaintenanceMsg:O,bulkShowError:s,confirmBulkAction:D,removeBulkMsg:r,isCustomImageId:H,recheckQuota:J,openImageMenu:h,menuCloseEvent:false,loadComparer:P,displayComparerPopup:E,closeComparerPopup:q,convertPunycode:z,comparerData:{cssLoaded:false,jsLoaded:false,origUrl:false,optUrl:false,width:0,height:0},toRefresh:false,resizeSizesAlert:false}}();function showToolBarAlert(c,b,d){var a=jQuery("li.shortpixel-toolbar-processing");switch(c){case ShortPixel.STATUS_QUOTA_EXCEEDED:if(window.location.href.search("wp-short-pixel-bulk")>0&&jQuery(".sp-quota-exceeded-alert").length==0){location.reload();return}a.addClass("shortpixel-alert");a.addClass("shortpixel-quota-exceeded");jQuery("a",a).attr("href","options-general.php?page=wp-shortpixel");jQuery("a div",a).attr("title","ShortPixel quota exceeded. Click for details.");break;case ShortPixel.STATUS_SKIP:case ShortPixel.STATUS_FAIL:a.addClass("shortpixel-alert shortpixel-processing");jQuery("a div",a).attr("title",b);if(typeof d!=="undefined"){jQuery("a",a).attr("href","post.php?post="+d+"&action=edit")}break;case ShortPixel.STATUS_NO_KEY:a.addClass("shortpixel-alert");a.addClass("shortpixel-quota-exceeded");jQuery("a",a).attr("href","options-general.php?page=wp-shortpixel");jQuery("a div",a).attr("title","Get API Key");break;case ShortPixel.STATUS_SUCCESS:case ShortPixel.STATUS_RETRY:a.addClass("shortpixel-processing");a.removeClass("shortpixel-alert");jQuery("a",a).removeAttr("target");jQuery("a",a).attr("href",jQuery("a img",a).attr("success-url"))}a.removeClass("shortpixel-hide")}function hideToolBarAlert(){jQuery("li.shortpixel-toolbar-processing.shortpixel-processing").addClass("shortpixel-hide")}function hideQuotaExceededToolBarAlert(){jQuery("li.shortpixel-toolbar-processing.shortpixel-quota-exceeded").addClass("shortpixel-hide")}function checkQuotaExceededAlert(){if(typeof shortPixelQuotaExceeded!="undefined"){if(shortPixelQuotaExceeded==1){showToolBarAlert(ShortPixel.STATUS_QUOTA_EXCEEDED)}else{hideQuotaExceededToolBarAlert()}}}function checkBulkProgress(){var b=function(e){if(!d){d=true;return e}return"/"};var d=false;var a=window.location.href.toLowerCase().replace(/\/\//g,b);d=false;var c=ShortPixel.WP_ADMIN_URL.toLowerCase().replace(/\/\//g,b);if(a.search(c)<0){a=ShortPixel.convertPunycode(a);c=ShortPixel.convertPunycode(c)}if(a.search(c+"upload.php")<0&&a.search(c+"edit.php")<0&&a.search(c+"edit-tags.php")<0&&a.search(c+"post-new.php")<0&&a.search(c+"post.php")<0&&a.search("page=nggallery-manage-gallery")<0&&(ShortPixel.FRONT_BOOTSTRAP==0||a.search(c)==0)){hideToolBarAlert();return}if(ShortPixel.bulkProcessor==true&&window.location.href.search("wp-short-pixel-bulk")<0&&typeof localStorage.bulkPage!=="undefined"&&localStorage.bulkPage>0){ShortPixel.bulkProcessor=false}if(window.location.href.search("wp-short-pixel-bulk")>=0){ShortPixel.bulkProcessor=true;localStorage.bulkTime=Math.floor(Date.now()/1000);localStorage.bulkPage=1}if(ShortPixel.bulkProcessor==true||typeof localStorage.bulkTime=="undefined"||Math.floor(Date.now()/1000)-localStorage.bulkTime>90){ShortPixel.bulkProcessor=true;localStorage.bulkPage=(window.location.href.search("wp-short-pixel-bulk")>=0?1:0);localStorage.bulkTime=Math.floor(Date.now()/1000);console.log(localStorage.bulkTime);checkBulkProcessingCallApi()}else{setTimeout(checkBulkProgress,5000)}}function checkBulkProcessingCallApi(){var a={action:"shortpixel_image_processing"};jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:a,success:function(g){if(g.length>0){var i=null;try{var i=JSON.parse(g)}catch(k){ShortPixel.retry(k.message);return}ShortPixel.retries=0;var d=i.ImageID;var j=(jQuery("div.short-pixel-bulk-page").length>0);switch(i.Status){case ShortPixel.STATUS_NO_KEY:setCellMessage(d,i.Message,"<a class='button button-smaller button-primary' href=\"https://shortpixel.com/wp-apikey"+ShortPixel.AFFILIATE+'" target="_blank">'+_spTr.getApiKey+"</a>");showToolBarAlert(ShortPixel.STATUS_NO_KEY);break;case ShortPixel.STATUS_QUOTA_EXCEEDED:setCellMessage(d,i.Message,"<a class='button button-smaller button-primary' href=\"https://shortpixel.com/login/"+ShortPixel.API_KEY+'" target="_blank">'+_spTr.extendQuota+"</a><a class='button button-smaller' href='admin.php?action=shortpixel_check_quota'>"+_spTr.check__Quota+"</a>");showToolBarAlert(ShortPixel.STATUS_QUOTA_EXCEEDED);if(i.Stop==false){setTimeout(checkBulkProgress,5000)}ShortPixel.otherMediaUpdateActions(d,["quota","view"]);break;case ShortPixel.STATUS_FAIL:setCellMessage(d,i.Message,"<a class='button button-smaller button-primary' href=\"javascript:manualOptimization('"+d+"', false)\">"+_spTr.retry+"</a>");showToolBarAlert(ShortPixel.STATUS_FAIL,i.Message,d);if(j){ShortPixel.bulkShowError(d,i.Message,i.Filename,i.CustomImageLink);if(i.BulkPercent){progressUpdate(i.BulkPercent,i.BulkMsg)}ShortPixel.otherMediaUpdateActions(d,["retry","view"])}console.log(i.Message);setTimeout(checkBulkProgress,5000);break;case ShortPixel.STATUS_EMPTY_QUEUE:console.log(i.Message);clearBulkProcessor();hideToolBarAlert();var c=jQuery("#bulk-progress");if(j&&c.length&&i.BulkStatus!="2"){progressUpdate(100,"Bulk finished!");jQuery("a.bulk-cancel").attr("disabled","disabled");hideSlider();setTimeout(function(){window.location.reload()},3000)}break;case ShortPixel.STATUS_SUCCESS:if(j){ShortPixel.bulkHideLengthyMsg();ShortPixel.bulkHideMaintenanceMsg()}var l=i.PercentImprovement;showToolBarAlert(ShortPixel.STATUS_SUCCESS,"");var b=ShortPixel.isCustomImageId(d)?"":ShortPixel.successActions(d,i.Type,i.ThumbsCount,i.ThumbsTotal,i.BackupEnabled,i.Filename);setCellMessage(d,ShortPixel.successMsg(d,l,i.Type,i.ThumbsCount,i.RetinasCount),b);var h=jQuery(["restore","view","redolossy","redoglossy","redolossless"]).not(["redo"+i.Type]).get();ShortPixel.otherMediaUpdateActions(d,h);var f=new PercentageAnimator("#sp-msg-"+d+" span.percent",l);f.animate(l);if(j&&typeof i.Thumb!=="undefined"){if(i.BulkPercent){progressUpdate(i.BulkPercent,i.BulkMsg)}if(i.Thumb.length>0){sliderUpdate(d,i.Thumb,i.BkThumb,i.PercentImprovement,i.Filename);if(typeof i.AverageCompression!=="undefined"&&0+i.AverageCompression>0){jQuery("#sp-avg-optimization").html('<input type="text" class="dial" value="'+Math.round(i.AverageCompression)+'"/>');ShortPixel.percentDial("#sp-avg-optimization .dial",60)}}}console.log("Server response: "+g);if(j&&typeof i.BulkPercent!=="undefined"){progressUpdate(i.BulkPercent,i.BulkMsg)}setTimeout(checkBulkProgress,5000);break;case ShortPixel.STATUS_SKIP:if(i.Silent!==1){ShortPixel.bulkShowError(d,i.Message,i.Filename,i.CustomImageLink)}case ShortPixel.STATUS_ERROR:if(typeof i.Message!=="undefined"){showToolBarAlert(ShortPixel.STATUS_SKIP,i.Message+" Image ID: "+d);setCellMessage(d,i.Message,"")}ShortPixel.otherMediaUpdateActions(d,["retry","view"]);case ShortPixel.STATUS_RETRY:console.log("Server response: "+g);showToolBarAlert(ShortPixel.STATUS_RETRY,"");if(j&&typeof i.BulkPercent!=="undefined"){progressUpdate(i.BulkPercent,i.BulkMsg)}if(j&&i.Count>3){ShortPixel.bulkShowLengthyMsg(d,i.Filename,i.CustomImageLink)}setTimeout(checkBulkProgress,5000);break;case ShortPixel.STATUS_MAINTENANCE:ShortPixel.bulkShowMaintenanceMsg("maintenance");setTimeout(checkBulkProgress,60000);break;case ShortPixel.STATUS_QUEUE_FULL:ShortPixel.bulkShowMaintenanceMsg("queue-full");setTimeout(checkBulkProgress,60000);break;default:ShortPixel.retry("Unknown status "+i.Status+". Retrying...");break}}},error:function(b){ShortPixel.retry(b.statusText)}})}function clearBulkProcessor(){ShortPixel.bulkProcessor=false;localStorage.bulkTime=0;if(window.location.href.search("wp-short-pixel-bulk")>=0){localStorage.bulkPage=0}}function setCellMessage(d,a,c){var b=jQuery("#sp-msg-"+d);if(b.length>0){b.html("<div class='sp-column-actions'>"+c+"</div><div class='sp-column-info'>"+a+"</div>");b.css("color","")}b=jQuery("#sp-cust-msg-"+d);if(b.length>0){b.html("<div class='sp-column-info'>"+a+"</div>")}}function manualOptimization(c,a){setCellMessage(c,"<img src='"+ShortPixel.WP_PLUGIN_URL+"/res/img/loading.gif' class='sp-loading-small'>Image waiting to be processed","");jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-alert");jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");var b={action:"shortpixel_manual_optimization",image_id:c,cleanup:a};jQuery.ajax({type:"GET",url:ShortPixel.AJAX_URL,data:b,success:function(d){var e=JSON.parse(d);if(e.Status==ShortPixel.STATUS_SUCCESS){setTimeout(checkBulkProgress,2000)}else{setCellMessage(c,typeof e.Message!=="undefined"?e.Message:_spTr.thisContentNotProcessable,"")}},error:function(d){b.action="shortpixel_check_status";jQuery.ajax({type:"GET",url:ShortPixel.AJAX_URL,data:b,success:function(e){var f=JSON.parse(e);if(f.Status!==ShortPixel.STATUS_SUCCESS){setCellMessage(c,typeof f.Message!=="undefined"?f.Message:_spTr.thisContentNotProcessable,"")}}})}})}function reoptimize(c,a){setCellMessage(c,"<img src='"+ShortPixel.WP_PLUGIN_URL+"/res/img/loading.gif' class='sp-loading-small'>Image waiting to be reprocessed","");jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");var b={action:"shortpixel_redo",attachment_ID:c,type:a};jQuery.get(ShortPixel.AJAX_URL,b,function(d){b=JSON.parse(d);if(b.Status==ShortPixel.STATUS_SUCCESS){setTimeout(checkBulkProgress,2000)}else{$msg=typeof b.Message!=="undefined"?b.Message:_spTr.thisContentNotProcessable;setCellMessage(c,$msg,"");showToolBarAlert(ShortPixel.STATUS_FAIL,$msg)}})}function optimizeThumbs(b){setCellMessage(b,"<img src='"+ShortPixel.WP_PLUGIN_URL+"/res/img/loading.gif' class='sp-loading-small'>"+_spTr.imageWaitOptThumbs,"");jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide");jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");var a={action:"shortpixel_optimize_thumbs",attachment_ID:b};jQuery.get(ShortPixel.AJAX_URL,a,function(c){a=JSON.parse(c);if(a.Status==ShortPixel.STATUS_SUCCESS){setTimeout(checkBulkProgress,2000)}else{setCellMessage(b,typeof a.Message!=="undefined"?a.Message:_spTr.thisContentNotProcessable,"")}})}function dismissShortPixelNoticeExceed(b){jQuery("#wp-admin-bar-shortpixel_processing").hide();var a={action:"shortpixel_dismiss_notice",notice_id:"exceed"};jQuery.get(ShortPixel.AJAX_URL,a,function(c){a=JSON.parse(c);if(a.Status==ShortPixel.STATUS_SUCCESS){console.log("dismissed")}});b.preventDefault()}function dismissShortPixelNotice(b){jQuery("#short-pixel-notice-"+b).hide();var a={action:"shortpixel_dismiss_notice",notice_id:b};jQuery.get(ShortPixel.AJAX_URL,a,function(c){a=JSON.parse(c);if(a.Status==ShortPixel.STATUS_SUCCESS){console.log("dismissed")}})}function PercentageAnimator(b,a){this.animationSpeed=10;this.increment=2;this.curPercentage=0;this.targetPercentage=a;this.outputSelector=b;this.animate=function(c){this.targetPercentage=c;setTimeout(PercentageTimer.bind(null,this),this.animationSpeed)}}function PercentageTimer(a){if(a.curPercentage-a.targetPercentage<-a.increment){a.curPercentage+=a.increment}else{if(a.curPercentage-a.targetPercentage>a.increment){a.curPercentage-=a.increment}else{a.curPercentage=a.targetPercentage}}jQuery(a.outputSelector).text(a.curPercentage+"%");if(a.curPercentage!=a.targetPercentage){setTimeout(PercentageTimer.bind(null,a),a.animationSpeed)}}function progressUpdate(c,b){var a=jQuery("#bulk-progress");if(a.length){jQuery(".progress-left",a).css("width",c+"%");jQuery(".progress-img",a).css("left",c+"%");if(c>24){jQuery(".progress-img span",a).html("");jQuery(".progress-left",a).html(c+"%")}else{jQuery(".progress-img span",a).html(c+"%");jQuery(".progress-left",a).html("")}jQuery(".bulk-estimate").html(b)}}function sliderUpdate(g,c,d,e,b){var f=jQuery(".bulk-slider div.bulk-slide:first-child");if(f.length===0){return}if(f.attr("id")!="empty-slide"){f.hide()}f.css("z-index",1000);jQuery(".bulk-img-opt",f).attr("src","");if(typeof d==="undefined"){d=""}if(d.length>0){jQuery(".bulk-img-orig",f).attr("src","")}var a=f.clone();a.attr("id","slide-"+g);jQuery(".bulk-img-opt",a).attr("src",c);if(d.length>0){jQuery(".img-original",a).css("display","inline-block");jQuery(".bulk-img-orig",a).attr("src",d)}else{jQuery(".img-original",a).css("display","none")}jQuery(".bulk-opt-percent",a).html('<input type="text" class="dial" value="'+e+'"/>');jQuery(".bulk-slider").append(a);ShortPixel.percentDial("#"+a.attr("id")+" .dial",100);jQuery(".bulk-slider-container span.filename").html(" "+b);if(f.attr("id")=="empty-slide"){f.remove();jQuery(".bulk-slider-container").css("display","block")}else{f.animate({left:f.width()+f.position().left},"slow","swing",function(){f.remove();a.fadeIn("slow")})}}function hideSlider(){jQuery(".bulk-slider-container").css("display","none")}function showStats(){var a=jQuery(".bulk-stats");if(a.length>0){}}if(!(typeof String.prototype.format=="function")){String.prototype.format=function(){var b=this,a=arguments.length;while(a--){b=b.replace(new RegExp("\\{"+a+"\\}","gm"),arguments[a])}return b}};
|
res/js/sp-file-tree.min.js
CHANGED
@@ -1,2 +1 @@
|
|
1 |
-
|
2 |
var bind=function(a,b){return function(){return a.apply(b,arguments)}};(function(b,a){var c;c=(function(){function d(g,e,j){this.onEvent=bind(this.onEvent,this);var f,i,h;f=b(g);i=this;h={root:"/",script:"/files/filetree",folderEvent:"click",expandSpeed:500,collapseSpeed:500,expandEasing:"swing",collapseEasing:"swing",multiFolder:true,loadMessage:"Loading...",errorMessage:"Unable to get file tree information",multiSelect:false,onlyFolders:false,onlyFiles:false,preventLinkAction:false};this.jqft={container:f};this.options=b.extend(h,e);this.callback=j;this.data={};f.html('<ul class="jqueryFileTree start"><li class="wait">'+this.options.loadMessage+"<li></ul>");i.showTree(f,escape(this.options.root),function(){return i._trigger("filetreeinitiated",{})});f.delegate("li a",this.options.folderEvent,i.onEvent)}d.prototype.onEvent=function(h){var f,k,j,i,e,g;f=b(h.target);e=this.options;i=this.jqft;k=this;j=this.callback;k.data={};k.data.li=f.closest("li");k.data.type=(g=k.data.li.hasClass("directory"))!=null?g:{directory:"file"};k.data.value=f.text();k.data.rel=f.prop("rel");k.data.container=i.container;if(e.preventLinkAction){h.preventDefault()}if(f.parent().hasClass("directory")){k.jqft.container.find("LI.directory").removeClass("selected");f.parent().addClass("selected");if(f.parent().hasClass("collapsed")){if(!e.multiFolder){f.parent().parent().find("UL").slideUp({duration:e.collapseSpeed,easing:e.collapseEasing});f.parent().parent().find("LI.directory").removeClass("expanded").addClass("collapsed")}f.parent().removeClass("collapsed").addClass("expanded");f.parent().find("UL").remove();return k.showTree(f.parent(),f.attr("rel"),function(){k._trigger("filetreeexpanded",k.data);return j!=null})}else{return f.parent().find("UL").slideUp({duration:e.collapseSpeed,easing:e.collapseEasing,start:function(){return k._trigger("filetreecollapse",k.data)},complete:function(){f.parent().removeClass("expanded").addClass("collapsed");k._trigger("filetreecollapsed",k.data);return j!=null}})}}else{if(!e.multiSelect){i.container.find("li").removeClass("selected");f.parent().addClass("selected")}else{if(f.parent().find("input").is(":checked")){f.parent().find("input").prop("checked",false);f.parent().removeClass("selected")}else{f.parent().find("input").prop("checked",true);f.parent().addClass("selected")}}k._trigger("filetreeclicked",k.data);return typeof j==="function"?j(f.attr("rel")):void 0}};d.prototype.showTree=function(f,g,n){var m,i,h,e,j,l,k;m=b(f);l=this.options;i=this;m.addClass("wait");b(".jqueryFileTree.start").remove();h={dir:g,onlyFolders:l.onlyFolders,onlyFiles:l.onlyFiles,multiSelect:l.multiSelect};j=function(p){var o;m.find(".start").html("");m.removeClass("wait").append(p);if(l.root===g){m.find("UL:hidden").show(typeof callback!=="undefined"&&callback!==null)}else{if(jQuery.easing[l.expandEasing]===void 0){console.log("Easing library not loaded. Include jQueryUI or 3rd party lib.");l.expandEasing="swing"}m.find("UL:hidden").slideDown({duration:l.expandSpeed,easing:l.expandEasing,start:function(){return i._trigger("filetreeexpand",i.data)},complete:n})}o=b('[rel="'+decodeURIComponent(g)+'"]').parent();if(l.multiSelect&&o.children("input").is(":checked")){o.find("ul li input").each(function(){b(this).prop("checked",true);return b(this).parent().addClass("selected")})}return false};e=function(){m.find(".start").html("");m.removeClass("wait").append("<p>"+l.errorMessage+"</p>");return false};if(typeof l.script==="function"){k=l.script(h);if(typeof k==="string"||k instanceof jQuery){return j(k)}else{return e()}}else{return b.ajax({url:l.script,type:"POST",dataType:"HTML",data:h}).done(function(o){return j(o)}).fail(function(){return e()})}};d.prototype._trigger=function(f,g){var e;e=this.jqft.container;return e.triggerHandler(f,g)};return d})();return b.fn.extend({fileTree:function(d,e){return this.each(function(){var g,f;g=b(this);f=g.data("fileTree");if(!f){g.data("fileTree",(f=new c(this,d,e)))}if(typeof d==="string"){return f[option].apply(f)}})}})})(window.jQuery,window);
|
|
|
1 |
var bind=function(a,b){return function(){return a.apply(b,arguments)}};(function(b,a){var c;c=(function(){function d(g,e,j){this.onEvent=bind(this.onEvent,this);var f,i,h;f=b(g);i=this;h={root:"/",script:"/files/filetree",folderEvent:"click",expandSpeed:500,collapseSpeed:500,expandEasing:"swing",collapseEasing:"swing",multiFolder:true,loadMessage:"Loading...",errorMessage:"Unable to get file tree information",multiSelect:false,onlyFolders:false,onlyFiles:false,preventLinkAction:false};this.jqft={container:f};this.options=b.extend(h,e);this.callback=j;this.data={};f.html('<ul class="jqueryFileTree start"><li class="wait">'+this.options.loadMessage+"<li></ul>");i.showTree(f,escape(this.options.root),function(){return i._trigger("filetreeinitiated",{})});f.delegate("li a",this.options.folderEvent,i.onEvent)}d.prototype.onEvent=function(h){var f,k,j,i,e,g;f=b(h.target);e=this.options;i=this.jqft;k=this;j=this.callback;k.data={};k.data.li=f.closest("li");k.data.type=(g=k.data.li.hasClass("directory"))!=null?g:{directory:"file"};k.data.value=f.text();k.data.rel=f.prop("rel");k.data.container=i.container;if(e.preventLinkAction){h.preventDefault()}if(f.parent().hasClass("directory")){k.jqft.container.find("LI.directory").removeClass("selected");f.parent().addClass("selected");if(f.parent().hasClass("collapsed")){if(!e.multiFolder){f.parent().parent().find("UL").slideUp({duration:e.collapseSpeed,easing:e.collapseEasing});f.parent().parent().find("LI.directory").removeClass("expanded").addClass("collapsed")}f.parent().removeClass("collapsed").addClass("expanded");f.parent().find("UL").remove();return k.showTree(f.parent(),f.attr("rel"),function(){k._trigger("filetreeexpanded",k.data);return j!=null})}else{return f.parent().find("UL").slideUp({duration:e.collapseSpeed,easing:e.collapseEasing,start:function(){return k._trigger("filetreecollapse",k.data)},complete:function(){f.parent().removeClass("expanded").addClass("collapsed");k._trigger("filetreecollapsed",k.data);return j!=null}})}}else{if(!e.multiSelect){i.container.find("li").removeClass("selected");f.parent().addClass("selected")}else{if(f.parent().find("input").is(":checked")){f.parent().find("input").prop("checked",false);f.parent().removeClass("selected")}else{f.parent().find("input").prop("checked",true);f.parent().addClass("selected")}}k._trigger("filetreeclicked",k.data);return typeof j==="function"?j(f.attr("rel")):void 0}};d.prototype.showTree=function(f,g,n){var m,i,h,e,j,l,k;m=b(f);l=this.options;i=this;m.addClass("wait");b(".jqueryFileTree.start").remove();h={dir:g,onlyFolders:l.onlyFolders,onlyFiles:l.onlyFiles,multiSelect:l.multiSelect};j=function(p){var o;m.find(".start").html("");m.removeClass("wait").append(p);if(l.root===g){m.find("UL:hidden").show(typeof callback!=="undefined"&&callback!==null)}else{if(jQuery.easing[l.expandEasing]===void 0){console.log("Easing library not loaded. Include jQueryUI or 3rd party lib.");l.expandEasing="swing"}m.find("UL:hidden").slideDown({duration:l.expandSpeed,easing:l.expandEasing,start:function(){return i._trigger("filetreeexpand",i.data)},complete:n})}o=b('[rel="'+decodeURIComponent(g)+'"]').parent();if(l.multiSelect&&o.children("input").is(":checked")){o.find("ul li input").each(function(){b(this).prop("checked",true);return b(this).parent().addClass("selected")})}return false};e=function(){m.find(".start").html("");m.removeClass("wait").append("<p>"+l.errorMessage+"</p>");return false};if(typeof l.script==="function"){k=l.script(h);if(typeof k==="string"||k instanceof jQuery){return j(k)}else{return e()}}else{return b.ajax({url:l.script,type:"POST",dataType:"HTML",data:h}).done(function(o){return j(o)}).fail(function(){return e()})}};d.prototype._trigger=function(f,g){var e;e=this.jqft.container;return e.triggerHandler(f,g)};return d})();return b.fn.extend({fileTree:function(d,e){return this.each(function(){var g,f;g=b(this);f=g.data("fileTree");if(!f){g.data("fileTree",(f=new c(this,d,e)))}if(typeof d==="string"){return f[option].apply(f)}})}})})(window.jQuery,window);
|
shortpixel_api.php
CHANGED
@@ -4,7 +4,7 @@ if ( !function_exists( 'download_url' ) ) {
|
|
4 |
}
|
5 |
|
6 |
class ShortPixelAPI {
|
7 |
-
|
8 |
const STATUS_SUCCESS = 1;
|
9 |
const STATUS_UNCHANGED = 0;
|
10 |
const STATUS_ERROR = -1;
|
@@ -16,7 +16,7 @@ class ShortPixelAPI {
|
|
16 |
const STATUS_RETRY = -7;
|
17 |
const STATUS_QUEUE_FULL = -404;
|
18 |
const STATUS_MAINTENANCE = -500;
|
19 |
-
|
20 |
const ERR_FILE_NOT_FOUND = -2;
|
21 |
const ERR_TIMEOUT = -3;
|
22 |
const ERR_SAVE = -4;
|
@@ -81,7 +81,7 @@ class ShortPixelAPI {
|
|
81 |
* @throws Exception
|
82 |
*/
|
83 |
public function doRequests($URLs, $Blocking, $itemHandler, $compressionType = false, $refresh = false) {
|
84 |
-
|
85 |
if(!count($URLs)) {
|
86 |
$meta = $itemHandler->getMeta();
|
87 |
if(count($meta->getThumbsMissing())) {
|
@@ -131,10 +131,10 @@ class ShortPixelAPI {
|
|
131 |
if ( $Blocking )
|
132 |
{
|
133 |
//WpShortPixel::log("API response : " . json_encode($response));
|
134 |
-
|
135 |
//die(var_dump(array('URL: ' => $this->_apiEndPoint, '<br><br>REQUEST:' => $requestParameters, '<br><br>RESPONSE: ' => $response, '<br><br>BODY: ' => isset($response['body']) ? $response['body'] : '' )));
|
136 |
//there was an error, save this error inside file's SP optimization field
|
137 |
-
if ( is_object($response) && get_class($response) == 'WP_Error' )
|
138 |
{
|
139 |
$errorMessage = $response->errors['http_request_failed'][0];
|
140 |
$errorCode = 503;
|
@@ -144,7 +144,7 @@ class ShortPixelAPI {
|
|
144 |
$errorMessage = $response['response']['code'] . " - " . $response['response']['message'];
|
145 |
$errorCode = $response['response']['code'];
|
146 |
}
|
147 |
-
|
148 |
if ( isset($errorMessage) )
|
149 |
{//set details inside file so user can know what happened
|
150 |
$itemHandler->incrementRetries(1, $errorCode, $errorMessage);
|
@@ -153,7 +153,7 @@ class ShortPixelAPI {
|
|
153 |
|
154 |
return $response;//this can be an error or a good response
|
155 |
}
|
156 |
-
|
157 |
return $response;
|
158 |
}
|
159 |
|
@@ -175,10 +175,10 @@ class ShortPixelAPI {
|
|
175 |
* @param ShortPixelMetaFacade $itemHandler - the Facade that manages different types of image metadatas: MediaLibrary (postmeta table), ShortPixel custom (shortpixel_meta table)
|
176 |
* @return array status/message array
|
177 |
*/
|
178 |
-
public function processImage($URLs, $PATHs, $itemHandler = null) {
|
179 |
-
return $this->processImageRecursive($URLs, $PATHs, $itemHandler, 0);
|
180 |
}
|
181 |
-
|
182 |
/**
|
183 |
* handles the processing of the image using the ShortPixel API - cals itself recursively until success
|
184 |
* @param array $URLs - list of urls to send to API
|
@@ -187,10 +187,10 @@ class ShortPixelAPI {
|
|
187 |
* @param int $startTime - time of the first call
|
188 |
* @return array status/message array
|
189 |
*/
|
190 |
-
private function processImageRecursive($URLs, $PATHs, $itemHandler = null, $startTime = 0)
|
191 |
-
{
|
192 |
//WPShortPixel::log("processImageRecursive ID: " . $itemHandler->getId() . " PATHs: " . json_encode($PATHs));
|
193 |
-
|
194 |
$PATHs = self::CheckAndFixImagePaths($PATHs);//check for images to make sure they exist on disk
|
195 |
if ( $PATHs === false || isset($PATHs['error'])) {
|
196 |
$missingFiles = '';
|
@@ -203,39 +203,39 @@ class ShortPixelAPI {
|
|
203 |
$itemHandler->setError(self::ERR_FILE_NOT_FOUND, $msg );
|
204 |
return array("Status" => self::STATUS_SKIP, "Message" => $msg, "Silent" => $itemHandler->getType() == ShortPixelMetaFacade::CUSTOM_TYPE ? 1 : 0);
|
205 |
}
|
206 |
-
|
207 |
//tries multiple times (till timeout almost reached) to fetch images.
|
208 |
-
if($startTime == 0) {
|
209 |
-
$startTime = time();
|
210 |
-
}
|
211 |
$apiRetries = $this->_settings->apiRetries;
|
212 |
-
|
213 |
-
if( time() - $startTime > SHORTPIXEL_MAX_EXECUTION_TIME2)
|
214 |
{//keeps track of time
|
215 |
if ( $apiRetries > SHORTPIXEL_MAX_API_RETRIES )//we tried to process this time too many times, giving up...
|
216 |
{
|
217 |
$itemHandler->incrementRetries(1, self::ERR_TIMEOUT, __('Timed out while processing.','shortpixel-image-optimiser'));
|
218 |
$this->_settings->apiRetries = 0; //fai added to solve a bug?
|
219 |
-
return array("Status" => self::STATUS_SKIP,
|
220 |
-
"Message" => ($itemHandler->getType() == ShortPixelMetaFacade::CUSTOM_TYPE ? __('Image ID','shortpixel-image-optimiser') : __('Media ID','shortpixel-image-optimiser'))
|
221 |
-
. ": " . $itemHandler->getId() .' ' . __('Skip this image, try the next one.','shortpixel-image-optimiser'));
|
222 |
}
|
223 |
else
|
224 |
{//we'll try again next time user visits a page on admin panel
|
225 |
$apiRetries++;
|
226 |
$this->_settings->apiRetries = $apiRetries;
|
227 |
-
return array("Status" => self::STATUS_RETRY, "Message" => __('Timed out while processing.','shortpixel-image-optimiser') . ' (pass '.$apiRetries.')',
|
228 |
"Count" => $apiRetries);
|
229 |
}
|
230 |
}
|
231 |
-
|
232 |
//#$compressionType = isset($meta['ShortPixel']['type']) ? ($meta['ShortPixel']['type'] == 'lossy' ? 1 : 0) : $this->_settings->compressionType;
|
233 |
$meta = $itemHandler->getMeta();
|
234 |
$compressionType = $meta->getCompressionType() !== null ? $meta->getCompressionType() : $this->_settings->compressionType;
|
235 |
$response = $this->doRequests($URLs, true, $itemHandler, $compressionType);//send requests to API
|
236 |
-
|
237 |
//die($response['body']);
|
238 |
-
|
239 |
if($response['response']['code'] != 200) {//response <> 200 -> there was an error apparently?
|
240 |
return array("Status" => self::STATUS_FAIL, "Message" => __('There was an error and your request was not processed.', 'shortpixel-image-optimiser')
|
241 |
. (isset($response['response']['message']) ? ' (' . $response['response']['message'] . ')' : ''), "Code" => $response['response']['code']);
|
@@ -248,12 +248,12 @@ class ShortPixelAPI {
|
|
248 |
foreach ( $APIresponse as $imageObject ) {//this part makes sure that all the sizes were processed and ready to be downloaded
|
249 |
if ( isset($imageObject->Status) && ( $imageObject->Status->Code == 0 || $imageObject->Status->Code == 1 ) ) {
|
250 |
sleep(1);
|
251 |
-
return $this->processImageRecursive($URLs, $PATHs, $itemHandler, $startTime);
|
252 |
-
}
|
253 |
}
|
254 |
|
255 |
$firstImage = $APIresponse[0];//extract as object first image
|
256 |
-
switch($firstImage->Status->Code)
|
257 |
{
|
258 |
case 2:
|
259 |
//handle image has been processed
|
@@ -271,15 +271,15 @@ class ShortPixelAPI {
|
|
271 |
$incR = 3;
|
272 |
}
|
273 |
elseif ( isset($APIresponse[0]->Status->Message) ) {
|
274 |
-
//return array("Status" => self::STATUS_FAIL, "Message" => "There was an error and your request was not processed (" . $APIresponse[0]->Status->Message . "). REQ: " . json_encode($URLs));
|
275 |
-
$err = array("Status" => self::STATUS_FAIL, "Code" => (isset($APIresponse[0]->Status->Code) ? $APIresponse[0]->Status->Code : self::ERR_UNKNOWN),
|
276 |
-
"Message" => __('There was an error and your request was not processed.','shortpixel-image-optimiser')
|
277 |
. " (" . wp_basename($APIresponse[0]->OriginalURL) . ": " . $APIresponse[0]->Status->Message . ")");
|
278 |
} else {
|
279 |
$err = array("Status" => self::STATUS_FAIL, "Message" => __('There was an error and your request was not processed.','shortpixel-image-optimiser'),
|
280 |
"Code" => (isset($APIresponse[0]->Status->Code) ? $APIresponse[0]->Status->Code : self::ERR_UNKNOWN));
|
281 |
}
|
282 |
-
|
283 |
$itemHandler->incrementRetries($incR, $err["Code"], $err["Message"]);
|
284 |
$meta = $itemHandler->getMeta();
|
285 |
if($meta->getRetries() >= SHORTPIXEL_MAX_FAIL_RETRIES) {
|
@@ -290,22 +290,22 @@ class ShortPixelAPI {
|
|
290 |
return $err;
|
291 |
}
|
292 |
}
|
293 |
-
|
294 |
if(!isset($APIresponse['Status'])) {
|
295 |
WpShortPixel::log("API Response Status unfound : " . json_encode($APIresponse));
|
296 |
return array("Status" => self::STATUS_FAIL, "Message" => __('Unrecognized API response. Please contact support.','shortpixel-image-optimiser'),
|
297 |
"Code" => self::ERR_UNKNOWN, "Debug" => ' (SERVER RESPONSE: ' . json_encode($response) . ')');
|
298 |
} else {
|
299 |
-
switch($APIresponse['Status']->Code)
|
300 |
-
{
|
301 |
case -403:
|
302 |
@delete_option('bulkProcessingStatus');
|
303 |
$this->_settings->quotaExceeded = 1;
|
304 |
return array("Status" => self::STATUS_QUOTA_EXCEEDED, "Message" => __('Quota exceeded.','shortpixel-image-optimiser'));
|
305 |
-
break;
|
306 |
-
case -404:
|
307 |
return array("Status" => self::STATUS_QUEUE_FULL, "Message" => $APIresponse['Status']->Message);
|
308 |
-
case -500:
|
309 |
return array("Status" => self::STATUS_MAINTENANCE, "Message" => $APIresponse['Status']->Message);
|
310 |
}
|
311 |
|
@@ -317,10 +317,10 @@ class ShortPixelAPI {
|
|
317 |
}
|
318 |
}
|
319 |
}
|
320 |
-
|
321 |
/**
|
322 |
* sets the preferred protocol of URL using the globally set preferred protocol.
|
323 |
-
* If global protocol not set, sets it by testing the download of a http test image from ShortPixel site.
|
324 |
* If http works then it's http, otherwise sets https
|
325 |
* @param string $url
|
326 |
* @param bool $reset - forces recheck even if preferred protocol is already set
|
@@ -334,7 +334,7 @@ class ShortPixelAPI {
|
|
334 |
$result = download_url($testURL, 10);
|
335 |
$this->_settings->downloadProto = is_wp_error( $result ) ? 'https' : 'http';
|
336 |
}
|
337 |
-
return $this->_settings->downloadProto == 'http' ?
|
338 |
str_replace('https://', 'http://', $url) :
|
339 |
str_replace('http://', 'https://', $url);
|
340 |
|
@@ -402,26 +402,26 @@ class ShortPixelAPI {
|
|
402 |
|
403 |
$correctFileSize = $optimizedSize;
|
404 |
$fileURL = $this->setPreferredProtocol(urldecode($optimizedUrl));
|
405 |
-
|
406 |
$tempFile = download_url($fileURL, $downloadTimeout);
|
407 |
WPShortPixel::log('Downloading file: '.json_encode($tempFile));
|
408 |
-
if(is_wp_error( $tempFile ))
|
409 |
{ //try to switch the default protocol
|
410 |
$fileURL = $this->setPreferredProtocol(urldecode($optimizedUrl), true); //force recheck of the protocol
|
411 |
$tempFile = download_url($fileURL, $downloadTimeout);
|
412 |
-
}
|
413 |
|
414 |
//on success we return this
|
415 |
$returnMessage = array("Status" => self::STATUS_SUCCESS, "Message" => $tempFile, "WebP" => $webpTempFile);
|
416 |
-
|
417 |
if ( is_wp_error( $tempFile ) ) {
|
418 |
@unlink($tempFile);
|
419 |
@unlink($webpTempFile);
|
420 |
$returnMessage = array(
|
421 |
-
"Status" => self::STATUS_ERROR,
|
422 |
"Code" => self::ERR_DOWNLOAD,
|
423 |
"Message" => __('Error downloading file','shortpixel-image-optimiser') . " ({$optimizedUrl}) " . $tempFile->get_error_message());
|
424 |
-
}
|
425 |
//check response so that download is OK
|
426 |
elseif (!file_exists($tempFile)) {
|
427 |
$returnMessage = array("Status" => self::STATUS_ERROR,
|
@@ -439,7 +439,7 @@ class ShortPixelAPI {
|
|
439 |
}
|
440 |
return $returnMessage;
|
441 |
}
|
442 |
-
|
443 |
public static function backupImage($mainPath, $PATHs) {
|
444 |
//$fullSubDir = str_replace(wp_normalize_path(get_home_path()), "", wp_normalize_path(dirname($itemHandler->getMeta()->getPath()))) . '/';
|
445 |
//$SubDir = ShortPixelMetaFacade::returnSubDir($itemHandler->getMeta()->getPath(), $itemHandler->getType());
|
@@ -454,17 +454,17 @@ class ShortPixelAPI {
|
|
454 |
|
455 |
foreach ( $source as $fileID => $filePATH )//create destination files array
|
456 |
{
|
457 |
-
$destination[$fileID] = SHORTPIXEL_BACKUP_FOLDER . '/' . $fullSubDir . self::MB_basename($source[$fileID]);
|
458 |
}
|
459 |
//die("IZ BACKUP: " . SHORTPIXEL_BACKUP_FOLDER . '/' . $SubDir . var_dump($destination));
|
460 |
|
461 |
//now that we have original files and where we should back them up we attempt to do just that
|
462 |
-
if(is_writable(SHORTPIXEL_BACKUP_FOLDER))
|
463 |
{
|
464 |
foreach ( $destination as $fileID => $filePATH )
|
465 |
{
|
466 |
if ( !file_exists($filePATH) )
|
467 |
-
{
|
468 |
if ( !@copy($source[$fileID], $filePATH) )
|
469 |
{//file couldn't be saved in backup folder
|
470 |
$msg = sprintf(__('Cannot save file <i>%s</i> in backup directory','shortpixel-image-optimiser'),self::MB_basename($source[$fileID]));
|
@@ -473,7 +473,7 @@ class ShortPixelAPI {
|
|
473 |
}
|
474 |
}
|
475 |
return array("Status" => self::STATUS_SUCCESS);
|
476 |
-
}
|
477 |
else {//cannot write to the backup dir, return with an error
|
478 |
$msg = __('Cannot save file in backup directory','shortpixel-image-optimiser');
|
479 |
return array("Status" => self::STATUS_FAIL, "Message" => $msg);
|
@@ -598,7 +598,7 @@ class ShortPixelAPI {
|
|
598 |
$tempFiles[$counter] = $downloadResult;
|
599 |
if ( $downloadResult['Status'] == self::STATUS_SUCCESS ) {
|
600 |
//nothing to do
|
601 |
-
}
|
602 |
//when the status is STATUS_UNCHANGED we just skip the array line for that one
|
603 |
elseif( $downloadResult['Status'] == self::STATUS_UNCHANGED ) {
|
604 |
//this image is unchanged so won't be copied below, only the optimization stats need to be computed
|
@@ -609,8 +609,8 @@ class ShortPixelAPI {
|
|
609 |
self::cleanupTemporaryFiles($archive, $tempFiles);
|
610 |
return array("Status" => $downloadResult['Status'], "Code" => $downloadResult['Code'], "Message" => $downloadResult['Message']);
|
611 |
}
|
612 |
-
|
613 |
-
}
|
614 |
else { //there was an error while trying to download a file
|
615 |
$tempFiles[$counter] = "";
|
616 |
}
|
@@ -643,9 +643,9 @@ class ShortPixelAPI {
|
|
643 |
{
|
644 |
//overwrite the original files with the optimized ones
|
645 |
foreach ( $tempFiles as $tempFileID => $tempFile )
|
646 |
-
{
|
647 |
if(!is_array($tempFile)) continue;
|
648 |
-
|
649 |
$targetFile = $PATHs[$tempFileID];
|
650 |
$isRetina = ShortPixelMetaFacade::isRetina($targetFile);
|
651 |
|
@@ -654,7 +654,7 @@ class ShortPixelAPI {
|
|
654 |
$thumbsOpt++;
|
655 |
$thumbsOptList[] = self::MB_basename($targetFile);
|
656 |
}
|
657 |
-
|
658 |
if($tempFile['Status'] == self::STATUS_SUCCESS) { //if it's unchanged it will still be in the array but only for WebP (handled below)
|
659 |
$tempFilePATH = $tempFile["Message"];
|
660 |
if ( file_exists($tempFilePATH) && file_exists($targetFile) && is_writable($targetFile) ) {
|
@@ -677,9 +677,9 @@ class ShortPixelAPI {
|
|
677 |
|
678 |
//add the number of files with < 5% optimization
|
679 |
if ( ( ( 1 - $APIresponse[$tempFileID]->$fileSize/$APIresponse[$tempFileID]->OriginalSize ) * 100 ) < 5 ) {
|
680 |
-
$this->_settings->under5Percent++;
|
681 |
}
|
682 |
-
}
|
683 |
else {
|
684 |
if($archive && SHORTPIXEL_DEBUG === true) {
|
685 |
if(!file_exists($tempFilePATH)) {
|
@@ -697,8 +697,12 @@ class ShortPixelAPI {
|
|
697 |
|
698 |
$tempWebpFilePATH = $tempFile["WebP"];
|
699 |
if(file_exists($tempWebpFilePATH)) {
|
700 |
-
$
|
|
|
701 |
copy($tempWebpFilePATH, $targetWebPFile);
|
|
|
|
|
|
|
702 |
@unlink($tempWebpFilePATH);
|
703 |
}
|
704 |
}
|
@@ -718,7 +722,7 @@ class ShortPixelAPI {
|
|
718 |
return array("Status" => self::STATUS_FAIL, "Code" =>"write-fail", "Message" => $msg);
|
719 |
}
|
720 |
} elseif( 0 + $fileData->PercentImprovement < 5) {
|
721 |
-
$this->_settings->under5Percent++;
|
722 |
}
|
723 |
//old average counting
|
724 |
$this->_settings->savedSpace += $savedSpace;
|
@@ -728,7 +732,7 @@ class ShortPixelAPI {
|
|
728 |
//new average counting
|
729 |
$this->_settings->totalOriginal += $originalSpace;
|
730 |
$this->_settings->totalOptimized += $optimizedSpace;
|
731 |
-
|
732 |
//update metadata for this file
|
733 |
$meta = $itemHandler->getMeta();
|
734 |
// die(var_dump($percentImprovement));
|
@@ -737,7 +741,7 @@ class ShortPixelAPI {
|
|
737 |
}
|
738 |
$png2jpg = $meta->getPng2Jpg();
|
739 |
$png2jpg = is_array($png2jpg) ? $png2jpg['optimizationPercent'] : 0;
|
740 |
-
$meta->setMessage($originalSpace
|
741 |
? number_format(100.0 * (1.0 - $optimizedSpace / $originalSpace), 2)
|
742 |
: "Couldn't compute thumbs optimization percent. Main image: " . $percentImprovement);
|
743 |
WPShortPixel::log("HANDLE SUCCESS: Image optimization: ".$meta->getMessage());
|
@@ -760,7 +764,7 @@ class ShortPixelAPI {
|
|
760 |
$meta->setRetries($meta->getRetries() + 1);
|
761 |
$meta->setBackup(!$NoBackup);
|
762 |
$meta->setStatus(2);
|
763 |
-
|
764 |
$itemHandler->updateMeta($meta);
|
765 |
$itemHandler->optimizationSucceeded();
|
766 |
WPShortPixel::log("HANDLE SUCCESS: Metadata saved.");
|
@@ -768,10 +772,10 @@ class ShortPixelAPI {
|
|
768 |
if(!$originalSpace) { //das kann nicht sein, alles klar?!
|
769 |
throw new Exception("OriginalSpace = 0. APIResponse" . json_encode($APIresponse));
|
770 |
}
|
771 |
-
|
772 |
//we reset the retry counter in case of success
|
773 |
$this->_settings->apiRetries = 0;
|
774 |
-
|
775 |
return array("Status" => self::STATUS_SUCCESS, "Message" => 'Success: No pixels remained unsqueezed :-)',
|
776 |
"PercentImprovement" => $originalSpace
|
777 |
? number_format(100.0 * (1.0 - (1.0 - $png2jpg / 100.0) * $optimizedSpace / $originalSpace), 2)
|
@@ -816,7 +820,7 @@ class ShortPixelAPI {
|
|
816 |
$Base = str_replace($Separator, "", $Base);
|
817 |
return $Base;
|
818 |
}
|
819 |
-
|
820 |
/**
|
821 |
* sometimes, the paths to the files as defined in metadata are wrong, we try to automatically correct them
|
822 |
* @param array $PATHs
|
@@ -849,7 +853,7 @@ class ShortPixelAPI {
|
|
849 |
}
|
850 |
}
|
851 |
}
|
852 |
-
|
853 |
if ( $ErrorCount > 0 ) {
|
854 |
return array("error" => $missingFiles);//false;
|
855 |
} else {
|
@@ -863,7 +867,7 @@ class ShortPixelAPI {
|
|
863 |
}
|
864 |
return 0 + $compressionType == 2 ? 'glossy' : (0 + $compressionType == 1 ? 'lossy' : 'lossless');
|
865 |
}
|
866 |
-
|
867 |
static public function getCompressionTypeCode($compressionName) {
|
868 |
return $compressionName == 'glossy' ? 2 : ($compressionName == 'lossy' ? 1 : 0);
|
869 |
}
|
4 |
}
|
5 |
|
6 |
class ShortPixelAPI {
|
7 |
+
|
8 |
const STATUS_SUCCESS = 1;
|
9 |
const STATUS_UNCHANGED = 0;
|
10 |
const STATUS_ERROR = -1;
|
16 |
const STATUS_RETRY = -7;
|
17 |
const STATUS_QUEUE_FULL = -404;
|
18 |
const STATUS_MAINTENANCE = -500;
|
19 |
+
|
20 |
const ERR_FILE_NOT_FOUND = -2;
|
21 |
const ERR_TIMEOUT = -3;
|
22 |
const ERR_SAVE = -4;
|
81 |
* @throws Exception
|
82 |
*/
|
83 |
public function doRequests($URLs, $Blocking, $itemHandler, $compressionType = false, $refresh = false) {
|
84 |
+
|
85 |
if(!count($URLs)) {
|
86 |
$meta = $itemHandler->getMeta();
|
87 |
if(count($meta->getThumbsMissing())) {
|
131 |
if ( $Blocking )
|
132 |
{
|
133 |
//WpShortPixel::log("API response : " . json_encode($response));
|
134 |
+
|
135 |
//die(var_dump(array('URL: ' => $this->_apiEndPoint, '<br><br>REQUEST:' => $requestParameters, '<br><br>RESPONSE: ' => $response, '<br><br>BODY: ' => isset($response['body']) ? $response['body'] : '' )));
|
136 |
//there was an error, save this error inside file's SP optimization field
|
137 |
+
if ( is_object($response) && get_class($response) == 'WP_Error' )
|
138 |
{
|
139 |
$errorMessage = $response->errors['http_request_failed'][0];
|
140 |
$errorCode = 503;
|
144 |
$errorMessage = $response['response']['code'] . " - " . $response['response']['message'];
|
145 |
$errorCode = $response['response']['code'];
|
146 |
}
|
147 |
+
|
148 |
if ( isset($errorMessage) )
|
149 |
{//set details inside file so user can know what happened
|
150 |
$itemHandler->incrementRetries(1, $errorCode, $errorMessage);
|
153 |
|
154 |
return $response;//this can be an error or a good response
|
155 |
}
|
156 |
+
|
157 |
return $response;
|
158 |
}
|
159 |
|
175 |
* @param ShortPixelMetaFacade $itemHandler - the Facade that manages different types of image metadatas: MediaLibrary (postmeta table), ShortPixel custom (shortpixel_meta table)
|
176 |
* @return array status/message array
|
177 |
*/
|
178 |
+
public function processImage($URLs, $PATHs, $itemHandler = null) {
|
179 |
+
return $this->processImageRecursive($URLs, $PATHs, $itemHandler, 0);
|
180 |
}
|
181 |
+
|
182 |
/**
|
183 |
* handles the processing of the image using the ShortPixel API - cals itself recursively until success
|
184 |
* @param array $URLs - list of urls to send to API
|
187 |
* @param int $startTime - time of the first call
|
188 |
* @return array status/message array
|
189 |
*/
|
190 |
+
private function processImageRecursive($URLs, $PATHs, $itemHandler = null, $startTime = 0)
|
191 |
+
{
|
192 |
//WPShortPixel::log("processImageRecursive ID: " . $itemHandler->getId() . " PATHs: " . json_encode($PATHs));
|
193 |
+
|
194 |
$PATHs = self::CheckAndFixImagePaths($PATHs);//check for images to make sure they exist on disk
|
195 |
if ( $PATHs === false || isset($PATHs['error'])) {
|
196 |
$missingFiles = '';
|
203 |
$itemHandler->setError(self::ERR_FILE_NOT_FOUND, $msg );
|
204 |
return array("Status" => self::STATUS_SKIP, "Message" => $msg, "Silent" => $itemHandler->getType() == ShortPixelMetaFacade::CUSTOM_TYPE ? 1 : 0);
|
205 |
}
|
206 |
+
|
207 |
//tries multiple times (till timeout almost reached) to fetch images.
|
208 |
+
if($startTime == 0) {
|
209 |
+
$startTime = time();
|
210 |
+
}
|
211 |
$apiRetries = $this->_settings->apiRetries;
|
212 |
+
|
213 |
+
if( time() - $startTime > SHORTPIXEL_MAX_EXECUTION_TIME2)
|
214 |
{//keeps track of time
|
215 |
if ( $apiRetries > SHORTPIXEL_MAX_API_RETRIES )//we tried to process this time too many times, giving up...
|
216 |
{
|
217 |
$itemHandler->incrementRetries(1, self::ERR_TIMEOUT, __('Timed out while processing.','shortpixel-image-optimiser'));
|
218 |
$this->_settings->apiRetries = 0; //fai added to solve a bug?
|
219 |
+
return array("Status" => self::STATUS_SKIP,
|
220 |
+
"Message" => ($itemHandler->getType() == ShortPixelMetaFacade::CUSTOM_TYPE ? __('Image ID','shortpixel-image-optimiser') : __('Media ID','shortpixel-image-optimiser'))
|
221 |
+
. ": " . $itemHandler->getId() .' ' . __('Skip this image, try the next one.','shortpixel-image-optimiser'));
|
222 |
}
|
223 |
else
|
224 |
{//we'll try again next time user visits a page on admin panel
|
225 |
$apiRetries++;
|
226 |
$this->_settings->apiRetries = $apiRetries;
|
227 |
+
return array("Status" => self::STATUS_RETRY, "Message" => __('Timed out while processing.','shortpixel-image-optimiser') . ' (pass '.$apiRetries.')',
|
228 |
"Count" => $apiRetries);
|
229 |
}
|
230 |
}
|
231 |
+
|
232 |
//#$compressionType = isset($meta['ShortPixel']['type']) ? ($meta['ShortPixel']['type'] == 'lossy' ? 1 : 0) : $this->_settings->compressionType;
|
233 |
$meta = $itemHandler->getMeta();
|
234 |
$compressionType = $meta->getCompressionType() !== null ? $meta->getCompressionType() : $this->_settings->compressionType;
|
235 |
$response = $this->doRequests($URLs, true, $itemHandler, $compressionType);//send requests to API
|
236 |
+
|
237 |
//die($response['body']);
|
238 |
+
|
239 |
if($response['response']['code'] != 200) {//response <> 200 -> there was an error apparently?
|
240 |
return array("Status" => self::STATUS_FAIL, "Message" => __('There was an error and your request was not processed.', 'shortpixel-image-optimiser')
|
241 |
. (isset($response['response']['message']) ? ' (' . $response['response']['message'] . ')' : ''), "Code" => $response['response']['code']);
|
248 |
foreach ( $APIresponse as $imageObject ) {//this part makes sure that all the sizes were processed and ready to be downloaded
|
249 |
if ( isset($imageObject->Status) && ( $imageObject->Status->Code == 0 || $imageObject->Status->Code == 1 ) ) {
|
250 |
sleep(1);
|
251 |
+
return $this->processImageRecursive($URLs, $PATHs, $itemHandler, $startTime);
|
252 |
+
}
|
253 |
}
|
254 |
|
255 |
$firstImage = $APIresponse[0];//extract as object first image
|
256 |
+
switch($firstImage->Status->Code)
|
257 |
{
|
258 |
case 2:
|
259 |
//handle image has been processed
|
271 |
$incR = 3;
|
272 |
}
|
273 |
elseif ( isset($APIresponse[0]->Status->Message) ) {
|
274 |
+
//return array("Status" => self::STATUS_FAIL, "Message" => "There was an error and your request was not processed (" . $APIresponse[0]->Status->Message . "). REQ: " . json_encode($URLs));
|
275 |
+
$err = array("Status" => self::STATUS_FAIL, "Code" => (isset($APIresponse[0]->Status->Code) ? $APIresponse[0]->Status->Code : self::ERR_UNKNOWN),
|
276 |
+
"Message" => __('There was an error and your request was not processed.','shortpixel-image-optimiser')
|
277 |
. " (" . wp_basename($APIresponse[0]->OriginalURL) . ": " . $APIresponse[0]->Status->Message . ")");
|
278 |
} else {
|
279 |
$err = array("Status" => self::STATUS_FAIL, "Message" => __('There was an error and your request was not processed.','shortpixel-image-optimiser'),
|
280 |
"Code" => (isset($APIresponse[0]->Status->Code) ? $APIresponse[0]->Status->Code : self::ERR_UNKNOWN));
|
281 |
}
|
282 |
+
|
283 |
$itemHandler->incrementRetries($incR, $err["Code"], $err["Message"]);
|
284 |
$meta = $itemHandler->getMeta();
|
285 |
if($meta->getRetries() >= SHORTPIXEL_MAX_FAIL_RETRIES) {
|
290 |
return $err;
|
291 |
}
|
292 |
}
|
293 |
+
|
294 |
if(!isset($APIresponse['Status'])) {
|
295 |
WpShortPixel::log("API Response Status unfound : " . json_encode($APIresponse));
|
296 |
return array("Status" => self::STATUS_FAIL, "Message" => __('Unrecognized API response. Please contact support.','shortpixel-image-optimiser'),
|
297 |
"Code" => self::ERR_UNKNOWN, "Debug" => ' (SERVER RESPONSE: ' . json_encode($response) . ')');
|
298 |
} else {
|
299 |
+
switch($APIresponse['Status']->Code)
|
300 |
+
{
|
301 |
case -403:
|
302 |
@delete_option('bulkProcessingStatus');
|
303 |
$this->_settings->quotaExceeded = 1;
|
304 |
return array("Status" => self::STATUS_QUOTA_EXCEEDED, "Message" => __('Quota exceeded.','shortpixel-image-optimiser'));
|
305 |
+
break;
|
306 |
+
case -404:
|
307 |
return array("Status" => self::STATUS_QUEUE_FULL, "Message" => $APIresponse['Status']->Message);
|
308 |
+
case -500:
|
309 |
return array("Status" => self::STATUS_MAINTENANCE, "Message" => $APIresponse['Status']->Message);
|
310 |
}
|
311 |
|
317 |
}
|
318 |
}
|
319 |
}
|
320 |
+
|
321 |
/**
|
322 |
* sets the preferred protocol of URL using the globally set preferred protocol.
|
323 |
+
* If global protocol not set, sets it by testing the download of a http test image from ShortPixel site.
|
324 |
* If http works then it's http, otherwise sets https
|
325 |
* @param string $url
|
326 |
* @param bool $reset - forces recheck even if preferred protocol is already set
|
334 |
$result = download_url($testURL, 10);
|
335 |
$this->_settings->downloadProto = is_wp_error( $result ) ? 'https' : 'http';
|
336 |
}
|
337 |
+
return $this->_settings->downloadProto == 'http' ?
|
338 |
str_replace('https://', 'http://', $url) :
|
339 |
str_replace('http://', 'https://', $url);
|
340 |
|
402 |
|
403 |
$correctFileSize = $optimizedSize;
|
404 |
$fileURL = $this->setPreferredProtocol(urldecode($optimizedUrl));
|
405 |
+
|
406 |
$tempFile = download_url($fileURL, $downloadTimeout);
|
407 |
WPShortPixel::log('Downloading file: '.json_encode($tempFile));
|
408 |
+
if(is_wp_error( $tempFile ))
|
409 |
{ //try to switch the default protocol
|
410 |
$fileURL = $this->setPreferredProtocol(urldecode($optimizedUrl), true); //force recheck of the protocol
|
411 |
$tempFile = download_url($fileURL, $downloadTimeout);
|
412 |
+
}
|
413 |
|
414 |
//on success we return this
|
415 |
$returnMessage = array("Status" => self::STATUS_SUCCESS, "Message" => $tempFile, "WebP" => $webpTempFile);
|
416 |
+
|
417 |
if ( is_wp_error( $tempFile ) ) {
|
418 |
@unlink($tempFile);
|
419 |
@unlink($webpTempFile);
|
420 |
$returnMessage = array(
|
421 |
+
"Status" => self::STATUS_ERROR,
|
422 |
"Code" => self::ERR_DOWNLOAD,
|
423 |
"Message" => __('Error downloading file','shortpixel-image-optimiser') . " ({$optimizedUrl}) " . $tempFile->get_error_message());
|
424 |
+
}
|
425 |
//check response so that download is OK
|
426 |
elseif (!file_exists($tempFile)) {
|
427 |
$returnMessage = array("Status" => self::STATUS_ERROR,
|
439 |
}
|
440 |
return $returnMessage;
|
441 |
}
|
442 |
+
|
443 |
public static function backupImage($mainPath, $PATHs) {
|
444 |
//$fullSubDir = str_replace(wp_normalize_path(get_home_path()), "", wp_normalize_path(dirname($itemHandler->getMeta()->getPath()))) . '/';
|
445 |
//$SubDir = ShortPixelMetaFacade::returnSubDir($itemHandler->getMeta()->getPath(), $itemHandler->getType());
|
454 |
|
455 |
foreach ( $source as $fileID => $filePATH )//create destination files array
|
456 |
{
|
457 |
+
$destination[$fileID] = SHORTPIXEL_BACKUP_FOLDER . '/' . $fullSubDir . self::MB_basename($source[$fileID]);
|
458 |
}
|
459 |
//die("IZ BACKUP: " . SHORTPIXEL_BACKUP_FOLDER . '/' . $SubDir . var_dump($destination));
|
460 |
|
461 |
//now that we have original files and where we should back them up we attempt to do just that
|
462 |
+
if(is_writable(SHORTPIXEL_BACKUP_FOLDER))
|
463 |
{
|
464 |
foreach ( $destination as $fileID => $filePATH )
|
465 |
{
|
466 |
if ( !file_exists($filePATH) )
|
467 |
+
{
|
468 |
if ( !@copy($source[$fileID], $filePATH) )
|
469 |
{//file couldn't be saved in backup folder
|
470 |
$msg = sprintf(__('Cannot save file <i>%s</i> in backup directory','shortpixel-image-optimiser'),self::MB_basename($source[$fileID]));
|
473 |
}
|
474 |
}
|
475 |
return array("Status" => self::STATUS_SUCCESS);
|
476 |
+
}
|
477 |
else {//cannot write to the backup dir, return with an error
|
478 |
$msg = __('Cannot save file in backup directory','shortpixel-image-optimiser');
|
479 |
return array("Status" => self::STATUS_FAIL, "Message" => $msg);
|
598 |
$tempFiles[$counter] = $downloadResult;
|
599 |
if ( $downloadResult['Status'] == self::STATUS_SUCCESS ) {
|
600 |
//nothing to do
|
601 |
+
}
|
602 |
//when the status is STATUS_UNCHANGED we just skip the array line for that one
|
603 |
elseif( $downloadResult['Status'] == self::STATUS_UNCHANGED ) {
|
604 |
//this image is unchanged so won't be copied below, only the optimization stats need to be computed
|
609 |
self::cleanupTemporaryFiles($archive, $tempFiles);
|
610 |
return array("Status" => $downloadResult['Status'], "Code" => $downloadResult['Code'], "Message" => $downloadResult['Message']);
|
611 |
}
|
612 |
+
|
613 |
+
}
|
614 |
else { //there was an error while trying to download a file
|
615 |
$tempFiles[$counter] = "";
|
616 |
}
|
643 |
{
|
644 |
//overwrite the original files with the optimized ones
|
645 |
foreach ( $tempFiles as $tempFileID => $tempFile )
|
646 |
+
{
|
647 |
if(!is_array($tempFile)) continue;
|
648 |
+
|
649 |
$targetFile = $PATHs[$tempFileID];
|
650 |
$isRetina = ShortPixelMetaFacade::isRetina($targetFile);
|
651 |
|
654 |
$thumbsOpt++;
|
655 |
$thumbsOptList[] = self::MB_basename($targetFile);
|
656 |
}
|
657 |
+
|
658 |
if($tempFile['Status'] == self::STATUS_SUCCESS) { //if it's unchanged it will still be in the array but only for WebP (handled below)
|
659 |
$tempFilePATH = $tempFile["Message"];
|
660 |
if ( file_exists($tempFilePATH) && file_exists($targetFile) && is_writable($targetFile) ) {
|
677 |
|
678 |
//add the number of files with < 5% optimization
|
679 |
if ( ( ( 1 - $APIresponse[$tempFileID]->$fileSize/$APIresponse[$tempFileID]->OriginalSize ) * 100 ) < 5 ) {
|
680 |
+
$this->_settings->under5Percent++;
|
681 |
}
|
682 |
+
}
|
683 |
else {
|
684 |
if($archive && SHORTPIXEL_DEBUG === true) {
|
685 |
if(!file_exists($tempFilePATH)) {
|
697 |
|
698 |
$tempWebpFilePATH = $tempFile["WebP"];
|
699 |
if(file_exists($tempWebpFilePATH)) {
|
700 |
+
$targetWebPFileCompat = dirname($targetFile) . '/'. self::MB_basename($targetFile, '.' . pathinfo($targetFile, PATHINFO_EXTENSION)) . ".webp";
|
701 |
+
$targetWebPFile = dirname($targetFile) . '/' . self::MB_basename($targetFile) . ".webp";
|
702 |
copy($tempWebpFilePATH, $targetWebPFile);
|
703 |
+
if(!file_exists($targetWebPFileCompat)) {
|
704 |
+
@symlink($targetWebPFile,$targetWebPFileCompat);
|
705 |
+
}
|
706 |
@unlink($tempWebpFilePATH);
|
707 |
}
|
708 |
}
|
722 |
return array("Status" => self::STATUS_FAIL, "Code" =>"write-fail", "Message" => $msg);
|
723 |
}
|
724 |
} elseif( 0 + $fileData->PercentImprovement < 5) {
|
725 |
+
$this->_settings->under5Percent++;
|
726 |
}
|
727 |
//old average counting
|
728 |
$this->_settings->savedSpace += $savedSpace;
|
732 |
//new average counting
|
733 |
$this->_settings->totalOriginal += $originalSpace;
|
734 |
$this->_settings->totalOptimized += $optimizedSpace;
|
735 |
+
|
736 |
//update metadata for this file
|
737 |
$meta = $itemHandler->getMeta();
|
738 |
// die(var_dump($percentImprovement));
|
741 |
}
|
742 |
$png2jpg = $meta->getPng2Jpg();
|
743 |
$png2jpg = is_array($png2jpg) ? $png2jpg['optimizationPercent'] : 0;
|
744 |
+
$meta->setMessage($originalSpace
|
745 |
? number_format(100.0 * (1.0 - $optimizedSpace / $originalSpace), 2)
|
746 |
: "Couldn't compute thumbs optimization percent. Main image: " . $percentImprovement);
|
747 |
WPShortPixel::log("HANDLE SUCCESS: Image optimization: ".$meta->getMessage());
|
764 |
$meta->setRetries($meta->getRetries() + 1);
|
765 |
$meta->setBackup(!$NoBackup);
|
766 |
$meta->setStatus(2);
|
767 |
+
|
768 |
$itemHandler->updateMeta($meta);
|
769 |
$itemHandler->optimizationSucceeded();
|
770 |
WPShortPixel::log("HANDLE SUCCESS: Metadata saved.");
|
772 |
if(!$originalSpace) { //das kann nicht sein, alles klar?!
|
773 |
throw new Exception("OriginalSpace = 0. APIResponse" . json_encode($APIresponse));
|
774 |
}
|
775 |
+
|
776 |
//we reset the retry counter in case of success
|
777 |
$this->_settings->apiRetries = 0;
|
778 |
+
|
779 |
return array("Status" => self::STATUS_SUCCESS, "Message" => 'Success: No pixels remained unsqueezed :-)',
|
780 |
"PercentImprovement" => $originalSpace
|
781 |
? number_format(100.0 * (1.0 - (1.0 - $png2jpg / 100.0) * $optimizedSpace / $originalSpace), 2)
|
820 |
$Base = str_replace($Separator, "", $Base);
|
821 |
return $Base;
|
822 |
}
|
823 |
+
|
824 |
/**
|
825 |
* sometimes, the paths to the files as defined in metadata are wrong, we try to automatically correct them
|
826 |
* @param array $PATHs
|
853 |
}
|
854 |
}
|
855 |
}
|
856 |
+
|
857 |
if ( $ErrorCount > 0 ) {
|
858 |
return array("error" => $missingFiles);//false;
|
859 |
} else {
|
867 |
}
|
868 |
return 0 + $compressionType == 2 ? 'glossy' : (0 + $compressionType == 1 ? 'lossy' : 'lossless');
|
869 |
}
|
870 |
+
|
871 |
static public function getCompressionTypeCode($compressionName) {
|
872 |
return $compressionName == 'glossy' ? 2 : ($compressionName == 'lossy' ? 1 : 0);
|
873 |
}
|
wp-shortpixel.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: ShortPixel Image Optimizer
|
4 |
* Plugin URI: https://shortpixel.com/
|
5 |
* Description: ShortPixel optimizes images automatically, while guarding the quality of your images. Check your <a href="options-general.php?page=wp-shortpixel" target="_blank">Settings > ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
|
6 |
-
* Version: 4.12.
|
7 |
* Author: ShortPixel
|
8 |
* Author URI: https://shortpixel.com
|
9 |
* Text Domain: shortpixel-image-optimiser
|
@@ -18,7 +18,7 @@ define('SHORTPIXEL_PLUGIN_FILE', __FILE__);
|
|
18 |
|
19 |
//define('SHORTPIXEL_AFFILIATE_CODE', '');
|
20 |
|
21 |
-
define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.12.
|
22 |
define('SHORTPIXEL_MAX_TIMEOUT', 10);
|
23 |
define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
|
24 |
define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');
|
@@ -38,10 +38,15 @@ require_once(ABSPATH . 'wp-admin/includes/file.php');
|
|
38 |
|
39 |
$sp__uploads = wp_upload_dir();
|
40 |
define('SHORTPIXEL_UPLOADS_BASE', (file_exists($sp__uploads['basedir']) ? '' : ABSPATH) . $sp__uploads['basedir'] );
|
41 |
-
define('SHORTPIXEL_UPLOADS_URL', is_main_site() ? $sp__uploads['baseurl'] : dirname(dirname($sp__uploads['baseurl'])));
|
42 |
define('SHORTPIXEL_UPLOADS_NAME', basename(is_main_site() ? SHORTPIXEL_UPLOADS_BASE : dirname(dirname(SHORTPIXEL_UPLOADS_BASE))));
|
43 |
$sp__backupBase = is_main_site() ? SHORTPIXEL_UPLOADS_BASE : dirname(dirname(SHORTPIXEL_UPLOADS_BASE));
|
44 |
define('SHORTPIXEL_BACKUP_FOLDER', $sp__backupBase . '/' . SHORTPIXEL_BACKUP);
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
/*
|
47 |
if ( is_numeric(SHORTPIXEL_MAX_EXECUTION_TIME) && SHORTPIXEL_MAX_EXECUTION_TIME > 10 )
|
3 |
* Plugin Name: ShortPixel Image Optimizer
|
4 |
* Plugin URI: https://shortpixel.com/
|
5 |
* Description: ShortPixel optimizes images automatically, while guarding the quality of your images. Check your <a href="options-general.php?page=wp-shortpixel" target="_blank">Settings > ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
|
6 |
+
* Version: 4.12.7
|
7 |
* Author: ShortPixel
|
8 |
* Author URI: https://shortpixel.com
|
9 |
* Text Domain: shortpixel-image-optimiser
|
18 |
|
19 |
//define('SHORTPIXEL_AFFILIATE_CODE', '');
|
20 |
|
21 |
+
define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.12.7");
|
22 |
define('SHORTPIXEL_MAX_TIMEOUT', 10);
|
23 |
define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
|
24 |
define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');
|
38 |
|
39 |
$sp__uploads = wp_upload_dir();
|
40 |
define('SHORTPIXEL_UPLOADS_BASE', (file_exists($sp__uploads['basedir']) ? '' : ABSPATH) . $sp__uploads['basedir'] );
|
41 |
+
//define('SHORTPIXEL_UPLOADS_URL', is_main_site() ? $sp__uploads['baseurl'] : dirname(dirname($sp__uploads['baseurl'])));
|
42 |
define('SHORTPIXEL_UPLOADS_NAME', basename(is_main_site() ? SHORTPIXEL_UPLOADS_BASE : dirname(dirname(SHORTPIXEL_UPLOADS_BASE))));
|
43 |
$sp__backupBase = is_main_site() ? SHORTPIXEL_UPLOADS_BASE : dirname(dirname(SHORTPIXEL_UPLOADS_BASE));
|
44 |
define('SHORTPIXEL_BACKUP_FOLDER', $sp__backupBase . '/' . SHORTPIXEL_BACKUP);
|
45 |
+
define('SHORTPIXEL_BACKUP_URL',
|
46 |
+
((is_main_site() || (defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL))
|
47 |
+
? $sp__uploads['baseurl']
|
48 |
+
: dirname(dirname($sp__uploads['baseurl'])))
|
49 |
+
. '/' . SHORTPIXEL_BACKUP);
|
50 |
|
51 |
/*
|
52 |
if ( is_numeric(SHORTPIXEL_MAX_EXECUTION_TIME) && SHORTPIXEL_MAX_EXECUTION_TIME > 10 )
|