Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using Wordpress 3.4.2 for a private blog, i.e. one on which only I can post. Now, Wordpress prevents me from uploading certain file types (like C# source files). As far as I understand it, there's a white-list that defines what can be uploaded.

Is there a plugin that can extend - or better, even disable - this white-list?

All other answers tell me I should edit my theme but I'd rather have a plugin for that (so that I don't need to edit all my themes).

Also, I found this plugin but, again, it requires me to edit some file on my server (that's probably overwritten when the plugin is updated).

So, is there anything else?

share|improve this question

3 Answers 3

You can create a plugin or add this to the config file, but for 3.9.2 this worked for me.

define('ALLOW_UNFILTERED_UPLOADS', true);
share|improve this answer
    
This is the Core way of doing it. +1 –  Patrik Alienus 7 hours ago
up vote 1 down vote accepted

Unfortunately, toscho's answer doesn't work - at least not in Wordpress 3.4 and above.

The correct solution is the following:

#
# For this, see: wp-includes/capabilities.php > map_meta_cap()
#
function wpse_6533_map_unrestricted_upload_filter($caps, $cap) {
  if ($cap == 'unfiltered_upload') {
    $caps = array();
    $caps[] = $cap;
  }

  return $caps;
}

add_filter('map_meta_cap', 'wpse_6533_map_unrestricted_upload_filter', 0, 2);
share|improve this answer

Filter 'user_has_cap' and set 'unfiltered_upload' to 1.

Sample code not tested:

/*
Plugin Name: Remove Uploads Filter
Plugin URI: http://wordpress.stackexchange.com/questions/67225/allow-all-file-types-for-upload
Description: Disables white-list filter for uploads
Version: 1.0
Author: WPSE - @toscho
*/

add_filter( 'user_has_cap', 'wpse_67225_unfiltered_upload' );

function wpse_67225_unfiltered_upload( $caps )
{
    $caps['unfiltered_upload'] = 1;
    return $caps;
}
share|improve this answer
    
Thanks for the code snippet, but it's not a plugin. I was specifically asking for a plugin. –  Sebastian Krysmanski Oct 5 '12 at 11:16
    
You can easily make that a plug-in... –  Joseph Oct 5 '12 at 12:10
    
@SebastianKrysmanski This is a plugin. Just add the common plugin header and save it as a separate file in your plugin directory. Plain plugin recommendation questions are off topic here, we deal with code solutions only. :) –  toscho Oct 6 '12 at 13:22
2  
Boom. Now it's a plugin. lol –  Brian Fegter Oct 7 '12 at 1:51
    
Awesome. Thanks. –  Sebastian Krysmanski Oct 8 '12 at 7:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.