WordPress Widgets
A place for widgets
Since I do most of my blog template editing by hand I wasn’t sure how much I’d use widgets, but I’ve seen some with some decent functionality, so I may rethink that. I was especially hesitant because I didn’t want to lose all the custom content I’d placed in the sidebar, but when I discovered that you can simply include the dynamic widgets within your existing sidebar content I was relieved of that concern. To do so take just a minor modification to the code that Matt placed on Automattic:
<?php if ( !function_exists('dynamic_sidebar')
|| !dynamic_sidebar() ) ?>
In fact, the modification was literally removing 1 character, the “:” portion of the “if” structure; in Matt’s code if there was no dynamic_sidebar function or no dynamic sidebars to display then the normal sidebar would display, but otherwise the dynamic sidebars would display. My modification basically has WordPress try to display the dynamic sidebar, failing gracefully if the widget plugin is not present. Not a modification I’d suggest for out of the box themes or for WP users who are not comfortable with editing sidebar.php files, since you could easily end up with some funky results, and users who want to use just the Widgets plugin to manage their sidebars will rapidly become frustrated. However, if you have content you want in your sidebar that’s not available in a widget yet, but still want to use widgets, this works a charm.
First widget: gapingvoid for WordPress
My first widget, and what inspired me to get into the explorations above after a lot of procrastinating, is a WordPress widget to emulate the gapingvoid widget that Hugh MacLeod and Paul Farnell have published. It mimics the options that the gapingvoid widget script page offers and generates a sidebar-friendly
<li>
<div>
<script />
</div>
</li>
structure.
Installation is easy. Download the widget (zip or code) and upload it to your widgets plugin folder. Activate the widget (and the Widgets plugin, if it’s not already) and configure the widget (some modifications to pre-widget plugin themes may be required).
Comments are welcome below.


