Enable Media Replace - Version 2.9

Version Description

  • Added Portuguese translation, thanks Bruno Miguel Bras Silva!
  • New edit link from media library
  • After uploading, the plugin now takes you back to edit screen instead of library
Download this release

Release Info

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

Code changes from version 2.8.2 to 2.9

enable-media-replace-pt_PT.po ADDED
@@ -0,0 +1,89 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: enable-media-replace\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2010-09-13 14:57+0100\n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: Bruno Silva <bruno.b.silva@co.sapo.pt>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Poedit-KeywordsList: __;_e\n"
13
+ "X-Poedit-Basepath: .\n"
14
+ "X-Poedit-SearchPath-0: .\n"
15
+
16
+ #: enable-media-replace.php:40
17
+ #: enable-media-replace.php:68
18
+ msgid "Replace media"
19
+ msgstr "Substituir media"
20
+
21
+ #: enable-media-replace.php:68
22
+ msgid "Upload a new file"
23
+ msgstr "Enviar novo ficheiro"
24
+
25
+ #: enable-media-replace.php:68
26
+ msgid "To replace the current file, click the link and upload a replacement."
27
+ msgstr "Para subtituir o ficheiro actual, clique no link e carregue um substituto"
28
+
29
+ #: popup.php:14
30
+ #: upload.php:21
31
+ msgid "You do not have permission to upload files."
32
+ msgstr "Não tem permissões para carregar ficheiros."
33
+
34
+ #: popup.php:30
35
+ msgid "Replace Media Upload"
36
+ msgstr "Carregar Substituição de Media"
37
+
38
+ #: popup.php:41
39
+ msgid "NOTE: You are about to replace the media file"
40
+ msgstr "NOTA: Está prestes a substituir o ficheiro de media"
41
+
42
+ #: popup.php:41
43
+ msgid "There is no undo. Think about it!"
44
+ msgstr "Não é possível cancelar esta ação."
45
+
46
+ #: popup.php:43
47
+ msgid "Choose a file to upload from your computer"
48
+ msgstr "Escolher um ficheiro para carregar a partir do computador"
49
+
50
+ #: popup.php:47
51
+ msgid "Select media replacement type:"
52
+ msgstr "Selecione o tipo de substituição"
53
+
54
+ #: popup.php:49
55
+ msgid "Just replace the file"
56
+ msgstr "Apenas substituir ficheiro"
57
+
58
+ #: popup.php:50
59
+ msgid "Note: This option requires you to upload a file of the same type ("
60
+ msgstr "Nota: Esta opção requer o carregamento de um ficheiro do mesmo tipo ("
61
+
62
+ #: popup.php:50
63
+ msgid ") as the one you are replacing. The name of the attachment will stay the same ("
64
+ msgstr ") daquele a substituir. O nome do ficheiro permanecerá o mesmo("
65
+
66
+ #: popup.php:50
67
+ msgid ") no matter what the file you upload is called."
68
+ msgstr "), independentemente do nome do ficheiro carregado."
69
+
70
+ #: popup.php:52
71
+ msgid "Replace the file, use new file name and update all links"
72
+ msgstr "Substituir o ficheiro, usar o novo nome de ficheiro, e actualizar todos os links"
73
+
74
+ #: popup.php:53
75
+ msgid "Note: If you check this option, the name and type of the file you are about to upload will replace the old file. All links pointing to the current file ("
76
+ msgstr "Nota: Se selecionar esta opção, o nome e tipo do ficheiro que está prestes a carregar irá substituir os do ficheiro antigo. Todos os links que referenciam o ficheiro actual ("
77
+
78
+ #: popup.php:53
79
+ msgid ") will be updated to point to the new file name."
80
+ msgstr ") serão actualizados de forma a referenciar o novo nome de ficheiro."
81
+
82
+ #: popup.php:55
83
+ msgid "Upload"
84
+ msgstr "Carregar"
85
+
86
+ #: popup.php:55
87
+ msgid "Cancel"
88
+ msgstr "Cancelar"
89
+
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.8.2
7
Author: Måns Jonasson
8
Author URI: http://www.mansjonasson.se
9
@@ -28,6 +28,7 @@ Developed for .SE (Stiftelsen för Internetinfrastruktur) - http://www.iis.se
28
add_action('admin_init', 'enable_media_replace_init');
29
add_action('admin_menu', 'emr_menu');
30
add_filter('attachment_fields_to_edit', 'enable_media_replace', 10, 2);
31
32
add_shortcode('file_modified', 'emr_get_modified_date');
33
@@ -102,6 +103,24 @@ function emr_options() {
102
103
}
104
105
/**
106
* Shorttag function to show the media file modification date/time.
107
* @param array shorttag attributes
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
7
Author: Måns Jonasson
8
Author URI: http://www.mansjonasson.se
9
28
add_action('admin_init', 'enable_media_replace_init');
29
add_action('admin_menu', 'emr_menu');
30
add_filter('attachment_fields_to_edit', 'enable_media_replace', 10, 2);
31
+ add_filter('media_row_actions', 'add_media_action', 10, 2);
32
33
add_shortcode('file_modified', 'emr_get_modified_date');
34
103
104
}
105
106
+ /**
107
+ * Function called by filter 'media_row_actions'
108
+ * Enables linking to EMR straight from the media library
109
+ */
110
+ function add_media_action( $actions, $post) {
111
+ $url = admin_url( "upload.php?page=enable-media-replace/enable-media-replace.php&action=media_replace&attachment_id=" . $post->ID);
112
+ $action = "media_replace";
113
+ $editurl = wp_nonce_url( $url, $action );
114
+
115
+ if (FORCE_SSL_ADMIN) {
116
+ $editurl = str_replace("http:", "https:", $editurl);
117
+ }
118
+ $link = "href=\"$editurl\"";
119
+
120
+ $newaction['adddata'] = '<a ' . $link . ' title="' . __("Replace media", "enable-media-replace") . '" rel="permalink">' . __("Replace media", "enable-media-replace") . '</a>';
121
+ return array_merge($actions,$newaction);
122
+ }
123
+
124
/**
125
* Shorttag function to show the media file modification date/time.
126
* @param array shorttag attributes
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
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,11 @@ If you want more control over the format used to display the time, you can use t
37
38
== Changelog ==
39
40
= 2.8.2 =
41
* Made another change to the discovery of media context which will hopefully fix a bug in certain cases. Thanks to "Joolee" at the WordPress.org forums!
42
* Added a new, supposedly better Russian translation from "Vlad".
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
38
== Changelog ==
39
40
+ = 2.9 =
41
+ * Added Portuguese translation, thanks Bruno Miguel Bras Silva!
42
+ * New edit link from media library
43
+ * After uploading, the plugin now takes you back to edit screen instead of library
44
+
45
= 2.8.2 =
46
* Made another change to the discovery of media context which will hopefully fix a bug in certain cases. Thanks to "Joolee" at the WordPress.org forums!
47
* Added a new, supposedly better Russian translation from "Vlad".
upload.php CHANGED
@@ -49,16 +49,19 @@ if (is_uploaded_file($_FILES["userfile"]["tmp_name"])) {
49
$suffix = substr($current_file, (strlen($current_file)-4));
50
$prefix = substr($current_file, 0, (strlen($current_file)-4));
51
$imgAr = array(".png", ".gif", ".jpg");
52
- if (in_array($suffix, $imgAr)) {
53
// Get thumbnail filenames from metadata
54
$metadata = wp_get_attachment_metadata($_POST["ID"]);
55
- foreach($metadata["sizes"] AS $thissize) {
56
- // Get all filenames and do an unlink() on each one;
57
- $thisfile = $thissize["file"];
58
- if (strlen($thisfile)) {
59
- $thisfile = $current_path . "/" . $thissize["file"];
60
- if (file_exists($thisfile)) {
61
- unlink($thisfile);
62
}
63
}
64
}
@@ -151,6 +154,7 @@ if (is_uploaded_file($_FILES["userfile"]["tmp_name"])) {
151
}
152
153
$returnurl = get_bloginfo("wpurl") . "/wp-admin/upload.php?posted=3";
154
} else {
155
//TODO Better error handling when no file is selected.
156
//For now just go back to media management
49
$suffix = substr($current_file, (strlen($current_file)-4));
50
$prefix = substr($current_file, 0, (strlen($current_file)-4));
51
$imgAr = array(".png", ".gif", ".jpg");
52
+ if (in_array($suffix, $imgAr)) {
53
+ // It's a png/gif/jpg based on file name
54
// Get thumbnail filenames from metadata
55
$metadata = wp_get_attachment_metadata($_POST["ID"]);
56
+ if (is_array($metadata)) { // Added fix for error messages when there is no metadata (but WHY would there not be? I don't know…)
57
+ foreach($metadata["sizes"] AS $thissize) {
58
+ // Get all filenames and do an unlink() on each one;
59
+ $thisfile = $thissize["file"];
60
+ if (strlen($thisfile)) {
61
+ $thisfile = $current_path . "/" . $thissize["file"];
62
+ if (file_exists($thisfile)) {
63
+ unlink($thisfile);
64
+ }
65
}
66
}
67
}
154
}
155
156
$returnurl = get_bloginfo("wpurl") . "/wp-admin/upload.php?posted=3";
157
+ $returnurl = get_bloginfo("wpurl") . "/wp-admin/post.php?post={$_POST["ID"]}&action=edit&message=1";
158
} else {
159
//TODO Better error handling when no file is selected.
160
//For now just go back to media management