WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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 Dec 22 '14 at 20:30
    
Confirmed to work in Wordpress 4.1 as well! – Joel Purra Jan 14 '15 at 13:46
    
This, in wp-config.php. I really don't understand why it isn't the default, at least for administrators. – Guntram Blohm Jun 2 at 20:19
    
@GuntramBlohm - It shouldn't be the default. I have an SSO that makes sure that no one outside of our company has the ability to load files. I can't imagine turning it on on some of the "normal" sites I admin. Basically a hacker could use any loophole to download anything to your site. That would be a mess. Also make your own plugin so you can keep track of things easier - changing the wp-config is just a lot of work and then you have to update it on every WP update. Too messy. – STing Jun 3 at 4:07
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

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.