ShortPixel Image Optimizer - Version 4.14.1

Version Description

=

Release date: 17th June 2019 * Fix errors when DOMDocument not present

=

Download this release

Release Info

Developer ShortPixel
Plugin Icon 128x128 ShortPixel Image Optimizer
Version 4.14.1
Comparing to
See all releases

Code changes from version 4.14.0 to 4.14.1

class/front/img-to-picture-webp.php CHANGED
@@ -53,40 +53,44 @@ class ShortPixelImgToPictureWebp
53
  public static function testPictures($content)
54
  {
55
  // [BS] Escape when DOM Module not installed
56
- if (! class_exists('DOMDocument'))
57
- return false;
58
 
59
- //$dom = new DOMDocument();
60
- //@$dom->loadHTML($content, LIBXML_HTML_NOIMPLIED, LIBXML_HTML_NODEFDTD);
 
 
61
 
62
- $dom = new DomDocument();
63
- $fragment = $dom->createDocumentFragment();
64
- $fragment->appendXML($content);
65
- $dom->appendChild($fragment);
66
 
67
- $elements = $dom->getElementsByTagName('picture');
 
 
 
 
68
 
69
- if ($elements->length == 0)
70
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
- foreach($elements as $element)
73
- {
74
- if ($element->hasChildNodes() )
75
- {
76
- foreach($element->childNodes as $elchild)
77
- {
78
- if ($elchild->tagName == 'img')
79
- {
80
- $class = ($elchild->hasAttribute('class')) ? $elchild->getAttribute('class') . ' ' : '';
81
- $class .= 'sp-no-webp';
82
- $elchild->setAttribute('class', $class);
83
- Log::addInfo('Found Picture with Img, added skip class', array($elchild->getAttribute('src')) );
84
- }
85
- }
86
- }
87
  }
 
 
 
88
 
89
- return $dom->saveHTML();
90
 
91
  }
92
 
53
  public static function testPictures($content)
54
  {
55
  // [BS] Escape when DOM Module not installed
56
+ //if (! class_exists('DOMDocument'))
57
+ // return false;
58
 
59
+ //$pattern =''
60
+ //$pattern ='/(?<=(<picture>))(.*)(?=(<\/picture>))/mi';
61
+ $pattern = '/<picture.*?>.*?(<img.*?>).*?<\/picture>/is';
62
+ preg_match_all($pattern, $content, $matches);
63
 
64
+ if ($matches === false)
65
+ return false;
 
 
66
 
67
+ if ( is_array($matches) && count($matches) > 0)
68
+ {
69
+ foreach($matches[1] as $match)
70
+ {
71
+ $imgtag = $match;
72
 
73
+ if (strpos($imgtag, 'class=') !== false) // test for class, if there, insert ours in there.
74
+ {
75
+ $pos = strpos($imgtag, 'class=');
76
+ $pos = $pos + 7;
77
+
78
+ $newimg = substr($imgtag, 0, $pos) . 'sp-no-webp ' . substr($imgtag, $pos);
79
+
80
+ }
81
+ else {
82
+ $pos = 4;
83
+ $newimg = substr($imgtag, 0, $pos) . ' class="sp-no-webp" ' . substr($imgtag, $pos);
84
+ }
85
+
86
+ $content = str_replace($imgtag, $newimg, $content);
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  }
89
+ }
90
+
91
+
92
 
93
+ return $content;
94
 
95
  }
96
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: compressor, image, compression, optimize, image optimizer, image optimiser
4
  Requires at least: 3.2.0
5
  Tested up to: 5.2
6
  Requires PHP: 5.3
7
- Stable tag: 4.14.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -243,6 +243,11 @@ The ShortPixel Image Optimiser plugin calls the following actions and filters:
243
 
244
  == Changelog ==
245
 
 
 
 
 
 
246
  == 4.14.0 ==
247
 
248
  Release date: 17th June 2019
@@ -259,6 +264,7 @@ Release date: 17th June 2019
259
  * Clear SP optimization cache in order to be able to optimize an image which initially had permissions error, after changing the permissions.
260
  * Fix being able to list the contents of ShortpixelBackups on some badly configured servers.
261
  * Fix error when inputting D'Artagnan in the AUTH pass field of settings.
 
262
 
263
  = 4.13.1 =
264
 
4
  Requires at least: 3.2.0
5
  Tested up to: 5.2
6
  Requires PHP: 5.3
7
+ Stable tag: 4.14.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
243
 
244
  == Changelog ==
245
 
246
+ == 4.14.1 ==
247
+
248
+ Release date: 17th June 2019
249
+ * Fix errors when DOMDocument not present
250
+
251
  == 4.14.0 ==
252
 
253
  Release date: 17th June 2019
264
  * Clear SP optimization cache in order to be able to optimize an image which initially had permissions error, after changing the permissions.
265
  * Fix being able to list the contents of ShortpixelBackups on some badly configured servers.
266
  * Fix error when inputting D'Artagnan in the AUTH pass field of settings.
267
+ * Add the Quriobot for support.
268
 
269
  = 4.13.1 =
270
 
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-settings" target="_blank">Settings &gt; ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
6
- * Version: 4.14.0
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  * Text Domain: shortpixel-image-optimiser
@@ -19,7 +19,7 @@ define('SHORTPIXEL_PLUGIN_FILE', __FILE__);
19
 
20
  //define('SHORTPIXEL_AFFILIATE_CODE', '');
21
 
22
- define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.14.0");
23
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
24
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
25
  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-settings" target="_blank">Settings &gt; ShortPixel</a> page on how to start optimizing your image library and make your website load faster.
6
+ * Version: 4.14.1
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  * Text Domain: shortpixel-image-optimiser
19
 
20
  //define('SHORTPIXEL_AFFILIATE_CODE', '');
21
 
22
+ define('SHORTPIXEL_IMAGE_OPTIMISER_VERSION', "4.14.1");
23
  define('SHORTPIXEL_MAX_TIMEOUT', 10);
24
  define('SHORTPIXEL_VALIDATE_MAX_TIMEOUT', 15);
25
  define('SHORTPIXEL_BACKUP', 'ShortpixelBackups');