davidgagne.net

  • About
  • Archives
  • Twitter
  • Facebook
  • bartender.live
  • GitHub
  • LinkedIn

Disable WordPress File Upload

September 29th, 2006 @ 4:05 pm PDT
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.

More posts tagged:
code / hacks / plugins / wordpress

More posts categorized:
blogtech Programming

More posts from:
September 2006 / 2006

Post navigation

Previous Post
Previous Post Goodbye in Gasoline
Next Post
Next Post Studio 60 on the Sunset Strip

One Response to “Disable WordPress File Upload”

  1. October 25th, 2006 @ 8:39 pm
    Eduardo

    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

Comments Closed

New comments are disabled on this post.

Search


Give Easily

Give Easily

Did you know that Amazon will donate to the charity of your choice when you use smile.amazon.com to do your online shopping? It doesn't cost you anything extra, and you can make a big difference just by using this link.

  • Support A Charity

© David Vincent Gagne. All rights reserved. Custom WordPress Theme by Jacket Industries.