Version Description
- fix backup thumbnail js error
Download this release
Release Info
Developer | ShortPixel |
Plugin | ShortPixel Image Optimizer |
Version | 4.1.7 |
Comparing to | |
See all releases |
Code changes from version 4.1.5 to 4.1.7
- readme.txt +10 -1
- res/js/short-pixel.js +9 -5
- shortpixel_api.php +56 -45
- wp-shortpixel.php +2 -2
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: image optimizer, image optimization, compress pdf, compress jpeg, compress
|
|
5 |
|
6 |
Requires at least: 3.2.0
|
7 |
Tested up to: 4.6
|
8 |
-
Stable tag: 4.1.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -178,6 +178,15 @@ The ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Co
|
|
178 |
|
179 |
== Changelog ==
|
180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
= 4.1.5 =
|
182 |
|
183 |
* readme updates - links to informative articles
|
5 |
|
6 |
Requires at least: 3.2.0
|
7 |
Tested up to: 4.6
|
8 |
+
Stable tag: 4.1.7
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
178 |
|
179 |
== Changelog ==
|
180 |
|
181 |
+
= 4.1.7 =
|
182 |
+
|
183 |
+
* fix backup thumbnail js error
|
184 |
+
|
185 |
+
= 4.1.6 =
|
186 |
+
|
187 |
+
* fix processing for sites with caps path like http://mysite.com/My-Path/
|
188 |
+
* fix WebP generation for images that are already optimized
|
189 |
+
|
190 |
= 4.1.5 =
|
191 |
|
192 |
* readme updates - links to informative articles
|
res/js/short-pixel.js
CHANGED
@@ -371,11 +371,12 @@ function checkQuotaExceededAlert() {
|
|
371 |
*/
|
372 |
function checkBulkProgress() {
|
373 |
var url = window.location.href.toLowerCase();
|
374 |
-
|
375 |
-
|
376 |
-
&& url.search(
|
377 |
-
&& url.search(
|
378 |
-
&& url.search(
|
|
|
379 |
&& url.search("page=nggallery-manage-gallery") < 0
|
380 |
&& (ShortPixel.FRONT_BOOTSTRAP == 0 || url.search(ShortPixel.WP_ADMIN_URL) == 0)
|
381 |
) {
|
@@ -687,6 +688,9 @@ function sliderUpdate(id, thumb, bkThumb, percent, filename){
|
|
687 |
}
|
688 |
oldSlide.css("z-index", 1000);
|
689 |
jQuery(".bulk-img-opt", oldSlide).attr("src", "");
|
|
|
|
|
|
|
690 |
if(bkThumb.length > 0) {
|
691 |
jQuery(".bulk-img-orig", oldSlide).attr("src", "");
|
692 |
}
|
371 |
*/
|
372 |
function checkBulkProgress() {
|
373 |
var url = window.location.href.toLowerCase();
|
374 |
+
var adminUrl = ShortPixel.WP_ADMIN_URL.toLowerCase();
|
375 |
+
if( url.search(adminUrl + "upload.php") < 0
|
376 |
+
&& url.search(adminUrl + "edit.php") < 0
|
377 |
+
&& url.search(adminUrl + "edit-tags.php") < 0
|
378 |
+
&& url.search(adminUrl + "post-new.php") < 0
|
379 |
+
&& url.search(adminUrl + "post.php") < 0
|
380 |
&& url.search("page=nggallery-manage-gallery") < 0
|
381 |
&& (ShortPixel.FRONT_BOOTSTRAP == 0 || url.search(ShortPixel.WP_ADMIN_URL) == 0)
|
382 |
) {
|
688 |
}
|
689 |
oldSlide.css("z-index", 1000);
|
690 |
jQuery(".bulk-img-opt", oldSlide).attr("src", "");
|
691 |
+
if(typeof bkThumb === 'undefined') {
|
692 |
+
bkThumb = '';
|
693 |
+
}
|
694 |
if(bkThumb.length > 0) {
|
695 |
jQuery(".bulk-img-orig", oldSlide).attr("src", "");
|
696 |
}
|
shortpixel_api.php
CHANGED
@@ -308,14 +308,21 @@ class ShortPixelAPI {
|
|
308 |
$webpSize = "WebPLosslessSize";
|
309 |
}
|
310 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
//if there is no improvement in size then we do not download this file
|
312 |
if ( $fileData->OriginalSize == $fileData->$fileSize )
|
313 |
-
return array("Status" => self::STATUS_UNCHANGED, "Message" => "File wasn't optimized so we do not download it.");
|
314 |
|
315 |
$correctFileSize = $fileData->$fileSize;
|
316 |
$fileURL = $this->setPreferredProtocol(urldecode($fileData->$fileType));
|
317 |
|
318 |
-
$downloadTimeout = max(ini_get('max_execution_time') - 10, 15);
|
319 |
$tempFile = download_url($fileURL, $downloadTimeout);
|
320 |
if(is_wp_error( $tempFile ))
|
321 |
{ //try to switch the default protocol
|
@@ -323,13 +330,8 @@ class ShortPixelAPI {
|
|
323 |
$tempFile = download_url($fileURL, $downloadTimeout);
|
324 |
}
|
325 |
|
326 |
-
if($webpType !== "NA") {
|
327 |
-
$webpURL = $this->setPreferredProtocol(urldecode($fileData->$webpType));
|
328 |
-
$webpTempFile = download_url($webpURL, $downloadTimeout);
|
329 |
-
}
|
330 |
-
|
331 |
//on success we return this
|
332 |
-
$returnMessage = array("Status" => self::STATUS_SUCCESS, "Message" => $tempFile, "WebP" =>
|
333 |
|
334 |
if ( is_wp_error( $tempFile ) ) {
|
335 |
@unlink($tempFile);
|
@@ -376,16 +378,19 @@ class ShortPixelAPI {
|
|
376 |
$this->_settings->thumbsCount = $this->_settings->thumbsCount + 1;
|
377 |
}
|
378 |
$downloadResult = $this->handleDownload($fileData,$compressionType);
|
|
|
379 |
if ( $downloadResult['Status'] == self::STATUS_SUCCESS ) {
|
380 |
$tempFiles[$counter] = $downloadResult;
|
381 |
}
|
382 |
//when the status is STATUS_UNCHANGED we just skip the array line for that one
|
383 |
-
elseif
|
384 |
-
|
385 |
-
}
|
386 |
-
else { //this image is unchanged so won't be copied below, only the optimization stats need to be computed
|
387 |
$originalSpace += $fileData->OriginalSize;
|
388 |
$optimizedSpace += $fileData->$fileType;
|
|
|
|
|
|
|
|
|
389 |
}
|
390 |
|
391 |
}
|
@@ -394,7 +399,7 @@ class ShortPixelAPI {
|
|
394 |
}
|
395 |
$counter++;
|
396 |
}
|
397 |
-
|
398 |
//figure out in what SubDir files should land
|
399 |
//#$SubDir = $this->returnSubDir(get_attached_file($ID));
|
400 |
$fullSubDir = str_replace(wp_normalize_path(get_home_path()), "", wp_normalize_path(dirname($itemHandler->getMeta()->getPath()))) . '/';
|
@@ -454,43 +459,49 @@ class ShortPixelAPI {
|
|
454 |
if ( !empty($tempFiles) )
|
455 |
{
|
456 |
//overwrite the original files with the optimized ones
|
457 |
-
foreach ( $tempFiles as $tempFileID => $
|
458 |
{
|
459 |
-
if(!is_array($
|
460 |
-
|
461 |
-
$
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
if(file_exists($
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
$height = $size[1];
|
475 |
}
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
WPShortPixel::log("HANDLE SUCCESS: Image " . $PATHs[$tempFileID] . " original size: ".$fileData->OriginalSize . " optimized: " . $fileData->$fileType);
|
484 |
|
485 |
-
|
486 |
-
|
487 |
-
|
|
|
|
|
|
|
|
|
488 |
}
|
489 |
-
|
490 |
-
|
491 |
-
|
|
|
|
|
|
|
|
|
492 |
}
|
493 |
-
@unlink($
|
494 |
}
|
495 |
|
496 |
if ( $writeFailed > 0 )//there was an error
|
308 |
$webpSize = "WebPLosslessSize";
|
309 |
}
|
310 |
|
311 |
+
$downloadTimeout = max(ini_get('max_execution_time') - 10, 15);
|
312 |
+
|
313 |
+
if($webpType !== "NA") {
|
314 |
+
$webpURL = $this->setPreferredProtocol(urldecode($fileData->$webpType));
|
315 |
+
$webpTempFile = download_url($webpURL, $downloadTimeout);
|
316 |
+
}
|
317 |
+
$webpTempFile = is_wp_error( $webpTempFile ) ? "NA" : $webpTempFile;
|
318 |
+
|
319 |
//if there is no improvement in size then we do not download this file
|
320 |
if ( $fileData->OriginalSize == $fileData->$fileSize )
|
321 |
+
return array("Status" => self::STATUS_UNCHANGED, "Message" => "File wasn't optimized so we do not download it.", "WebP" => $webpTempFile);
|
322 |
|
323 |
$correctFileSize = $fileData->$fileSize;
|
324 |
$fileURL = $this->setPreferredProtocol(urldecode($fileData->$fileType));
|
325 |
|
|
|
326 |
$tempFile = download_url($fileURL, $downloadTimeout);
|
327 |
if(is_wp_error( $tempFile ))
|
328 |
{ //try to switch the default protocol
|
330 |
$tempFile = download_url($fileURL, $downloadTimeout);
|
331 |
}
|
332 |
|
|
|
|
|
|
|
|
|
|
|
333 |
//on success we return this
|
334 |
+
$returnMessage = array("Status" => self::STATUS_SUCCESS, "Message" => $tempFile, "WebP" => $webpTempFile);
|
335 |
|
336 |
if ( is_wp_error( $tempFile ) ) {
|
337 |
@unlink($tempFile);
|
378 |
$this->_settings->thumbsCount = $this->_settings->thumbsCount + 1;
|
379 |
}
|
380 |
$downloadResult = $this->handleDownload($fileData,$compressionType);
|
381 |
+
|
382 |
if ( $downloadResult['Status'] == self::STATUS_SUCCESS ) {
|
383 |
$tempFiles[$counter] = $downloadResult;
|
384 |
}
|
385 |
//when the status is STATUS_UNCHANGED we just skip the array line for that one
|
386 |
+
elseif( $downloadResult['Status'] == self::STATUS_UNCHANGED ) {
|
387 |
+
//this image is unchanged so won't be copied below, only the optimization stats need to be computed
|
|
|
|
|
388 |
$originalSpace += $fileData->OriginalSize;
|
389 |
$optimizedSpace += $fileData->$fileType;
|
390 |
+
$tempFiles[$counter] = $downloadResult;
|
391 |
+
}
|
392 |
+
else {
|
393 |
+
return array("Status" => $downloadResult['Status'], "Message" => $downloadResult['Message']);
|
394 |
}
|
395 |
|
396 |
}
|
399 |
}
|
400 |
$counter++;
|
401 |
}
|
402 |
+
|
403 |
//figure out in what SubDir files should land
|
404 |
//#$SubDir = $this->returnSubDir(get_attached_file($ID));
|
405 |
$fullSubDir = str_replace(wp_normalize_path(get_home_path()), "", wp_normalize_path(dirname($itemHandler->getMeta()->getPath()))) . '/';
|
459 |
if ( !empty($tempFiles) )
|
460 |
{
|
461 |
//overwrite the original files with the optimized ones
|
462 |
+
foreach ( $tempFiles as $tempFileID => $tempFile )
|
463 |
{
|
464 |
+
if(!is_array($tempFile)) continue;
|
465 |
+
|
466 |
+
$targetFile = $PATHs[$tempFileID];
|
467 |
+
|
468 |
+
if($tempFile['Status'] == self::STATUS_SUCCESS) { //if it's unchanged it will still be in the array but only for WebP (handled below)
|
469 |
+
$tempFilePATH = $tempFile["Message"];
|
470 |
+
if ( file_exists($tempFilePATH) && file_exists($PATHs[$tempFileID]) && is_writable($PATHs[$tempFileID]) ) {
|
471 |
+
copy($tempFilePATH, $targetFile);
|
472 |
+
if($firstImage) { //this is the main image
|
473 |
+
$firstImage = false;
|
474 |
+
if($resize) {
|
475 |
+
$size = getimagesize($PATHs[$tempFileID]);
|
476 |
+
$width = $size[0];
|
477 |
+
$height = $size[1];
|
478 |
+
}
|
|
|
479 |
}
|
480 |
+
//Calculate the saved space
|
481 |
+
$fileData = $APIresponse[$tempFileID];
|
482 |
+
$savedSpace += $fileData->OriginalSize - $fileData->$fileType;
|
483 |
+
$originalSpace += $fileData->OriginalSize;
|
484 |
+
$optimizedSpace += $fileData->$fileType;
|
485 |
+
$averageCompression += $fileData->PercentImprovement;
|
486 |
+
WPShortPixel::log("HANDLE SUCCESS: Image " . $PATHs[$tempFileID] . " original size: ".$fileData->OriginalSize . " optimized: " . $fileData->$fileType);
|
|
|
487 |
|
488 |
+
//add the number of files with < 5% optimization
|
489 |
+
if ( ( ( 1 - $APIresponse[$tempFileID]->$fileType/$APIresponse[$tempFileID]->OriginalSize ) * 100 ) < 5 ) {
|
490 |
+
$this->_settings->under5Percent++;
|
491 |
+
}
|
492 |
+
}
|
493 |
+
else {
|
494 |
+
$writeFailed++;
|
495 |
}
|
496 |
+
@unlink($tempFilePATH);
|
497 |
+
}
|
498 |
+
|
499 |
+
$tempWebpFilePATH = $tempFile["WebP"];
|
500 |
+
if(file_exists($tempWebpFilePATH)) {
|
501 |
+
$targetWebPFile = dirname($targetFile) . '/' . basename($targetFile, '.' . pathinfo($targetFile, PATHINFO_EXTENSION)) . ".webp";
|
502 |
+
copy($tempWebpFilePATH, $targetWebPFile);
|
503 |
}
|
504 |
+
@unlink($tempWebpFilePATH);
|
505 |
}
|
506 |
|
507 |
if ( $writeFailed > 0 )//there was an error
|
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.1.
|
7 |
* Author: ShortPixel
|
8 |
* Author URI: https://shortpixel.com
|
9 |
*/
|
@@ -12,7 +12,7 @@ define('SP_RESET_ON_ACTIVATE', false); //if true TODO set false
|
|
12 |
|
13 |
define('SP_AFFILIATE_CODE', '');
|
14 |
|
15 |
-
define('PLUGIN_VERSION', "4.1.
|
16 |
define('SP_MAX_TIMEOUT', 10);
|
17 |
define('SP_VALIDATE_MAX_TIMEOUT', 15);
|
18 |
define('SP_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" target="_blank">Settings > ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
|
6 |
+
* Version: 4.1.7
|
7 |
* Author: ShortPixel
|
8 |
* Author URI: https://shortpixel.com
|
9 |
*/
|
12 |
|
13 |
define('SP_AFFILIATE_CODE', '');
|
14 |
|
15 |
+
define('PLUGIN_VERSION', "4.1.7");
|
16 |
define('SP_MAX_TIMEOUT', 10);
|
17 |
define('SP_VALIDATE_MAX_TIMEOUT', 15);
|
18 |
define('SP_BACKUP', 'ShortpixelBackups');
|