Skip to content

Commit

Permalink
Merge pull request #57 from short-pixel-optimizer/updates
Browse files Browse the repository at this point in the history
prepare 3.3.10 release
  • Loading branch information
ShortPixel authored Feb 23, 2020
2 parents 8c144db + c6de1c4 commit a9a3a07
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
17 changes: 9 additions & 8 deletions classes/replacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,38 +508,41 @@ private function replaceContent($content, $search, $replace)

if ($isJson)
{
Log::addDebug('Found JSON Content');
$content = json_decode($content);
}

if (is_string($content)) // let's check the normal one first.
{
return str_replace($search, $replace, $content);
$content = str_replace($search, $replace, $content);
}
elseif (is_wp_error($content)) // seen this.
{
return $content; // do nothing.
//return $content; // do nothing.
}
elseif (is_array($content) ) // array metadata and such.
{
foreach($content as $index => $value)
{
$content[$index] = $this->replaceContent($value, $search, $replace); //str_replace($value, $search, $replace);
}
return $content;
//return $content;
}
elseif(is_object($content)) // metadata objects, they exist.
{
foreach($content as $key => $value)
{
$content->{$key} = $this->replaceContent($value, $search, $replace); //str_replace($value, $search, $replace);
}
return $content;
//return $content;
}

if ($isJson) // convert back to JSON, if this was JSON. Different than serialize which does WP automatically.
{
Log::addDebug('Value was found to be JSON, encoding');
$content = json_encode($content);
// wp-slash -> WP does stripslashes_deep which destroys JSON
$content = wp_slash(json_encode($content, JSON_UNESCAPED_SLASHES));
Log::addDebug('Content returning', array($content));
}

return $content;
Expand Down Expand Up @@ -571,9 +574,7 @@ private function isJSON($content)
return false; // can never be.

$json = json_decode($content);
$json = is_string($content) && json_decode($content);

return $json && $content != $json;
return $json && $json != $content;
}

// Get REL Urls of both source and target.
Expand Down
4 changes: 2 additions & 2 deletions enable-media-replace.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Enable Media Replace
Plugin URI: https://wordpress.org/plugins/enable-media-replace/
Description: Enable replacing media files by uploading a new file in the "Edit Media" section of the WordPress Media Library.
Version: 3.3.9
Version: 3.3.10
Author: ShortPixel
Author URI: https://shortpixel.com
Text Domain: enable-media-replace
Expand All @@ -25,7 +25,7 @@
*/

namespace EnableMediaReplace;
define('EMR_VERSION', '3.3.9');
define('EMR_VERSION', '3.3.10');

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
Expand Down
5 changes: 5 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ If you want more control over the format used to display the time, you can use t

= 3.3.9 =

Release date: 23rd February 2020
* Fix issue with JSON encoded strings
* Language – 0 new strings added, 2 updated, 0 fuzzied, and 0 obsoleted

Release date: 19th February 2020
* Fix issue with search/replacing non-image attachments and query
* Language – 0 new strings added, 2 updated, 0 fuzzied, and 0 obsoleted

= 3.3.8 =

Expand Down

0 comments on commit a9a3a07

Please sign in to comment.