Disable WordPress File Upload

Friday, September 29, 2006

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.

{ 1 comment… read it below or add one }

1 Eduardo 10.25.06 at 8:39 pm

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

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>