Enable Media Replace - Version 3.3.6

Version Description

Release date: 5th September 2019 * fix JSON compatibility for hostings that don't have JSON module activated

Download this release

Release Info

Developer ShortPixel
Plugin Icon 128x128 Enable Media Replace
Version 3.3.6
Comparing to
See all releases

Code changes from version 3.3.5 to 3.3.6

build/shortpixel/PackageLoader.php CHANGED
@@ -14,6 +14,8 @@ class PackageLoader
14
  {
15
  $this->dir = $dir;
16
  $composer = $this->getComposerFile();
 
 
17
  if(isset($composer["autoload"]["psr-4"])){
18
  $this->loadPSR4($composer['autoload']['psr-4']);
19
  }
@@ -59,9 +61,10 @@ class PackageLoader
59
  if ($psr4) {
60
  $classname = str_replace($namespace, "", $classname);
61
  }
62
- $filename = preg_replace("#\\\\#", "/", $classname).".php";
 
63
  foreach ($classpaths as $classpath) {
64
- $fullpath = $dir."/".$classpath."/$filename";
65
  if (file_exists($fullpath)) {
66
  include_once $fullpath;
67
  }
14
  {
15
  $this->dir = $dir;
16
  $composer = $this->getComposerFile();
17
+
18
+
19
  if(isset($composer["autoload"]["psr-4"])){
20
  $this->loadPSR4($composer['autoload']['psr-4']);
21
  }
61
  if ($psr4) {
62
  $classname = str_replace($namespace, "", $classname);
63
  }
64
+ $filename = preg_replace("#\\\\#", "", $classname).".php";
65
+
66
  foreach ($classpaths as $classpath) {
67
+ $fullpath = trailingslashit($dir) . trailingslashit($classpath) .$filename;
68
  if (file_exists($fullpath)) {
69
  include_once $fullpath;
70
  }
build/shortpixel/composer.json CHANGED
@@ -1 +1 @@
1
- {"name":"EnableMediaReplace\/shortpixelmodules","description":"ShortPixel submodules","type":"function","autoload":{"psr-4":{"EnableMediaReplace\\ShortPixelLogger\\":"log\/src\/","EnableMediaReplace\\Notices\\":"notices\/src\/"}}}
1
+ {"name":"EnableMediaReplace\/shortpixelmodules","description":"ShortPixel submodules","type":"function","autoload":{"psr-4":{"EnableMediaReplace\\ShortPixelLogger":"log\/src","EnableMediaReplace\\Notices":"notices\/src"}}}
build/shortpixel/log/composer.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "name": "shortpixel/log",
3
  "description": "ShortPixel Logging",
4
- "version": "1.1",
5
  "type": "library",
6
  "license": "MIT",
7
  "authors": [
@@ -13,6 +13,6 @@
13
  "minimum-stability": "dev",
14
  "require": {},
15
  "autoload": {
16
- "psr-4": { "ShortPixel\\ShortPixelLogger\\" : "src/" }
17
  }
18
  }
1
  {
2
  "name": "shortpixel/log",
3
  "description": "ShortPixel Logging",
4
+ "version": "1.1.2",
5
  "type": "library",
6
  "license": "MIT",
7
  "authors": [
13
  "minimum-stability": "dev",
14
  "require": {},
15
  "autoload": {
16
+ "psr-4": { "ShortPixel\\ShortPixelLogger\\" : "src" }
17
  }
18
  }
build/shortpixel/log/src/ShortPixelLogger.php CHANGED
@@ -52,7 +52,7 @@ namespace EnableMediaReplace\ShortPixelLogger;
52
  if ($this->logPath === false)
53
  {
54
  $upload_dir = wp_upload_dir(null,false,false);
55
- $this->logPath = $upload_dir['basedir'] . '/' . $this->namespace . ".log";
56
  }
57
 
58
  if (isset($_REQUEST['SHORTPIXEL_DEBUG'])) // manual takes precedence over constants
@@ -130,7 +130,7 @@ namespace EnableMediaReplace\ShortPixelLogger;
130
 
131
  public function setLogPath($logPath)
132
  {
133
- $this->logPath = $logPath;
134
  }
135
  protected static function addLog($message, $level, $data = array())
136
  {
@@ -170,7 +170,8 @@ namespace EnableMediaReplace\ShortPixelLogger;
170
 
171
  $line = $this->formatLine($items);
172
 
173
- if ($this->logPath)
 
174
  {
175
  file_put_contents($this->logPath,$line, FILE_APPEND);
176
  }
52
  if ($this->logPath === false)
53
  {
54
  $upload_dir = wp_upload_dir(null,false,false);
55
+ $this->logPath = $this->setLogPath($upload_dir['basedir'] . '/' . $this->namespace . ".log");
56
  }
57
 
58
  if (isset($_REQUEST['SHORTPIXEL_DEBUG'])) // manual takes precedence over constants
130
 
131
  public function setLogPath($logPath)
132
  {
133
+ $this->logPath = $logPath;
134
  }
135
  protected static function addLog($message, $level, $data = array())
136
  {
170
 
171
  $line = $this->formatLine($items);
172
 
173
+ // try to write to file. Don't write if directory doesn't exists (leads to notices)
174
+ if ($this->logPath && is_dir(dirname($this->logPath) ))
175
  {
176
  file_put_contents($this->logPath,$line, FILE_APPEND);
177
  }
build/shortpixel/notices/composer.json CHANGED
@@ -26,6 +26,6 @@
26
  ],
27
 
28
  "autoload": {
29
- "psr-4": { "ShortPixel\\Notices\\" : "src/" }
30
  }
31
  }
26
  ],
27
 
28
  "autoload": {
29
+ "psr-4": { "ShortPixel\\Notices\\" : "src" }
30
  }
31
  }
classes/compat.php CHANGED
@@ -94,3 +94,14 @@ if (! function_exists('wp_delete_file_from_directory'))
94
  }
95
 
96
  } // end function
 
 
 
 
 
 
 
 
 
 
 
94
  }
95
 
96
  } // end function
97
+
98
+
99
+ /*
100
+ * Introduced in WP 4.5.0 - needed for compat function of wp_delete_attachment_files
101
+ */
102
+ if (! function_exists('wp_get_upload_dir'))
103
+ {
104
+ function wp_get_upload_dir() {
105
+ return wp_upload_dir( null, false );
106
+ }
107
+ }
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.5
7
  Author: ShortPixel
8
  Author URI: https://shortpixel.com
9
  Text Domain: enable-media-replace
@@ -18,7 +18,7 @@ http://www.gnu.org/licenses/gpl.html
18
  * Set action hooks and add shortcode
19
  *
20
  * @author ShortPixel <https://shortpixel.com>
21
- * @copyright ShortPixel 2018
22
  * @package wordpress
23
  * @subpackage enable-media-replace
24
  *
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.6
7
  Author: ShortPixel
8
  Author URI: https://shortpixel.com
9
  Text Domain: enable-media-replace
18
  * Set action hooks and add shortcode
19
  *
20
  * @author ShortPixel <https://shortpixel.com>
21
+ * @copyright ShortPixel 2018-2019
22
  * @package wordpress
23
  * @subpackage enable-media-replace
24
  *
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.5 =
51
 
52
  Release date: 25th July 2019
47
 
48
  == Changelog ==
49
 
50
+ = 3.3.6 =
51
+
52
+ Release date: 5th September 2019
53
+ * fix JSON compatibility for hostings that don't have JSON module activated
54
+
55
  = 3.3.5 =
56
 
57
  Release date: 25th July 2019