Enable Media Replace - Version 2.5.2

Version Description

  • The "more reliable way" of determining MIME types turned out to be less reliable. Go figure. There seems to be no perfect way of performing a reliable check for MIME-types on an uploaded file that is also truly portable. I have now made checks for the availability of mime_content_type() before using it, using the old method as a fall-back. It is far from beautiful, so if anybody has a better way of doing it, please contact me!
Download this release

Release Info

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

Code changes from version 2.5.1 to 2.5.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.5.1
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.5.2
7
  Author: M�ns Jonasson
8
  Author URI: http://www.mansjonasson.se
9
 
readme.txt CHANGED
@@ -37,6 +37,9 @@ If you want more control over the format used to display the time, you can use t
37
 
38
  == Changelog ==
39
 
 
 
 
40
  = 2.5.1 =
41
  * Bug fix - there is now a more reliable way of determining file type on your upload so you can upload PDF files without seeing that pesky "File type does not meet security guidelines" message.
42
  * New translation to Danish - thanks to Michael Bering Petersen!
37
 
38
  == Changelog ==
39
 
40
+ = 2.5.2 =
41
+ * The "more reliable way" of determining MIME types turned out to be less reliable. Go figure. There seems to be no perfect way of performing a reliable check for MIME-types on an uploaded file that is also truly portable. I have now made checks for the availability of mime_content_type() before using it, using the old method as a fall-back. It is far from beautiful, so if anybody has a better way of doing it, please contact me!
42
+
43
  = 2.5.1 =
44
  * Bug fix - there is now a more reliable way of determining file type on your upload so you can upload PDF files without seeing that pesky "File type does not meet security guidelines" message.
45
  * New translation to Danish - thanks to Michael Bering Petersen!
trunk/enable-media-replace-da_DK.mo DELETED
Binary file
trunk/enable-media-replace-da_DK.po DELETED
@@ -1,89 +0,0 @@
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: Michael Bering Petersen <michaelbering@gmail.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
- "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 "Udskift media"
20
-
21
- #: enable-media-replace.php:68
22
- msgid "Upload a new file"
23
- msgstr "Upload en ny fil"
24
-
25
- #: enable-media-replace.php:68
26
- msgid "To replace the current file, click the link and upload a replacement."
27
- msgstr "Hvis du ønsker at udskifte den aktuelle fil - klik på linket og upload den nye fil."
28
-
29
- #: popup.php:14
30
- #: upload.php:21
31
- msgid "You do not have permission to upload files."
32
- msgstr "Du har ikke tilladelse til at uploade filer."
33
-
34
- #: popup.php:30
35
- msgid "Replace Media Upload"
36
- msgstr "Replace Media Upload"
37
-
38
- #: popup.php:41
39
- msgid "NOTE: You are about to replace the media file"
40
- msgstr "OBS: Du er nu ved at overskrive filen,"
41
-
42
- #: popup.php:41
43
- msgid "There is no undo. Think about it!"
44
- msgstr "Der er ingen mulighed for at fortryde, så tænkt dig godt om inden du accepterer."
45
-
46
- #: popup.php:43
47
- msgid "Choose a file to upload from your computer"
48
- msgstr "Vælg den fil du ønsker at uploade fra din computer."
49
-
50
- #: popup.php:47
51
- msgid "Select media replacement type:"
52
- msgstr "Vælg media type:"
53
-
54
- #: popup.php:49
55
- msgid "Just replace the file"
56
- msgstr "Udskift filen"
57
-
58
- #: popup.php:50
59
- msgid "Note: This option requires you to upload a file of the same type ("
60
- msgstr "OBS: Denne mulighed kræver at du uploader en fil af samme type ("
61
-
62
- #: popup.php:50
63
- msgid ") as the one you are replacing. The name of the attachment will stay the same ("
64
- msgstr ") som den du overskriver. Navnet på filen vil forblive det samme ("
65
-
66
- #: popup.php:50
67
- msgid ") no matter what the file you upload is called."
68
- msgstr ") uanset hvad den fil du uploader hedder."
69
-
70
- #: popup.php:52
71
- msgid "Replace the file, use new file name and update all links"
72
- msgstr "Overskriv filen, brug det nye fil navn og opdater alle 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 "OBS: Hvis du vælger denne mulighed - vil filnavnet og filtypen som du er ved at uploade overskrive den gamle fil. Alle links der peger på den nuværende fil ("
77
-
78
- #: popup.php:53
79
- msgid ") will be updated to point to the new file name."
80
- msgstr ") vil blive opdateret så de peger på den nye fil."
81
-
82
- #: popup.php:55
83
- msgid "Upload"
84
- msgstr "Upload"
85
-
86
- #: popup.php:55
87
- msgid "Cancel"
88
- msgstr "Fortryd"
89
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/enable-media-replace-de_DE.mo DELETED
Binary file
trunk/enable-media-replace-de_DE.po DELETED
@@ -1,89 +0,0 @@
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: Martin Lettner <m.lettner@gmail.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
- "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 "Datei ersetzen"
20
-
21
- #: enable-media-replace.php:68
22
- msgid "Upload a new file"
23
- msgstr "Eine neue Datei hochladen"
24
-
25
- #: enable-media-replace.php:68
26
- msgid "To replace the current file, click the link and upload a replacement."
27
- msgstr "Eine neue Datei hochladen, die die aktuelle ersetzen soll."
28
-
29
- #: popup.php:14
30
- #: upload.php:21
31
- msgid "You do not have permission to upload files."
32
- msgstr "Sie haben nicht die benötigten Rechte um Dateien hochzuladen."
33
-
34
- #: popup.php:30
35
- msgid "Replace Media Upload"
36
- msgstr "Medien-Datei ersetzen"
37
-
38
- #: popup.php:41
39
- msgid "NOTE: You are about to replace the media file"
40
- msgstr "HINWEIS: Sie sind dabei, eine Datei in der Mediathek zu ersetzen"
41
-
42
- #: popup.php:41
43
- msgid "There is no undo. Think about it!"
44
- msgstr "Diese Aktion kann nicht rückgängig gemacht werden!"
45
-
46
- #: popup.php:43
47
- msgid "Choose a file to upload from your computer"
48
- msgstr "Datei vom Computer auswählen:"
49
-
50
- #: popup.php:47
51
- msgid "Select media replacement type:"
52
- msgstr "Wählen Sie die gewünschte Aktion:"
53
-
54
- #: popup.php:49
55
- msgid "Just replace the file"
56
- msgstr "Datei einfach ersetzen"
57
-
58
- #: popup.php:50
59
- msgid "Note: This option requires you to upload a file of the same type ("
60
- msgstr "Hinweis: Die Datei muss vom selben Dateityp sein ("
61
-
62
- #: popup.php:50
63
- msgid ") as the one you are replacing. The name of the attachment will stay the same ("
64
- msgstr ") wie die Datei, die Sie ersetzen. Der Name der der Datei bleibt erhalten ("
65
-
66
- #: popup.php:50
67
- msgid ") no matter what the file you upload is called."
68
- msgstr "), ganz egal wie die neue Datei heißt."
69
-
70
- #: popup.php:52
71
- msgid "Replace the file, use new file name and update all links"
72
- msgstr "Datei ersetzen, aber neuen Dateinamen verwenden und alle Links automatisch aktualisieren"
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 "Hinweis: Der Name der neuen Datei wird die alte ersetzen. Alle Verweise auf die aktuelle Datei ("
77
-
78
- #: popup.php:53
79
- msgid ") will be updated to point to the new file name."
80
- msgstr ") werden auf die neue aktualisiert."
81
-
82
- #: popup.php:55
83
- msgid "Upload"
84
- msgstr "Hochladen"
85
-
86
- #: popup.php:55
87
- msgid "Cancel"
88
- msgstr "Abbrechen"
89
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/enable-media-replace-fr_FR.mo DELETED
Binary file
trunk/enable-media-replace-fr_FR.po DELETED
@@ -1,93 +0,0 @@
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: 2011-03-24 11:41+0100\n"
7
- "Last-Translator: François Collette <francois.collette@gmail.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
- "X-Poedit-KeywordsList: _e;__\n"
13
- "X-Poedit-Basepath: .\n"
14
- "X-Poedit-SearchPath-0: .\n"
15
-
16
- #: enable-media-replace.php:39
17
- #: enable-media-replace.php:67
18
- msgid "Replace media"
19
- msgstr "Remplacer le média"
20
-
21
- #: enable-media-replace.php:67
22
- msgid "Upload a new file"
23
- msgstr "Choisir le nouveau fichier"
24
-
25
- #: enable-media-replace.php:67
26
- msgid "To replace the current file, click the link and upload a replacement."
27
- msgstr "Pour remplacer le fichier actuel, cliquez ci-dessus et choisissez le nouveau fichier."
28
-
29
- #: popup.php:14
30
- #: upload.php:3
31
- msgid "You do not have permission to upload files."
32
- msgstr "Vous n'avez pas la permission d'envoyer des fichiers."
33
-
34
- #: popup.php:30
35
- msgid "Replace Media Upload"
36
- msgstr "Remplacement de média"
37
-
38
- #: popup.php:46
39
- msgid "NOTE: You are about to replace the media file"
40
- msgstr "ATTENTION : vous vous apprêtez à remplacer le fichier"
41
-
42
- #: popup.php:46
43
- msgid "There is no undo. Think about it!"
44
- msgstr "Cette opération est irréversible. Soyez sûr(e) de vous !"
45
-
46
- #: popup.php:48
47
- msgid "Choose a file to upload from your computer"
48
- msgstr "Envoyez un fichier depuis votre ordinateur :"
49
-
50
- #: popup.php:52
51
- msgid "Select media replacement type:"
52
- msgstr "Choisissez la méthode de remplacement :"
53
-
54
- #: popup.php:54
55
- msgid "Just replace the file"
56
- msgstr "Remplacer le fichier seulement"
57
-
58
- #: popup.php:55
59
- msgid "Note: This option requires you to upload a file of the same type ("
60
- msgstr "Avec cette option, vous devez choisir un fichier du même type ("
61
-
62
- #: popup.php:55
63
- msgid ") as the one you are replacing. The name of the attachment will stay the same ("
64
- msgstr ") que le précédent. Le nom du fichier actuel ("
65
-
66
- #: popup.php:55
67
- msgid ") no matter what the file you upload is called."
68
- msgstr ") sera conservé, quel que soit le nom de votre nouveau fichier."
69
-
70
- #: popup.php:57
71
- msgid "Replace the file, use new file name and update all links"
72
- msgstr "Remplacer le fichier, utiliser le nouveau nom de fichier et mettre à jour tous les liens"
73
-
74
- #: popup.php:58
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 "Avec cette option, le nom et le type de votre nouveau fichier vont remplacer ceux du fichier actuel. Tous les liens vers celui-ci ("
77
-
78
- #: popup.php:58
79
- msgid ") will be updated to point to the new file name."
80
- msgstr ") seront mis à jour selon le nouveau nom du fichier."
81
-
82
- #: popup.php:60
83
- msgid "Upload"
84
- msgstr "Envoyer"
85
-
86
- #: popup.php:60
87
- msgid "Cancel"
88
- msgstr "Annuler"
89
-
90
- #: upload.php:35
91
- msgid "File type does not meet security guidelines. Try another."
92
- msgstr "Ce type de fichier est incompatible avec les règles de sécurité. Essayez-en un autre."
93
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/enable-media-replace-nl_NL.mo DELETED
Binary file
trunk/enable-media-replace-nl_NL.po DELETED
@@ -1,89 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: enable-media-replace\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2010-09-10 20:53+0100\n"
6
- "PO-Revision-Date: \n"
7
- "Last-Translator: WarmStal D!sign | Ben ter Stal <mail@warmstal.nl>\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:26
17
- #: enable-media-replace.php:45
18
- msgid "Replace media"
19
- msgstr "Vervangen media"
20
-
21
- #: enable-media-replace.php:45
22
- msgid "Upload a new file"
23
- msgstr "Uploaden nieuw bestand"
24
-
25
- #: enable-media-replace.php:45
26
- msgid "To replace the current file, click the link and upload a replacement."
27
- msgstr "Klik om het bestaande bestand te vervangen door een nieuw te uploaden bestand."
28
-
29
- #: popup.php:7
30
- #: upload.php:10
31
- msgid "You do not have permission to upload files."
32
- msgstr "U heeft geen rechten om bestanden te uplaoden"
33
-
34
- #: popup.php:23
35
- msgid "Replace Media Upload"
36
- msgstr "Replace Media Upload"
37
-
38
- #: popup.php:34
39
- msgid "NOTE: You are about to replace the media file"
40
- msgstr "Opmerking: U staat op het punt het media bestand"
41
-
42
- #: popup.php:34
43
- msgid "There is no undo. Think about it!"
44
- msgstr "Deze bewerking kan niet ongedaan worden gemaakt!"
45
-
46
- #: popup.php:36
47
- msgid "Choose a file to upload from your computer"
48
- msgstr "Selecteer een bestand op de PC om te uploaden"
49
-
50
- #: popup.php:40
51
- msgid "Select media replacement type:"
52
- msgstr "Selecteer de wijze van vervanging"
53
-
54
- #: popup.php:42
55
- msgid "Just replace the file"
56
- msgstr "Vervang alleen het bestand"
57
-
58
- #: popup.php:43
59
- msgid "Note: This option requires you to upload a file of the same type ("
60
- msgstr "Opmerking: voor deze optie moet u een bestand van hetzelfde type uploaden ("
61
-
62
- #: popup.php:43
63
- msgid ") as the one you are replacing. The name of the attachment will stay the same ("
64
- msgstr ") De naam in de media bibliotheek blijft hetzelfde ("
65
-
66
- #: popup.php:43
67
- msgid ") no matter what the file you upload is called."
68
- msgstr ") onafhankelijk van de naam van het nieuwe bestand."
69
-
70
- #: popup.php:45
71
- msgid "Replace the file, use new file name and update all links"
72
- msgstr "Vervang het bestand, gebruik de nieuwe naam en werk alle links bij."
73
-
74
- #: popup.php:46
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 "Opmerking: bij deze keuze wordt het bestand volledig vervangen. Alle links naar het huidige bestand ("
77
-
78
- #: popup.php:46
79
- msgid ") will be updated to point to the new file name."
80
- msgstr ") worden bijgewerkt naar het nieuwe bestand."
81
-
82
- #: popup.php:48
83
- msgid "Upload"
84
- msgstr "Uploaden"
85
-
86
- #: popup.php:48
87
- msgid "Cancel"
88
- msgstr "Annuleren"
89
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/enable-media-replace-ru_RU.mo DELETED
Binary file
trunk/enable-media-replace-ru_RU.po DELETED
@@ -1,94 +0,0 @@
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: Måns Jonasson <mans@mansjonasson.se>\n"
8
- "Language-Team: <zhr@tut.by>\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: Russian\n"
15
- "X-Poedit-Country: RUSSIAN FEDERATION\n"
16
- "X-Poedit-SourceCharset: utf-8\n"
17
- "X-Poedit-SearchPath-0: .\n"
18
-
19
- #: enable-media-replace.php:40
20
- #: enable-media-replace.php:68
21
- msgid "Replace media"
22
- msgstr "Заменить медиа"
23
-
24
- #: enable-media-replace.php:68
25
- msgid "Upload a new file"
26
- msgstr "Загрузить новый файл"
27
-
28
- #: enable-media-replace.php:68
29
- msgid "To replace the current file, click the link and upload a replacement."
30
- msgstr "Для того, чтобы заменить текущий файл, нажмите на ссылку и загрузите замену. "
31
-
32
- #: popup.php:14
33
- #: upload.php:21
34
- msgid "You do not have permission to upload files."
35
- msgstr "У вас нет прав для загрузки файлов. "
36
-
37
- #: popup.php:30
38
- msgid "Replace Media Upload"
39
- msgstr "Загрузить замену"
40
-
41
- #: popup.php:41
42
- msgid "NOTE: You are about to replace the media file"
43
- msgstr "Памятка: о замене медиафайла"
44
-
45
- #: popup.php:41
46
- msgid "There is no undo. Think about it!"
47
- msgstr "Нельзя отменить. Знайте это!"
48
-
49
- #: popup.php:43
50
- msgid "Choose a file to upload from your computer"
51
- msgstr "Выберите файл для загрузки с вашего компьютера"
52
-
53
- #: popup.php:47
54
- msgid "Select media replacement type:"
55
- msgstr "Выберите тип замены:"
56
-
57
- #: popup.php:49
58
- msgid "Just replace the file"
59
- msgstr "Только заменить файл"
60
-
61
- #: popup.php:50
62
- msgid "Note: This option requires you to upload a file of the same type ("
63
- msgstr "Примечание: Этот вариант требуется, если нужно загрузить файл того же типа"
64
-
65
- #: popup.php:50
66
- msgid ") as the one you are replacing. The name of the attachment will stay the same ("
67
- msgstr ") в качестве одного вы заменяете. Имя вложения останется той же ( "
68
-
69
- #: popup.php:50
70
- msgid ") no matter what the file you upload is called."
71
- msgstr ") Вне зависимости от того, как называется загружаемый файл."
72
-
73
- #: popup.php:52
74
- msgid "Replace the file, use new file name and update all links"
75
- msgstr "Для того, чтобы заменить этот файл, используйте новое имя файла и обновите все ссылки"
76
-
77
- #: popup.php:53
78
- 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 ("
79
- msgstr "Примечание: Если вы отметите эту опцию, название и тип файла, который Вы собираетесь загрузить, заменит старый файл. Все ссылки, указывающие на текущий файл ( "
80
-
81
- #: popup.php:53
82
- msgid ") will be updated to point to the new file name."
83
- msgstr ") бдет обновлен "
84
-
85
- #: popup.php:55
86
- msgid "Upload"
87
- msgstr "Загрузить"
88
-
89
- #: popup.php:55
90
- msgid "Cancel"
91
- msgstr "Отмена"
92
-
93
- #~ msgid "Replace media upload"
94
- #~ msgstr "Загрузить замену"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/enable-media-replace-sv_SE.mo DELETED
Binary file
trunk/enable-media-replace-sv_SE.po DELETED
@@ -1,114 +0,0 @@
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: Måns Jonasson <mans@mansjonasson.se>\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 "Ersätt media"
20
-
21
- #: enable-media-replace.php:68
22
- msgid "Upload a new file"
23
- msgstr "Ladda upp en ny fil"
24
-
25
- #: enable-media-replace.php:68
26
- msgid "To replace the current file, click the link and upload a replacement."
27
- msgstr "För att ersätta den nuvarande filen, klicka på länken och ladda upp en ny fil."
28
-
29
- #: popup.php:14
30
- #: upload.php:21
31
- msgid "You do not have permission to upload files."
32
- msgstr "Du har inte tillåtelse att ladda upp filer."
33
-
34
- #: popup.php:30
35
- msgid "Replace Media Upload"
36
- msgstr "Ladda upp ny fil"
37
-
38
- #: popup.php:41
39
- msgid "NOTE: You are about to replace the media file"
40
- msgstr "OBS: Du är på väg att ersätta filen"
41
-
42
- #: popup.php:41
43
- msgid "There is no undo. Think about it!"
44
- msgstr "Det finns inget sätt att ångra. Tänk efter först!"
45
-
46
- #: popup.php:43
47
- msgid "Choose a file to upload from your computer"
48
- msgstr "Välj en fil att ladda upp från din dator"
49
-
50
- #: popup.php:47
51
- msgid "Select media replacement type:"
52
- msgstr "Välj ersättningsform:"
53
-
54
- #: popup.php:49
55
- msgid "Just replace the file"
56
- msgstr "Ersätt bara filen"
57
-
58
- #: popup.php:50
59
- msgid "Note: This option requires you to upload a file of the same type ("
60
- msgstr "Detta val kräver att du laddar upp en fil av exakt samma typ ("
61
-
62
- #: popup.php:50
63
- msgid ") as the one you are replacing. The name of the attachment will stay the same ("
64
- msgstr ") som den du ersätter. Namnet på filen kommer att behållas ("
65
-
66
- #: popup.php:50
67
- msgid ") no matter what the file you upload is called."
68
- msgstr ") oavsett vad filen du laddar upp heter på din dator."
69
-
70
- #: popup.php:52
71
- msgid "Replace the file, use new file name and update all links"
72
- msgstr "Ersätt filen, använd det nya filnamnet och uppdatera alla länkar"
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 "Om du klickar i den här rutan kommer den även namnet och typen på den nya filen du laddar upp helt att ersätta den gamla. Alla länkar som pekar på den gamla filen ("
77
-
78
- #: popup.php:53
79
- msgid ") will be updated to point to the new file name."
80
- msgstr ") kommer att uppdateras så att de pekar på det nya filnamnet."
81
-
82
- #: popup.php:55
83
- msgid "Upload"
84
- msgstr "Ladda upp"
85
-
86
- #: popup.php:55
87
- msgid "Cancel"
88
- msgstr "Avbryt"
89
-
90
- #~ msgid "Enable Media Replace"
91
- #~ msgstr "Ladda upp ny fil"
92
-
93
- #~ msgid ""
94
- #~ "This plugin allows you to replace any uploaded media file by uploading a "
95
- #~ "new one."
96
- #~ msgstr ""
97
- #~ "Detta plugin låter dig ersätta en fil i mediebiblioteket genom att ladda "
98
- #~ "upp en ny."
99
-
100
- #~ msgid "First, locate the uploaded file you want to replace, using the"
101
- #~ msgstr "Hitta först den fil du vill ersätta genom att bläddra i "
102
-
103
- #~ msgid "media library browser"
104
- #~ msgstr "mediebiblioteket"
105
-
106
- #~ msgid "Click the \"Edit\" link"
107
- #~ msgstr "Tryck på \"Redigera\"-länken"
108
-
109
- #~ msgid ""
110
- #~ "Second, click the link \"Upload a new file\" and follow the instructions."
111
- #~ msgstr "Tryck sen på länken \"Ladda upp ny fil\" och följ instruktionerna."
112
-
113
- #~ msgid "Replace media upload"
114
- #~ msgstr "Ladda upp ny fil"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/enable-media-replace.mo DELETED
Binary file
trunk/enable-media-replace.php DELETED
@@ -1,131 +0,0 @@
1
- <?php
2
- /*
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.5.1
7
- Author: M�ns Jonasson
8
- Author URI: http://www.mansjonasson.se
9
-
10
- Dual licensed under the MIT and GPL licenses:
11
- http://www.opensource.org/licenses/mit-license.php
12
- http://www.gnu.org/licenses/gpl.html
13
-
14
- Developed for .SE (Stiftelsen f�r Internetinfrastruktur) - http://www.iis.se
15
- */
16
-
17
- /**
18
- * Main Plugin file
19
- * Set action hooks and add shortcode
20
- *
21
- * @author M�ns Jonasson <http://www.mansjonasson.se>
22
- * @copyright M�ns Jonasson 13 sep 2010
23
- * @package wordpress
24
- * @subpackage enable-media-replace
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
-
32
- add_shortcode('file_modified', 'emr_get_modified_date');
33
-
34
- /**
35
- * Register this file in WordPress so we can call it with a ?page= GET var.
36
- * To suppress it in the menu we give it an empty menu title.
37
- */
38
- function emr_menu() {
39
- add_submenu_page('upload.php', __("Replace media", "enable-media-replace"), '','upload_files', __FILE__, 'emr_options');
40
- }
41
-
42
- /**
43
- * Initialize this plugin. Called by 'admin_init' hook.
44
- * Only languages files needs loading during init.
45
- */
46
- function enable_media_replace_init() {
47
- load_plugin_textdomain( 'enable-media-replace', false, dirname( plugin_basename( __FILE__ ) ) );
48
- }
49
-
50
- /**
51
- * Add some new fields to the attachment edit panel.
52
- * @param array form fields edit panel
53
- * @return array form fields with enable-media-replace fields added
54
- */
55
- function enable_media_replace( $form_fields ) {
56
-
57
- if (isset($_GET["attachment_id"]) && $_GET["attachment_id"]) {
58
-
59
- $url = admin_url( "upload.php?page=enable-media-replace/enable-media-replace.php&action=media_replace&attachment_id=" . (int) $_GET["attachment_id"]);
60
- $action = "media_replace";
61
- $editurl = wp_nonce_url( $url, $action );
62
-
63
- if (FORCE_SSL_ADMIN) {
64
- $editurl = str_replace("http:", "https:", $editurl);
65
- }
66
- $link = "href=\"$editurl\"";
67
- $form_fields["enable-media-replace"] = array("label" => __("Replace media", "enable-media-replace"), "input" => "html", "html" => "<p><a class='button-secondary'$link>" . __("Upload a new file", "enable-media-replace") . "</a></p>", "helps" => __("To replace the current file, click the link and upload a replacement.", "enable-media-replace"));
68
- }
69
- return $form_fields;
70
- }
71
-
72
- /**
73
- * Load the replace media panel.
74
- * Panel is show on the action 'media-replace' and a given attachement.
75
- * Called by GET var ?page=enable-media-replace/enable-media-replace.php
76
- */
77
- function emr_options() {
78
-
79
- if ( isset( $_GET['action'] ) && $_GET['action'] == 'media_replace' ) {
80
- check_admin_referer( 'media_replace' ); // die if invalid or missing nonce
81
- if ( array_key_exists("attachment_id", $_GET) && (int) $_GET["attachment_id"] > 0) {
82
- include("popup.php");
83
- }
84
- }
85
-
86
- if ( isset( $_GET['action'] ) && $_GET['action'] == 'media_replace_upload' ) {
87
- $plugin_url = str_replace("enable-media-replace.php", "", __FILE__);
88
- check_admin_referer( 'media_replace_upload' ); // die if invalid or missing nonce
89
- require_once($plugin_url . "upload.php");
90
- }
91
-
92
- }
93
-
94
- /**
95
- * Shorttag function to show the media file modification date/time.
96
- * @param array shorttag attributes
97
- * @return string content / replacement shorttag
98
- */
99
- function emr_get_modified_date($atts) {
100
- $id=0;
101
- $format= '';
102
-
103
- extract(shortcode_atts(array(
104
- 'id' => '',
105
- 'format' => get_option('date_format') . " " . get_option('time_format'),
106
- ), $atts));
107
-
108
- if ($id == '') return false;
109
-
110
- // Get path to file
111
- $current_file = get_attached_file($id, true);
112
-
113
- // Get file modification time
114
- $filetime = filemtime($current_file);
115
-
116
- // Do timezone magic to get around UTC
117
- $timezone = date_default_timezone_get();
118
- date_default_timezone_set(get_option('timezone_string'));
119
-
120
- // do date conversion
121
- $content = date($format, $filetime);
122
-
123
- // Set timezone back to default
124
- date_default_timezone_set($timezone);
125
-
126
- return $content;
127
-
128
- }
129
-
130
-
131
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/enable-media-replace.po DELETED
@@ -1,89 +0,0 @@
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: Måns Jonasson <mans@mansjonasson.se>\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 ""
20
-
21
- #: enable-media-replace.php:68
22
- msgid "Upload a new file"
23
- msgstr ""
24
-
25
- #: enable-media-replace.php:68
26
- msgid "To replace the current file, click the link and upload a replacement."
27
- msgstr ""
28
-
29
- #: popup.php:14
30
- #: upload.php:21
31
- msgid "You do not have permission to upload files."
32
- msgstr ""
33
-
34
- #: popup.php:30
35
- msgid "Replace Media Upload"
36
- msgstr ""
37
-
38
- #: popup.php:41
39
- msgid "NOTE: You are about to replace the media file"
40
- msgstr ""
41
-
42
- #: popup.php:41
43
- msgid "There is no undo. Think about it!"
44
- msgstr ""
45
-
46
- #: popup.php:43
47
- msgid "Choose a file to upload from your computer"
48
- msgstr ""
49
-
50
- #: popup.php:47
51
- msgid "Select media replacement type:"
52
- msgstr ""
53
-
54
- #: popup.php:49
55
- msgid "Just replace the file"
56
- msgstr ""
57
-
58
- #: popup.php:50
59
- msgid "Note: This option requires you to upload a file of the same type ("
60
- msgstr ""
61
-
62
- #: popup.php:50
63
- msgid ") as the one you are replacing. The name of the attachment will stay the same ("
64
- msgstr ""
65
-
66
- #: popup.php:50
67
- msgid ") no matter what the file you upload is called."
68
- msgstr ""
69
-
70
- #: popup.php:52
71
- msgid "Replace the file, use new file name and update all links"
72
- msgstr ""
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 ""
77
-
78
- #: popup.php:53
79
- msgid ") will be updated to point to the new file name."
80
- msgstr ""
81
-
82
- #: popup.php:55
83
- msgid "Upload"
84
- msgstr ""
85
-
86
- #: popup.php:55
87
- msgid "Cancel"
88
- msgstr ""
89
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/popup.php DELETED
@@ -1,63 +0,0 @@
1
- <?php
2
- /**
3
- * Uploadscreen for selecting and uploading new media file
4
- *
5
- * @author M�ns Jonasson <http://www.mansjonasson.se>
6
- * @copyright M�ns Jonasson 13 sep 2010
7
- * @version $Revision: 2303 $ | $Date: 2010-09-13 11:12:35 +0200 (ma, 13 sep 2010) $
8
- * @package wordpress
9
- * @subpackage enable-media-replace
10
- *
11
- */
12
-
13
- if (!current_user_can('upload_files'))
14
- wp_die(__('You do not have permission to upload files.', 'enable-media-replace'));
15
-
16
- global $wpdb;
17
-
18
- $table_name = $wpdb->prefix . "posts";
19
-
20
- $sql = "SELECT guid, post_mime_type FROM $table_name WHERE ID = " . (int) $_GET["attachment_id"];
21
-
22
- list($current_filename, $current_filetype) = mysql_fetch_array(mysql_query($sql));
23
-
24
- $current_filename = substr($current_filename, (strrpos($current_filename, "/") + 1));
25
-
26
-
27
- ?>
28
- <div class="wrap">
29
- <div id="icon-upload" class="icon32"><br /></div>
30
- <h2><?php echo __("Replace Media Upload", "enable-media-replace"); ?></h2>
31
-
32
- <?php
33
- $url = admin_url( "upload.php?page=enable-media-replace/enable-media-replace.php&noheader=true&action=media_replace_upload&attachment_id=" . (int) $_GET["attachment_id"]);
34
- $action = "media_replace_upload";
35
- $formurl = wp_nonce_url( $url, $action );
36
- if (FORCE_SSL_ADMIN) {
37
- $formurl = str_replace("http:", "https:", $formurl);
38
- }
39
- ?>
40
-
41
- <form enctype="multipart/form-data" method="post" action="<?php echo $formurl; ?>">
42
- <?php
43
- #wp_nonce_field('enable-media-replace');
44
- ?>
45
- <input type="hidden" name="ID" value="<?php echo (int) $_GET["attachment_id"]; ?>" />
46
- <div id="message" class="updated fade"><p><?php echo __("NOTE: You are about to replace the media file", "enable-media-replace"); ?> "<?php echo $current_filename?>". <?php echo __("There is no undo. Think about it!", "enable-media-replace"); ?></p></div>
47
-
48
- <p><?php echo __("Choose a file to upload from your computer", "enable-media-replace"); ?></p>
49
-
50
- <input type="file" name="userfile" />
51
-
52
- <p><?php echo __("Select media replacement type:", "enable-media-replace"); ?></p>
53
-
54
- <label for="replace_type_1"><input CHECKED id="replace_type_1" type="radio" name="replace_type" value="replace"> <?php echo __("Just replace the file", "enable-media-replace"); ?></label>
55
- <p class="howto"><?php echo __("Note: This option requires you to upload a file of the same type (", "enable-media-replace"); ?><?php echo $current_filetype; ?><?php echo __(") as the one you are replacing. The name of the attachment will stay the same (", "enable-media-replace"); ?><?php echo $current_filename; ?><?php echo __(") no matter what the file you upload is called.", "enable-media-replace"); ?></p>
56
-
57
- <label for="replace_type_2"><input id="replace_type_2" type="radio" name="replace_type" value="replace_and_search"> <?php echo __("Replace the file, use new file name and update all links", "enable-media-replace"); ?></label>
58
- <p class="howto"><?php echo __("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 (", "enable-media-replace"); ?><?php echo $current_filename; ?><?php echo __(") will be updated to point to the new file name.", "enable-media-replace"); ?></p>
59
-
60
- <input type="submit" class="button" value="<?php echo __("Upload", "enable-media-replace"); ?>" /> <a href="#" onclick="window.close();"><?php echo __("Cancel", "enable-media-replace"); ?></a>
61
-
62
- </form>
63
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/readme.txt DELETED
@@ -1,119 +0,0 @@
1
- === Enable Media Replace ===
2
- Contributors: mungobbq
3
- Tags: admin, attachment, media, files
4
- Requires at least: 2.8
5
- Tested up to: 3.2.1
6
- Stable tag: trunk
7
-
8
- Enables replacing attachment files by simply uploading a new file in the media library edit view.
9
-
10
- == Description ==
11
-
12
- This plugin allows you to replace a file in your media library by uploading a new file in its place. No more deleting, renaming and re-uploading files!
13
-
14
- #### A real timesaver
15
-
16
- Don't you find it tedious and complicated to have to first delete a file and then upload one with the exact same name every time you want to update an image or any uploaded file inside the WordPress media library?
17
-
18
- Well, no longer!
19
-
20
- Now you'll be able to replace any uploaded file from the media "edit" view, where it should be. Media replacement can be done in one of two ways:
21
-
22
- #### It's simple to replace a file
23
-
24
- 1. Just replace the file. This option requires you to upload a file of the same type as the one you are replacing. The name of the attachment will stay the same no matter what the file you upload is called.
25
- 1. Replace the file, use new file name and update all links. 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 will be updated to point to the new file name.
26
-
27
- This plugin is very powerful and a must-have for any larger sites built with WordPress.
28
-
29
- #### Display file modification time
30
-
31
- There is a shortcode available which picks up the file modification date and displays it in a post or a page. The code is:
32
- `[file_modified id=XX format=XXXX]` where the "id" is required and the "format" is optional and defaults to your current WordPress settings for date and time format.
33
-
34
- So `[file_modified id=870]` would display the last time the file with ID 870 was updated on your site. To get the ID for a file, check the URL when editing a file in the media library (see screenshot #3)
35
-
36
- If you want more control over the format used to display the time, you can use the format option, so `[file_modified id=870 format=Y-m-d]` would display the file modification date but not the time. The format string uses [standard PHP date() formatting tags](http://php.net/manual/en/function.date.php).
37
-
38
- == Changelog ==
39
-
40
- = 2.5.1 =
41
- * Bug fix - there is now a more reliable way of determining file type on your upload so you can upload PDF files without seeing that pesky "File type does not meet security guidelines" message.
42
- * New translation to Danish - thanks to Michael Bering Petersen!
43
-
44
- = 2.5 =
45
- * Tested with WordPress 3.2.1
46
- * New translation to German - thanks to Martin Lettner!
47
- * New translation to French - thanks to Fran�ois Collette!
48
-
49
- = 2.4.1 =
50
- * Bug fix for WordPress 3.1 RC. Now properly tested and should be working with 3.1 whenever it finally comes out. :)
51
-
52
- = 2.4 =
53
- * Bug fixes, security fixes. Thanks to my old pal Ulf "&Aring;rsta" H&auml;rnhammar for pointing them out!
54
- * New method for uploading avoids going around WP, for greater security.
55
-
56
- = 2.3 =
57
- * Lots of code trimmed and enhanced, thanks to Ben ter Stal! Now working properly with Windows systems, better security, optimized loading, and much more.
58
- * Added Dutch translation by Ben ter Stal.
59
-
60
- = 2.2 =
61
- * Bug fix, fixed typo in popup.php, thanks to Bill Dennen and others for pointing this out!
62
-
63
- = 2.1 =
64
- * New shortcode - display file modification date on your site (see description for more info)
65
- * A couple of bug fixes for final release of 3.0 - Thanks to Jim Isaacs for pointing them out!
66
-
67
- = 2.0.1 =
68
- * Added support for SSL admin
69
-
70
- = 2.0 =
71
- * Replaced popup with inline navigation when replacing media
72
- * Added instructions in admin link under Media
73
-
74
- = 1.4.1 =
75
- * Tested with WordPress 3.0 beta 2
76
-
77
- = 1.4 =
78
- * Removed short tags for better compatibility.
79
-
80
- = 1.3 =
81
- * Added support for wp_config setting "FORCE_SSL_ADMIN"
82
-
83
- = 1.2 =
84
- * Added Russian translation, thanks to [Fat Cower](http://www.fatcow.com)
85
-
86
- = 1.1 =
87
- * Minor bugfix, now working with IE8 too!
88
-
89
- = 1.0 =
90
- * First stable version of plugin.
91
-
92
- == Installation ==
93
-
94
- Quick and easy installation:
95
-
96
- 1. Upload the folder `enable-media-replace` to the `/wp-content/plugins/` directory
97
- 1. Activate the plugin through the 'Plugins' menu in WordPress
98
- 1. Done!
99
-
100
- == Frequently Asked Questions ==
101
-
102
- = What does this plugin actually do? =
103
-
104
- This plugin makes it easy to update/replace files that have been uploaded to the WordPress Media Library.
105
-
106
- = How does it work? =
107
-
108
- A new option will be available in the Edit Media view, called "Replace Media". This is where you can upload a new file to replace the old one.
109
-
110
- == Screenshots ==
111
-
112
- 1. The new link in the WordPress Edit Media view.
113
- 2. The upload window.
114
- 3. Get the file ID in the edit file URL
115
-
116
- == Wishlist / Coming attractons ==
117
-
118
- Do you have suggestions? Feel free to contact me at mans@mansjonasson.se
119
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/screenshot-1.png DELETED
Binary file
trunk/screenshot-2.png DELETED
Binary file
trunk/screenshot-3.png DELETED
Binary file
trunk/upload.php DELETED
@@ -1,142 +0,0 @@
1
- <?php
2
- if (!current_user_can('upload_files'))
3
- wp_die(__('You do not have permission to upload files.'));
4
-
5
- // Define DB table names
6
- global $wpdb;
7
- $table_name = $wpdb->prefix . "posts";
8
- $postmeta_table_name = $wpdb->prefix . "postmeta";
9
-
10
- // Get old guid and filetype from DB
11
- $sql = "SELECT guid, post_mime_type FROM $table_name WHERE ID = '" . (int) $_POST["ID"] . "'";
12
- list($current_filename, $current_filetype) = mysql_fetch_array(mysql_query($sql));
13
-
14
- // Massage a bunch of vars
15
- $current_guid = $current_filename;
16
- $current_filename = substr($current_filename, (strrpos($current_filename, "/") + 1));
17
-
18
- $current_file = get_attached_file((int) $_POST["ID"], true);
19
- $current_path = substr($current_file, 0, (strrpos($current_file, "/")));
20
- $current_file = str_replace("//", "/", $current_file);
21
- $current_filename = basename($current_file);
22
-
23
-
24
- $replace_type = $_POST["replace_type"];
25
- // We have two types: replace / replace_and_search
26
-
27
- if (is_uploaded_file($_FILES["userfile"]["tmp_name"])) {
28
- $new_filename = $_FILES["userfile"]["name"];
29
- $new_filesize = $_FILES["userfile"]["size"];
30
-
31
- // More reliable way of determining file type
32
- $new_filetype = mime_content_type($_FILES["userfile"]["tmp_name"]);
33
-
34
-
35
- // Check that mime type is allowed
36
- $allowed_mime_types = get_allowed_mime_types();
37
- if (!in_array($new_filetype, $allowed_mime_types)) {
38
- echo __("File type does not meet security guidelines. Try another.");
39
- exit;
40
- }
41
-
42
-
43
- if ($replace_type == "replace") {
44
- // Drop-in replace and we don't even care if you uploaded something that is the wrong file-type.
45
- // That's your own fault, because we warned you!
46
-
47
- // Delete old file
48
- unlink($current_file);
49
-
50
- // Delete old resized versions if this was an image
51
- $suffix = substr($current_file, (strlen($current_file)-4));
52
- $prefix = substr($current_file, 0, (strlen($current_file)-4));
53
- $imgAr = array(".png", ".gif", ".jpg");
54
- if (in_array($suffix, $imgAr)) {
55
- $mask = $prefix . "-*x*" . $suffix;
56
- array_map( "unlink", glob( $mask ) );
57
- }
58
-
59
- // Move new file to old location/name
60
- move_uploaded_file($_FILES["userfile"]["tmp_name"], $current_file);
61
-
62
- // Chmod new file to 644
63
- chmod($current_file, 0644);
64
-
65
- // Make thumb and/or update metadata
66
- wp_update_attachment_metadata( (int) $_POST["ID"], wp_generate_attachment_metadata( (int) $_POST["ID"], $current_file ) );
67
-
68
- }
69
-
70
- else {
71
- // Replace file, replace file name, update meta data, replace links pointing to old file name
72
-
73
- // Delete old file
74
- unlink($current_file);
75
-
76
- // Delete old resized versions if this was an image
77
- $suffix = substr($current_file, (strlen($current_file)-4));
78
- $prefix = substr($current_file, 0, (strlen($current_file)-4));
79
- $imgAr = array(".png", ".gif", ".jpg");
80
- if (in_array($suffix, $imgAr)) {
81
- $mask = $prefix . "-*x*" . $suffix;
82
- array_map( "unlink", glob( $mask ) );
83
- }
84
-
85
- // Massage new filename to adhere to WordPress standards
86
- $new_filename= wp_unique_filename( $current_path, $new_filename );
87
-
88
- // Move new file to old location, new name
89
- $new_file = $current_path . "/" . $new_filename;
90
- move_uploaded_file($_FILES["userfile"]["tmp_name"], $new_file);
91
-
92
- // Chmod new file to 644
93
- chmod($new_file, 0644);
94
-
95
- $new_filetitle = preg_replace('/\.[^.]+$/', '', basename($new_file));
96
- $new_guid = str_replace($current_filename, $new_filename, $current_guid);
97
-
98
- // Update database file name
99
- mysql_query("UPDATE $table_name SET post_title = '$new_filetitle', post_name = '$new_filetitle', guid = '$new_guid', post_mime_type = '$new_filetype' WHERE ID = '" . (int) $_POST["ID"] . "'");
100
-
101
- // Update the postmeta file name
102
-
103
- // Get old postmeta _wp_attached_file
104
- $sql = "SELECT meta_value FROM $postmeta_table_name WHERE meta_key = '_wp_attached_file' AND post_id = '" . (int) $_POST["ID"] . "'";
105
- $old_meta_name = mysql_result(mysql_query($sql),0);
106
-
107
- // Make new postmeta _wp_attached_file
108
- $new_meta_name = str_replace($current_filename, $new_filename, $old_meta_name);
109
- mysql_query("UPDATE $postmeta_table_name SET meta_value = '$new_meta_name' WHERE meta_key = '_wp_attached_file' AND post_id = '" . (int) $_POST["ID"] . "'");
110
-
111
- // Make thumb and/or update metadata
112
- wp_update_attachment_metadata( (int) $_POST["ID"], wp_generate_attachment_metadata( (int) $_POST["ID"], $new_file) );
113
-
114
- // Search-and-replace filename in post database
115
- $sql = "SELECT ID, post_content FROM $table_name WHERE post_content LIKE '%$current_guid%'";
116
- $rs = mysql_query($sql);
117
-
118
- while($rows = mysql_fetch_assoc($rs)) {
119
-
120
- // replace old guid with new guid
121
- $post_content = $rows["post_content"];
122
- $post_content = addslashes(str_replace($current_guid, $new_guid, $post_content));
123
-
124
- mysql_query("UPDATE $table_name SET post_content = '$post_content' WHERE ID = {$rows["ID"]}");
125
- }
126
-
127
- }
128
-
129
- $returnurl = get_bloginfo("wpurl") . "/wp-admin/upload.php?posted=3";
130
- } else {
131
- //TODO Better error handling when no file is selected.
132
- //For now just go back to media management
133
- $returnurl = get_bloginfo("wpurl") . "/wp-admin/upload.php";
134
- }
135
-
136
- if (FORCE_SSL_ADMIN) {
137
- $returnurl = str_replace("http:", "https:", $returnurl);
138
- }
139
-
140
- //save redirection
141
- wp_redirect($returnurl);
142
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
upload.php CHANGED
@@ -26,9 +26,16 @@ $replace_type = $_POST["replace_type"];
26
 
27
  if (is_uploaded_file($_FILES["userfile"]["tmp_name"])) {
28
  $new_filename = $_FILES["userfile"]["name"];
29
- $new_filetype = $_FILES["userfile"]["type"];
30
  $new_filesize = $_FILES["userfile"]["size"];
31
 
 
 
 
 
 
 
 
 
32
  // Check that mime type is allowed
33
  $allowed_mime_types = get_allowed_mime_types();
34
  if (!in_array($new_filetype, $allowed_mime_types)) {
26
 
27
  if (is_uploaded_file($_FILES["userfile"]["tmp_name"])) {
28
  $new_filename = $_FILES["userfile"]["name"];
 
29
  $new_filesize = $_FILES["userfile"]["size"];
30
 
31
+ if (function_exists("mime_content_type")) {
32
+ // More reliable way of determining file type
33
+ $new_filetype = mime_content_type($_FILES["userfile"]["tmp_name"]);
34
+ }
35
+ else {
36
+ $new_filetype = $_FILES['userfile']['type'];
37
+ }
38
+
39
  // Check that mime type is allowed
40
  $allowed_mime_types = get_allowed_mime_types();
41
  if (!in_array($new_filetype, $allowed_mime_types)) {