Version Description
- fix warnings on PHP 7.1 for empty array settings.
Download this release
Release Info
Developer | ShortPixel |
Plugin | ShortPixel Image Optimizer |
Version | 4.4.1 |
Comparing to | |
See all releases |
Code changes from version 4.4.0 to 4.4.1
- class/db/shortpixel-custom-meta-dao.php +4 -0
- class/db/shortpixel-meta-facade.php +1 -1
- class/shortpixel_queue.php +1 -1
- class/view/shortpixel_view.php +1 -0
- class/wp-short-pixel.php +18 -13
- class/wp-shortpixel-settings.php +3 -3
- readme.txt +6 -1
- res/js/short-pixel.js +0 -1
- wp-shortpixel.php +2 -2
class/db/shortpixel-custom-meta-dao.php
CHANGED
@@ -427,6 +427,10 @@ class ShortPixelCustomMetaDao {
|
|
427 |
foreach($failRows as $failLine) {
|
428 |
$filesWithErrors['C-' . $failLine->id] = array('Name' => $failLine->name, 'Message' => $failLine->message, 'Path' => $failLine->path);
|
429 |
}
|
|
|
|
|
|
|
|
|
430 |
|
431 |
return array("totalFiles" => $rows[0]->totalFiles, "mainFiles" => $rows[0]->totalFiles,
|
432 |
"totalProcessedFiles" => $rows[0]->totalProcessedFiles, "mainProcessedFiles" => $rows[0]->totalProcessedFiles,
|
427 |
foreach($failRows as $failLine) {
|
428 |
$filesWithErrors['C-' . $failLine->id] = array('Name' => $failLine->name, 'Message' => $failLine->message, 'Path' => $failLine->path);
|
429 |
}
|
430 |
+
|
431 |
+
if(!isset($rows[0])) {
|
432 |
+
$rows[0] = (object)array('totalFiles' => 0, 'totalProcessedFiles' => 0, 'totalProcLossyFiles' => 0, 'totalProcGlossyFiles' => 0, 'totalProcLosslessFiles' => 0);
|
433 |
+
}
|
434 |
|
435 |
return array("totalFiles" => $rows[0]->totalFiles, "mainFiles" => $rows[0]->totalFiles,
|
436 |
"totalProcessedFiles" => $rows[0]->totalProcessedFiles, "mainProcessedFiles" => $rows[0]->totalProcessedFiles,
|
class/db/shortpixel-meta-facade.php
CHANGED
@@ -194,7 +194,7 @@ class ShortPixelMetaFacade {
|
|
194 |
}
|
195 |
}
|
196 |
|
197 |
-
function incrementRetries($count = 1, $errorCode =
|
198 |
if($this->type == self::CUSTOM_TYPE) {
|
199 |
$this->meta->setRetries($this->meta->getRetries() + $count);
|
200 |
} else {
|
194 |
}
|
195 |
}
|
196 |
|
197 |
+
function incrementRetries($count = 1, $errorCode = ShortPixelAPI::ERR_UNKNOWN, $errorMessage = '') {
|
198 |
if($this->type == self::CUSTOM_TYPE) {
|
199 |
$this->meta->setRetries($this->meta->getRetries() + $count);
|
200 |
} else {
|
class/shortpixel_queue.php
CHANGED
@@ -21,7 +21,7 @@ class ShortPixelQueue {
|
|
21 |
if( !isset($_SESSION["wp-short-pixel-priorityQueue"]) //session is not defined
|
22 |
|| !(is_admin() && function_exists("is_user_logged_in") && is_user_logged_in())) { //or we're not in the admin - re-init each time
|
23 |
//take the priority list from the options (we persist there the priority IDs from the previous session)
|
24 |
-
$prioQueueOpt = $this->settings->getOpt( '
|
25 |
$_SESSION["wp-short-pixel-priorityQueue"] = array();
|
26 |
foreach($prioQueueOpt as $ID) {
|
27 |
if(ShortPixelMetaFacade::isCustomQueuedId($ID)) {
|
21 |
if( !isset($_SESSION["wp-short-pixel-priorityQueue"]) //session is not defined
|
22 |
|| !(is_admin() && function_exists("is_user_logged_in") && is_user_logged_in())) { //or we're not in the admin - re-init each time
|
23 |
//take the priority list from the options (we persist there the priority IDs from the previous session)
|
24 |
+
$prioQueueOpt = $this->settings->getOpt( 'priorityQueue', array());//here we save the IDs for the files that need to be processed after an image upload for example
|
25 |
$_SESSION["wp-short-pixel-priorityQueue"] = array();
|
26 |
foreach($prioQueueOpt as $ID) {
|
27 |
if(ShortPixelMetaFacade::isCustomQueuedId($ID)) {
|
class/view/shortpixel_view.php
CHANGED
@@ -973,6 +973,7 @@ class ShortPixelView {
|
|
973 |
. '<br>For a <strong>"file"</strong> pattern only the filename will be matched but for a <strong>"path"</strong>, '
|
974 |
. 'all the path will be matched (useful for excluding certain subdirectories altoghether).'
|
975 |
. 'For these you can also use regular expressions accepted by preg_match, but without "," or ":". '
|
|
|
976 |
. '<br>For the <strong>"size"</strong> type, '
|
977 |
. 'which applies only to Media Library images, <strong>the main images (not thumbnails)</strong> that have the size in the specified range will be excluded. '
|
978 |
. 'The format for the "size" exclude is: <strong>minWidth</strong>-<strong>maxWidth</strong>x<strong>minHeight</strong>-<strong>maxHeight</strong>, for example <strong>size:1000-1100x2000-2200</strong>. You can also specify a precise size, as <strong>1000x2000</strong>.','shortpixel-image-optimiser');?>
|
973 |
. '<br>For a <strong>"file"</strong> pattern only the filename will be matched but for a <strong>"path"</strong>, '
|
974 |
. 'all the path will be matched (useful for excluding certain subdirectories altoghether).'
|
975 |
. 'For these you can also use regular expressions accepted by preg_match, but without "," or ":". '
|
976 |
+
. 'A pattern will be considered a regex if it starts with a "/" and is valid. '
|
977 |
. '<br>For the <strong>"size"</strong> type, '
|
978 |
. 'which applies only to Media Library images, <strong>the main images (not thumbnails)</strong> that have the size in the specified range will be excluded. '
|
979 |
. 'The format for the "size" exclude is: <strong>minWidth</strong>-<strong>maxWidth</strong>x<strong>minHeight</strong>-<strong>maxHeight</strong>, for example <strong>size:1000-1100x2000-2200</strong>. You can also specify a precise size, as <strong>1000x2000</strong>.','shortpixel-image-optimiser');?>
|
class/wp-short-pixel.php
CHANGED
@@ -876,7 +876,7 @@ class WPShortPixel {
|
|
876 |
if(isset($result['Code'])) {
|
877 |
$itemHandler->incrementRetries(1, $result['Code'], $result["Message"]);
|
878 |
} else {
|
879 |
-
$itemHandler->incrementRetries(1,
|
880 |
}
|
881 |
}
|
882 |
}
|
@@ -1644,9 +1644,9 @@ class WPShortPixel {
|
|
1644 |
}
|
1645 |
|
1646 |
$root = self::getCustomFolderBase();
|
|
|
1647 |
|
1648 |
-
$postDir = rawurldecode($root.(isset($_POST['dir']) ? $_POST['dir'] : null ));
|
1649 |
-
|
1650 |
// set checkbox if multiSelect set to true
|
1651 |
$checkbox = ( isset($_POST['multiSelect']) && $_POST['multiSelect'] == 'true' ) ? "<input type='checkbox' />" : null;
|
1652 |
$onlyFolders = ($_POST['dir'] == '/' || isset($_POST['onlyFolders']) && $_POST['onlyFolders'] == 'true' ) ? true : false;
|
@@ -1656,7 +1656,7 @@ class WPShortPixel {
|
|
1656 |
|
1657 |
$files = scandir($postDir);
|
1658 |
$returnDir = substr($postDir, strlen($root));
|
1659 |
-
|
1660 |
natcasesort($files);
|
1661 |
|
1662 |
if( count($files) > 2 ) { // The 2 accounts for . and ..
|
@@ -1670,14 +1670,16 @@ class WPShortPixel {
|
|
1670 |
$ext = preg_replace('/^.*\./', '', $file);
|
1671 |
|
1672 |
if( file_exists($postDir . $file) && $file != '.' && $file != '..' ) {
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
|
|
1677 |
}
|
1678 |
}
|
|
|
1679 |
|
1680 |
-
|
1681 |
}
|
1682 |
}
|
1683 |
die();
|
@@ -1873,15 +1875,18 @@ class WPShortPixel {
|
|
1873 |
$this->_settings->createWebp = (isset($_POST['createWebp']) ? 1: 0);
|
1874 |
$this->_settings->optimizeRetina = (isset($_POST['optimizeRetina']) ? 1: 0);
|
1875 |
$this->_settings->optimizePdfs = (isset($_POST['optimizePdfs']) ? 1: 0);
|
|
|
|
|
|
|
1876 |
if(isset($_POST['excludePatterns']) && strlen($_POST['excludePatterns'])) {
|
1877 |
$patterns = array();
|
1878 |
$items = explode(',', $_POST['excludePatterns']);
|
1879 |
foreach($items as $pat) {
|
1880 |
$parts = explode(':', $pat);
|
1881 |
if(count($parts) == 1) {
|
1882 |
-
$patterns[] = array("type" =>"name", "value" => trim($pat));
|
1883 |
} else {
|
1884 |
-
$patterns[] = array("type" =>trim($parts[0]), "value" => trim($parts[1]));
|
1885 |
}
|
1886 |
}
|
1887 |
$this->_settings->excludePatterns = $patterns;
|
@@ -1930,7 +1935,7 @@ class WPShortPixel {
|
|
1930 |
}
|
1931 |
}
|
1932 |
|
1933 |
-
$showApiKey = ( is_main_site() || (function_exists("is_multisite") && is_multisite() && !defined("SHORTPIXEL_API_KEY"))
|
1934 |
&& !defined("SHORTPIXEL_HIDE_API_KEY"));
|
1935 |
$editApiKey = !defined("SHORTPIXEL_API_KEY") && $showApiKey;
|
1936 |
|
@@ -2389,7 +2394,7 @@ class WPShortPixel {
|
|
2389 |
if(in_array($type, array("name", "path"))) {
|
2390 |
$pattern = trim($item["value"]);
|
2391 |
$target = $type == "name" ? ShortPixelAPI::MB_basename($path) : $path;
|
2392 |
-
if( $pattern[0] == '/' && preg_match($pattern, $target) //search as regex pattern if starts with a /
|
2393 |
|| $pattern[0] != '/' && strpos($target, $pattern) !== false) { //search as a substring if not
|
2394 |
return false;
|
2395 |
}
|
876 |
if(isset($result['Code'])) {
|
877 |
$itemHandler->incrementRetries(1, $result['Code'], $result["Message"]);
|
878 |
} else {
|
879 |
+
$itemHandler->incrementRetries(1, ShortPixelAPI::ERR_UNKNOWN, "Connection error (" . $result["Message"] . ")" );
|
880 |
}
|
881 |
}
|
882 |
}
|
1644 |
}
|
1645 |
|
1646 |
$root = self::getCustomFolderBase();
|
1647 |
+
|
1648 |
|
1649 |
+
$postDir = rawurldecode($root.(isset($_POST['dir']) ? trim($_POST['dir']) : null ));
|
|
|
1650 |
// set checkbox if multiSelect set to true
|
1651 |
$checkbox = ( isset($_POST['multiSelect']) && $_POST['multiSelect'] == 'true' ) ? "<input type='checkbox' />" : null;
|
1652 |
$onlyFolders = ($_POST['dir'] == '/' || isset($_POST['onlyFolders']) && $_POST['onlyFolders'] == 'true' ) ? true : false;
|
1656 |
|
1657 |
$files = scandir($postDir);
|
1658 |
$returnDir = substr($postDir, strlen($root));
|
1659 |
+
|
1660 |
natcasesort($files);
|
1661 |
|
1662 |
if( count($files) > 2 ) { // The 2 accounts for . and ..
|
1670 |
$ext = preg_replace('/^.*\./', '', $file);
|
1671 |
|
1672 |
if( file_exists($postDir . $file) && $file != '.' && $file != '..' ) {
|
1673 |
+
//KEEP the spaces in front of the rel values - it's a trick to make WP Hide not replace the wp-content path
|
1674 |
+
if( is_dir($postDir . $file) && (!$onlyFiles || $onlyFolders) ) {
|
1675 |
+
echo "<li class='directory collapsed'>{$checkbox}<a rel=' " .$htmlRel. "/'>" . $htmlName . "</a></li>";
|
1676 |
+
} else if (!$onlyFolders || $onlyFiles) {
|
1677 |
+
echo "<li class='file ext_{$ext}'>{$checkbox}<a rel=' " . $htmlRel . "'>" . $htmlName . "</a></li>";
|
1678 |
}
|
1679 |
}
|
1680 |
+
}
|
1681 |
|
1682 |
+
echo "</ul>";
|
1683 |
}
|
1684 |
}
|
1685 |
die();
|
1875 |
$this->_settings->createWebp = (isset($_POST['createWebp']) ? 1: 0);
|
1876 |
$this->_settings->optimizeRetina = (isset($_POST['optimizeRetina']) ? 1: 0);
|
1877 |
$this->_settings->optimizePdfs = (isset($_POST['optimizePdfs']) ? 1: 0);
|
1878 |
+
|
1879 |
+
//die(var_dump($_POST['excludePatterns']));
|
1880 |
+
|
1881 |
if(isset($_POST['excludePatterns']) && strlen($_POST['excludePatterns'])) {
|
1882 |
$patterns = array();
|
1883 |
$items = explode(',', $_POST['excludePatterns']);
|
1884 |
foreach($items as $pat) {
|
1885 |
$parts = explode(':', $pat);
|
1886 |
if(count($parts) == 1) {
|
1887 |
+
$patterns[] = array("type" =>"name", "value" => str_replace('\\\\','\\',trim($pat)));
|
1888 |
} else {
|
1889 |
+
$patterns[] = array("type" =>trim($parts[0]), "value" => str_replace('\\\\','\\',trim($parts[1])));
|
1890 |
}
|
1891 |
}
|
1892 |
$this->_settings->excludePatterns = $patterns;
|
1935 |
}
|
1936 |
}
|
1937 |
|
1938 |
+
$showApiKey = ( (is_main_site() || (function_exists("is_multisite") && is_multisite() && !defined("SHORTPIXEL_API_KEY")))
|
1939 |
&& !defined("SHORTPIXEL_HIDE_API_KEY"));
|
1940 |
$editApiKey = !defined("SHORTPIXEL_API_KEY") && $showApiKey;
|
1941 |
|
2394 |
if(in_array($type, array("name", "path"))) {
|
2395 |
$pattern = trim($item["value"]);
|
2396 |
$target = $type == "name" ? ShortPixelAPI::MB_basename($path) : $path;
|
2397 |
+
if( $pattern[0] == '/' && @preg_match($pattern, false) !== false && preg_match($pattern, $target) //search as regex pattern if starts with a / and regex is valid
|
2398 |
|| $pattern[0] != '/' && strpos($target, $pattern) !== false) { //search as a substring if not
|
2399 |
return false;
|
2400 |
}
|
class/wp-shortpixel-settings.php
CHANGED
@@ -57,7 +57,7 @@ class WPShortPixelSettings {
|
|
57 |
'httpProto' => array('key' => 'wp-short-pixel-protocol', 'default' => 'https'),
|
58 |
'downloadProto' => array('key' => 'wp-short-pixel-download-protocol', 'default' => null),
|
59 |
'mediaAlert' => array('key' => 'wp-short-pixel-media-alert', 'default' => null),
|
60 |
-
'dismissedNotices' => array('key' => 'wp-short-pixel-dismissed-notices', 'default' =>
|
61 |
'activationDate' => array('key' => 'wp-short-pixel-activation-date', 'default' => null),
|
62 |
'activationNotice' => array('key' => 'wp-short-pixel-activation-notice', 'default' => null),
|
63 |
'mediaLibraryViewMode' => array('key' => 'wp-short-pixel-view-mode', 'default' => null),
|
@@ -82,8 +82,8 @@ class WPShortPixelSettings {
|
|
82 |
'failedImages' => array('key' => 'wp-short-pixel-failed-imgs', 'default' => 0),
|
83 |
'bulkProcessingStatus' => array('key' => 'bulkProcessingStatus', 'default' => null),
|
84 |
|
85 |
-
'priorityQueue' => array('key' => 'wp-short-pixel-priorityQueue', 'default' =>
|
86 |
-
'prioritySkip' => array('key' => 'wp-short-pixel-prioritySkip', 'default' =>
|
87 |
|
88 |
//'' => array('key' => 'wp-short-pixel-', 'default' => null),
|
89 |
);
|
57 |
'httpProto' => array('key' => 'wp-short-pixel-protocol', 'default' => 'https'),
|
58 |
'downloadProto' => array('key' => 'wp-short-pixel-download-protocol', 'default' => null),
|
59 |
'mediaAlert' => array('key' => 'wp-short-pixel-media-alert', 'default' => null),
|
60 |
+
'dismissedNotices' => array('key' => 'wp-short-pixel-dismissed-notices', 'default' => array()),
|
61 |
'activationDate' => array('key' => 'wp-short-pixel-activation-date', 'default' => null),
|
62 |
'activationNotice' => array('key' => 'wp-short-pixel-activation-notice', 'default' => null),
|
63 |
'mediaLibraryViewMode' => array('key' => 'wp-short-pixel-view-mode', 'default' => null),
|
82 |
'failedImages' => array('key' => 'wp-short-pixel-failed-imgs', 'default' => 0),
|
83 |
'bulkProcessingStatus' => array('key' => 'bulkProcessingStatus', 'default' => null),
|
84 |
|
85 |
+
'priorityQueue' => array('key' => 'wp-short-pixel-priorityQueue', 'default' => array()),
|
86 |
+
'prioritySkip' => array('key' => 'wp-short-pixel-prioritySkip', 'default' => array()),
|
87 |
|
88 |
//'' => array('key' => 'wp-short-pixel-', 'default' => null),
|
89 |
);
|
readme.txt
CHANGED
@@ -6,7 +6,7 @@ Tags: compress, image, compression, optimize, image optimizer, image compression
|
|
6 |
|
7 |
Requires at least: 3.2.0
|
8 |
Tested up to: 4.7
|
9 |
-
Stable tag: 4.4.
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
@@ -71,6 +71,7 @@ Check out <a rel="friend" href="https://shortpixel.com/pricing" target="_blank">
|
|
71 |
> ★★★★★ **Great image compression, solid plugin, equally great support.** [matters1959](https://wordpress.org/support/topic/support-shortpixel-image-optimizer/)
|
72 |
> [more testimonials](https://wordpress.org/support/plugin/shortpixel-image-optimiser/reviews/?filter=5)
|
73 |
|
|
|
74 |
|
75 |
Help us spread a the word by recommending ShortPixel to your friends and collect 100 additional image credits for each referred sign up. Make money by promoting a great plugin with our <a href="https://shortpixel.com/free-sign-up-affiliate" target="_blank">50/50 affiliate program</a>.
|
76 |
|
@@ -221,6 +222,10 @@ The ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Co
|
|
221 |
|
222 |
== Changelog ==
|
223 |
|
|
|
|
|
|
|
|
|
224 |
= 4.4.0 =
|
225 |
|
226 |
* exclude images based on patterns or image sizes, exclude paths based on patterns
|
6 |
|
7 |
Requires at least: 3.2.0
|
8 |
Tested up to: 4.7
|
9 |
+
Stable tag: 4.4.1
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
71 |
> ★★★★★ **Great image compression, solid plugin, equally great support.** [matters1959](https://wordpress.org/support/topic/support-shortpixel-image-optimizer/)
|
72 |
> [more testimonials](https://wordpress.org/support/plugin/shortpixel-image-optimiser/reviews/?filter=5)
|
73 |
|
74 |
+
[youtube https://www.youtube.com/watch?v=5EbX0Hsy6j4]
|
75 |
|
76 |
Help us spread a the word by recommending ShortPixel to your friends and collect 100 additional image credits for each referred sign up. Make money by promoting a great plugin with our <a href="https://shortpixel.com/free-sign-up-affiliate" target="_blank">50/50 affiliate program</a>.
|
77 |
|
222 |
|
223 |
== Changelog ==
|
224 |
|
225 |
+
= 4.4.1 =
|
226 |
+
|
227 |
+
* fix warnings on PHP 7.1 for empty array settings.
|
228 |
+
|
229 |
= 4.4.0 =
|
230 |
|
231 |
* exclude images based on patterns or image sizes, exclude paths based on patterns
|
res/js/short-pixel.js
CHANGED
@@ -400,7 +400,6 @@ function showToolBarAlert($status, $message) {
|
|
400 |
}
|
401 |
robo.addClass("shortpixel-alert");
|
402 |
robo.addClass("shortpixel-quota-exceeded");
|
403 |
-
//jQuery("a", robo).attr("href", "http://shortpixel.com/login/" + ShortPixel.API_KEY);
|
404 |
jQuery("a", robo).attr("href", "options-general.php?page=wp-shortpixel");
|
405 |
//jQuery("a", robo).attr("target", "_blank");
|
406 |
//jQuery("a div", robo).attr("title", "ShortPixel quota exceeded. Click to top-up");
|
400 |
}
|
401 |
robo.addClass("shortpixel-alert");
|
402 |
robo.addClass("shortpixel-quota-exceeded");
|
|
|
403 |
jQuery("a", robo).attr("href", "options-general.php?page=wp-shortpixel");
|
404 |
//jQuery("a", robo).attr("target", "_blank");
|
405 |
//jQuery("a div", robo).attr("title", "ShortPixel quota exceeded. Click to top-up");
|
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.4.
|
7 |
* Author: ShortPixel
|
8 |
* Author URI: https://shortpixel.com
|
9 |
* Text Domain: shortpixel-image-optimiser
|
@@ -17,7 +17,7 @@ define('SHORTPIXEL_PLUGIN_FILE', __FILE__);
|
|
17 |
|
18 |
define('SP_AFFILIATE_CODE', '');
|
19 |
|
20 |
-
define('PLUGIN_VERSION', "4.4.
|
21 |
define('SP_MAX_TIMEOUT', 10);
|
22 |
define('SP_VALIDATE_MAX_TIMEOUT', 15);
|
23 |
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.4.1
|
7 |
* Author: ShortPixel
|
8 |
* Author URI: https://shortpixel.com
|
9 |
* Text Domain: shortpixel-image-optimiser
|
17 |
|
18 |
define('SP_AFFILIATE_CODE', '');
|
19 |
|
20 |
+
define('PLUGIN_VERSION', "4.4.1");
|
21 |
define('SP_MAX_TIMEOUT', 10);
|
22 |
define('SP_VALIDATE_MAX_TIMEOUT', 15);
|
23 |
define('SP_BACKUP', 'ShortpixelBackups');
|