Version Description
Release date: 19th February 2020 * Fix issue with search/replacing non-image attachments and query
Download this release
Release Info
| Developer | ShortPixel |
| Plugin | |
| Version | 3.3.9 |
| Comparing to | |
| See all releases | |
Code changes from version 3.3.8 to 3.3.9
- classes/replacer.php +22 -1
- enable-media-replace.php +2 -2
- readme.txt +5 -0
classes/replacer.php
CHANGED
|
@@ -55,7 +55,13 @@ class Replacer
|
|
| 55 |
$this->source_metadata = wp_get_attachment_metadata( $post_id );
|
| 56 |
|
| 57 |
if (function_exists('wp_get_original_image_url')) // WP 5.3+
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
else
|
| 60 |
$this->source_url = wp_get_attachment_url($post_id);
|
| 61 |
// $this->ThumbnailUpdater = new \ThumbnailUpdater($post_id);
|
|
@@ -322,6 +328,7 @@ class Replacer
|
|
| 322 |
$current_base_url = parse_url($this->source_url, PHP_URL_PATH);// emr_get_match_url( $this->source_url);
|
| 323 |
$current_base_url = str_replace('.' . pathinfo($current_base_url, PATHINFO_EXTENSION), '', $current_base_url);
|
| 324 |
|
|
|
|
| 325 |
/** Fail-safe if base_url is a whole directory, don't go search/replace */
|
| 326 |
if (is_dir($current_base_url))
|
| 327 |
{
|
|
@@ -330,6 +337,14 @@ class Replacer
|
|
| 330 |
return;
|
| 331 |
}
|
| 332 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
//$search_files = $this->getFilesFromMetadata($this->source_metadata);
|
| 334 |
//$replace_files = $this->getFilesFromMetadata($this->target_metadata);
|
| 335 |
// $arr = $this->getRelativeURLS();
|
|
@@ -523,6 +538,7 @@ class Replacer
|
|
| 523 |
|
| 524 |
if ($isJson) // convert back to JSON, if this was JSON. Different than serialize which does WP automatically.
|
| 525 |
{
|
|
|
|
| 526 |
$content = json_encode($content);
|
| 527 |
}
|
| 528 |
|
|
@@ -551,7 +567,12 @@ class Replacer
|
|
| 551 |
/* Check if given content is JSON format. */
|
| 552 |
private function isJSON($content)
|
| 553 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
| 554 |
$json = is_string($content) && json_decode($content);
|
|
|
|
| 555 |
return $json && $content != $json;
|
| 556 |
}
|
| 557 |
|
| 55 |
$this->source_metadata = wp_get_attachment_metadata( $post_id );
|
| 56 |
|
| 57 |
if (function_exists('wp_get_original_image_url')) // WP 5.3+
|
| 58 |
+
{
|
| 59 |
+
$source_url = wp_get_original_image_url($post_id);
|
| 60 |
+
if ($source_url === false) // not an image, or borked, try the old way
|
| 61 |
+
$source_url = wp_get_attachment_url($post_id);
|
| 62 |
+
|
| 63 |
+
$this->source_url = $source_url;
|
| 64 |
+
}
|
| 65 |
else
|
| 66 |
$this->source_url = wp_get_attachment_url($post_id);
|
| 67 |
// $this->ThumbnailUpdater = new \ThumbnailUpdater($post_id);
|
| 328 |
$current_base_url = parse_url($this->source_url, PHP_URL_PATH);// emr_get_match_url( $this->source_url);
|
| 329 |
$current_base_url = str_replace('.' . pathinfo($current_base_url, PATHINFO_EXTENSION), '', $current_base_url);
|
| 330 |
|
| 331 |
+
|
| 332 |
/** Fail-safe if base_url is a whole directory, don't go search/replace */
|
| 333 |
if (is_dir($current_base_url))
|
| 334 |
{
|
| 337 |
return;
|
| 338 |
}
|
| 339 |
|
| 340 |
+
if (strlen(trim($current_base_url)) == 0)
|
| 341 |
+
{
|
| 342 |
+
Log::addError('Current Base URL emtpy - ' . $current_base_url);
|
| 343 |
+
Notices::addError(__('Fail Safe :: Source Location returned empty string. Not replacing content','enable-media-replace'));
|
| 344 |
+
return;
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
|
| 348 |
//$search_files = $this->getFilesFromMetadata($this->source_metadata);
|
| 349 |
//$replace_files = $this->getFilesFromMetadata($this->target_metadata);
|
| 350 |
// $arr = $this->getRelativeURLS();
|
| 538 |
|
| 539 |
if ($isJson) // convert back to JSON, if this was JSON. Different than serialize which does WP automatically.
|
| 540 |
{
|
| 541 |
+
Log::addDebug('Value was found to be JSON, encoding');
|
| 542 |
$content = json_encode($content);
|
| 543 |
}
|
| 544 |
|
| 567 |
/* Check if given content is JSON format. */
|
| 568 |
private function isJSON($content)
|
| 569 |
{
|
| 570 |
+
if (is_array($content) || is_object($content))
|
| 571 |
+
return false; // can never be.
|
| 572 |
+
|
| 573 |
+
$json = json_decode($content);
|
| 574 |
$json = is_string($content) && json_decode($content);
|
| 575 |
+
|
| 576 |
return $json && $content != $json;
|
| 577 |
}
|
| 578 |
|
enable-media-replace.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
Plugin Name: Enable Media Replace
|
| 4 |
Plugin URI: https://wordpress.org/plugins/enable-media-replace/
|
| 5 |
Description: Enable replacing media files by uploading a new file in the "Edit Media" section of the WordPress Media Library.
|
| 6 |
-
Version: 3.3.
|
| 7 |
Author: ShortPixel
|
| 8 |
Author URI: https://shortpixel.com
|
| 9 |
Text Domain: enable-media-replace
|
|
@@ -25,7 +25,7 @@ http://www.gnu.org/licenses/gpl.html
|
|
| 25 |
*/
|
| 26 |
|
| 27 |
namespace EnableMediaReplace;
|
| 28 |
-
define('EMR_VERSION', '3.3.
|
| 29 |
|
| 30 |
if ( ! defined( 'ABSPATH' ) ) {
|
| 31 |
exit; // Exit if accessed directly.
|
| 3 |
Plugin Name: Enable Media Replace
|
| 4 |
Plugin URI: https://wordpress.org/plugins/enable-media-replace/
|
| 5 |
Description: Enable replacing media files by uploading a new file in the "Edit Media" section of the WordPress Media Library.
|
| 6 |
+
Version: 3.3.9
|
| 7 |
Author: ShortPixel
|
| 8 |
Author URI: https://shortpixel.com
|
| 9 |
Text Domain: enable-media-replace
|
| 25 |
*/
|
| 26 |
|
| 27 |
namespace EnableMediaReplace;
|
| 28 |
+
define('EMR_VERSION', '3.3.9');
|
| 29 |
|
| 30 |
if ( ! defined( 'ABSPATH' ) ) {
|
| 31 |
exit; // Exit if accessed directly.
|
readme.txt
CHANGED
|
@@ -47,6 +47,11 @@ If you want more control over the format used to display the time, you can use t
|
|
| 47 |
|
| 48 |
== Changelog ==
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
= 3.3.8 =
|
| 51 |
|
| 52 |
Release date: 18th February 2020
|
| 47 |
|
| 48 |
== Changelog ==
|
| 49 |
|
| 50 |
+
= 3.3.9 =
|
| 51 |
+
|
| 52 |
+
Release date: 19th February 2020
|
| 53 |
+
* Fix issue with search/replacing non-image attachments and query
|
| 54 |
+
|
| 55 |
= 3.3.8 =
|
| 56 |
|
| 57 |
Release date: 18th February 2020
|
