Smarter handling of WordPress plugin uploads Google

Smarter handling of WordPress plugin uploads

While preparing my previous post on new features in WordPress 2.9, I ran across a ticket in Trac for something I’d been wanting to do for a while: specify a subfolder of the uploads directory for specific plugins, like my Blog Icons plugin, to upload their files to. This way, the blog icons plugin would upload its files to /uploads/blog-icons/, which is a lot better for everyone.

Aaron Campbell and Denis de Bernardy, both well respected WordPress developers come to a surprisingly simple way of doing that without core needing any patching. To use it, you only have to change the prefix of the function and the sub dir to use:

add_filter('upload_dir', 'my_upload_dir');
$upload = wp_upload_dir();
remove_filter('upload_dir', 'my_upload_dir');
 
funcion my_upload_dir($upload) {
	$upload['subdir']	= '/sub-dir-to-use' . $upload['subdir'];
	$upload['path']		= $upload['basedir'] . $upload['subdir'];
	$upload['url']		= $upload['baseurl'] . $upload['subdir'];
	return $upload;
}

Smarter handling of WordPress plugin uploads is a post from Joost de Valk's Yoast – Tweaking Websites.A good WordPress blog needs good hosting, you don’t want your blog to be slow, or, even worse, down, do you? Check out my thoughts on WordPress hosting!

 Smarter handling of WordPress plugin uploads

Smarter handling of WordPress plugin uploads

SOURCE : http://feeds.feedburner.com/joostdevalk?format=xml

FOR MORE INFORMATION PLEASE VISITE AUTHOR WEBSITE

Popularity: unranked [?]

Related posts

Post A Comment