Version Description
- Handle malformed image metadata.
- Go directly to settings after activating if the API Key is not set up.
Download this release
Release Info
Developer | ShortPixel |
Plugin | ShortPixel Image Optimizer |
Version | 3.3.8 |
Comparing to | |
See all releases |
Code changes from version 3.3.7 to 3.3.8
- readme.txt +6 -1
- shortpixel_api.php +1 -1
- shortpixel_view.php +2 -2
- wp-shortpixel-settings.php +2 -0
- wp-shortpixel.php +30 -12
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: 3.3.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -193,6 +193,11 @@ The ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Co
|
|
193 |
|
194 |
== Changelog ==
|
195 |
|
|
|
|
|
|
|
|
|
|
|
196 |
= 3.3.7 =
|
197 |
|
198 |
* Solve CSS compatibility issue with WPEstate
|
5 |
|
6 |
Requires at least: 3.2.0
|
7 |
Tested up to: 4.6
|
8 |
+
Stable tag: 3.3.8
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
193 |
|
194 |
== Changelog ==
|
195 |
|
196 |
+
= 3.3.8 =
|
197 |
+
|
198 |
+
* Handle malformed image metadata.
|
199 |
+
* Go directly to settings after activating if the API Key is not set up.
|
200 |
+
|
201 |
= 3.3.7 =
|
202 |
|
203 |
* Solve CSS compatibility issue with WPEstate
|
shortpixel_api.php
CHANGED
@@ -405,7 +405,7 @@ class ShortPixelAPI {
|
|
405 |
$meta['ShortPixel']['thumbsOpt'] = (isset($meta['ShortPixel']['thumbsTodo']) || $this->_settings->processThumbnails) && isset($meta['sizes']) ? count($meta['sizes']) : 0;
|
406 |
//if thumbsTodo - this means there was an explicit request to process thumbs for an image that was previously processed without
|
407 |
// don't update the ShortPixelImprovement ratio as this is only calculated based on main image
|
408 |
-
if(isset($meta['ShortPixel']['thumbsTodo'])) {
|
409 |
unset($meta['ShortPixel']['thumbsTodo']);
|
410 |
$percentImprovement = $meta['ShortPixelImprovement'];
|
411 |
} else {
|
405 |
$meta['ShortPixel']['thumbsOpt'] = (isset($meta['ShortPixel']['thumbsTodo']) || $this->_settings->processThumbnails) && isset($meta['sizes']) ? count($meta['sizes']) : 0;
|
406 |
//if thumbsTodo - this means there was an explicit request to process thumbs for an image that was previously processed without
|
407 |
// don't update the ShortPixelImprovement ratio as this is only calculated based on main image
|
408 |
+
if(isset($meta['ShortPixel']['thumbsTodo']) && is_numeric($meta['ShortPixelImprovement'])) {
|
409 |
unset($meta['ShortPixel']['thumbsTodo']);
|
410 |
$percentImprovement = $meta['ShortPixelImprovement'];
|
411 |
} else {
|
shortpixel_view.php
CHANGED
@@ -126,7 +126,7 @@ class ShortPixelView {
|
|
126 |
<div class="bulk-text-container">
|
127 |
<h3>What are Thumbnails?</h3>
|
128 |
<p>Thumbnails are smaller images generated by your WP theme. Most themes generate between 3 and 6 thumbnails for each Media Library image.</p>
|
129 |
-
<p>The thumbnails also generate
|
130 |
<p>It's highly recommended that you include thumbnails in the optimization as well.</p>
|
131 |
</div>
|
132 |
<div class="bulk-text-container" style="padding-right:0">
|
@@ -470,7 +470,7 @@ class ShortPixelView {
|
|
470 |
<th scope="row"><label for="backupImages">Image backup</label></th>
|
471 |
<td>
|
472 |
<input name="backupImages" type="checkbox" id="backupImages" <?php echo( $checkedBackupImages );?>> Save and keep a backup of your original images in a separate folder.
|
473 |
-
<p class="settings-info">
|
474 |
</td>
|
475 |
</tr>
|
476 |
<tr>
|
126 |
<div class="bulk-text-container">
|
127 |
<h3>What are Thumbnails?</h3>
|
128 |
<p>Thumbnails are smaller images generated by your WP theme. Most themes generate between 3 and 6 thumbnails for each Media Library image.</p>
|
129 |
+
<p>The thumbnails also generate traffic on your website pages and they influence your website's speed.</p>
|
130 |
<p>It's highly recommended that you include thumbnails in the optimization as well.</p>
|
131 |
</div>
|
132 |
<div class="bulk-text-container" style="padding-right:0">
|
470 |
<th scope="row"><label for="backupImages">Image backup</label></th>
|
471 |
<td>
|
472 |
<input name="backupImages" type="checkbox" id="backupImages" <?php echo( $checkedBackupImages );?>> Save and keep a backup of your original images in a separate folder.
|
473 |
+
<p class="settings-info">You need to have backup active in order to be able to restore images to originals or to convert from Lossy to Lossless and back.</p>
|
474 |
</td>
|
475 |
</tr>
|
476 |
<tr>
|
wp-shortpixel-settings.php
CHANGED
@@ -39,6 +39,7 @@ class WPShortPixelSettings {
|
|
39 |
'siteAuthUser' => 'wp-short-pixel-site-auth-user',
|
40 |
'siteAuthPass' => 'wp-short-pixel-site-auth-pass',
|
41 |
'prioritySkip' => 'wp-short-pixel-prioritySkip',
|
|
|
42 |
'' => '',
|
43 |
);
|
44 |
|
@@ -95,6 +96,7 @@ class WPShortPixelSettings {
|
|
95 |
delete_option( 'wp-short-pixel-resize-width');
|
96 |
delete_option( 'wp-short-pixel-resize-height');
|
97 |
delete_option( 'wp-short-pixel-dismissed-notices');
|
|
|
98 |
if(isset($_SESSION["wp-short-pixel-priorityQueue"])) {
|
99 |
unset($_SESSION["wp-short-pixel-priorityQueue"]);
|
100 |
}
|
39 |
'siteAuthUser' => 'wp-short-pixel-site-auth-user',
|
40 |
'siteAuthPass' => 'wp-short-pixel-site-auth-pass',
|
41 |
'prioritySkip' => 'wp-short-pixel-prioritySkip',
|
42 |
+
'redirectedSettings' => 'wp-short-pixel-redirected-settings',
|
43 |
'' => '',
|
44 |
);
|
45 |
|
96 |
delete_option( 'wp-short-pixel-resize-width');
|
97 |
delete_option( 'wp-short-pixel-resize-height');
|
98 |
delete_option( 'wp-short-pixel-dismissed-notices');
|
99 |
+
delete_option( 'wp-short-pixel-redirected-settings');
|
100 |
if(isset($_SESSION["wp-short-pixel-priorityQueue"])) {
|
101 |
unset($_SESSION["wp-short-pixel-priorityQueue"]);
|
102 |
}
|
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: 3.3.
|
7 |
* Author: ShortPixel
|
8 |
* Author URI: https://shortpixel.com
|
9 |
*/
|
@@ -14,15 +14,17 @@ require_once('shortpixel_queue.php');
|
|
14 |
require_once('shortpixel_view.php');
|
15 |
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
16 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
17 |
-
|
|
|
18 |
require_once( ABSPATH . 'wp-includes/pluggable.php' );//to avoid conflict with wpmandrill plugin
|
19 |
}
|
|
|
20 |
|
21 |
define('SP_RESET_ON_ACTIVATE', false); //if true TODO set false
|
22 |
|
23 |
define('SP_AFFILIATE_CODE', '');
|
24 |
|
25 |
-
define('PLUGIN_VERSION', "3.3.
|
26 |
define('SP_MAX_TIMEOUT', 10);
|
27 |
define('SP_VALIDATE_MAX_TIMEOUT', 15);
|
28 |
define('SP_BACKUP', 'ShortpixelBackups');
|
@@ -116,6 +118,12 @@ class WPShortPixel {
|
|
116 |
add_action('admin_notices', array( &$this, 'displayAdminNotices'));
|
117 |
|
118 |
$this->migrateBackupFolder();
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
}
|
120 |
|
121 |
//handling older
|
@@ -153,7 +161,7 @@ class WPShortPixel {
|
|
153 |
$dismissed = $this->_settings->getOpt( 'wp-short-pixel-dismissed-notices', array());
|
154 |
$now = time();
|
155 |
$act = $this->_settings->getOpt( 'wp-short-pixel-activation-date', $now);
|
156 |
-
if($this->_settings->getOpt( 'wp-short-pixel-activation-notice', false)) {
|
157 |
ShortPixelView::displayActivationNotice();
|
158 |
delete_option('wp-short-pixel-activation-notice');
|
159 |
}
|
@@ -219,7 +227,7 @@ class WPShortPixel {
|
|
219 |
STATUS_NO_KEY: <?php echo ShortPixelAPI::STATUS_NO_KEY; ?>,
|
220 |
STATUS_RETRY: <?php echo ShortPixelAPI::STATUS_RETRY; ?>,
|
221 |
WP_PLUGIN_URL: '<?php echo plugins_url( '', __FILE__ ); ?>',
|
222 |
-
WP_ADMIN_URL: '<?php echo admin_url(); ?>',
|
223 |
API_KEY: "<?php echo $this->_settings->apiKey; ?>",
|
224 |
MEDIA_ALERT: '<?php echo $this->_settings->mediaAlert ? "done" : "todo"; ?>'
|
225 |
});
|
@@ -606,6 +614,9 @@ class WPShortPixel {
|
|
606 |
$URLsAndPATHs = $this->getURLsAndPATHs($ID, NULL, $onlyThumbs);
|
607 |
$this->_apiInterface->doRequests($URLsAndPATHs['URLs'], false, $ID, $compressionType === false ? $this->_settings->compressionType : $compressionType);//send a request, do NOT wait for response
|
608 |
$meta = wp_get_attachment_metadata($ID);
|
|
|
|
|
|
|
609 |
$meta['ShortPixel']['WaitingProcessing'] = true;
|
610 |
wp_update_attachment_metadata($ID, $meta);
|
611 |
return $URLsAndPATHs;
|
@@ -679,9 +690,11 @@ class WPShortPixel {
|
|
679 |
$thumbsPaths = array();
|
680 |
if( !empty($meta['file']) && is_array($meta["sizes"]) ) {
|
681 |
foreach($meta["sizes"] as $size => $imageData) {
|
682 |
-
$
|
683 |
-
|
684 |
-
|
|
|
|
|
685 |
}
|
686 |
}
|
687 |
|
@@ -796,7 +809,9 @@ class WPShortPixel {
|
|
796 |
//remove thumbs thumbnails
|
797 |
if(isset($meta["sizes"])) {
|
798 |
foreach($meta["sizes"] as $size => $imageData) {
|
799 |
-
|
|
|
|
|
800 |
}
|
801 |
}
|
802 |
}
|
@@ -969,6 +984,8 @@ class WPShortPixel {
|
|
969 |
$noticeHTML = "";
|
970 |
$notice = null;
|
971 |
|
|
|
|
|
972 |
//by default we try to fetch the API Key from wp-config.php (if defined)
|
973 |
if ( defined("SHORTPIXEL_API_KEY") && strlen(SHORTPIXEL_API_KEY) == 20)
|
974 |
{
|
@@ -1387,11 +1404,12 @@ class WPShortPixel {
|
|
1387 |
&& ($this->_settings->processThumbnails || $onlyThumbs)
|
1388 |
&& isset($meta['sizes']) && is_array($meta['sizes']))
|
1389 |
{
|
1390 |
-
foreach( $meta['sizes'] as $thumbnailInfo )
|
1391 |
-
{
|
1392 |
$urlList[] = str_replace(ShortPixelAPI::MB_basename($urlList[0]), $thumbnailInfo['file'], $url);
|
1393 |
$filePath[] = str_replace(ShortPixelAPI::MB_basename($filePath[0]), $thumbnailInfo['file'], $path);
|
1394 |
-
}
|
|
|
1395 |
}
|
1396 |
if(!isset($meta['sizes']) || !is_array($meta['sizes'])) {
|
1397 |
self::log("getURLsAndPATHs: no meta sizes for ID $ID : " . json_encode($meta));
|
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: 3.3.8
|
7 |
* Author: ShortPixel
|
8 |
* Author URI: https://shortpixel.com
|
9 |
*/
|
14 |
require_once('shortpixel_view.php');
|
15 |
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
16 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
17 |
+
|
18 |
+
/*if ( !is_plugin_active( 'wpmandrill/wpmandrill.php' ) && !is_plugin_active( 'wp-ses/wp-ses.php' ) ) {
|
19 |
require_once( ABSPATH . 'wp-includes/pluggable.php' );//to avoid conflict with wpmandrill plugin
|
20 |
}
|
21 |
+
*/
|
22 |
|
23 |
define('SP_RESET_ON_ACTIVATE', false); //if true TODO set false
|
24 |
|
25 |
define('SP_AFFILIATE_CODE', '');
|
26 |
|
27 |
+
define('PLUGIN_VERSION', "3.3.8");
|
28 |
define('SP_MAX_TIMEOUT', 10);
|
29 |
define('SP_VALIDATE_MAX_TIMEOUT', 15);
|
30 |
define('SP_BACKUP', 'ShortpixelBackups');
|
118 |
add_action('admin_notices', array( &$this, 'displayAdminNotices'));
|
119 |
|
120 |
$this->migrateBackupFolder();
|
121 |
+
|
122 |
+
if(!$this->_settings->redirectedSettings && !$this->_settings->verifiedKey && (!function_exists("is_multisite") || !is_multisite())) {
|
123 |
+
$this->_settings->redirectedSettings = 1;
|
124 |
+
wp_redirect(admin_url("options-general.php?page=wp-shortpixel"));
|
125 |
+
exit();
|
126 |
+
}
|
127 |
}
|
128 |
|
129 |
//handling older
|
161 |
$dismissed = $this->_settings->getOpt( 'wp-short-pixel-dismissed-notices', array());
|
162 |
$now = time();
|
163 |
$act = $this->_settings->getOpt( 'wp-short-pixel-activation-date', $now);
|
164 |
+
if($this->_settings->getOpt( 'wp-short-pixel-activation-notice', false) && $this->_settings->redirectedSettings >= 2) {
|
165 |
ShortPixelView::displayActivationNotice();
|
166 |
delete_option('wp-short-pixel-activation-notice');
|
167 |
}
|
227 |
STATUS_NO_KEY: <?php echo ShortPixelAPI::STATUS_NO_KEY; ?>,
|
228 |
STATUS_RETRY: <?php echo ShortPixelAPI::STATUS_RETRY; ?>,
|
229 |
WP_PLUGIN_URL: '<?php echo plugins_url( '', __FILE__ ); ?>',
|
230 |
+
WP_ADMIN_URL: '<?php echo strtolower(admin_url()); ?>',
|
231 |
API_KEY: "<?php echo $this->_settings->apiKey; ?>",
|
232 |
MEDIA_ALERT: '<?php echo $this->_settings->mediaAlert ? "done" : "todo"; ?>'
|
233 |
});
|
614 |
$URLsAndPATHs = $this->getURLsAndPATHs($ID, NULL, $onlyThumbs);
|
615 |
$this->_apiInterface->doRequests($URLsAndPATHs['URLs'], false, $ID, $compressionType === false ? $this->_settings->compressionType : $compressionType);//send a request, do NOT wait for response
|
616 |
$meta = wp_get_attachment_metadata($ID);
|
617 |
+
if(!is_array($meta)) {
|
618 |
+
$meta = array("previous_meta" => $meta, 'ShortPixel' => array());
|
619 |
+
}
|
620 |
$meta['ShortPixel']['WaitingProcessing'] = true;
|
621 |
wp_update_attachment_metadata($ID, $meta);
|
622 |
return $URLsAndPATHs;
|
690 |
$thumbsPaths = array();
|
691 |
if( !empty($meta['file']) && is_array($meta["sizes"]) ) {
|
692 |
foreach($meta["sizes"] as $size => $imageData) {
|
693 |
+
if(isset($imageData['file'])) {
|
694 |
+
$source = $bkFolder . $imageData['file'];
|
695 |
+
$thumbsPaths[$source] = $pathInfo['dirname'] . DIRECTORY_SEPARATOR . $imageData['file'];
|
696 |
+
if(! $this->setFilePerms($source)) return false;
|
697 |
+
}
|
698 |
}
|
699 |
}
|
700 |
|
809 |
//remove thumbs thumbnails
|
810 |
if(isset($meta["sizes"])) {
|
811 |
foreach($meta["sizes"] as $size => $imageData) {
|
812 |
+
if(isset($imageData['file'])) {
|
813 |
+
@unlink($filesPath . ShortPixelAPI::MB_basename($imageData['file']));//remove thumbs
|
814 |
+
}
|
815 |
}
|
816 |
}
|
817 |
}
|
984 |
$noticeHTML = "";
|
985 |
$notice = null;
|
986 |
|
987 |
+
$this->_settings->redirectedSettings = 2;
|
988 |
+
|
989 |
//by default we try to fetch the API Key from wp-config.php (if defined)
|
990 |
if ( defined("SHORTPIXEL_API_KEY") && strlen(SHORTPIXEL_API_KEY) == 20)
|
991 |
{
|
1404 |
&& ($this->_settings->processThumbnails || $onlyThumbs)
|
1405 |
&& isset($meta['sizes']) && is_array($meta['sizes']))
|
1406 |
{
|
1407 |
+
foreach( $meta['sizes'] as $thumbnailInfo ) {
|
1408 |
+
if(isset($thumbnailInfo['file'])) {
|
1409 |
$urlList[] = str_replace(ShortPixelAPI::MB_basename($urlList[0]), $thumbnailInfo['file'], $url);
|
1410 |
$filePath[] = str_replace(ShortPixelAPI::MB_basename($filePath[0]), $thumbnailInfo['file'], $path);
|
1411 |
+
}
|
1412 |
+
}
|
1413 |
}
|
1414 |
if(!isset($meta['sizes']) || !is_array($meta['sizes'])) {
|
1415 |
self::log("getURLsAndPATHs: no meta sizes for ID $ID : " . json_encode($meta));
|