Enable Media Replace - Version 3.4.1

Version Description

Release date: June 18th 2020 * Fix - PHP Error when settings permissions failed.

Download this release

Release Info

Developer petredobrescu
Plugin Icon 128x128 Enable Media Replace
Version 3.4.1
Comparing to
See all releases

Code changes from version 3.4.0 to 3.4.1

build/shortpixel/log/src/ShortPixelLogger.php CHANGED
@@ -237,6 +237,11 @@ namespace EnableMediaReplace\ShortPixelLogger;
237
  $log = self::getInstance();
238
  $log->addLog($message, $level, $args);
239
  }
 
 
 
 
 
240
  public static function addInfo($message, $args = array())
241
  {
242
  $level = DebugItem::LEVEL_INFO;
237
  $log = self::getInstance();
238
  $log->addLog($message, $level, $args);
239
  }
240
+ // Alias, since it goes wrong so often.
241
+ public static function addWarning($message, $args = array())
242
+ {
243
+ self::addWarn($message, $args);
244
+ }
245
  public static function addInfo($message, $args = array())
246
  {
247
  $level = DebugItem::LEVEL_INFO;
build/shortpixel/notices/src/NoticeController.php CHANGED
@@ -39,6 +39,14 @@ class NoticeController //extends ShortPixelController
39
  return self::$instance;
40
  }
41
 
 
 
 
 
 
 
 
 
42
  /** Load Notices Config File, if any
43
  *
44
  * [ Future Use ]
@@ -67,7 +75,15 @@ class NoticeController //extends ShortPixelController
67
 
68
  if ($notices !== false && is_array($notices))
69
  {
70
- self::$notices = $notices;
 
 
 
 
 
 
 
 
71
  $this->has_stored = true;
72
  }
73
  else {
@@ -182,7 +198,7 @@ class NoticeController //extends ShortPixelController
182
  for($i = 0; $i < count(self::$notices); $i++)
183
  {
184
  $item = self::$notices[$i];
185
- if ($item->getID() == $id)
186
  {
187
  Log::addDebug('Removing notice with ID ' . $id);
188
  unset(self::$notices[$i]);
39
  return self::$instance;
40
  }
41
 
42
+ /** Reset all notices, before loading them, to ensure on updates / activations one starts fresh */
43
+ public static function resetNotices()
44
+ {
45
+ $ns = __NAMESPACE__;
46
+ $ns = substr($ns, 0, strpos($ns, '\\')); // try to get first part of namespace
47
+ $result = delete_option($ns . '-notices');
48
+ }
49
+
50
  /** Load Notices Config File, if any
51
  *
52
  * [ Future Use ]
75
 
76
  if ($notices !== false && is_array($notices))
77
  {
78
+ $checked = array();
79
+ foreach($notices as $noticeObj)
80
+ {
81
+ if (is_object($noticeObj) && $noticeObj instanceOf NoticeModel)
82
+ {
83
+ $checked[] = $noticeObj;
84
+ }
85
+ }
86
+ self::$notices = $checked;
87
  $this->has_stored = true;
88
  }
89
  else {
198
  for($i = 0; $i < count(self::$notices); $i++)
199
  {
200
  $item = self::$notices[$i];
201
+ if (is_object($item) && $item->getID() == $id)
202
  {
203
  Log::addDebug('Removing notice with ID ' . $id);
204
  unset(self::$notices[$i]);
build/shortpixel/notices/src/NoticeModel.php CHANGED
@@ -134,6 +134,11 @@ class NoticeModel //extends ShortPixelModel
134
  self::$icons[$type] = $icon;
135
  }
136
 
 
 
 
 
 
137
  public function getForDisplay()
138
  {
139
  $this->viewed = true;
@@ -143,6 +148,21 @@ class NoticeModel //extends ShortPixelModel
143
 
144
  if ($this->callback)
145
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  $return = call_user_func($this->callback, $this);
147
  if ($return === false) // don't display is callback returns false explicitly.
148
  return;
134
  self::$icons[$type] = $icon;
135
  }
136
 
137
+ private function checkIncomplete($var)
138
+ {
139
+ return ($var instanceof \__PHP_Incomplete_Class);
140
+ }
141
+
142
  public function getForDisplay()
143
  {
144
  $this->viewed = true;
148
 
149
  if ($this->callback)
150
  {
151
+ if (is_array($this->callback))
152
+ {
153
+ foreach($this->callback as $part)
154
+ {
155
+ if ($this->checkIncomplete($part) === true)
156
+ {
157
+ return false;
158
+ }
159
+ }
160
+ } elseif (is_object($this->callback))
161
+ {
162
+ if ($this->checkIncomplete($part) === true)
163
+ return false;
164
+ }
165
+
166
  $return = call_user_func($this->callback, $this);
167
  if ($return === false) // don't display is callback returns false explicitly.
168
  return;
classes/replacer.php CHANGED
@@ -130,7 +130,7 @@ class Replacer
130
  if ($this->sourceFile->getPermissions() > 0)
131
  chmod( $targetFile, $this->sourceFile->getPermissions() ); // restore permissions
132
  else {
133
- Log::addWarning('Setting permissions failed');
134
  }
135
 
136
  // update the file attached. This is required for wp_get_attachment_url to work.
@@ -158,10 +158,10 @@ class Replacer
158
 
159
  /** If author is different from replacer, note this */
160
  $author_id = get_post_meta($this->post_id, '_emr_replace_author', true);
161
- Log::addTemp('Previous Author ID', $author_id);
162
  if ( intval($this->source_post->post_author) !== get_current_user_id())
163
  {
164
- Log::addTemp("THIS AUTHOR NOT THE SAME AS THE OTHER");
165
  update_post_meta($this->post_id, '_emr_replace_author', get_current_user_id());
166
  }
167
  elseif ($author_id)
130
  if ($this->sourceFile->getPermissions() > 0)
131
  chmod( $targetFile, $this->sourceFile->getPermissions() ); // restore permissions
132
  else {
133
+ Log::addWarn('Setting permissions failed');
134
  }
135
 
136
  // update the file attached. This is required for wp_get_attachment_url to work.
158
 
159
  /** If author is different from replacer, note this */
160
  $author_id = get_post_meta($this->post_id, '_emr_replace_author', true);
161
+
162
  if ( intval($this->source_post->post_author) !== get_current_user_id())
163
  {
164
+
165
  update_post_meta($this->post_id, '_emr_replace_author', get_current_user_id());
166
  }
167
  elseif ($author_id)
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.4.0
7
  Author: ShortPixel
8
  Author URI: https://shortpixel.com
9
  Text Domain: enable-media-replace
@@ -26,7 +26,7 @@ http://www.gnu.org/licenses/gpl.html
26
 
27
  namespace EnableMediaReplace;
28
 
29
- define('EMR_VERSION', '3.4.0');
30
 
31
  if ( ! defined( 'ABSPATH' ) ) {
32
  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.4.1
7
  Author: ShortPixel
8
  Author URI: https://shortpixel.com
9
  Text Domain: enable-media-replace
26
 
27
  namespace EnableMediaReplace;
28
 
29
+ define('EMR_VERSION', '3.4.1');
30
 
31
  if ( ! defined( 'ABSPATH' ) ) {
32
  exit; // Exit if accessed directly.
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: ShortPixel
3
  Donate link: https://www.paypal.me/resizeImage
4
  Tags: replace, attachment, media, files, replace image, replace jpg, change media, replace media, image, file
5
  Requires at least: 4.9.7
6
- Tested up to: 5.4.1
7
  Requires PHP: 5.6
8
- Stable tag: 3.4.0
9
 
10
  Easily replace any attached image/file by simply uploading a new file in the Media Library edit view - a real time saver!
11
 
@@ -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.4.0 =
51
 
52
  Release date: June 9th 2020
3
  Donate link: https://www.paypal.me/resizeImage
4
  Tags: replace, attachment, media, files, replace image, replace jpg, change media, replace media, image, file
5
  Requires at least: 4.9.7
6
+ Tested up to: 5.5
7
  Requires PHP: 5.6
8
+ Stable tag: 3.4.1
9
 
10
  Easily replace any attached image/file by simply uploading a new file in the Media Library edit view - a real time saver!
11
 
47
 
48
  == Changelog ==
49
 
50
+ = 3.4.1 =
51
+
52
+ Release date: June 18th 2020
53
+ * Fix - PHP Error when settings permissions failed.
54
+
55
  = 3.4.0 =
56
 
57
  Release date: June 9th 2020