Enable Media Replace - Version 2.9.3

Version Description

  • Added call to update_attached_file() which should purge changed files for various CDN and cache plugs. Thanks Dylan Barlett for the suggestion! (http://wordpress.org/support/topic/compatibility-with-w3-total-cache)
  • Suppressed possible error in new hook added in 2.9.2
Download this release

Release Info

Developer MungoBBQ
Plugin Icon 128x128 Enable Media Replace
Version 2.9.3
Comparing to
See all releases

Code changes from version 2.9.2 to 2.9.3

Files changed (3) hide show
  1. enable-media-replace.php +1 -1
  2. readme.txt +5 -1
  3. upload.php +7 -2
enable-media-replace.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Enable Media Replace
4
  Plugin URI: http://www.mansjonasson.se/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: 2.9.2
7
  Author: Måns Jonasson
8
  Author URI: http://www.mansjonasson.se
9
 
3
  Plugin Name: Enable Media Replace
4
  Plugin URI: http://www.mansjonasson.se/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: 2.9.3
7
  Author: Måns Jonasson
8
  Author URI: http://www.mansjonasson.se
9
 
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: mungobbq
3
  Tags: admin, attachment, media, files
4
  Requires at least: 2.8
5
- Tested up to: 3.5.1
6
  Stable tag: trunk
7
 
8
  Enables replacing attachment files by simply uploading a new file in the media library edit view.
@@ -37,6 +37,10 @@ If you want more control over the format used to display the time, you can use t
37
 
38
  == Changelog ==
39
 
 
 
 
 
40
  = 2.9.2 =
41
  * Small bug fix
42
  * Added hook for developers to enable purging possible CDN when updating files - thanks rubious for the suggestion!
2
  Contributors: mungobbq
3
  Tags: admin, attachment, media, files
4
  Requires at least: 2.8
5
+ Tested up to: 3.6
6
  Stable tag: trunk
7
 
8
  Enables replacing attachment files by simply uploading a new file in the media library edit view.
37
 
38
  == Changelog ==
39
 
40
+ = 2.9.3 =
41
+ * Added call to update_attached_file() which should purge changed files for various CDN and cache plugs. Thanks Dylan Barlett for the suggestion! (http://wordpress.org/support/topic/compatibility-with-w3-total-cache)
42
+ * Suppressed possible error in new hook added in 2.9.2
43
+
44
  = 2.9.2 =
45
  * Small bug fix
46
  * Added hook for developers to enable purging possible CDN when updating files - thanks rubious for the suggestion!
upload.php CHANGED
@@ -101,6 +101,8 @@ if (is_uploaded_file($_FILES["userfile"]["tmp_name"])) {
101
  // Make thumb and/or update metadata
102
  wp_update_attachment_metadata( (int) $_POST["ID"], wp_generate_attachment_metadata( (int) $_POST["ID"], $current_file ) );
103
 
 
 
104
  }
105
 
106
  else {
@@ -150,6 +152,9 @@ if (is_uploaded_file($_FILES["userfile"]["tmp_name"])) {
150
 
151
  mysql_query("UPDATE $table_name SET post_content = '$post_content' WHERE ID = {$rows["ID"]}");
152
  }
 
 
 
153
 
154
  }
155
 
@@ -157,7 +162,7 @@ if (is_uploaded_file($_FILES["userfile"]["tmp_name"])) {
157
  $returnurl = get_bloginfo("wpurl") . "/wp-admin/post.php?post={$_POST["ID"]}&action=edit&message=1";
158
 
159
  // Execute hook actions - thanks rubious for the suggestion!
160
- do_action("enable-media-replace-upload-done", ($new_guid ? $new_guid : $current_guid));
161
 
162
  } else {
163
  //TODO Better error handling when no file is selected.
@@ -171,4 +176,4 @@ if (FORCE_SSL_ADMIN) {
171
 
172
  //save redirection
173
  wp_redirect($returnurl);
174
- ?>
101
  // Make thumb and/or update metadata
102
  wp_update_attachment_metadata( (int) $_POST["ID"], wp_generate_attachment_metadata( (int) $_POST["ID"], $current_file ) );
103
 
104
+ // Trigger possible updates on CDN and other plugins
105
+ update_attached_file( (int) $_POST["ID"], $current_file);
106
  }
107
 
108
  else {
152
 
153
  mysql_query("UPDATE $table_name SET post_content = '$post_content' WHERE ID = {$rows["ID"]}");
154
  }
155
+
156
+ // Trigger possible updates on CDN and other plugins
157
+ update_attached_file( (int) $_POST["ID"], $new_file);
158
 
159
  }
160
 
162
  $returnurl = get_bloginfo("wpurl") . "/wp-admin/post.php?post={$_POST["ID"]}&action=edit&message=1";
163
 
164
  // Execute hook actions - thanks rubious for the suggestion!
165
+ if (isset($new_guid)) { do_action("enable-media-replace-upload-done", ($new_guid ? $new_guid : $current_guid)); }
166
 
167
  } else {
168
  //TODO Better error handling when no file is selected.
176
 
177
  //save redirection
178
  wp_redirect($returnurl);
179
+ ?>