Version Description
- look and feel improvements
Download this release
Release Info
Developer | ShortPixel |
Plugin | ShortPixel Image Optimizer |
Version | 3.1.6 |
Comparing to | |
See all releases |
Code changes from version 3.1.5 to 3.1.6
- css/short-pixel.css +97 -2
- img/arrow.png +0 -0
- js/short-pixel.js +30 -6
- readme.txt +5 -1
- shortpixel_api.php +7 -3
- shortpixel_view.php +120 -49
- wp-shortpixel.php +37 -27
css/short-pixel.css
CHANGED
@@ -31,6 +31,101 @@ li.shortpixel-toolbar-processing.shortpixel-alert > a.ab-item > div,
|
|
31 |
li.shortpixel-hide {
|
32 |
display:none;
|
33 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
.bulk-progress {
|
35 |
padding: 20px 32px 17px;
|
36 |
background-color: #ffffff;
|
@@ -130,7 +225,7 @@ li.shortpixel-hide {
|
|
130 |
p.settings-info {
|
131 |
padding-top: 0px;
|
132 |
color: #818181;
|
133 |
-
font-size:13px;
|
134 |
}
|
135 |
|
136 |
/* TABS CONTROLS */
|
@@ -183,7 +278,7 @@ article.tabs section h2 a {
|
|
183 |
line-height: 1.8em;
|
184 |
text-align: center;
|
185 |
text-decoration: none;
|
186 |
-
color:
|
187 |
outline: 0 none;
|
188 |
}
|
189 |
article.tabs section h2 a:focus,
|
31 |
li.shortpixel-hide {
|
32 |
display:none;
|
33 |
}
|
34 |
+
.clearfix {
|
35 |
+
width:100%;
|
36 |
+
float:left;
|
37 |
+
}
|
38 |
+
.short-pixel-bulk-page p {
|
39 |
+
margin: 0.6em 0;
|
40 |
+
}
|
41 |
+
|
42 |
+
.short-pixel-bulk-page form.start {
|
43 |
+
display:table;
|
44 |
+
content:" ";
|
45 |
+
width:98%;
|
46 |
+
background-color:white;
|
47 |
+
padding:10px 10px 0;
|
48 |
+
margin-top: 2em;
|
49 |
+
}
|
50 |
+
|
51 |
+
.bulk-stats-container{
|
52 |
+
display: inline-block;
|
53 |
+
min-width:450px;
|
54 |
+
width: 45%;
|
55 |
+
float:left;
|
56 |
+
padding-right: 50px;
|
57 |
+
font-size:1.1em;
|
58 |
+
line-height: 1.5em;
|
59 |
+
}
|
60 |
+
.bulk-text-container{
|
61 |
+
display: inline-block;
|
62 |
+
min-width:440px;
|
63 |
+
width: 45%;
|
64 |
+
float:left;
|
65 |
+
padding-right: 50px;
|
66 |
+
}
|
67 |
+
.bulk-text-container h3{
|
68 |
+
border-bottom: 1px solid #a8a8a8;
|
69 |
+
margin-bottom: 0.5em;
|
70 |
+
padding-bottom: 0.5em;
|
71 |
+
}
|
72 |
+
.bulk-wide {
|
73 |
+
display: inline-block;
|
74 |
+
width: 90%;
|
75 |
+
float:left;
|
76 |
+
margin-top: 25px;
|
77 |
+
}
|
78 |
+
.bulk-stats-container .bulk-label{
|
79 |
+
width:220px;
|
80 |
+
display:inline-block;
|
81 |
+
}
|
82 |
+
.bulk-stats-container .bulk-val{
|
83 |
+
width:50px;
|
84 |
+
display:inline-block;
|
85 |
+
text-align: right;
|
86 |
+
}
|
87 |
+
.bulk-stats-container .bulk-total{
|
88 |
+
font-weight: bold;
|
89 |
+
margin-top:10px;
|
90 |
+
margin-bottom:10px;
|
91 |
+
}
|
92 |
+
.wp-core-ui .bulk-play{
|
93 |
+
display: inline;
|
94 |
+
width: 310px;
|
95 |
+
float:left;
|
96 |
+
margin-bottom:20px;
|
97 |
+
}
|
98 |
+
.wp-core-ui .bulk-play a.button{
|
99 |
+
height:60px;
|
100 |
+
margin-top: 27px;
|
101 |
+
width: 290px;
|
102 |
+
overflow: hidden;
|
103 |
+
}
|
104 |
+
.wp-core-ui .column-wp-shortPixel .button.button-smaller {
|
105 |
+
font-size: 13px;
|
106 |
+
padding:0px 5px;
|
107 |
+
height:20px;
|
108 |
+
line-height:16px;
|
109 |
+
float:right;
|
110 |
+
}
|
111 |
+
.wp-core-ui .bulk-play a.button .bulk-btn-img {
|
112 |
+
float:left;
|
113 |
+
display:inline-block;
|
114 |
+
padding-top:6px;
|
115 |
+
}
|
116 |
+
.wp-core-ui .bulk-play a.button .bulk-btn-txt {
|
117 |
+
float:left;
|
118 |
+
display:inline-block;
|
119 |
+
text-align: right;
|
120 |
+
line-height: 1.3em;
|
121 |
+
margin: 11px 10px;
|
122 |
+
}
|
123 |
+
.wp-core-ui .bulk-play a.button .bulk-btn-txt span.label {
|
124 |
+
font-size: 1.6em;
|
125 |
+
}
|
126 |
+
.wp-core-ui .bulk-play a.button .bulk-btn-txt span.total {
|
127 |
+
font-size: 1.4em;
|
128 |
+
}
|
129 |
.bulk-progress {
|
130 |
padding: 20px 32px 17px;
|
131 |
background-color: #ffffff;
|
225 |
p.settings-info {
|
226 |
padding-top: 0px;
|
227 |
color: #818181;
|
228 |
+
font-size:13px !important;
|
229 |
}
|
230 |
|
231 |
/* TABS CONTROLS */
|
278 |
line-height: 1.8em;
|
279 |
text-align: center;
|
280 |
text-decoration: none;
|
281 |
+
color: #23282d;
|
282 |
outline: 0 none;
|
283 |
}
|
284 |
article.tabs section h2 a:focus,
|
img/arrow.png
ADDED
Binary file
|
js/short-pixel.js
CHANGED
@@ -28,8 +28,24 @@ var ShortPixel = function() {
|
|
28 |
}
|
29 |
}
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
return {
|
32 |
-
setOptions: setOptions
|
|
|
|
|
33 |
}
|
34 |
}();
|
35 |
|
@@ -37,6 +53,10 @@ function showToolBarAlert($status, $message) {
|
|
37 |
var robo = jQuery("li.shortpixel-toolbar-processing");
|
38 |
switch($status) {
|
39 |
case ShortPixel.STATUS_QUOTA_EXCEEDED:
|
|
|
|
|
|
|
|
|
40 |
robo.addClass("shortpixel-alert");
|
41 |
robo.addClass("shortpixel-quota-exceeded");
|
42 |
jQuery("a", robo).attr("href", "http://shortpixel.com/login/" + ShortPixel.API_KEY);
|
@@ -50,8 +70,8 @@ function showToolBarAlert($status, $message) {
|
|
50 |
case ShortPixel.STATUS_NO_KEY:
|
51 |
robo.addClass("shortpixel-alert");
|
52 |
robo.addClass("shortpixel-quota-exceeded");
|
53 |
-
jQuery("a", robo).attr("href", "http://shortpixel.com/wp-apikey");
|
54 |
-
jQuery("a", robo).attr("target", "_blank");
|
55 |
jQuery("a div", robo).attr("title", "Get API Key");
|
56 |
break;
|
57 |
case ShortPixel.STATUS_SUCCESS:
|
@@ -83,11 +103,14 @@ function checkQuotaExceededAlert() {
|
|
83 |
* calls itself until receives an Empty queue message
|
84 |
*/
|
85 |
function checkBulkProgress() {
|
86 |
-
if(
|
87 |
&& window.location.href.search("wp-admin/edit.php") < 0
|
88 |
&& window.location.href.search("wp-admin/edit-tags.php") < 0
|
89 |
&& window.location.href.search("wp-admin/post-new.php") < 0
|
90 |
-
&& window.location.href.search("wp-admin/post.php") < 0)
|
|
|
|
|
|
|
91 |
|
92 |
//if i'm the bulk processor and i'm not the bulk page and a bulk page comes around, leave the bulk processor role
|
93 |
if(ShortPixel.bulkProcessor == true && window.location.href.search("wp-short-pixel-bulk") < 0
|
@@ -144,7 +167,7 @@ function checkBulkProcessingCallApi(){
|
|
144 |
showToolBarAlert(ShortPixel.STATUS_NO_KEY);
|
145 |
break;
|
146 |
case ShortPixel.STATUS_QUOTA_EXCEEDED:
|
147 |
-
setCellMessage(id, data["Message"] + "
|
148 |
+ ShortPixel.API_KEY + "\" target=\"_blank\">Extend Quota</a>");
|
149 |
showToolBarAlert(ShortPixel.STATUS_QUOTA_EXCEEDED);
|
150 |
break;
|
@@ -332,3 +355,4 @@ function showStats() {
|
|
332 |
|
333 |
}
|
334 |
}
|
|
28 |
}
|
29 |
}
|
30 |
|
31 |
+
function checkThumbsUpdTotal(el) {
|
32 |
+
var total = jQuery("#" +(el.checked ? "total" : "main")+ "ToProcess").val();
|
33 |
+
jQuery("div.bulk-play span.total").text(total);
|
34 |
+
jQuery("#displayTotal").text(total);
|
35 |
+
}
|
36 |
+
|
37 |
+
function switchSettingsTab(target){
|
38 |
+
var section = jQuery("section#" +target);
|
39 |
+
if(section.length > 0){
|
40 |
+
jQuery("section").removeClass("sel-tab");
|
41 |
+
jQuery("section#" +target).addClass("sel-tab");
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
return {
|
46 |
+
setOptions : setOptions,
|
47 |
+
checkThumbsUpdTotal: checkThumbsUpdTotal,
|
48 |
+
switchSettingsTab : switchSettingsTab
|
49 |
}
|
50 |
}();
|
51 |
|
53 |
var robo = jQuery("li.shortpixel-toolbar-processing");
|
54 |
switch($status) {
|
55 |
case ShortPixel.STATUS_QUOTA_EXCEEDED:
|
56 |
+
if(window.location.href.search("wp-short-pixel-bulk") > 0) { //if we're in bulk reload to see all options
|
57 |
+
location.reload();
|
58 |
+
return;
|
59 |
+
}
|
60 |
robo.addClass("shortpixel-alert");
|
61 |
robo.addClass("shortpixel-quota-exceeded");
|
62 |
jQuery("a", robo).attr("href", "http://shortpixel.com/login/" + ShortPixel.API_KEY);
|
70 |
case ShortPixel.STATUS_NO_KEY:
|
71 |
robo.addClass("shortpixel-alert");
|
72 |
robo.addClass("shortpixel-quota-exceeded");
|
73 |
+
jQuery("a", robo).attr("href", "options-general.php?page=wp-shortpixel");//"http://shortpixel.com/wp-apikey");
|
74 |
+
//jQuery("a", robo).attr("target", "_blank");
|
75 |
jQuery("a div", robo).attr("title", "Get API Key");
|
76 |
break;
|
77 |
case ShortPixel.STATUS_SUCCESS:
|
103 |
* calls itself until receives an Empty queue message
|
104 |
*/
|
105 |
function checkBulkProgress() {
|
106 |
+
if(false && window.location.href.search("wp-admin/upload.php") < 0
|
107 |
&& window.location.href.search("wp-admin/edit.php") < 0
|
108 |
&& window.location.href.search("wp-admin/edit-tags.php") < 0
|
109 |
&& window.location.href.search("wp-admin/post-new.php") < 0
|
110 |
+
&& window.location.href.search("wp-admin/post.php") < 0) {
|
111 |
+
hideToolBarAlert();
|
112 |
+
return;
|
113 |
+
}
|
114 |
|
115 |
//if i'm the bulk processor and i'm not the bulk page and a bulk page comes around, leave the bulk processor role
|
116 |
if(ShortPixel.bulkProcessor == true && window.location.href.search("wp-short-pixel-bulk") < 0
|
167 |
showToolBarAlert(ShortPixel.STATUS_NO_KEY);
|
168 |
break;
|
169 |
case ShortPixel.STATUS_QUOTA_EXCEEDED:
|
170 |
+
setCellMessage(id, data["Message"] + " <a class='button button-smaller button-primary' href=\"https://shortpixel.com/login/"
|
171 |
+ ShortPixel.API_KEY + "\" target=\"_blank\">Extend Quota</a>");
|
172 |
showToolBarAlert(ShortPixel.STATUS_QUOTA_EXCEEDED);
|
173 |
break;
|
355 |
|
356 |
}
|
357 |
}
|
358 |
+
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: picture, optimization, image editor, pngout, upload speed, shortpixel, co
|
|
5 |
|
6 |
Requires at least: 3.0.1
|
7 |
Tested up to: 4.3
|
8 |
-
Stable tag: 3.1.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -168,6 +168,10 @@ The ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Co
|
|
168 |
|
169 |
== Changelog ==
|
170 |
|
|
|
|
|
|
|
|
|
171 |
= 3.1.5 =
|
172 |
|
173 |
* longer timeout for the API Key validation postback
|
5 |
|
6 |
Requires at least: 3.0.1
|
7 |
Tested up to: 4.3
|
8 |
+
Stable tag: 3.1.6
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
168 |
|
169 |
== Changelog ==
|
170 |
|
171 |
+
= 3.1.6 =
|
172 |
+
|
173 |
+
* look and feel improvements
|
174 |
+
|
175 |
= 3.1.5 =
|
176 |
|
177 |
* longer timeout for the API Key validation postback
|
shortpixel_api.php
CHANGED
@@ -229,20 +229,24 @@ class ShortPixelAPI {
|
|
229 |
|
230 |
if(is_wp_error( $tempFiles[$counter] )) //also tries with http instead of https
|
231 |
{
|
232 |
-
$tempFiles[$counter] = download_url(str_replace('
|
233 |
}
|
234 |
//on success we return this
|
235 |
$returnMessage = array("Status" => self::STATUS_SUCCESS, "Message" => $tempFiles[$counter]);
|
236 |
|
237 |
if ( is_wp_error( $tempFiles[$counter] ) ) {
|
238 |
@unlink($tempFiles[$counter]);
|
239 |
-
$returnMessage = array(
|
|
|
|
|
240 |
}
|
241 |
//check response so that download is OK
|
242 |
elseif( filesize($tempFiles[$counter]) != $correctFileSize) {
|
243 |
$size = filesize($tempFiles[$counter]);
|
244 |
@unlink($tempFiles[$counter]);
|
245 |
-
$returnMessage = array(
|
|
|
|
|
246 |
}
|
247 |
elseif (!file_exists($tempFiles[$counter])) {
|
248 |
$returnMessage = array("Status" => self::STATUS_ERROR, "Message" => "Unable to locate downloaded file " . $tempFiles[$counter]);
|
229 |
|
230 |
if(is_wp_error( $tempFiles[$counter] )) //also tries with http instead of https
|
231 |
{
|
232 |
+
$tempFiles[$counter] = download_url(str_replace('http://', 'https://', urldecode($fileData->$fileType)));
|
233 |
}
|
234 |
//on success we return this
|
235 |
$returnMessage = array("Status" => self::STATUS_SUCCESS, "Message" => $tempFiles[$counter]);
|
236 |
|
237 |
if ( is_wp_error( $tempFiles[$counter] ) ) {
|
238 |
@unlink($tempFiles[$counter]);
|
239 |
+
$returnMessage = array(
|
240 |
+
"Status" => self::STATUS_ERROR,
|
241 |
+
"Message" => "Error downloading file ({$fileData->$fileType}) " . $tempFiles[$counter]->get_error_message());
|
242 |
}
|
243 |
//check response so that download is OK
|
244 |
elseif( filesize($tempFiles[$counter]) != $correctFileSize) {
|
245 |
$size = filesize($tempFiles[$counter]);
|
246 |
@unlink($tempFiles[$counter]);
|
247 |
+
$returnMessage = array(
|
248 |
+
"Status" => self::STATUS_ERROR,
|
249 |
+
"Message" => "Error downloading file - incorrect file size (downloaded: {$size}, correct: {$correctFileSize} )");
|
250 |
}
|
251 |
elseif (!file_exists($tempFiles[$counter])) {
|
252 |
$returnMessage = array("Status" => self::STATUS_ERROR, "Message" => "Unable to locate downloaded file " . $tempFiles[$counter]);
|
shortpixel_view.php
CHANGED
@@ -23,16 +23,20 @@ class ShortPixelView {
|
|
23 |
<strong><?=number_format($quotaData['mainFiles'] - $quotaData['mainProcessedFiles'])?> images and
|
24 |
<?=number_format(($quotaData['totalFiles'] - $quotaData['mainFiles']) - ($quotaData['totalProcessedFiles'] - $quotaData['mainProcessedFiles']))?> thumbnails</strong> are not yet optimized by ShortPixel.
|
25 |
<?php } ?></p>
|
26 |
-
<
|
27 |
-
|
|
|
|
|
|
|
|
|
28 |
<p>Get more image credits by referring ShortPixel to your friends! <a href="https://shortpixel.com/login/<?=$this->ctrl->getApiKey()?>/tell-a-friend" target="_blank">Check your account</a> for your unique referral link. For each user that joins, you will receive +100 additional image credits/month.</p>
|
29 |
-
|
30 |
</div> <?php
|
31 |
}
|
32 |
|
33 |
public static function displayApiKeyAlert()
|
34 |
{ ?>
|
35 |
-
<p>In order to start the optimization process, you need to validate your API
|
36 |
<p>If you don’t have an API Key, you can get one delivered to your inbox, for free.</p>
|
37 |
<p>Please <a href="https://shortpixel.com/wp-apikey" target="_blank">sign up</a> to get your API key.</p>
|
38 |
<?php
|
@@ -65,20 +69,73 @@ class ShortPixelView {
|
|
65 |
<div class="wrap short-pixel-bulk-page">
|
66 |
<h1>Bulk Image Optimization by ShortPixel</h1>
|
67 |
<?php
|
68 |
-
if ( !$bulkRan ) {
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
<?php
|
83 |
} elseif($percent) // bulk is paused
|
84 |
{ ?>
|
@@ -93,16 +150,32 @@ class ShortPixelView {
|
|
93 |
<p>You can continue optimizing your Media Gallery from where you left, by clicking the Resume processing button. Already optimized images will not be reprocessed.</p>
|
94 |
<?php
|
95 |
} else { ?>
|
96 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
<?=$this->displayBulkStats($quotaData['totalProcessedFiles'], $quotaData['mainProcessedFiles'], $under5PercentCount, $averageCompression, $savedSpace)?>
|
98 |
-
<p>Go to the ShortPixel <a href='<?=get_admin_url()?>options-general.php?page=wp-shortpixel#
|
99 |
<?php if($quotaData['totalProcessedFiles'] < $quotaData['totalFiles']) { ?>
|
100 |
<p><?=number_format($quotaData['mainFiles'] - $quotaData['mainProcessedFiles'])?> images and
|
101 |
<?=number_format(($quotaData['totalFiles'] - $quotaData['mainFiles']) - ($quotaData['totalProcessedFiles'] - $quotaData['mainProcessedFiles']))?> thumbnails are not yet optimized by ShortPixel.</p>
|
102 |
<?php }
|
103 |
$failed = $this->ctrl->getPrioQ()->getFailed();
|
104 |
if(count($failed)) { ?>
|
105 |
-
<p>The following images
|
106 |
<?=$this->displayFailed($failed)?>
|
107 |
<?php } ?>
|
108 |
<p>Restart the optimization process for new images added to your library by clicking the button below. Already optimized images will not be reprocessed.
|
@@ -174,8 +247,7 @@ class ShortPixelView {
|
|
174 |
<?php
|
175 |
}
|
176 |
|
177 |
-
public function displayBulkStats($totalOptimized, $mainOptimized, $under5PercentCount, $averageCompression, $savedSpace) {
|
178 |
-
?>
|
179 |
<div class="bulk-progress bulk-stats">
|
180 |
<div class="label">Processed Images and PDFs:</div><div class="stat-value"><?=number_format($mainOptimized)?></div><br>
|
181 |
<div class="label">Processed Thumbnails:</div><div class="stat-value"><?=number_format($totalOptimized - $mainOptimized)?></div><br>
|
@@ -209,10 +281,11 @@ class ShortPixelView {
|
|
209 |
//wp_enqueue_script('jquery.idTabs.js', plugins_url('/js/jquery.idTabs.js',__FILE__) );
|
210 |
?>
|
211 |
<h1>ShortPixel Plugin Settings</h1>
|
212 |
-
<p>
|
213 |
-
<a href="https://shortpixel.com" target="_blank">
|
214 |
-
|
215 |
-
|
|
|
216 |
</p>
|
217 |
<?php if($notice !== null) { ?>
|
218 |
<br/>
|
@@ -243,11 +316,11 @@ class ShortPixelView {
|
|
243 |
</article>
|
244 |
<script>
|
245 |
jQuery(document).ready(function () {
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
});
|
251 |
});
|
252 |
</script>
|
253 |
<?php
|
@@ -260,11 +333,15 @@ class ShortPixelView {
|
|
260 |
$resize = ($this->ctrl->getResizeImages() ? 'checked' : '');
|
261 |
$resizeDisabled = ($this->ctrl->getResizeImages() ? '' : 'disabled');
|
262 |
$minSizes = $this->ctrl->getMaxIntermediateImageSize();
|
|
|
263 |
?>
|
264 |
<?php if($this->ctrl->getVerifiedKey()) { ?>
|
265 |
-
<p>New images uploaded to the Media Library will be optimized automatically.<br/>If you have existing images you would like to optimize, you can use the <a href="
|
266 |
<?php } else { ?>
|
267 |
-
<
|
|
|
|
|
|
|
268 |
<?php } ?>
|
269 |
<form name='wp_shortpixel_options' action='options-general.php?page=wp-shortpixel&noheader=true' method='post' id='wp_shortpixel_options'>
|
270 |
<table class="form-table">
|
@@ -278,11 +355,6 @@ class ShortPixelView {
|
|
278 |
</td>
|
279 |
</tr>
|
280 |
<?php if (!$this->ctrl->getVerifiedKey()) { //if invalid key we display the link to the API Key ?>
|
281 |
-
<tr>
|
282 |
-
<td style="padding-left: 0px;" colspan="2">Don’t have an API Key?
|
283 |
-
<a href="https://shortpixel.com/wp-apikey<?= $this->ctrl->getAffiliateSufix() ?>" target="_blank">Sign up, it’s free.</a>
|
284 |
-
</td>
|
285 |
-
</tr>
|
286 |
</tbody>
|
287 |
</table>
|
288 |
</form>
|
@@ -292,24 +364,23 @@ class ShortPixelView {
|
|
292 |
<label for="compressionType">Compression type:</label>
|
293 |
</th>
|
294 |
<td>
|
295 |
-
<input type="radio" name="compressionType" value="1" <?= $this->ctrl->getCompressionType() == 1 ? "checked" : "" ?>>Lossy</br
|
|
|
|
|
296 |
<input type="radio" name="compressionType" value="0" <?= $this->ctrl->getCompressionType() != 1 ? "checked" : "" ?>>Lossless
|
|
|
|
|
|
|
297 |
</td>
|
298 |
</tr>
|
299 |
</tbody>
|
300 |
</table>
|
301 |
-
<p style="color: #818181;"> <b>Lossy compression: </b>lossy has a better compression rate than lossless compression.</br>The resulting image
|
302 |
-
is not 100% identical with the original. Works well for photos taken with your camera.</br></br>
|
303 |
-
<b>Lossless compression: </b> the shrunk image will be identical with the original and smaller in size.</br>Use this
|
304 |
-
when you do not want to lose any of the original image's details. Works best for technical drawings,
|
305 |
-
clip art and comics. </p>
|
306 |
<table class="form-table">
|
307 |
<tbody>
|
308 |
<tr>
|
309 |
<th scope="row"><label for="thumbnails">Also include thumbnails:</label></th>
|
310 |
<td><input name="thumbnails" type="checkbox" id="thumbnails" <?= $checked ?>> Apply compression also to
|
311 |
-
<strong
|
312 |
-
image thumbnails.</strong>
|
313 |
<p class="settings-info">Thumbnails count up to your total quota, and should be optimized for best results of your website's speed.</p>
|
314 |
</td>
|
315 |
</tr>
|
@@ -326,12 +397,12 @@ class ShortPixelView {
|
|
326 |
</td>
|
327 |
</tr>
|
328 |
<tr>
|
329 |
-
<th scope="row"><label for="resize">Resize
|
330 |
<td>
|
331 |
<input name="resize" type="checkbox" id="resize" <?= $resize ?>> to maximum
|
332 |
<input type="text" name="width" id="width" style="width:70px" value="<?= max($this->ctrl->getResizeWidth(), min(1024, $minSizes['width'])) ?>" <?= $resizeDisabled ?>/> pixels wide ×
|
333 |
<input type="text" name="height" id="height" style="width:70px" value="<?= max($this->ctrl->getResizeHeight(), min(1024, $minSizes['height'])) ?>" <?= $resizeDisabled ?>/> pixels high
|
334 |
-
<p class="settings-info"> Recommended for large photos, like the ones taken with your phone. Saved space can go up to 80% after resizing.<br/>
|
335 |
The new resolution should not be less than your largest thumbnail size, which is <?=$minSizes['width']?> × <?=$minSizes['height']?> pixels.</p>
|
336 |
</td>
|
337 |
</tr>
|
@@ -339,7 +410,7 @@ class ShortPixelView {
|
|
339 |
</table>
|
340 |
<p class="submit">
|
341 |
<input type="submit" name="save" id="save" class="button button-primary" title="Save Changes" value="Save Changes">
|
342 |
-
<input type="submit" name="save" id="bulk" class="button button-primary" title="Save and go to the Bulk Processing page" value="Bulk Process">
|
343 |
</p>
|
344 |
</form>
|
345 |
<script>
|
23 |
<strong><?=number_format($quotaData['mainFiles'] - $quotaData['mainProcessedFiles'])?> images and
|
24 |
<?=number_format(($quotaData['totalFiles'] - $quotaData['mainFiles']) - ($quotaData['totalProcessedFiles'] - $quotaData['mainProcessedFiles']))?> thumbnails</strong> are not yet optimized by ShortPixel.
|
25 |
<?php } ?></p>
|
26 |
+
<div> <!-- style='float:right;margin-top:20px;'> -->
|
27 |
+
<a class='button button-primary' href='https://shortpixel.com/login/<?=$this->ctrl->getApiKey()?>' target='_blank'>Upgrade</a>
|
28 |
+
<input type='button' name='checkQuota' class='button' value='Confirm New Quota' onclick="javascript:window.location.reload();">
|
29 |
+
</div>
|
30 |
+
<!-- <p>It’s simple to upgrade, just <a href='https://shortpixel.com/login/<?=$this->ctrl->getApiKey()?>' target='_blank'>log into your account</a> and see the available options.
|
31 |
+
You can immediately start processing 5,000 images/month for $4,99, choose another plan that suits you or <a href='https://shortpixel.com/contact' target='_blank'>contact us</a> for larger compression needs.</p> -->
|
32 |
<p>Get more image credits by referring ShortPixel to your friends! <a href="https://shortpixel.com/login/<?=$this->ctrl->getApiKey()?>/tell-a-friend" target="_blank">Check your account</a> for your unique referral link. For each user that joins, you will receive +100 additional image credits/month.</p>
|
33 |
+
|
34 |
</div> <?php
|
35 |
}
|
36 |
|
37 |
public static function displayApiKeyAlert()
|
38 |
{ ?>
|
39 |
+
<p>In order to start the optimization process, you need to validate your API Key in the <a href="options-general.php?page=wp-shortpixel">ShortPixel Settings</a> page in your WordPress Admin.</p>
|
40 |
<p>If you don’t have an API Key, you can get one delivered to your inbox, for free.</p>
|
41 |
<p>Please <a href="https://shortpixel.com/wp-apikey" target="_blank">sign up</a> to get your API key.</p>
|
42 |
<?php
|
69 |
<div class="wrap short-pixel-bulk-page">
|
70 |
<h1>Bulk Image Optimization by ShortPixel</h1>
|
71 |
<?php
|
72 |
+
if ( !$bulkRan ) {
|
73 |
+
?>
|
74 |
+
<form class='start' action='' method='POST' id='startBulk'>
|
75 |
+
<input type='hidden' id='mainToProcess' value='<?=$quotaData['mainFiles'] - $quotaData['mainProcessedFiles']?>'/>
|
76 |
+
<input type='hidden' id='totalToProcess' value='<?=$quotaData['totalFiles'] - $quotaData['totalProcessedFiles']?>'/>
|
77 |
+
<div class="bulk-stats-container">
|
78 |
+
<h3 style='margin-top:0;'>Your image library</h3>
|
79 |
+
<div class="bulk-label">Original images</div>
|
80 |
+
<div class="bulk-val"><?=number_format($quotaData['mainFiles'])?></div><br>
|
81 |
+
<div class="bulk-label">Smaller thumbnails</div>
|
82 |
+
<div class="bulk-val"><?=number_format($quotaData['totalFiles'] - $quotaData['mainFiles'])?></div>
|
83 |
+
<div style='width:165px; display:inline-block; padding-left: 5px'>
|
84 |
+
<input type='checkbox' id='thumbnails' name='thumbnails' onclick='ShortPixel.checkThumbsUpdTotal(this)' <?=$this->ctrl->processThumbnails() ? "checked":""?>> Include thumbnails
|
85 |
+
</div><br>
|
86 |
+
<?php if($quotaData["totalProcessedFiles"] > 0) { ?>
|
87 |
+
<div class="bulk-label bulk-total">Total images</div>
|
88 |
+
<div class="bulk-val bulk-total"><?=number_format($quotaData['totalFiles'])?></div>
|
89 |
+
<br><div class="bulk-label">Already optimized originals</div>
|
90 |
+
<div class="bulk-val"><?=number_format($quotaData['mainProcessedFiles'])?></div><br>
|
91 |
+
<div class="bulk-label">Already optimized thumbnails</div>
|
92 |
+
<div class="bulk-val"><?=number_format($quotaData['totalProcessedFiles'] - $quotaData['mainProcessedFiles'])?></div><br>
|
93 |
+
<?php } ?>
|
94 |
+
<div class="bulk-label bulk-total">Total to be optimized</div>
|
95 |
+
<div class="bulk-val bulk-total" id='displayTotal'><?=number_format($quotaData['totalFiles'] - $quotaData['totalProcessedFiles'])?></div>
|
96 |
+
</div>
|
97 |
+
<?php if($quotaData['totalFiles'] - $quotaData['totalProcessedFiles'] > 0) { ?>
|
98 |
+
<div class="bulk-play">
|
99 |
+
<input type='hidden' name='bulkProcess' id='bulkProcess' value='Start Optimizing'/>
|
100 |
+
<a href='javascript:void();' onclick="document.getElementById('startBulk').submit();" class='button'>
|
101 |
+
<div style="width: 320px">
|
102 |
+
<div class="bulk-btn-img" class="bulk-btn-img">
|
103 |
+
<img src='https://shortpixel.com/img/robo-slider.png'/>
|
104 |
+
</div>
|
105 |
+
<div class="bulk-btn-txt">
|
106 |
+
<span class="label">Start Optimizing</span><br>
|
107 |
+
<span class='total'><?=number_format($quotaData['totalFiles'] - $quotaData['totalProcessedFiles'])?></span> images
|
108 |
+
</div>
|
109 |
+
<div class="bulk-btn-img" class="bulk-btn-img">
|
110 |
+
<img src='<?=plugins_url( 'img/arrow.png', __FILE__ )?>'/>
|
111 |
+
</div>
|
112 |
+
</div>
|
113 |
+
</a>
|
114 |
+
</div>
|
115 |
+
<?php } else {?>
|
116 |
+
<div class="bulk-play">
|
117 |
+
Nothing to optimize! The images that you add to Media Gallery will be automatically optimized after upload.
|
118 |
+
</div>
|
119 |
+
<?php } ?>
|
120 |
</form>
|
121 |
+
<div class='clearfix'></div>
|
122 |
+
<div class="bulk-wide">
|
123 |
+
<h3 style='font-size: 1.1em; font-weight: bold;'>In order for the optimization to run, you must keep this page open and your computer running. If you close the page for whatever reason, just turn back to it and the bulk process will resume.</h3>
|
124 |
+
</div>
|
125 |
+
<div class='clearfix'></div>
|
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 trafic 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">
|
133 |
+
<h3>How does it work?</h3>
|
134 |
+
<p>The plugin processes images starting with the newest ones you uploaded in your Media Library.</p>
|
135 |
+
<p>You will be able to pause the process anytime.</p>
|
136 |
+
<p><?=$this->ctrl->backupImages() ? "<p>Your original images will be stored in a separate back-up folder.</p>" : ""?></p>
|
137 |
+
<p>You can watch the images being processed live, right here, after you start optimizing.</p>
|
138 |
+
</div>
|
139 |
<?php
|
140 |
} elseif($percent) // bulk is paused
|
141 |
{ ?>
|
150 |
<p>You can continue optimizing your Media Gallery from where you left, by clicking the Resume processing button. Already optimized images will not be reprocessed.</p>
|
151 |
<?php
|
152 |
} else { ?>
|
153 |
+
<div class='notice notice-success'>
|
154 |
+
<p style='display:inline-block;'>Congratulations, your media library has been successfully optimized!<br>Share your optimization results on Twitter:
|
155 |
+
</p>
|
156 |
+
<div style='display:inline-block;margin-left: 20px;'>
|
157 |
+
<a href="https://twitter.com/share" class="twitter-share-button" data-url="https://shortpixel.com"
|
158 |
+
data-text="I just optimized my images<?=0+$averageCompression>20 ? " by ".round($averageCompression) ."%" : ""?><?=false && (0+$savedSpace>0 ? " saving $savedSpace" : "")?> with @ShortPixel, a great plugin for increasing #WordPress page speed:" data-size='large'>Tweet</a>
|
159 |
+
<script>
|
160 |
+
!function(d,s,id){//Just optimized my site with ShortPixel image optimization plugin
|
161 |
+
var js,
|
162 |
+
fjs=d.getElementsByTagName(s)[0],
|
163 |
+
p=/^http:/.test(d.location)?'http':'https';
|
164 |
+
if(!d.getElementById(id)){js=d.createElement(s);
|
165 |
+
js.id=id;js.src=p+'://platform.twitter.com/widgets.js';
|
166 |
+
fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');
|
167 |
+
</script>
|
168 |
+
</div>
|
169 |
+
</div>
|
170 |
<?=$this->displayBulkStats($quotaData['totalProcessedFiles'], $quotaData['mainProcessedFiles'], $under5PercentCount, $averageCompression, $savedSpace)?>
|
171 |
+
<p>Go to the ShortPixel <a href='<?=get_admin_url()?>options-general.php?page=wp-shortpixel#stats'>Stats</a> and see all your websites' optimized stats. Download your detailed <a href="https://api.shortpixel.com/v2/report.php?key=<?=$this->ctrl->getApiKey()?>">Optimization Report</a> to check your image optimization statistics for the last 40 days</p>
|
172 |
<?php if($quotaData['totalProcessedFiles'] < $quotaData['totalFiles']) { ?>
|
173 |
<p><?=number_format($quotaData['mainFiles'] - $quotaData['mainProcessedFiles'])?> images and
|
174 |
<?=number_format(($quotaData['totalFiles'] - $quotaData['mainFiles']) - ($quotaData['totalProcessedFiles'] - $quotaData['mainProcessedFiles']))?> thumbnails are not yet optimized by ShortPixel.</p>
|
175 |
<?php }
|
176 |
$failed = $this->ctrl->getPrioQ()->getFailed();
|
177 |
if(count($failed)) { ?>
|
178 |
+
<p>The following images could not be processed because of their limited write rights. This usually happens if you have changed your hosting provider. Please restart the optimization process after you granted write rights to all the files below.</p>
|
179 |
<?=$this->displayFailed($failed)?>
|
180 |
<?php } ?>
|
181 |
<p>Restart the optimization process for new images added to your library by clicking the button below. Already optimized images will not be reprocessed.
|
247 |
<?php
|
248 |
}
|
249 |
|
250 |
+
public function displayBulkStats($totalOptimized, $mainOptimized, $under5PercentCount, $averageCompression, $savedSpace) {?>
|
|
|
251 |
<div class="bulk-progress bulk-stats">
|
252 |
<div class="label">Processed Images and PDFs:</div><div class="stat-value"><?=number_format($mainOptimized)?></div><br>
|
253 |
<div class="label">Processed Thumbnails:</div><div class="stat-value"><?=number_format($totalOptimized - $mainOptimized)?></div><br>
|
281 |
//wp_enqueue_script('jquery.idTabs.js', plugins_url('/js/jquery.idTabs.js',__FILE__) );
|
282 |
?>
|
283 |
<h1>ShortPixel Plugin Settings</h1>
|
284 |
+
<p style="font-size:18px">
|
285 |
+
<a href="https://shortpixel.com/<?=$this->ctrl->getVerifiedKey() ? "login/".$this->ctrl->getApiKey() : "pricing"?>" target="_blank" style="font-size:18px">
|
286 |
+
Upgrade now
|
287 |
+
</a> |
|
288 |
+
<a href="https://shortpixel.com/contact" target="_blank" style="font-size:18px">Support </a>
|
289 |
</p>
|
290 |
<?php if($notice !== null) { ?>
|
291 |
<br/>
|
316 |
</article>
|
317 |
<script>
|
318 |
jQuery(document).ready(function () {
|
319 |
+
if(window.location.hash) {
|
320 |
+
var target = 'tab-' + window.location.hash.substring(window.location.hash.indexOf("#")+1)
|
321 |
+
ShortPixel.switchSettingsTab(target);
|
322 |
+
}
|
323 |
+
jQuery("article.tabs a.tab-link").click(function(){ShortPixel.switchSettingsTab(jQuery(this).data("id"))});
|
324 |
});
|
325 |
</script>
|
326 |
<?php
|
333 |
$resize = ($this->ctrl->getResizeImages() ? 'checked' : '');
|
334 |
$resizeDisabled = ($this->ctrl->getResizeImages() ? '' : 'disabled');
|
335 |
$minSizes = $this->ctrl->getMaxIntermediateImageSize();
|
336 |
+
$thumbnailsToProcess = isset($quotaData['totalFiles']) ? ($quotaData['totalFiles'] - $quotaData['mainFiles']) - ($quotaData['totalProcessedFiles'] - $quotaData['mainProcessedFiles']) : 0;
|
337 |
?>
|
338 |
<?php if($this->ctrl->getVerifiedKey()) { ?>
|
339 |
+
<p>New images uploaded to the Media Library will be optimized automatically.<br/>If you have existing images you would like to optimize, you can use the <a href="<?=get_admin_url()?>upload.php?page=wp-short-pixel-bulk">Bulk Optimization Tool</a>.</p>
|
340 |
<?php } else { ?>
|
341 |
+
<h3>Step 1:</h3>
|
342 |
+
<p style='font-size: 14px'>If you don't have an API Key, <a href="https://shortpixel.com/wp-apikey<?= $this->ctrl->getAffiliateSufix() ?>" target="_blank">sign up here.</a> It's free and it only takes one minute, we promise!</p>
|
343 |
+
<h3>Step 2:</h3>
|
344 |
+
<p style='font-size: 14px'>Please enter here the API Key you received by email and press Validate.</p>
|
345 |
<?php } ?>
|
346 |
<form name='wp_shortpixel_options' action='options-general.php?page=wp-shortpixel&noheader=true' method='post' id='wp_shortpixel_options'>
|
347 |
<table class="form-table">
|
355 |
</td>
|
356 |
</tr>
|
357 |
<?php if (!$this->ctrl->getVerifiedKey()) { //if invalid key we display the link to the API Key ?>
|
|
|
|
|
|
|
|
|
|
|
358 |
</tbody>
|
359 |
</table>
|
360 |
</form>
|
364 |
<label for="compressionType">Compression type:</label>
|
365 |
</th>
|
366 |
<td>
|
367 |
+
<input type="radio" name="compressionType" value="1" <?= $this->ctrl->getCompressionType() == 1 ? "checked" : "" ?>>Lossy</br>
|
368 |
+
<p class="settings-info"> <b>Lossy compression: </b>lossy has a better compression rate than lossless compression.</br>The resulting image
|
369 |
+
is not 100% identical with the original. Works well for photos taken with your camera.</p></br>
|
370 |
<input type="radio" name="compressionType" value="0" <?= $this->ctrl->getCompressionType() != 1 ? "checked" : "" ?>>Lossless
|
371 |
+
<p class="settings-info"><b>Lossless compression: </b> the shrunk image will be identical with the original and smaller in size.</br>Use this
|
372 |
+
when you do not want to lose any of the original image's details. Works best for technical drawings,
|
373 |
+
clip art and comics. </p>
|
374 |
</td>
|
375 |
</tr>
|
376 |
</tbody>
|
377 |
</table>
|
|
|
|
|
|
|
|
|
|
|
378 |
<table class="form-table">
|
379 |
<tbody>
|
380 |
<tr>
|
381 |
<th scope="row"><label for="thumbnails">Also include thumbnails:</label></th>
|
382 |
<td><input name="thumbnails" type="checkbox" id="thumbnails" <?= $checked ?>> Apply compression also to
|
383 |
+
<strong><?=$thumbnailsToProcess ? number_format($thumbnailsToProcess) : ""?> image thumbnails.</strong>
|
|
|
384 |
<p class="settings-info">Thumbnails count up to your total quota, and should be optimized for best results of your website's speed.</p>
|
385 |
</td>
|
386 |
</tr>
|
397 |
</td>
|
398 |
</tr>
|
399 |
<tr>
|
400 |
+
<th scope="row"><label for="resize">Resize large images</label></th>
|
401 |
<td>
|
402 |
<input name="resize" type="checkbox" id="resize" <?= $resize ?>> to maximum
|
403 |
<input type="text" name="width" id="width" style="width:70px" value="<?= max($this->ctrl->getResizeWidth(), min(1024, $minSizes['width'])) ?>" <?= $resizeDisabled ?>/> pixels wide ×
|
404 |
<input type="text" name="height" id="height" style="width:70px" value="<?= max($this->ctrl->getResizeHeight(), min(1024, $minSizes['height'])) ?>" <?= $resizeDisabled ?>/> pixels high
|
405 |
+
<p class="settings-info"> Recommended for large photos, like the ones taken with your phone. Saved space can go up to 80% or more after resizing.<br/>
|
406 |
The new resolution should not be less than your largest thumbnail size, which is <?=$minSizes['width']?> × <?=$minSizes['height']?> pixels.</p>
|
407 |
</td>
|
408 |
</tr>
|
410 |
</table>
|
411 |
<p class="submit">
|
412 |
<input type="submit" name="save" id="save" class="button button-primary" title="Save Changes" value="Save Changes">
|
413 |
+
<input type="submit" name="save" id="bulk" class="button button-primary" title="Save and go to the Bulk Processing page" value="Save and Go to Bulk Process">
|
414 |
</p>
|
415 |
</form>
|
416 |
<script>
|
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.1.
|
7 |
* Author: ShortPixel
|
8 |
* Author URI: https://shortpixel.com
|
9 |
*/
|
@@ -17,11 +17,11 @@ if ( !is_plugin_active( 'wpmandrill/wpmandrill.php' ) && !is_plugin_active( 'wp-
|
|
17 |
require_once( ABSPATH . 'wp-includes/pluggable.php' );//to avoid conflict with wpmandrill plugin
|
18 |
}
|
19 |
|
20 |
-
define('SP_RESET_ON_ACTIVATE', false);
|
21 |
|
22 |
define('SP_AFFILIATE_CODE', '');
|
23 |
|
24 |
-
define('PLUGIN_VERSION', "3.1.
|
25 |
define('SP_MAX_TIMEOUT', 10);
|
26 |
define('SP_VALIDATE_MAX_TIMEOUT', 60);
|
27 |
define('SP_BACKUP', 'ShortpixelBackups');
|
@@ -76,7 +76,7 @@ class WPShortPixel {
|
|
76 |
$this->prioQ = new ShortPixelQueue($this);
|
77 |
$this->view = new ShortPixelView($this);
|
78 |
|
79 |
-
define('QUOTA_EXCEEDED', "Quota Exceeded. <a href='https://shortpixel.com/login/".$this->_apiKey."' target='_blank'>Extend Quota</a>");
|
80 |
|
81 |
$this->setDefaultViewModeList();//set default mode as list. only @ first run
|
82 |
|
@@ -564,7 +564,9 @@ class WPShortPixel {
|
|
564 |
$result["BulkMsg"] = $msg;
|
565 |
}
|
566 |
}
|
567 |
-
|
|
|
|
|
568 |
die(json_encode($result));
|
569 |
}
|
570 |
|
@@ -585,7 +587,7 @@ class WPShortPixel {
|
|
585 |
$this->sendToProcessing($imageId);
|
586 |
$ret = array("Status" => ShortPixelAPI::STATUS_SUCCESS, "message" => "");
|
587 |
} else {
|
588 |
-
|
589 |
}
|
590 |
//TODO curata functia asta
|
591 |
die(json_encode($ret));
|
@@ -736,7 +738,7 @@ class WPShortPixel {
|
|
736 |
global $wpdb;
|
737 |
|
738 |
if( $this->_verifiedKey == false ) {//invalid API Key
|
739 |
-
ShortPixelView::
|
740 |
return;
|
741 |
}
|
742 |
|
@@ -940,7 +942,7 @@ class WPShortPixel {
|
|
940 |
update_option( 'wp-short-pixel-resize-width', 0 + $this->_resizeWidth);
|
941 |
update_option( 'wp-short-pixel-resize-height', 0 + $this->_resizeHeight);
|
942 |
|
943 |
-
if($_POST['save'] == "Bulk Process") {
|
944 |
wp_redirect("upload.php?page=wp-short-pixel-bulk");
|
945 |
exit();
|
946 |
}
|
@@ -1024,7 +1026,8 @@ class WPShortPixel {
|
|
1024 |
//Second fallback to HTTP get
|
1025 |
if(is_wp_error( $response )){
|
1026 |
$args['body'] = null;
|
1027 |
-
$
|
|
|
1028 |
}
|
1029 |
$defaultData = array(
|
1030 |
"APIKeyValid" => false,
|
@@ -1044,6 +1047,7 @@ class WPShortPixel {
|
|
1044 |
}
|
1045 |
|
1046 |
if($response['response']['code'] != 200) {
|
|
|
1047 |
return $defaultData;
|
1048 |
}
|
1049 |
|
@@ -1111,7 +1115,7 @@ class WPShortPixel {
|
|
1111 |
{
|
1112 |
print 'PDF not processed';
|
1113 |
//if($this->_verifiedKey) {
|
1114 |
-
print "
|
1115 |
//}
|
1116 |
return;
|
1117 |
}
|
@@ -1128,7 +1132,7 @@ class WPShortPixel {
|
|
1128 |
else
|
1129 |
{
|
1130 |
print 'Waiting for bulk processing';
|
1131 |
-
print "
|
1132 |
}
|
1133 |
}
|
1134 |
elseif( is_numeric($data['ShortPixelImprovement']) ) {
|
@@ -1142,7 +1146,7 @@ class WPShortPixel {
|
|
1142 |
print $data['ShortPixelImprovement'] . '%';
|
1143 |
}
|
1144 |
if ( get_option('wp-short-backup_images') && !isset($data['ShortPixel']['NoBackup'])) //display restore backup option only when backup is active
|
1145 |
-
print "
|
1146 |
if (isset($data['sizes']) && count($data['sizes'])) {
|
1147 |
print "<br>+" . count($data['sizes']) . " thumbnails optimized";
|
1148 |
}
|
@@ -1153,7 +1157,7 @@ class WPShortPixel {
|
|
1153 |
{
|
1154 |
print QUOTA_EXCEEDED;
|
1155 |
if ( !get_option('wp-short-pixel-quota-exceeded') )
|
1156 |
-
print "
|
1157 |
}
|
1158 |
elseif ( trim(strip_tags($data['ShortPixelImprovement'])) == "Cannot write optimized file" )
|
1159 |
{
|
@@ -1196,7 +1200,7 @@ class WPShortPixel {
|
|
1196 |
else
|
1197 |
{
|
1198 |
print 'Image not processed';
|
1199 |
-
print "
|
1200 |
}
|
1201 |
if (count($data['sizes'])) {
|
1202 |
print "<br>+" . count($data['sizes']) . " thumbnails";
|
@@ -1211,7 +1215,7 @@ class WPShortPixel {
|
|
1211 |
else
|
1212 |
{
|
1213 |
print 'PDF not processed';
|
1214 |
-
print "
|
1215 |
}
|
1216 |
}
|
1217 |
}
|
@@ -1220,7 +1224,7 @@ class WPShortPixel {
|
|
1220 |
}
|
1221 |
|
1222 |
public function columns( $defaults ) {
|
1223 |
-
$defaults['wp-shortPixel'] = 'ShortPixel Compression';
|
1224 |
return $defaults;
|
1225 |
}
|
1226 |
|
@@ -1256,12 +1260,16 @@ class WPShortPixel {
|
|
1256 |
|
1257 |
static public function isProcessable($ID) {
|
1258 |
$path = get_attached_file($ID);//get the full file PATH
|
|
|
|
|
|
|
|
|
1259 |
$pathParts = pathinfo($path);
|
1260 |
if( isset($pathParts['extension']) && in_array(strtolower($pathParts['extension']), array('jpg', 'jpeg', 'gif', 'png', 'pdf'))) {
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
}
|
1266 |
|
1267 |
|
@@ -1388,13 +1396,15 @@ class WPShortPixel {
|
|
1388 |
else
|
1389 |
{
|
1390 |
$attachment = unserialize($file->meta_value);
|
1391 |
-
if
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
|
|
|
|
1398 |
}
|
1399 |
}
|
1400 |
}
|
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.1.6
|
7 |
* Author: ShortPixel
|
8 |
* Author URI: https://shortpixel.com
|
9 |
*/
|
17 |
require_once( ABSPATH . 'wp-includes/pluggable.php' );//to avoid conflict with wpmandrill plugin
|
18 |
}
|
19 |
|
20 |
+
define('SP_RESET_ON_ACTIVATE', false); //TODO remove
|
21 |
|
22 |
define('SP_AFFILIATE_CODE', '');
|
23 |
|
24 |
+
define('PLUGIN_VERSION', "3.1.6");
|
25 |
define('SP_MAX_TIMEOUT', 10);
|
26 |
define('SP_VALIDATE_MAX_TIMEOUT', 60);
|
27 |
define('SP_BACKUP', 'ShortpixelBackups');
|
76 |
$this->prioQ = new ShortPixelQueue($this);
|
77 |
$this->view = new ShortPixelView($this);
|
78 |
|
79 |
+
define('QUOTA_EXCEEDED', "Quota Exceeded. <a class='button button-smaller button-primary' href='https://shortpixel.com/login/".$this->_apiKey."' target='_blank'>Extend Quota</a>");
|
80 |
|
81 |
$this->setDefaultViewModeList();//set default mode as list. only @ first run
|
82 |
|
564 |
$result["BulkMsg"] = $msg;
|
565 |
}
|
566 |
}
|
567 |
+
if($result["Status"] !== ShortPixelAPI::STATUS_RETRY) {
|
568 |
+
update_option( 'wp-short-pixel-bulk-last-status', $result);
|
569 |
+
}
|
570 |
die(json_encode($result));
|
571 |
}
|
572 |
|
587 |
$this->sendToProcessing($imageId);
|
588 |
$ret = array("Status" => ShortPixelAPI::STATUS_SUCCESS, "message" => "");
|
589 |
} else {
|
590 |
+
$ret = array("Status" => ShortPixelAPI::STATUS_SKIP, "message" => $imageId);
|
591 |
}
|
592 |
//TODO curata functia asta
|
593 |
die(json_encode($ret));
|
738 |
global $wpdb;
|
739 |
|
740 |
if( $this->_verifiedKey == false ) {//invalid API Key
|
741 |
+
ShortPixelView::displayActivationNotice();
|
742 |
return;
|
743 |
}
|
744 |
|
942 |
update_option( 'wp-short-pixel-resize-width', 0 + $this->_resizeWidth);
|
943 |
update_option( 'wp-short-pixel-resize-height', 0 + $this->_resizeHeight);
|
944 |
|
945 |
+
if($_POST['save'] == "Save and Go to Bulk Process") {
|
946 |
wp_redirect("upload.php?page=wp-short-pixel-bulk");
|
947 |
exit();
|
948 |
}
|
1026 |
//Second fallback to HTTP get
|
1027 |
if(is_wp_error( $response )){
|
1028 |
$args['body'] = null;
|
1029 |
+
$requestURL .= $argsStr;
|
1030 |
+
$response = wp_remote_get(str_replace('https://', 'http://', $requestURL), $args);
|
1031 |
}
|
1032 |
$defaultData = array(
|
1033 |
"APIKeyValid" => false,
|
1047 |
}
|
1048 |
|
1049 |
if($response['response']['code'] != 200) {
|
1050 |
+
//$defaultData['Message'] .= "<BR><i>Debug info: response code {$response['response']['code']} URL $requestURL , Response ".json_encode($response)."</i>";
|
1051 |
return $defaultData;
|
1052 |
}
|
1053 |
|
1115 |
{
|
1116 |
print 'PDF not processed';
|
1117 |
//if($this->_verifiedKey) {
|
1118 |
+
print " <a class='button button-smaller button-primary' href=\"javascript:manualOptimization({$id})\">Optimize now</a>";
|
1119 |
//}
|
1120 |
return;
|
1121 |
}
|
1132 |
else
|
1133 |
{
|
1134 |
print 'Waiting for bulk processing';
|
1135 |
+
print " <a class='button button-smaller button-primary' href=\"javascript:manualOptimization({$id})\">Optimize now</a>";
|
1136 |
}
|
1137 |
}
|
1138 |
elseif( is_numeric($data['ShortPixelImprovement']) ) {
|
1146 |
print $data['ShortPixelImprovement'] . '%';
|
1147 |
}
|
1148 |
if ( get_option('wp-short-backup_images') && !isset($data['ShortPixel']['NoBackup'])) //display restore backup option only when backup is active
|
1149 |
+
print " <a class='button button-smaller' href=\"admin.php?action=shortpixel_restore_backup&attachment_ID={$id}\">Restore backup</a>";
|
1150 |
if (isset($data['sizes']) && count($data['sizes'])) {
|
1151 |
print "<br>+" . count($data['sizes']) . " thumbnails optimized";
|
1152 |
}
|
1157 |
{
|
1158 |
print QUOTA_EXCEEDED;
|
1159 |
if ( !get_option('wp-short-pixel-quota-exceeded') )
|
1160 |
+
print " <a class='button button-smaller button-primary' href=\"javascript:manualOptimization({$id})\">Try again</a>";
|
1161 |
}
|
1162 |
elseif ( trim(strip_tags($data['ShortPixelImprovement'])) == "Cannot write optimized file" )
|
1163 |
{
|
1200 |
else
|
1201 |
{
|
1202 |
print 'Image not processed';
|
1203 |
+
print " <a class='button button-smaller button-primary' href=\"javascript:manualOptimization({$id})\">Optimize now</a>";
|
1204 |
}
|
1205 |
if (count($data['sizes'])) {
|
1206 |
print "<br>+" . count($data['sizes']) . " thumbnails";
|
1215 |
else
|
1216 |
{
|
1217 |
print 'PDF not processed';
|
1218 |
+
print " <a class='button button-smaller button-primary' href=\"javascript:manualOptimization({$id})\">Optimize now</a>";
|
1219 |
}
|
1220 |
}
|
1221 |
}
|
1224 |
}
|
1225 |
|
1226 |
public function columns( $defaults ) {
|
1227 |
+
$defaults['wp-shortPixel'] = 'ShortPixel Compression <a href="options-general.php?page=wp-shortpixel#stats" title="ShortPixel Statistics"><span class="dashicons dashicons-dashboard"></span></a>';
|
1228 |
return $defaults;
|
1229 |
}
|
1230 |
|
1260 |
|
1261 |
static public function isProcessable($ID) {
|
1262 |
$path = get_attached_file($ID);//get the full file PATH
|
1263 |
+
return self::isProcessablePath($path);
|
1264 |
+
}
|
1265 |
+
|
1266 |
+
static public function isProcessablePath($path) {
|
1267 |
$pathParts = pathinfo($path);
|
1268 |
if( isset($pathParts['extension']) && in_array(strtolower($pathParts['extension']), array('jpg', 'jpeg', 'gif', 'png', 'pdf'))) {
|
1269 |
+
return true;
|
1270 |
+
} else {
|
1271 |
+
return false;
|
1272 |
+
}
|
1273 |
}
|
1274 |
|
1275 |
|
1396 |
else
|
1397 |
{
|
1398 |
$attachment = unserialize($file->meta_value);
|
1399 |
+
if(self::isProcessablePath($attachment['file'])){
|
1400 |
+
if ( isset($attachment['sizes']) )
|
1401 |
+
$totalFiles += count($attachment['sizes']);
|
1402 |
+
|
1403 |
+
if ( isset($attachment['file']) )
|
1404 |
+
{
|
1405 |
+
$totalFiles++;
|
1406 |
+
$mainFiles++;
|
1407 |
+
}
|
1408 |
}
|
1409 |
}
|
1410 |
}
|