Version Description
Release date August 17th 2020 * New: Small refactor of the way to handle ABSPATH; * Fix: jQuery browser ( IE 6.0 support removed ) for WordPress 5.5; * Fix: Always reset quota when doing check notice, to prevent hanging notices; * Compat: Addded Phoenix Media Rename plugin to the conflicting plugins list, because of the way they treat the ShortPixel metadata; * Language: 0 new strings added, 0 updated, 0 fuzzied, and 0 obsoleted.
Download this release
Release Info
Developer | petredobrescu |
Plugin | ShortPixel Image Optimizer |
Version | 4.20.0 |
Comparing to | |
See all releases |
Code changes from version 4.19.3 to 4.20.0
- class/Controller/FileSystemController.php +24 -2
- class/Model/DirectoryModel.php +1 -1
- class/Model/FileModel.php +31 -23
- class/Tools.php +4 -0
- class/db/shortpixel-meta-facade.php +1 -1
- class/front/img-to-picture-webp.php +15 -2
- class/wp-short-pixel.php +2 -2
- readme.txt +9 -1
- res/js/jquery.tooltip.js +1 -6
- res/js/jquery.tooltip.min.js +1 -1
- wp-shortpixel.php +2 -2
class/Controller/FileSystemController.php
CHANGED
@@ -101,7 +101,7 @@ Class FileSystemController extends \ShortPixel\Controller
|
|
101 |
public function getWPFileBase()
|
102 |
{
|
103 |
if(\wpSPIO()->env()->is_mainsite) {
|
104 |
-
$path =
|
105 |
} else {
|
106 |
$up = wp_upload_dir();
|
107 |
$path = realpath($up['basedir']);
|
@@ -114,14 +114,36 @@ Class FileSystemController extends \ShortPixel\Controller
|
|
114 |
|
115 |
}
|
116 |
|
|
|
|
|
|
|
|
|
117 |
public function getWPUploadBase()
|
118 |
{
|
119 |
$upload_dir = wp_upload_dir(null, false);
|
120 |
|
121 |
return $this->getDirectory($upload_dir['basedir']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
|
|
123 |
}
|
124 |
|
|
|
|
|
125 |
/** Not in use yet, do not use. Future replacement. */
|
126 |
public function createBackUpFolder($folder = SHORTPIXEL_BACKUP_FOLDER)
|
127 |
{
|
@@ -152,7 +174,7 @@ Class FileSystemController extends \ShortPixel\Controller
|
|
152 |
}
|
153 |
}
|
154 |
|
155 |
-
$wp_home_path =
|
156 |
// If the whole WP homepath is still in URL, assume the replace when wrong ( not replaced w/ URL)
|
157 |
// This happens when file is outside of wp_uploads_dir
|
158 |
if (strpos($url, $wp_home_path) !== false)
|
101 |
public function getWPFileBase()
|
102 |
{
|
103 |
if(\wpSPIO()->env()->is_mainsite) {
|
104 |
+
$path = (string) $this->getWPAbsPath();
|
105 |
} else {
|
106 |
$up = wp_upload_dir();
|
107 |
$path = realpath($up['basedir']);
|
114 |
|
115 |
}
|
116 |
|
117 |
+
/** This function returns the WordPress Basedir for uploads ( without date and such )
|
118 |
+
* Normally this would point to /wp-content/uploads.
|
119 |
+
* @returns DirectoryModel
|
120 |
+
*/
|
121 |
public function getWPUploadBase()
|
122 |
{
|
123 |
$upload_dir = wp_upload_dir(null, false);
|
124 |
|
125 |
return $this->getDirectory($upload_dir['basedir']);
|
126 |
+
}
|
127 |
+
|
128 |
+
/** This function returns the Absolute Path of the WordPress installation
|
129 |
+
* Normally this would be the same as ABSPATH, but there are installations out there with -cough- alternative approaches
|
130 |
+
* @returns DirectoryModel
|
131 |
+
*/
|
132 |
+
public function getWPAbsPath()
|
133 |
+
{
|
134 |
+
$wpContentAbs = str_replace( 'wp-content', '', WP_CONTENT_DIR);
|
135 |
+
if (ABSPATH == $wpContentAbs)
|
136 |
+
$abspath = ABSPATH;
|
137 |
+
else
|
138 |
+
$abspath = $wpContentAbs;
|
139 |
+
|
140 |
+
$abspath = apply_filters('shortpixel/filesystem/abspath', $abspath );
|
141 |
|
142 |
+
return $this->getDirectory($abspath);
|
143 |
}
|
144 |
|
145 |
+
|
146 |
+
|
147 |
/** Not in use yet, do not use. Future replacement. */
|
148 |
public function createBackUpFolder($folder = SHORTPIXEL_BACKUP_FOLDER)
|
149 |
{
|
174 |
}
|
175 |
}
|
176 |
|
177 |
+
$wp_home_path = (string) $this->getWPAbsPath();
|
178 |
// If the whole WP homepath is still in URL, assume the replace when wrong ( not replaced w/ URL)
|
179 |
// This happens when file is outside of wp_uploads_dir
|
180 |
if (strpos($url, $wp_home_path) !== false)
|
class/Model/DirectoryModel.php
CHANGED
@@ -126,7 +126,7 @@ class DirectoryModel extends \ShortPixel\Model
|
|
126 |
|
127 |
$install_dir = get_home_path();
|
128 |
if($install_dir == '/') {
|
129 |
-
$install_dir =
|
130 |
}
|
131 |
|
132 |
$install_dir = trailingslashit($install_dir);
|
126 |
|
127 |
$install_dir = get_home_path();
|
128 |
if($install_dir == '/') {
|
129 |
+
$install_dir = \wpSPIO()->filesystem()->getWPAbsPath();
|
130 |
}
|
131 |
|
132 |
$install_dir = trailingslashit($install_dir);
|
class/Model/FileModel.php
CHANGED
@@ -59,7 +59,6 @@ class FileModel extends \ShortPixel\Model
|
|
59 |
|
60 |
|
61 |
$info = $this->mb_pathinfo($this->fullpath);
|
62 |
-
|
63 |
// Todo, maybe replace this with splFileINfo.
|
64 |
if ($this->is_file()) // only set fileinfo when it's an actual file.
|
65 |
{
|
@@ -161,11 +160,12 @@ class FileModel extends \ShortPixel\Model
|
|
161 |
*/
|
162 |
public function getFileDir()
|
163 |
{
|
|
|
164 |
// create this only when needed.
|
165 |
-
if (is_null($this->directory) && strlen($
|
166 |
{
|
167 |
// Feed to full path to DirectoryModel since it checks if input is file, or dir. Using dirname here would cause errors when fullpath is already just a dirpath ( faulty input )
|
168 |
-
$this->directory = new DirectoryModel($
|
169 |
}
|
170 |
return $this->directory;
|
171 |
}
|
@@ -253,7 +253,7 @@ class FileModel extends \ShortPixel\Model
|
|
253 |
|
254 |
public function getFullPath()
|
255 |
{
|
256 |
-
if (is_null($this->filename))
|
257 |
$this->setFileInfo();
|
258 |
|
259 |
return $this->fullpath;
|
@@ -269,20 +269,25 @@ class FileModel extends \ShortPixel\Model
|
|
269 |
|
270 |
public function getFileBase()
|
271 |
{
|
272 |
-
if (is_null($this->
|
273 |
$this->setFileInfo();
|
274 |
|
275 |
return $this->filebase;
|
276 |
}
|
277 |
|
|
|
278 |
public function getExtension()
|
279 |
{
|
280 |
-
if (is_null($this->
|
281 |
$this->setFileInfo();
|
282 |
|
283 |
return $this->extension;
|
284 |
}
|
285 |
|
|
|
|
|
|
|
|
|
286 |
/* Util function to get location of backup Directory.
|
287 |
* @return Boolean | DirectModel Returns false if directory is not properly set, otherwhise with a new directoryModel
|
288 |
*/
|
@@ -330,11 +335,12 @@ class FileModel extends \ShortPixel\Model
|
|
330 |
|
331 |
$path = wp_normalize_path($path);
|
332 |
|
333 |
-
|
334 |
// if path does not contain basepath.
|
335 |
-
$
|
336 |
-
$
|
337 |
-
|
|
|
|
|
338 |
$path = $this->relativeToFullPath($path);
|
339 |
|
340 |
$path = apply_filters('shortpixel/filesystem/processFilePath', $path, $original_path);
|
@@ -352,7 +358,7 @@ class FileModel extends \ShortPixel\Model
|
|
352 |
{
|
353 |
$is_http = (substr($path, 0, 4) == 'http') ? true : false;
|
354 |
$is_https = (substr($path, 0, 5) == 'https') ? true : false;
|
355 |
-
$is_neutralscheme = (substr($path, 0,
|
356 |
$has_urldots = (strpos($path, '://') !== false) ? true : false;
|
357 |
|
358 |
if ($is_http || $is_https || $is_neutralscheme || $has_urldots)
|
@@ -366,19 +372,24 @@ class FileModel extends \ShortPixel\Model
|
|
366 |
private function UrlToPath($url)
|
367 |
{
|
368 |
//$uploadDir = wp_upload_dir();
|
|
|
369 |
$site_url = str_replace('http:', '', get_site_url(null, '', 'http'));
|
370 |
$url = str_replace(array('http:', 'https:'), '', $url);
|
371 |
|
372 |
if (strpos($url, $site_url) !== false)
|
373 |
{
|
374 |
// try to replace URL for Path
|
375 |
-
$
|
|
|
|
|
376 |
if (! $this->pathIsUrl($path)) // test again.
|
377 |
{
|
378 |
return $path;
|
379 |
}
|
380 |
}
|
381 |
|
|
|
|
|
382 |
return false; // seems URL from other server, can't file that.
|
383 |
}
|
384 |
|
@@ -413,7 +424,10 @@ class FileModel extends \ShortPixel\Model
|
|
413 |
return $path;
|
414 |
|
415 |
// Path contains upload basedir. This happens when upload dir is outside of usual WP.
|
416 |
-
|
|
|
|
|
|
|
417 |
{
|
418 |
return $path;
|
419 |
}
|
@@ -422,18 +436,19 @@ class FileModel extends \ShortPixel\Model
|
|
422 |
// this is probably a bit of a sharp corner to take.
|
423 |
// if path starts with / remove it due to trailingslashing ABSPATH
|
424 |
$path = ltrim($path, '/');
|
425 |
-
$fullpath =
|
426 |
// We can't test for file_exists here, since file_model allows non-existing files.
|
427 |
return $fullpath;
|
428 |
}
|
429 |
|
430 |
-
private function getUploadPath()
|
431 |
{
|
432 |
$upload_dir = wp_upload_dir(null, false, false);
|
433 |
$basedir = $upload_dir['basedir'];
|
434 |
|
435 |
return $basedir;
|
436 |
-
}
|
|
|
437 |
|
438 |
/** Fix for multibyte pathnames and pathinfo which doesn't take into regard the locale.
|
439 |
* This snippet taken from PHPMailer.
|
@@ -476,10 +491,3 @@ class FileModel extends \ShortPixel\Model
|
|
476 |
|
477 |
|
478 |
} // FileModel Class
|
479 |
-
|
480 |
-
/*
|
481 |
-
// do this before putting the meta down, since maybeDump check for last timestamp
|
482 |
-
$URLsAndPATHs = $itemHandler->getURLsAndPATHs(false);
|
483 |
-
$this->maybeDumpFromProcessedOnServer($itemHandler, $URLsAndPATHs);
|
484 |
-
|
485 |
-
*/
|
59 |
|
60 |
|
61 |
$info = $this->mb_pathinfo($this->fullpath);
|
|
|
62 |
// Todo, maybe replace this with splFileINfo.
|
63 |
if ($this->is_file()) // only set fileinfo when it's an actual file.
|
64 |
{
|
160 |
*/
|
161 |
public function getFileDir()
|
162 |
{
|
163 |
+
$fullpath = $this->getFullPath(); // triggers a file lookup if needed.
|
164 |
// create this only when needed.
|
165 |
+
if (is_null($this->directory) && strlen($fullpath) > 0)
|
166 |
{
|
167 |
// Feed to full path to DirectoryModel since it checks if input is file, or dir. Using dirname here would cause errors when fullpath is already just a dirpath ( faulty input )
|
168 |
+
$this->directory = new DirectoryModel($fullpath);
|
169 |
}
|
170 |
return $this->directory;
|
171 |
}
|
253 |
|
254 |
public function getFullPath()
|
255 |
{
|
256 |
+
if (is_null($this->filename)) // filename here since fullpath is set unchecked in constructor, but might be a different take
|
257 |
$this->setFileInfo();
|
258 |
|
259 |
return $this->fullpath;
|
269 |
|
270 |
public function getFileBase()
|
271 |
{
|
272 |
+
if (is_null($this->filebase))
|
273 |
$this->setFileInfo();
|
274 |
|
275 |
return $this->filebase;
|
276 |
}
|
277 |
|
278 |
+
|
279 |
public function getExtension()
|
280 |
{
|
281 |
+
if (is_null($this->extension))
|
282 |
$this->setFileInfo();
|
283 |
|
284 |
return $this->extension;
|
285 |
}
|
286 |
|
287 |
+
public function getMime()
|
288 |
+
{
|
289 |
+
return wp_get_image_mime($this->fullpath);
|
290 |
+
}
|
291 |
/* Util function to get location of backup Directory.
|
292 |
* @return Boolean | DirectModel Returns false if directory is not properly set, otherwhise with a new directoryModel
|
293 |
*/
|
335 |
|
336 |
$path = wp_normalize_path($path);
|
337 |
|
|
|
338 |
// if path does not contain basepath.
|
339 |
+
$fs = \wpSPIO()->filesystem();
|
340 |
+
$uploadDir = $fs->getWPUploadBase();
|
341 |
+
$abspath = $fs->getWPAbsPath();
|
342 |
+
|
343 |
+
if (strpos($path, $abspath->getPath()) === false && strpos($path, $uploadDir->getPath()) === false)
|
344 |
$path = $this->relativeToFullPath($path);
|
345 |
|
346 |
$path = apply_filters('shortpixel/filesystem/processFilePath', $path, $original_path);
|
358 |
{
|
359 |
$is_http = (substr($path, 0, 4) == 'http') ? true : false;
|
360 |
$is_https = (substr($path, 0, 5) == 'https') ? true : false;
|
361 |
+
$is_neutralscheme = (substr($path, 0, 2) == '//') ? true : false; // when URL is relative like //wp-content/etc
|
362 |
$has_urldots = (strpos($path, '://') !== false) ? true : false;
|
363 |
|
364 |
if ($is_http || $is_https || $is_neutralscheme || $has_urldots)
|
372 |
private function UrlToPath($url)
|
373 |
{
|
374 |
//$uploadDir = wp_upload_dir();
|
375 |
+
|
376 |
$site_url = str_replace('http:', '', get_site_url(null, '', 'http'));
|
377 |
$url = str_replace(array('http:', 'https:'), '', $url);
|
378 |
|
379 |
if (strpos($url, $site_url) !== false)
|
380 |
{
|
381 |
// try to replace URL for Path
|
382 |
+
$abspath = \wpSPIO()->filesystem()->getWPAbsPath();
|
383 |
+
$path = str_replace($site_url, rtrim($abspath->getPath(),'/'), $url);
|
384 |
+
|
385 |
if (! $this->pathIsUrl($path)) // test again.
|
386 |
{
|
387 |
return $path;
|
388 |
}
|
389 |
}
|
390 |
|
391 |
+
|
392 |
+
|
393 |
return false; // seems URL from other server, can't file that.
|
394 |
}
|
395 |
|
424 |
return $path;
|
425 |
|
426 |
// Path contains upload basedir. This happens when upload dir is outside of usual WP.
|
427 |
+
$fs = \wpSPIO()->filesystem();
|
428 |
+
$uploadDir = $fs->getWPUploadBase();
|
429 |
+
$abspath = $fs->getWPAbsPath();
|
430 |
+
if (strpos($path, $uploadDir->getPath()) !== false)
|
431 |
{
|
432 |
return $path;
|
433 |
}
|
436 |
// this is probably a bit of a sharp corner to take.
|
437 |
// if path starts with / remove it due to trailingslashing ABSPATH
|
438 |
$path = ltrim($path, '/');
|
439 |
+
$fullpath = $abspath->getPath() . $path;
|
440 |
// We can't test for file_exists here, since file_model allows non-existing files.
|
441 |
return $fullpath;
|
442 |
}
|
443 |
|
444 |
+
/*private function getUploadPath()
|
445 |
{
|
446 |
$upload_dir = wp_upload_dir(null, false, false);
|
447 |
$basedir = $upload_dir['basedir'];
|
448 |
|
449 |
return $basedir;
|
450 |
+
} */
|
451 |
+
|
452 |
|
453 |
/** Fix for multibyte pathnames and pathinfo which doesn't take into regard the locale.
|
454 |
* This snippet taken from PHPMailer.
|
491 |
|
492 |
|
493 |
} // FileModel Class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class/Tools.php
CHANGED
@@ -164,6 +164,10 @@ static public function formatBytes($bytes, $precision = 2) {
|
|
164 |
'data'=>'optimus/optimus.php',
|
165 |
'page'=>'optimus'
|
166 |
),
|
|
|
|
|
|
|
|
|
167 |
'EWWW Image Optimizer'
|
168 |
=> array(
|
169 |
'action'=>'Deactivate',
|
164 |
'data'=>'optimus/optimus.php',
|
165 |
'page'=>'optimus'
|
166 |
),
|
167 |
+
'Phoenix Media Rename' => array(
|
168 |
+
'action' => 'Deactivate',
|
169 |
+
'data' => 'phoenix-media-rename/phoenix-media-rename.php',
|
170 |
+
),
|
171 |
'EWWW Image Optimizer'
|
172 |
=> array(
|
173 |
'action'=>'Deactivate',
|
class/db/shortpixel-meta-facade.php
CHANGED
@@ -1050,7 +1050,7 @@ class ShortPixelMetaFacade {
|
|
1050 |
|
1051 |
$homePath = get_home_path();
|
1052 |
if($homePath == '/') {
|
1053 |
-
$homePath =
|
1054 |
}
|
1055 |
$hp = wp_normalize_path($homePath);
|
1056 |
$file = wp_normalize_path($file);
|
1050 |
|
1051 |
$homePath = get_home_path();
|
1052 |
if($homePath == '/') {
|
1053 |
+
$homePath = \wpSPIO()->filesystem()->getWPAbsPath();
|
1054 |
}
|
1055 |
$hp = wp_normalize_path($homePath);
|
1056 |
$file = wp_normalize_path($file);
|
class/front/img-to-picture-webp.php
CHANGED
@@ -194,6 +194,7 @@ class ShortPixelImgToPictureWebp
|
|
194 |
}
|
195 |
|
196 |
// $defs = explode(",", $srcset);
|
|
|
197 |
|
198 |
foreach ($definitions as $item) {
|
199 |
$parts = preg_split('/\s+/', trim($item));
|
@@ -205,6 +206,7 @@ class ShortPixelImgToPictureWebp
|
|
205 |
|
206 |
$fsFile = $fs->getFile($fileurl);
|
207 |
$extension = $fsFile->getExtension(); // trigger setFileinfo, which will resolve URL -> Path
|
|
|
208 |
|
209 |
$fileWebp = $fs->getFile($imageBase . $fsFile->getFileBase() . '.webp');
|
210 |
$fileWebpCompat = $fs->getFile($imageBase . $fsFile->getFileName() . '.webp');
|
@@ -293,7 +295,7 @@ class ShortPixelImgToPictureWebp
|
|
293 |
|
294 |
return '<picture ' . $this->create_attributes($imgpicture) . '>'
|
295 |
.'<source ' . $srcsetPrefix . 'srcset="' . $srcsetWebP . '"' . ($sizes ? ' ' . $sizesPrefix . 'sizes="' . $sizes . '"' : '') . ' type="image/webp">'
|
296 |
-
.'<source ' . $srcsetPrefix . 'srcset="' . $srcset . '"' . ($sizes ? ' ' . $sizesPrefix . 'sizes="' . $sizes . '"' : '') . '>'
|
297 |
.'<img ' . $srcPrefix . 'src="' . $src . '" ' . $this->create_attributes($img) . $idAttr . $altAttr . $heightAttr . $widthAttr
|
298 |
. (strlen($srcset) ? ' srcset="' . $srcset . '"': '') . (strlen($sizes) ? ' sizes="' . $sizes . '"': '') . '>'
|
299 |
.'</picture>';
|
@@ -415,6 +417,14 @@ class ShortPixelImgToPictureWebp
|
|
415 |
**/
|
416 |
public function getImageBase($src)
|
417 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
418 |
$urlParsed = parse_url($src);
|
419 |
if(!isset($urlParsed['host'])) {
|
420 |
if($src[0] == '/') { //absolute URL, current domain
|
@@ -426,6 +436,8 @@ class ShortPixelImgToPictureWebp
|
|
426 |
$urlParsed = parse_url($src);
|
427 |
}
|
428 |
$updir = wp_upload_dir();
|
|
|
|
|
429 |
if(substr($src, 0, 2) == '//') {
|
430 |
$src = (stripos($_SERVER['SERVER_PROTOCOL'],'https') === false ? 'http:' : 'https:') . $src;
|
431 |
}
|
@@ -442,6 +454,7 @@ class ShortPixelImgToPictureWebp
|
|
442 |
}
|
443 |
|
444 |
$imageBase = str_replace($updir['baseurl'], SHORTPIXEL_UPLOADS_BASE, $src);
|
|
|
445 |
if ($imageBase == $src) { //for themes images or other non-uploads paths
|
446 |
$imageBase = str_replace(content_url(), WP_CONTENT_DIR, $src);
|
447 |
}
|
@@ -464,7 +477,7 @@ class ShortPixelImgToPictureWebp
|
|
464 |
|
465 |
Log::addDebug('Webp Image Base found: ' . $imageBase);
|
466 |
$imageBase = trailingslashit(dirname($imageBase));
|
467 |
-
return $imageBase;
|
468 |
}
|
469 |
|
470 |
public function get_attributes($image_node)
|
194 |
}
|
195 |
|
196 |
// $defs = explode(",", $srcset);
|
197 |
+
$mime = ''; // inint
|
198 |
|
199 |
foreach ($definitions as $item) {
|
200 |
$parts = preg_split('/\s+/', trim($item));
|
206 |
|
207 |
$fsFile = $fs->getFile($fileurl);
|
208 |
$extension = $fsFile->getExtension(); // trigger setFileinfo, which will resolve URL -> Path
|
209 |
+
$mime = $fsFile->getMime();
|
210 |
|
211 |
$fileWebp = $fs->getFile($imageBase . $fsFile->getFileBase() . '.webp');
|
212 |
$fileWebpCompat = $fs->getFile($imageBase . $fsFile->getFileName() . '.webp');
|
295 |
|
296 |
return '<picture ' . $this->create_attributes($imgpicture) . '>'
|
297 |
.'<source ' . $srcsetPrefix . 'srcset="' . $srcsetWebP . '"' . ($sizes ? ' ' . $sizesPrefix . 'sizes="' . $sizes . '"' : '') . ' type="image/webp">'
|
298 |
+
.'<source ' . $srcsetPrefix . 'srcset="' . $srcset . '"' . ($sizes ? ' ' . $sizesPrefix . 'sizes="' . $sizes . '"' : '') . ' type="' . $mime . '">'
|
299 |
.'<img ' . $srcPrefix . 'src="' . $src . '" ' . $this->create_attributes($img) . $idAttr . $altAttr . $heightAttr . $widthAttr
|
300 |
. (strlen($srcset) ? ' srcset="' . $srcset . '"': '') . (strlen($sizes) ? ' sizes="' . $sizes . '"': '') . '>'
|
301 |
.'</picture>';
|
417 |
**/
|
418 |
public function getImageBase($src)
|
419 |
{
|
420 |
+
|
421 |
+
$fs = \wpSPIO()->filesystem();
|
422 |
+
$fileObj = $fs->getFile($src);
|
423 |
+
$fileDir = $fileObj->getFileDir();
|
424 |
+
|
425 |
+
return $fileObj->getFileDir(); // Testing, the rest might be unneeded.
|
426 |
+
/*
|
427 |
+
|
428 |
$urlParsed = parse_url($src);
|
429 |
if(!isset($urlParsed['host'])) {
|
430 |
if($src[0] == '/') { //absolute URL, current domain
|
436 |
$urlParsed = parse_url($src);
|
437 |
}
|
438 |
$updir = wp_upload_dir();
|
439 |
+
|
440 |
+
|
441 |
if(substr($src, 0, 2) == '//') {
|
442 |
$src = (stripos($_SERVER['SERVER_PROTOCOL'],'https') === false ? 'http:' : 'https:') . $src;
|
443 |
}
|
454 |
}
|
455 |
|
456 |
$imageBase = str_replace($updir['baseurl'], SHORTPIXEL_UPLOADS_BASE, $src);
|
457 |
+
|
458 |
if ($imageBase == $src) { //for themes images or other non-uploads paths
|
459 |
$imageBase = str_replace(content_url(), WP_CONTENT_DIR, $src);
|
460 |
}
|
477 |
|
478 |
Log::addDebug('Webp Image Base found: ' . $imageBase);
|
479 |
$imageBase = trailingslashit(dirname($imageBase));
|
480 |
+
return $imageBase; */
|
481 |
}
|
482 |
|
483 |
public function get_attributes($image_node)
|
class/wp-short-pixel.php
CHANGED
@@ -2590,7 +2590,7 @@ class WPShortPixel {
|
|
2590 |
$result = $this->getQuotaInformation();
|
2591 |
|
2592 |
// If quota still exceeds, and manual check is requests, reset notices to update on situation.
|
2593 |
-
if ($this->_settings->quotaExceeded)
|
2594 |
AdminNoticesController::resetQuotaNotices();
|
2595 |
// store the referring webpage location
|
2596 |
$sendback = wp_get_referer();
|
@@ -2696,7 +2696,7 @@ class WPShortPixel {
|
|
2696 |
Log::addDebug("CURRENT STATS (not older than $time) ARE BEING CALCULATED...");
|
2697 |
if (! is_array($quotaData))
|
2698 |
$quotaData = array(); // quality control, we had issues here.
|
2699 |
-
|
2700 |
$imageCount = WpShortPixelMediaLbraryAdapter::countAllProcessable($this->_settings);
|
2701 |
$quotaData['time'] = time();
|
2702 |
$quotaData['optimizePdfs'] = $this->_settings->optimizePdfs;
|
2590 |
$result = $this->getQuotaInformation();
|
2591 |
|
2592 |
// If quota still exceeds, and manual check is requests, reset notices to update on situation.
|
2593 |
+
//if ($this->_settings->quotaExceeded) /// always do this. In case quota was exceeded, but not anymore, notices get stuck
|
2594 |
AdminNoticesController::resetQuotaNotices();
|
2595 |
// store the referring webpage location
|
2596 |
$sendback = wp_get_referer();
|
2696 |
Log::addDebug("CURRENT STATS (not older than $time) ARE BEING CALCULATED...");
|
2697 |
if (! is_array($quotaData))
|
2698 |
$quotaData = array(); // quality control, we had issues here.
|
2699 |
+
|
2700 |
$imageCount = WpShortPixelMediaLbraryAdapter::countAllProcessable($this->_settings);
|
2701 |
$quotaData['time'] = time();
|
2702 |
$quotaData['optimizePdfs'] = $this->_settings->optimizePdfs;
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: convert webp, optimize images, image optimization, resize, compressor, ima
|
|
4 |
Requires at least: 3.2.0
|
5 |
Tested up to: 5.5
|
6 |
Requires PHP: 5.3
|
7 |
-
Stable tag: 4.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -299,6 +299,14 @@ Hide the Cloudflare settings by defining these constants in wp-config.php:
|
|
299 |
9. Check other optimized images status - themes or other plugins' images. (Media>Other Media)
|
300 |
|
301 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
302 |
|
303 |
= 4.19.3 =
|
304 |
|
4 |
Requires at least: 3.2.0
|
5 |
Tested up to: 5.5
|
6 |
Requires PHP: 5.3
|
7 |
+
Stable tag: 4.20.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
299 |
9. Check other optimized images status - themes or other plugins' images. (Media>Other Media)
|
300 |
|
301 |
== Changelog ==
|
302 |
+
= 4.20.0 =
|
303 |
+
|
304 |
+
Release date August 17th 2020
|
305 |
+
* New: Small refactor of the way to handle ABSPATH;
|
306 |
+
* Fix: jQuery browser ( IE 6.0 support removed ) for WordPress 5.5;
|
307 |
+
* Fix: Always reset quota when doing check notice, to prevent hanging notices;
|
308 |
+
* Compat: Addded Phoenix Media Rename plugin to the conflicting plugins list, because of the way they treat the ShortPixel metadata;
|
309 |
+
* Language: 0 new strings added, 0 updated, 0 fuzzied, and 0 obsoleted.
|
310 |
|
311 |
= 4.19.3 =
|
312 |
|
res/js/jquery.tooltip.js
CHANGED
@@ -78,9 +78,7 @@
|
|
78 |
|
79 |
$('#'+s.tooltipID+' #tooltipContent').show();
|
80 |
|
81 |
-
|
82 |
-
$('#'+s.tooltipID).append('<iframe id="tooltipIE6FixIframe" style="width:'+($('#'+s.tooltipID).width()+parseFloat(s.borderSize)+parseFloat(s.borderSize)+20)+'px;height:'+($('#'+s.tooltipID).height()+parseFloat(s.borderSize)+parseFloat(s.borderSize)+20)+'px;position:absolute;top:-'+s.borderSize+'px;left:-'+s.borderSize+'px;filter:alpha(opacity=0);"src="blank.html"></iframe>');
|
83 |
-
};
|
84 |
}
|
85 |
|
86 |
var hideTooltip = function(valueOfThis){
|
@@ -148,9 +146,6 @@
|
|
148 |
s.tooltipSourceID = $(this).attr('href') || s.tooltipSourceID;
|
149 |
s.tooltipSourceURL = $(this).attr('href') || s.tooltipSourceURL;
|
150 |
|
151 |
-
console.log(s.tooltipSourceID);
|
152 |
-
console.log(s.tooltipSourceURL);
|
153 |
-
|
154 |
switch(s.tooltipSource){
|
155 |
case 'attribute':/*/////////////////////////////// attribute //////////////////////////////////////////*/
|
156 |
$ttContent.text(s.titleAttributeContent);
|
78 |
|
79 |
$('#'+s.tooltipID+' #tooltipContent').show();
|
80 |
|
81 |
+
|
|
|
|
|
82 |
}
|
83 |
|
84 |
var hideTooltip = function(valueOfThis){
|
146 |
s.tooltipSourceID = $(this).attr('href') || s.tooltipSourceID;
|
147 |
s.tooltipSourceURL = $(this).attr('href') || s.tooltipSourceURL;
|
148 |
|
|
|
|
|
|
|
149 |
switch(s.tooltipSource){
|
150 |
case 'attribute':/*/////////////////////////////// attribute //////////////////////////////////////////*/
|
151 |
$ttContent.text(s.titleAttributeContent);
|
res/js/jquery.tooltip.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(t){t.fn.spTooltip=function(o){t.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=t.extend({},t.fn.spTooltip.defaultsSettings,o||{}),i=function(o){o.preventDefault();var i=0,
|
1 |
+
!function(t){t.fn.spTooltip=function(o){t.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=t.extend({},t.fn.spTooltip.defaultsSettings,o||{}),i=function(o){o.preventDefault();var i=0,n=0;if(!o)o=window.event;o.pageX||o.pageY?(i=o.pageX,n=o.pageY):(o.clientX||o.clientY)&&(i=o.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,n=o.clientY+document.body.scrollTop+document.documentElement.scrollTop);var l={x:i+e.positionLeft,y:n+e.positionTop,w:t("#"+e.tooltipID).width(),h:t("#"+e.tooltipID).height()},r={x:t(window).scrollLeft(),y:t(window).scrollTop(),w:t(window).width()-20,h:t(window).height()-20};l.y+l.h>r.y+r.h&&l.x+l.w>r.x+r.w?(l.x=l.x-l.w-45,l.y=l.y-l.h-45):l.x+l.w>r.x+r.w?l.x=l.x-(l.x+l.w-(r.x+r.w)+20):l.y+l.h>r.y+r.h&&(l.y=l.y-(l.y+l.h-(r.y+r.h)+20)),t("#"+e.tooltipID).css({left:l.x+"px",top:l.y+"px"})},n=function(){t("#tooltipLoader").remove(),t("#"+e.tooltipID+" #tooltipContent").show()},l=function(o){t("#"+e.tooltipID).fadeOut("fast").trigger("unload").remove(),t(o).filter("[title]")&&t(o).attr("title",e.titleAttributeContent)},r=function(t){var o={};return t.replace(/b([^&=]*)=([^&=]*)b/g,function(t,e,i){void 0!==o[e]?o[e]+=","+i:o[e]=i}),o};return this.each(function(o){function p(o){t("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 p=t("#"+e.tooltipID),a=t("#"+e.tooltipID+" #tooltipContent");switch(e.loader&&""!=e.loaderImagePath&&p.append('<div id="tooltipLoader" style="width:'+e.loaderWidth+"px;height:"+e.loaderHeight+'px;"><img src="'+e.loaderImagePath+'" /></div>'),t(this).attr("title")&&(e.titleAttributeContent=t(this).attr("title"),t(this).attr("title","")),t(this).is("input")&&t(this).focus(function(){l(this)}),o.preventDefault(),i(o),p.show(),e.tooltipSourceID=t(this).attr("href")||e.tooltipSourceID,e.tooltipSourceURL=t(this).attr("href")||e.tooltipSourceURL,e.tooltipSource){case"attribute":a.text(e.titleAttributeContent),n();break;case"inline":a.html(t(e.tooltipSourceID).children()),p.unload(function(){t(e.tooltipSourceID).html(a.children())}),n();break;case"ajax":if("post"==e.tooltipHTTPType){var d,u;-1!==e.tooltipSourceURL.indexOf("?")?(d=e.windowSourceURL.substr(0,e.windowSourceURL.indexOf("?")),u=r(e.tooltipSourceURL)):(d=e.tooltipSourceURL,u={}),a.load(d,u,function(){n()})}else-1==e.tooltipSourceURL.indexOf("?")&&(e.tooltipSourceURL+="?"),a.load(e.tooltipSourceURL+"&random="+(new Date).getTime(),function(){n()})}return!1}function a(t){return l(this),!1}e.cancelClick&&t(this).bind("click",function(){return!1}),t.fn.hoverIntent?t(this).hoverIntent({sensitivity:e.hoverIntent.sensitivity,interval:e.hoverIntent.interval,over:p,timeout:e.hoverIntent.timeout,out:a}):t(this).hover(p,a),e.followMouse&&t(this).bind("mousemove",function(t){return i(t),!1})})}}(jQuery);
|
wp-shortpixel.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: ShortPixel Image Optimizer
|
4 |
* Plugin URI: https://shortpixel.com/
|
5 |
* Description: ShortPixel optimizes images automatically, while guarding the quality of your images. Check your <a href="options-general.php?page=wp-shortpixel-settings" target="_blank">Settings > ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
|
6 |
-
* Version: 4.
|
7 |
* Author: ShortPixel
|
8 |
* Author URI: https://shortpixel.com
|
9 |
* Text Domain: shortpixel-image-optimiser
|
@@ -32,7 +32,7 @@ define('SHORTPIXEL_PLUGIN_DIR', __DIR__);
|
|
32 |
|
33 |
//define('SHORTPIXEL_AFFILIATE_CODE', '');
|
34 |
|
35 |
-
define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.
|
36 |
define('SHORTPIXEL_MAX_TIMEOUT', 10);
|
37 |
define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
|
38 |
define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');
|
3 |
* Plugin Name: ShortPixel Image Optimizer
|
4 |
* Plugin URI: https://shortpixel.com/
|
5 |
* Description: ShortPixel optimizes images automatically, while guarding the quality of your images. Check your <a href="options-general.php?page=wp-shortpixel-settings" target="_blank">Settings > ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
|
6 |
+
* Version: 4.20.0
|
7 |
* Author: ShortPixel
|
8 |
* Author URI: https://shortpixel.com
|
9 |
* Text Domain: shortpixel-image-optimiser
|
32 |
|
33 |
//define('SHORTPIXEL_AFFILIATE_CODE', '');
|
34 |
|
35 |
+
define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.20.0");
|
36 |
define('SHORTPIXEL_MAX_TIMEOUT', 10);
|
37 |
define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
|
38 |
define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');
|