Here is a funny plugin. All it does is actually give you the opportunity of adding a small widget on the sidebar to display the latest LolCat from ICanHasCheezburger. If you don’t already know what a lolcat is then please visit their about page. Also, the Wikipedia article is very enlightening. Now to the point.
This simple plugin retreives the latest lolcat and displays it on a widget. It caches it for two hours so it won’t slow up the process of loading each time.
You need to make sure of two things:
- You have GD library with jpeg support installed.
- The folder within lolcats_widget (the plugin’s folder) called “cheezes” is writable by the webserver.
Download the plugin from here: Lolcats Widget (2379) - 9.2 KB. In there you will find the folder lolcats_widget. Just copy the whole folder in your plugins directory. Go to your administration and activate the plugin. Finaly, place the widget where you want it on the sidebar.
Because i don’t know wether this plugin will be even remotely usefull to anyone i didn’t bother creating any settings page or settings on the widget setup. If i see it is indeed usefull i’ll go on and do it (why don’t you drop a comment on the post “voting” for further development). For now, you can tweak it from within the code (no, do not worry, i’ll show you where and what). Just open the file “lolcats_widget/lolcats_widget.php” with your favorite text editor (i recommend notepad++) and go ahead…
Changing some settings
When you open it, please notice this area (from line 14 to 19):
//two hours caching before bringing in the new one
‘/lolcats_widget/cheezes/latest.jpeg’;//path to save image
‘/lolcats_widget/cheezes/link.txt’;//path to save image
//200px default width for image
//add an _blank to the lolcats page or not
Now, as you can see some of the “behavioral” settings are defined here. Change them as you need. For instance if you want the cache to timeout earlier than two hours change the “$cache_timeout” to how many seconds you want. Or, if you want the cache directory to be something else rather than the “cheezes” one change it on the next two lines (for instance “/tmp”). The “final_image_width” is actually the width that the lolcat will have after it is resized. Finaly, “use_blank” is a boolean that indicates whether the lolcats page should open on a new window (_blank) or not. Change it according to your theme.
Tweaking the output
Well if you are a bit more adventurus you can fix the output of the widget anyway you want it. It’s a fairly small plugin but i’ll still guide you guys through this just for those that are not as comfortable. Notice lines 63-72.
span class=”st0″>’s Latest!<?php echo $after_title;?>
<?php echo $link;?>
<img alt="lolcats" src="<?php bloginfo(‘url‘);?>/wp-content/plugins/lolcats_widget/cheezes/latest.jpeg"><br>
This actually is the function that renders the small widget. So let’s say you want to add something after the image. You can write any HTML after line 69. If you want to add it before then shoot between 68 and 69. Pretty easy. And if you still feel uncomfortable just let me know with a simple comment and i’ll get to work to add a small options page.
- 1.0 -> 1.0.1
- Added the “use_blank” feature.