Version Description
- New and safer method for deleting thumbnails when a new image file is uploaded.
- New translations for simplified Chinese (thanks Tunghsiao Liu) and Italian (grazie Marco Chiesi)
- Added method for detecting upload screen to ensure backwards compatibility with versions pre 3.5
Download this release
Release Info
Developer | MungoBBQ |
Plugin | Enable Media Replace |
Version | 2.8 |
Comparing to | |
See all releases |
Code changes from version 2.7 to 2.8
- enable-media-replace-it_IT.mo +0 -0
- enable-media-replace-it_IT.po +95 -0
- enable-media-replace-zh_CN.mo +0 -0
- enable-media-replace-zh_CN.po +119 -0
- enable-media-replace.php +14 -4
- readme.txt +5 -0
- upload.php +26 -23
enable-media-replace-it_IT.mo
ADDED
Binary file
|
enable-media-replace-it_IT.po
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Enable Media Replace\n"
|
4 |
+
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"POT-Creation-Date: 2011-03-24 10:57+0100\n"
|
6 |
+
"PO-Revision-Date: 2012-11-27 12:03+0100\n"
|
7 |
+
"Last-Translator: Marco <marco@blackstudio.it>\n"
|
8 |
+
"Language-Team: Black Studio <info@blackstudio.it>\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-Language: Italian\n"
|
15 |
+
"X-Poedit-Country: ITALY\n"
|
16 |
+
"X-Poedit-SearchPath-0: .\n"
|
17 |
+
|
18 |
+
#: enable-media-replace.php:39
|
19 |
+
#: enable-media-replace.php:67
|
20 |
+
msgid "Replace media"
|
21 |
+
msgstr "Sostituisci file"
|
22 |
+
|
23 |
+
#: enable-media-replace.php:67
|
24 |
+
msgid "Upload a new file"
|
25 |
+
msgstr "Carica un nuovo file"
|
26 |
+
|
27 |
+
#: enable-media-replace.php:67
|
28 |
+
msgid "To replace the current file, click the link and upload a replacement."
|
29 |
+
msgstr "Per sostituire il file corrente, clicca il link e carica un file sostitutivo."
|
30 |
+
|
31 |
+
#: popup.php:14
|
32 |
+
#: upload.php:3
|
33 |
+
msgid "You do not have permission to upload files."
|
34 |
+
msgstr "Non hai sufficienti permessi per caricare file."
|
35 |
+
|
36 |
+
#: popup.php:30
|
37 |
+
msgid "Replace Media Upload"
|
38 |
+
msgstr "Caricamento file sostitutivo"
|
39 |
+
|
40 |
+
#: popup.php:46
|
41 |
+
msgid "NOTE: You are about to replace the media file"
|
42 |
+
msgstr "NOTA: Stai per sostituire il file"
|
43 |
+
|
44 |
+
#: popup.php:46
|
45 |
+
msgid "There is no undo. Think about it!"
|
46 |
+
msgstr "Questa operazione non è reversibile. Fai attenzione!"
|
47 |
+
|
48 |
+
#: popup.php:48
|
49 |
+
msgid "Choose a file to upload from your computer"
|
50 |
+
msgstr "Seleziona un file da caricare dal tuo computer"
|
51 |
+
|
52 |
+
#: popup.php:52
|
53 |
+
msgid "Select media replacement type:"
|
54 |
+
msgstr "Seleziona il tipo di sostituzione:"
|
55 |
+
|
56 |
+
#: popup.php:54
|
57 |
+
msgid "Just replace the file"
|
58 |
+
msgstr "Sostituire semplicemente il file"
|
59 |
+
|
60 |
+
#: popup.php:55
|
61 |
+
msgid "Note: This option requires you to upload a file of the same type ("
|
62 |
+
msgstr "Nota: Questa opzione richiede il caricamento di un file dello stesso tipo ("
|
63 |
+
|
64 |
+
#: popup.php:55
|
65 |
+
msgid ") as the one you are replacing. The name of the attachment will stay the same ("
|
66 |
+
msgstr ") di quello sostituito. Il nome dell'allegato rimarrà invariato ("
|
67 |
+
|
68 |
+
#: popup.php:55
|
69 |
+
msgid ") no matter what the file you upload is called."
|
70 |
+
msgstr ") indipendentemente dal nome del file caricato."
|
71 |
+
|
72 |
+
#: popup.php:57
|
73 |
+
msgid "Replace the file, use new file name and update all links"
|
74 |
+
msgstr "Sostituire il file, usare il nome del nuovo file ed aggiornare tutti i collegamenti"
|
75 |
+
|
76 |
+
#: popup.php:58
|
77 |
+
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 ("
|
78 |
+
msgstr "Nota: Se selezioni questa opzione, il nome ed il tipo di file che stai per caricare sostituiranno quelli del file precedente. Tutti i collegamenti che puntavano al file precedente ("
|
79 |
+
|
80 |
+
#: popup.php:58
|
81 |
+
msgid ") will be updated to point to the new file name."
|
82 |
+
msgstr ") saranno aggiornati per puntare al nuovo file."
|
83 |
+
|
84 |
+
#: popup.php:60
|
85 |
+
msgid "Upload"
|
86 |
+
msgstr "Carica"
|
87 |
+
|
88 |
+
#: popup.php:60
|
89 |
+
msgid "Cancel"
|
90 |
+
msgstr "Annulla"
|
91 |
+
|
92 |
+
#: upload.php:35
|
93 |
+
msgid "File type does not meet security guidelines. Try another."
|
94 |
+
msgstr "Il tipo di file non rispetta le restrizioni di sicurezza. Riprova con un altro tipo."
|
95 |
+
|
enable-media-replace-zh_CN.mo
ADDED
Binary file
|
enable-media-replace-zh_CN.po
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Enable Media Replace v2.6\n"
|
4 |
+
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"POT-Creation-Date: \n"
|
6 |
+
"PO-Revision-Date: 2012-09-18 07:29:17+0000\n"
|
7 |
+
"Last-Translator: Tunghsiao Liu <info@sparanoid.com>\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 |
+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
13 |
+
"X-Poedit-Language: Chinese\n"
|
14 |
+
"X-Poedit-Country: PEOPLE'S REPUBLIC OF CHINA\n"
|
15 |
+
"X-Poedit-SourceCharset: utf-8\n"
|
16 |
+
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
|
17 |
+
"X-Poedit-Basepath: \n"
|
18 |
+
"X-Poedit-Bookmarks: \n"
|
19 |
+
"X-Poedit-SearchPath-0: .\n"
|
20 |
+
"X-Textdomain-Support: yes"
|
21 |
+
|
22 |
+
#: enable-media-replace.php:39
|
23 |
+
#: enable-media-replace.php:67
|
24 |
+
#@ enable-media-replace
|
25 |
+
msgid "Replace media"
|
26 |
+
msgstr "替换媒体"
|
27 |
+
|
28 |
+
#: enable-media-replace.php:67
|
29 |
+
#@ enable-media-replace
|
30 |
+
msgid "Upload a new file"
|
31 |
+
msgstr "上传新文件"
|
32 |
+
|
33 |
+
#: enable-media-replace.php:67
|
34 |
+
#@ enable-media-replace
|
35 |
+
msgid "To replace the current file, click the link and upload a replacement."
|
36 |
+
msgstr "想要替换当前文件,点击上述链接并上传新文件"
|
37 |
+
|
38 |
+
#: popup.php:14
|
39 |
+
#: upload.php:3
|
40 |
+
#@ enable-media-replace
|
41 |
+
#@ default
|
42 |
+
msgid "You do not have permission to upload files."
|
43 |
+
msgstr "您没有权限上传文件"
|
44 |
+
|
45 |
+
#: popup.php:30
|
46 |
+
#@ enable-media-replace
|
47 |
+
msgid "Replace Media Upload"
|
48 |
+
msgstr "替换媒体文件"
|
49 |
+
|
50 |
+
#: popup.php:46
|
51 |
+
#@ enable-media-replace
|
52 |
+
msgid "NOTE: You are about to replace the media file"
|
53 |
+
msgstr "注意:您将要替换媒体文件"
|
54 |
+
|
55 |
+
#: popup.php:46
|
56 |
+
#@ enable-media-replace
|
57 |
+
msgid "There is no undo. Think about it!"
|
58 |
+
msgstr "此操作无法撤销。"
|
59 |
+
|
60 |
+
#: popup.php:48
|
61 |
+
#@ enable-media-replace
|
62 |
+
msgid "Choose a file to upload from your computer"
|
63 |
+
msgstr "从计算机中选择文件上传"
|
64 |
+
|
65 |
+
#: popup.php:52
|
66 |
+
#@ enable-media-replace
|
67 |
+
msgid "Select media replacement type:"
|
68 |
+
msgstr "选择媒体替换类型"
|
69 |
+
|
70 |
+
#: popup.php:54
|
71 |
+
#@ enable-media-replace
|
72 |
+
msgid "Just replace the file"
|
73 |
+
msgstr "仅替换文件"
|
74 |
+
|
75 |
+
#: popup.php:55
|
76 |
+
#@ enable-media-replace
|
77 |
+
msgid "Note: This option requires you to upload a file of the same type ("
|
78 |
+
msgstr "说明:此选项要求您上传与之前文件相同的文件类型("
|
79 |
+
|
80 |
+
#: popup.php:55
|
81 |
+
#@ enable-media-replace
|
82 |
+
msgid ") as the one you are replacing. The name of the attachment will stay the same ("
|
83 |
+
msgstr "),替换后,无论您上传的文件名是什么,上传后的媒体文件名称与地址都会保持不变("
|
84 |
+
|
85 |
+
#: popup.php:55
|
86 |
+
#@ enable-media-replace
|
87 |
+
msgid ") no matter what the file you upload is called."
|
88 |
+
msgstr ")。"
|
89 |
+
|
90 |
+
#: popup.php:57
|
91 |
+
#@ enable-media-replace
|
92 |
+
msgid "Replace the file, use new file name and update all links"
|
93 |
+
msgstr "替换文件,使用新文件名并更新所有链接"
|
94 |
+
|
95 |
+
#: popup.php:58
|
96 |
+
#@ enable-media-replace
|
97 |
+
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 ("
|
98 |
+
msgstr "说明:使用此选项,将会使用新文件的文件名及文件类型,所有包含文件名("
|
99 |
+
|
100 |
+
#: popup.php:58
|
101 |
+
#@ enable-media-replace
|
102 |
+
msgid ") will be updated to point to the new file name."
|
103 |
+
msgstr ")的链接也将会被替换成新文件名。"
|
104 |
+
|
105 |
+
#: popup.php:60
|
106 |
+
#@ enable-media-replace
|
107 |
+
msgid "Upload"
|
108 |
+
msgstr "上传"
|
109 |
+
|
110 |
+
#: popup.php:60
|
111 |
+
#@ enable-media-replace
|
112 |
+
msgid "Cancel"
|
113 |
+
msgstr "取消"
|
114 |
+
|
115 |
+
#: upload.php:33
|
116 |
+
#@ default
|
117 |
+
msgid "File type does not meet security guidelines. Try another."
|
118 |
+
msgstr "文件类型不符合安全规范,请尝试其他文件。"
|
119 |
+
|
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.
|
7 |
Author: Måns Jonasson
|
8 |
Author URI: http://www.mansjonasson.se
|
9 |
|
@@ -25,7 +25,7 @@ Developed for .SE (Stiftelsen för Internetinfrastruktur) - http://www.iis.se
|
|
25 |
*
|
26 |
*/
|
27 |
|
28 |
-
add_action(
|
29 |
add_action('admin_menu', 'emr_menu');
|
30 |
add_filter('attachment_fields_to_edit', 'enable_media_replace', 10, 2);
|
31 |
|
@@ -54,8 +54,18 @@ function enable_media_replace_init() {
|
|
54 |
*/
|
55 |
function enable_media_replace( $form_fields, $post ) {
|
56 |
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
$url = admin_url( "upload.php?page=enable-media-replace/enable-media-replace.php&action=media_replace&attachment_id=" . $post->ID);
|
61 |
$action = "media_replace";
|
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
|
7 |
Author: Måns Jonasson
|
8 |
Author URI: http://www.mansjonasson.se
|
9 |
|
25 |
*
|
26 |
*/
|
27 |
|
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 |
|
54 |
*/
|
55 |
function enable_media_replace( $form_fields, $post ) {
|
56 |
|
57 |
+
// Check if we are on media upload screen for insertion of replace link
|
58 |
+
$on_media_edit_screen = false;
|
59 |
+
$current_wp_version = get_bloginfo('version');
|
60 |
+
if ($current_wp_version < 3.5) {
|
61 |
+
if (isset($_GET["attachment_id"]) && $_GET["attachment_id"]) { $on_media_edit_screen = true; }
|
62 |
+
}
|
63 |
+
else {
|
64 |
+
$current_screen = get_current_screen();
|
65 |
+
if ( $current_screen->base == 'post' && $current_screen->post_type == 'attachment' ) { $on_media_edit_screen = true; }
|
66 |
+
}
|
67 |
+
|
68 |
+
if ($on_media_edit_screen == true) {
|
69 |
|
70 |
$url = admin_url( "upload.php?page=enable-media-replace/enable-media-replace.php&action=media_replace&attachment_id=" . $post->ID);
|
71 |
$action = "media_replace";
|
readme.txt
CHANGED
@@ -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.7 =
|
41 |
* A couple of changes made to ensure compatibility with WordPress 3.5. Thanks to Elizabeth Powell for the fixes!
|
42 |
|
37 |
|
38 |
== Changelog ==
|
39 |
|
40 |
+
= 2.8 =
|
41 |
+
* New and safer method for deleting thumbnails when a new image file is uploaded.
|
42 |
+
* New translations for simplified Chinese (thanks Tunghsiao Liu) and Italian (grazie Marco Chiesi)
|
43 |
+
* Added method for detecting upload screen to ensure backwards compatibility with versions pre 3.5
|
44 |
+
|
45 |
= 2.7 =
|
46 |
* A couple of changes made to ensure compatibility with WordPress 3.5. Thanks to Elizabeth Powell for the fixes!
|
47 |
|
upload.php
CHANGED
@@ -38,25 +38,6 @@ if (is_uploaded_file($_FILES["userfile"]["tmp_name"])) {
|
|
38 |
$new_filesize = $_FILES["userfile"]["size"];
|
39 |
$new_filetype = $filedata["type"];
|
40 |
|
41 |
-
/**
|
42 |
-
* Keeping old method in code for posterity
|
43 |
-
*
|
44 |
-
if (function_exists("mime_content_type")) {
|
45 |
-
// More reliable way of determining file type
|
46 |
-
$new_filetype = mime_content_type($_FILES["userfile"]["tmp_name"]);
|
47 |
-
}
|
48 |
-
else {
|
49 |
-
$new_filetype = $_FILES['userfile']['type'];
|
50 |
-
}
|
51 |
-
|
52 |
-
// Check that mime type is allowed
|
53 |
-
$allowed_mime_types = get_allowed_mime_types();
|
54 |
-
if (!in_array($new_filetype, $allowed_mime_types)) {
|
55 |
-
echo __("File type does not meet security guidelines. Try another.");
|
56 |
-
exit;
|
57 |
-
}
|
58 |
-
**/
|
59 |
-
|
60 |
if ($replace_type == "replace") {
|
61 |
// Drop-in replace and we don't even care if you uploaded something that is the wrong file-type.
|
62 |
// That's your own fault, because we warned you!
|
@@ -69,8 +50,19 @@ if (is_uploaded_file($_FILES["userfile"]["tmp_name"])) {
|
|
69 |
$prefix = substr($current_file, 0, (strlen($current_file)-4));
|
70 |
$imgAr = array(".png", ".gif", ".jpg");
|
71 |
if (in_array($suffix, $imgAr)) {
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
}
|
75 |
|
76 |
// Move new file to old location/name
|
@@ -95,8 +87,19 @@ if (is_uploaded_file($_FILES["userfile"]["tmp_name"])) {
|
|
95 |
$prefix = substr($current_file, 0, (strlen($current_file)-4));
|
96 |
$imgAr = array(".png", ".gif", ".jpg");
|
97 |
if (in_array($suffix, $imgAr)) {
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
}
|
101 |
|
102 |
// Massage new filename to adhere to WordPress standards
|
38 |
$new_filesize = $_FILES["userfile"]["size"];
|
39 |
$new_filetype = $filedata["type"];
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
if ($replace_type == "replace") {
|
42 |
// Drop-in replace and we don't even care if you uploaded something that is the wrong file-type.
|
43 |
// That's your own fault, because we warned you!
|
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 |
+
unlink($thisfile);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
// Old (brutal) method, left here for now
|
64 |
+
//$mask = $prefix . "-*x*" . $suffix;
|
65 |
+
//array_map( "unlink", glob( $mask ) );
|
66 |
}
|
67 |
|
68 |
// Move new file to old location/name
|
87 |
$prefix = substr($current_file, 0, (strlen($current_file)-4));
|
88 |
$imgAr = array(".png", ".gif", ".jpg");
|
89 |
if (in_array($suffix, $imgAr)) {
|
90 |
+
// Get thumbnail filenames from metadata
|
91 |
+
$metadata = wp_get_attachment_metadata($_POST["ID"]);
|
92 |
+
foreach($metadata["sizes"] AS $thissize) {
|
93 |
+
// Get all filenames and do an unlink() on each one;
|
94 |
+
$thisfile = $thissize["file"];
|
95 |
+
if (strlen($thisfile)) {
|
96 |
+
$thisfile = $current_path . "/" . $thissize["file"];
|
97 |
+
unlink($thisfile);
|
98 |
+
}
|
99 |
+
}
|
100 |
+
// Old (brutal) method, left here for now
|
101 |
+
//$mask = $prefix . "-*x*" . $suffix;
|
102 |
+
//array_map( "unlink", glob( $mask ) );
|
103 |
}
|
104 |
|
105 |
// Massage new filename to adhere to WordPress standards
|