Version Description
- alert user when the plugin doesn't have rights to write to the uploads folder
Download this release
Release Info
Developer | ShortPixel |
Plugin | ShortPixel Image Optimizer |
Version | 4.8.6 |
Comparing to | |
See all releases |
Code changes from version 4.8.5 to 4.8.6
- class/db/shortpixel-custom-meta-dao.php +3 -3
- class/front/img-to-picture-webp.php +2 -2
- class/shortpixel_queue.php +13 -1
- class/view/shortpixel_view.php +10 -2
- class/wp-short-pixel.php +3 -0
- readme.txt +4 -1
- wp-shortpixel.php +2 -2
class/db/shortpixel-custom-meta-dao.php
CHANGED
@@ -43,7 +43,7 @@ class ShortPixelCustomMetaDao {
|
|
43 |
name varchar(64),
|
44 |
path_md5 char(32),
|
45 |
file_count int,
|
46 |
-
status
|
47 |
ts_updated timestamp,
|
48 |
ts_created timestamp,
|
49 |
UNIQUE KEY id (id)
|
@@ -67,8 +67,8 @@ class ShortPixelCustomMetaDao {
|
|
67 |
resize_width smallint,
|
68 |
resize_height smallint,
|
69 |
backup tinyint,
|
70 |
-
status
|
71 |
-
retries tinyint DEFAULT 0,
|
72 |
message varchar(255),
|
73 |
ts_added timestamp,
|
74 |
ts_optimized timestamp,
|
43 |
name varchar(64),
|
44 |
path_md5 char(32),
|
45 |
file_count int,
|
46 |
+
status SMALLINT NOT NULL DEFAULT 0,
|
47 |
ts_updated timestamp,
|
48 |
ts_created timestamp,
|
49 |
UNIQUE KEY id (id)
|
67 |
resize_width smallint,
|
68 |
resize_height smallint,
|
69 |
backup tinyint,
|
70 |
+
status SMALLINT NOT NULL DEFAULT 0,
|
71 |
+
retries tinyint NOT NULL DEFAULT 0,
|
72 |
message varchar(255),
|
73 |
ts_added timestamp,
|
74 |
ts_optimized timestamp,
|
class/front/img-to-picture-webp.php
CHANGED
@@ -85,7 +85,7 @@ class ShortPixelImgToPictureWebp {
|
|
85 |
}, $content);
|
86 |
}
|
87 |
|
88 |
-
|
89 |
{
|
90 |
$image_node = mb_convert_encoding($image_node, 'HTML-ENTITIES', 'UTF-8');
|
91 |
$dom = new DOMDocument();
|
@@ -104,7 +104,7 @@ class ShortPixelImgToPictureWebp {
|
|
104 |
* @param $attribute_array
|
105 |
* @return string
|
106 |
*/
|
107 |
-
|
108 |
{
|
109 |
$attributes = '';
|
110 |
foreach ($attribute_array as $attribute => $value) {
|
85 |
}, $content);
|
86 |
}
|
87 |
|
88 |
+
public static function get_attributes( $image_node )
|
89 |
{
|
90 |
$image_node = mb_convert_encoding($image_node, 'HTML-ENTITIES', 'UTF-8');
|
91 |
$dom = new DOMDocument();
|
104 |
* @param $attribute_array
|
105 |
* @return string
|
106 |
*/
|
107 |
+
public static function create_attributes( $attribute_array )
|
108 |
{
|
109 |
$attributes = '';
|
110 |
foreach ($attribute_array as $attribute => $value) {
|
class/shortpixel_queue.php
CHANGED
@@ -26,6 +26,7 @@ class ShortPixelQueue {
|
|
26 |
|
27 |
public static function get() {
|
28 |
$fp = self::openQ(LOCK_SH);
|
|
|
29 |
$itemsRaw = fgets($fp);
|
30 |
$items = strlen($itemsRaw) ? self::parseQ($itemsRaw) : array();
|
31 |
self::closeQ($fp);
|
@@ -34,6 +35,7 @@ class ShortPixelQueue {
|
|
34 |
|
35 |
public static function set($items) {
|
36 |
$fp = self::openQ();
|
|
|
37 |
fseek($fp, 0);
|
38 |
ftruncate($fp, 0); // truncate file
|
39 |
fwrite($fp, implode(',', $items));
|
@@ -43,6 +45,7 @@ class ShortPixelQueue {
|
|
43 |
|
44 |
public function apply($callable, $extra = false) {
|
45 |
$fp = self::openQ();
|
|
|
46 |
$itemsRaw = fgets($fp);
|
47 |
$items = strlen($itemsRaw) ? self::parseQ($itemsRaw) : array();
|
48 |
if($extra) {
|
@@ -58,13 +61,21 @@ class ShortPixelQueue {
|
|
58 |
return $items;
|
59 |
}
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
protected static function openQ($lock = LOCK_EX) {
|
62 |
$queueName = SHORTPIXEL_UPLOADS_BASE . "/.shortpixel-q-" . get_current_blog_id();
|
63 |
$fp = @fopen($queueName, "r+");
|
64 |
if(!$fp) {
|
65 |
$fp = @fopen($queueName, "w");
|
66 |
}
|
67 |
-
|
|
|
68 |
return $fp;
|
69 |
}
|
70 |
protected static function closeQ($fp) {
|
@@ -171,6 +182,7 @@ class ShortPixelQueue {
|
|
171 |
public function remove($ID)//remove an ID from priority queue
|
172 |
{
|
173 |
$fp = $this->openQ();
|
|
|
174 |
$items = fgets($fp);
|
175 |
$items = self::parseQ($items);
|
176 |
$items = is_array($items) ? $items : array();
|
26 |
|
27 |
public static function get() {
|
28 |
$fp = self::openQ(LOCK_SH);
|
29 |
+
if(!$fp) return false;
|
30 |
$itemsRaw = fgets($fp);
|
31 |
$items = strlen($itemsRaw) ? self::parseQ($itemsRaw) : array();
|
32 |
self::closeQ($fp);
|
35 |
|
36 |
public static function set($items) {
|
37 |
$fp = self::openQ();
|
38 |
+
if(!$fp) return false;
|
39 |
fseek($fp, 0);
|
40 |
ftruncate($fp, 0); // truncate file
|
41 |
fwrite($fp, implode(',', $items));
|
45 |
|
46 |
public function apply($callable, $extra = false) {
|
47 |
$fp = self::openQ();
|
48 |
+
if(!$fp) return false;
|
49 |
$itemsRaw = fgets($fp);
|
50 |
$items = strlen($itemsRaw) ? self::parseQ($itemsRaw) : array();
|
51 |
if($extra) {
|
61 |
return $items;
|
62 |
}
|
63 |
|
64 |
+
public static function testQ() {
|
65 |
+
$fp = self::openQ();
|
66 |
+
if($fp === false) return false;
|
67 |
+
self::closeQ($fp);
|
68 |
+
return true;
|
69 |
+
}
|
70 |
+
|
71 |
protected static function openQ($lock = LOCK_EX) {
|
72 |
$queueName = SHORTPIXEL_UPLOADS_BASE . "/.shortpixel-q-" . get_current_blog_id();
|
73 |
$fp = @fopen($queueName, "r+");
|
74 |
if(!$fp) {
|
75 |
$fp = @fopen($queueName, "w");
|
76 |
}
|
77 |
+
if(!$fp) return false;
|
78 |
+
while (!flock($fp, $lock)) {usleep(100000);} // acquire the lock, the stubborn way...
|
79 |
return $fp;
|
80 |
}
|
81 |
protected static function closeQ($fp) {
|
182 |
public function remove($ID)//remove an ID from priority queue
|
183 |
{
|
184 |
$fp = $this->openQ();
|
185 |
+
if(!$fp) return false;
|
186 |
$items = fgets($fp);
|
187 |
$items = self::parseQ($items);
|
188 |
$items = is_array($items) ? $items : array();
|
class/view/shortpixel_view.php
CHANGED
@@ -77,10 +77,11 @@ class ShortPixelView {
|
|
77 |
}
|
78 |
|
79 |
public static function displayActivationNotice($when = 'activate', $extra = '') {
|
80 |
-
$extraStyle = $when == 'compat' ? "style='border-left: 4px solid #ff0000;'" :
|
81 |
($when == 'upgmonth' || $when == 'upgbulk' ? "style='border-left: 4px solid #46b450;'" : '');
|
82 |
$icon = false;
|
83 |
switch($when) {
|
|
|
84 |
case 'unlisted': $icon = 'magnifier'; break;
|
85 |
case 'upgmonth':
|
86 |
case 'upgbulk': $icon = 'notes'; break;
|
@@ -96,8 +97,10 @@ class ShortPixelView {
|
|
96 |
<?php if($when == 'unlisted'){ ?>
|
97 |
<a href="javascript:ShortPixel.includeUnlisted()" class="button button-primary" style="margin-top:10px;margin-left:10px;">
|
98 |
<strong><?php _e('Yes, include these thumbnails','shortpixel-image-optimiser');?></strong></a>
|
99 |
-
<?php }
|
|
|
100 |
<a href="javascript:dismissShortPixelNotice('<?php echo($when);?>')" class="button" style="margin-top:10px;"><?php _e('Dismiss','shortpixel-image-optimiser');?></a>
|
|
|
101 |
</div>
|
102 |
<?php if($icon){ ?>
|
103 |
<img src="<?php echo(plugins_url('/shortpixel-image-optimiser/res/img/robo-' . $icon . '.png'));?>"
|
@@ -120,6 +123,10 @@ class ShortPixelView {
|
|
120 |
case 'activate':
|
121 |
self::displayApiKeyAlert();
|
122 |
break;
|
|
|
|
|
|
|
|
|
123 |
case 'compat' :
|
124 |
_e("Using ShortPixel while other image optimization plugins are active can lead to unpredictable results. We recommend to deactivate the following plugin(s): ",'shortpixel-image-optimiser');
|
125 |
echo('<ul>');
|
@@ -955,6 +962,7 @@ class ShortPixelView {
|
|
955 |
<tr>
|
956 |
<th scope="row"><label for="resize"><?php _e('Additional media folders','shortpixel-image-optimiser');?></label></th>
|
957 |
<td>
|
|
|
958 |
<?php if($customFolders) { ?>
|
959 |
<table class="shortpixel-folders-list">
|
960 |
<tr style="font-weight: bold;">
|
77 |
}
|
78 |
|
79 |
public static function displayActivationNotice($when = 'activate', $extra = '') {
|
80 |
+
$extraStyle = $when == 'compat' || $when == 'fileperms' ? "style='border-left: 4px solid #ff0000;'" :
|
81 |
($when == 'upgmonth' || $when == 'upgbulk' ? "style='border-left: 4px solid #46b450;'" : '');
|
82 |
$icon = false;
|
83 |
switch($when) {
|
84 |
+
case 'fileperms': $icon = 'scared'; break;
|
85 |
case 'unlisted': $icon = 'magnifier'; break;
|
86 |
case 'upgmonth':
|
87 |
case 'upgbulk': $icon = 'notes'; break;
|
97 |
<?php if($when == 'unlisted'){ ?>
|
98 |
<a href="javascript:ShortPixel.includeUnlisted()" class="button button-primary" style="margin-top:10px;margin-left:10px;">
|
99 |
<strong><?php _e('Yes, include these thumbnails','shortpixel-image-optimiser');?></strong></a>
|
100 |
+
<?php }
|
101 |
+
if($when !== 'fileperms') { ?>
|
102 |
<a href="javascript:dismissShortPixelNotice('<?php echo($when);?>')" class="button" style="margin-top:10px;"><?php _e('Dismiss','shortpixel-image-optimiser');?></a>
|
103 |
+
<?php } ?>
|
104 |
</div>
|
105 |
<?php if($icon){ ?>
|
106 |
<img src="<?php echo(plugins_url('/shortpixel-image-optimiser/res/img/robo-' . $icon . '.png'));?>"
|
123 |
case 'activate':
|
124 |
self::displayApiKeyAlert();
|
125 |
break;
|
126 |
+
case 'fileperms' :
|
127 |
+
printf(__("ShortPixel is not able to write to the uploads folder so it cannot optimize images, please check permissions (tried to create the file %s/.shortpixel-q-1).",'shortpixel-image-optimiser'),
|
128 |
+
SHORTPIXEL_UPLOADS_BASE);
|
129 |
+
break;
|
130 |
case 'compat' :
|
131 |
_e("Using ShortPixel while other image optimization plugins are active can lead to unpredictable results. We recommend to deactivate the following plugin(s): ",'shortpixel-image-optimiser');
|
132 |
echo('<ul>');
|
962 |
<tr>
|
963 |
<th scope="row"><label for="resize"><?php _e('Additional media folders','shortpixel-image-optimiser');?></label></th>
|
964 |
<td>
|
965 |
+
<span style="display:none;">Current PHP version: <?php echo(phpversion()) ?></span>
|
966 |
<?php if($customFolders) { ?>
|
967 |
<table class="shortpixel-folders-list">
|
968 |
<tr style="font-weight: bold;">
|
class/wp-short-pixel.php
CHANGED
@@ -191,6 +191,9 @@ class WPShortPixel {
|
|
191 |
}
|
192 |
|
193 |
public function displayAdminNotices() {
|
|
|
|
|
|
|
194 |
$dismissed = $this->_settings->dismissedNotices ? $this->_settings->dismissedNotices : array();
|
195 |
$this->_settings->dismissedNotices = $dismissed;
|
196 |
|
191 |
}
|
192 |
|
193 |
public function displayAdminNotices() {
|
194 |
+
if(!ShortPixelQueue::testQ()) {
|
195 |
+
ShortPixelView::displayActivationNotice('fileperms');
|
196 |
+
}
|
197 |
$dismissed = $this->_settings->dismissedNotices ? $this->_settings->dismissedNotices : array();
|
198 |
$this->_settings->dismissedNotices = $dismissed;
|
199 |
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: compress, image, compression, optimize, image optimizer, image optimiser,
|
|
4 |
Requires at least: 3.2.0
|
5 |
Tested up to: 4.9
|
6 |
Requires PHP: 5.2
|
7 |
-
Stable tag: 4.8.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -228,6 +228,9 @@ The ShortPixel team is here to help. <a href="https://shortpixel.com/contact">Co
|
|
228 |
|
229 |
== Changelog ==
|
230 |
|
|
|
|
|
|
|
231 |
= 4.8.5 =
|
232 |
* drop usage of the PHP session / wp_option for the priority queue - use a flat file instead.
|
233 |
|
4 |
Requires at least: 3.2.0
|
5 |
Tested up to: 4.9
|
6 |
Requires PHP: 5.2
|
7 |
+
Stable tag: 4.8.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
228 |
|
229 |
== Changelog ==
|
230 |
|
231 |
+
= 4.8.6 =
|
232 |
+
* alert user when the plugin doesn't have rights to write to the uploads folder
|
233 |
+
|
234 |
= 4.8.5 =
|
235 |
* drop usage of the PHP session / wp_option for the priority queue - use a flat file instead.
|
236 |
|
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.8.
|
7 |
* Author: ShortPixel
|
8 |
* Author URI: https://shortpixel.com
|
9 |
* Text Domain: shortpixel-image-optimiser
|
@@ -18,7 +18,7 @@ define('SHORTPIXEL_PLUGIN_FILE', __FILE__);
|
|
18 |
|
19 |
define('SHORTPIXEL_AFFILIATE_CODE', '');
|
20 |
|
21 |
-
define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.8.
|
22 |
define('SHORTPIXEL_MAX_TIMEOUT', 10);
|
23 |
define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
|
24 |
define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');
|
3 |
* Plugin Name: ShortPixel Image Optimizer
|
4 |
* Plugin URI: https://shortpixel.com/
|
5 |
* Description: ShortPixel optimizes images automatically, while guarding the quality of your images. Check your <a href="options-general.php?page=wp-shortpixel" target="_blank">Settings > ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
|
6 |
+
* Version: 4.8.6
|
7 |
* Author: ShortPixel
|
8 |
* Author URI: https://shortpixel.com
|
9 |
* Text Domain: shortpixel-image-optimiser
|
18 |
|
19 |
define('SHORTPIXEL_AFFILIATE_CODE', '');
|
20 |
|
21 |
+
define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.8.6");
|
22 |
define('SHORTPIXEL_MAX_TIMEOUT', 10);
|
23 |
define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
|
24 |
define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');
|