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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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);
Method 2
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;
}
Method 3
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);
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0