Make WordPress Core

Opened 17 years ago

Closed 17 years ago

#4615 closed defect (bug) (fixed)

Allow more open document formats

Reported by: nbachiyski's profile nbachiyski Owned by:
Milestone: 2.3 Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch commit
Focuses: Cc:

Description

We should allow the upload of more OD formats, not only ODT.

Below is a patch for presentation, spreadsheet, graphics, chart, database and formula.

Attachments (1)

opendocuments-upload.diff (1.2 KB) - added by nbachiyski 17 years ago.

Download all attachments as: .zip

Change History (11)

#1 @JeremyVisser
17 years ago

  • Milestone set to 2.3 (trunk)

+101. Desparately need to allow use of more open formats without hassle.

#2 @Nazgul
17 years ago

Attached patch won't work. There is an unneeded , after the last array entry.

I'm also not sure about the #. Is that a valid comment indicator in PHP?

#3 @Nazgul
17 years ago

  • Type changed from defect to enhancement

#4 @JeremyVisser
17 years ago

  • Type changed from enhancement to defect

Actually, the comma at the end is okay. Quoted from the PHP manual on arrays:

Having a trailing comma after the last defined array entry, while unusual, is a valid syntax.

And, yes, a # is a valid comment indicator, but for consistency with the rest of the WP code, you should change it to .

#5 @nbachiyski
17 years ago

You are right, about the #: too many perl/python :-)

I usually put а comma after the last element of long arrays, because it is easier to add new lines. You don't have to look where the last element is and add a comma after it. So I stick to it :-)

#6 follow-up: @Otto42
17 years ago

I suggest moving wp_check_filetype() into pluggable.php entirely and wrapping it with an if ( !function_exists('wp_check_filetype') ) test entirely.

Why? Well..

While adding new filetypes can be done through a filter, it's somewhat annoying to have to have a plugin or hack the core or mess with your theme just to modify your allowed filetypes.

Also, the current method of having it check by extension is kind of annoying to begin with. It would be nice if we could check by the file content using fileinfo or something (if you have that PECL extension) or looking it up in /etc/mime.types (via mime_content_type() ) or some other way that I cannot describe. Making it pluggable would allow a plugin to replace that function entirely instead of just adding types.

So while I give a +1 to adding more formats, this patch doesn't go far enough, IMO. The entire function should be made pluggable.

#7 in reply to: ↑ 6 ; follow-up: @westi
17 years ago

Replying to Otto42:

I suggest moving wp_check_filetype() into pluggable.php entirely and wrapping it with an if ( !function_exists('wp_check_filetype') ) test entirely.

Why? Well..

While adding new filetypes can be done through a filter, it's somewhat annoying to have to have a plugin or hack the core or mess with your theme just to modify your allowed filetypes.

I don't think this is something to move to pluggable.php. It is quite feasible that multiple plugins may want to extend the list of available mime types when extending WordPress and using pluggable.php means that the first one wins.

Adding new filetypes is easy - you only need to install a plugin that provides a UI for you to do this and you are done - http://blog.ftwr.co.uk/wordpress/mime-config/

#8 in reply to: ↑ 7 @Otto42
17 years ago

Replying to westi:

I don't think this is something to move to pluggable.php. It is quite feasible that multiple plugins may want to extend the list of available mime types when extending WordPress and using pluggable.php means that the first one wins.

Adding new filetypes is easy - you only need to install a plugin that provides a UI for you to do this and you are done - http://blog.ftwr.co.uk/wordpress/mime-config/

Adding new filetypes is indeed easy, but changing the way that it detects filetypes in the first place is not. What if I don't want to use the extension only? What if I want to use the "magic" methods to detect the type of file? This should be pluggable so that plugins can change the entire method, not just add new filetypes.

Leave the filter in there as it is, and then plugins can continue to add mime types that way, but if a plugin wants to change the whole thing, then it will be able to do so if the function is pluggable.

#9 @nbachiyski
17 years ago

  • Keywords has-patch commit added

#10 @westi
17 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [5929]) Allow upload of all Open Office document types props nbachiyski fixes #4615

Note: See TracTickets for help on using tickets.