Disable WordPress File Upload

Although I can appreciate that it’s a really nifty feature, I am likely never going to use the built-in File Upload feature in WordPress. What has bugged me is that it’s in an IFRAME in the Write Post panel; I think it slows the page load. I was trying to get rid of it, but the best I could find was the Clutter Free plugin from Tempus Fugit. It’s a great plugin, but unfortunately it doesn’t really remove the IFRAME, it just hides it.

So. I dug around in the code and did it myself. If you aren’t the file-uploadin’ type, you only need to change a few lines to prevent the File Upload widget from appearing on your Write Post panel. Open wp-admin/edit-form-advanced.php and look for the line containing $uploading_iframe_ID. It’s near or around line 223. There are a few different ways you can handle removing this.

Here is the original code …

<?php
if (current_user_can('upload_files')) {
	$uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
	$uploading_iframe_src = wp_nonce_url("inline-uploading.php?action=view&post=$uploading_iframe_ID", 'inlineuploading');
	$uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
	if ( false != $uploading_iframe_src )
		echo '<iframe id="uploading" border="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
}
?>

The first option we have is to simply change the “If” statement to something that will never be true:

<?php
#if (current_user_can('upload_files')) {
if (1 == 2) {
	$uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
	$uploading_iframe_src = wp_nonce_url("inline-uploading.php?action=view&post=$uploading_iframe_ID", 'inlineuploading');
	$uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
	if ( false != $uploading_iframe_src )
		echo '<iframe id="uploading" border="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
}
?>

Another option is to just code comment the entire block of code:

<?php
/*
if (current_user_can('upload_files')) {
	$uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
	$uploading_iframe_src = wp_nonce_url("inline-uploading.php?action=view&post=$uploading_iframe_ID", 'inlineuploading');
	$uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
	if ( false != $uploading_iframe_src )
		echo '<iframe id="uploading" border="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
}
*/
?>

There are a couple of other things you could do, of course, but these are the two easiest. Since I am the admin of my site / blog, I’ve got no way — that I could find — to remove my own file upload permission. Note that these changes will most likely get killed when you upgrade to the next version of WordPress.


There is one comment on this post

  1. I’m playing around with wp, that’s other way to remove File Upload:

    add_filter( ‘uploading_iframe_src’, ‘wp_lojavirtual_admin_removeupload’);

    function wp_lojavirtual_admin_removeupload($content) { return “”; }

    see ya

Add to the discussion:

I'll never share your email address and it won't be published.

What Is This?

davidgagne.net is the personal weblog of me, David Vincent Gagne. I've been publishing here since 1999, which makes this one of the oldest continuously-updated websites on the Internet.

bartender.live

A few years ago I was trying to determine what cocktails I could make with the alcohol I had at home. I searched the App Store but couldn't find an app that would let me do that, so I built one.

Hemingway

You can read dozens of essays and articles and find hundreds of links to other sites with stories and information about Ernest Hemingway in The Hemingway Collection.