Simple WordPress plugin (include-file)

I may have created one of the simplest possible plugins for WordPress. I also have no doubt that this has probably been created before my multiple other people, but it was easier to create than evaluate the existing options out there. If you just want to download the plugin click here.

This plugin includes the contents of a file from a URL or path into a WordPress page or post using a shortcode. It would look like this in your post:

[include_file url='http://example.org/somefile.txt']

I’ve posted the source code below as it might serve as a good template to someone who wants to create their own plugin.

<?php
/*
Plugin Name: include-file
Plugin URI: http://wordpress.org/extend/plugins/include-file/
Description: Includes the contents of a file at a given url in a post.
Version: 1
Author: Tyler Stafford <tyler.stafford@gmail.com>
Author URI: http://tylerstafford.net
*/

function tsIncludeFile($atts,$content=null,$code="") {
	$content = file_get_contents($atts['url']); 
	if ($content == true) {
		return $content;
	} else {
		return "An error occured retreiving " . $atts['url'];
	}
	return $atts['url'];
}

add_shortcode('include_file','tsIncludeFile');
?>