Long awaited feature which I missed since my move to WordPress from Joomla now materialized. I’m talking about Widgets. The comfort of moving around, positioning and enabling/disabling items on your sidebar(s) through admin side is the most useful feature of any good CMS. And I was sure that it is just a matter of time for this feature implementation in WordPress.
I expected this in WordPress as a core functionality feature, but it came as a plugin. Good news is that â€œIf adoption goes well, weâ€™ll consider rolling it into the next version of WordPress.â€ Letâ€™s look closer at widgets.
The real power and advantages of this useful WordPress add-on can be seen if you compare it. In Joomla this feature implementation is simple but not as flexible as in WordPress Widgets plugin. From the template side all you need is to place the function call, something like “LoadModules ()â€, where you want your modules to appear on a page. And there is an admin page where you have a list of all available modules with control buttons including enabling/disabling, changing position and saving changes. Changing modules position can be done only incrementally by pressing on up/down arrows. Each move requires page reloading.
Another very pleasant feature is automatic switch between dynamic (or widgetized) sidebar and old fashioned static. Static sidebar presents all items and code as they were before, without widget plugin. All you need is to drag out all widgets from dynamic sidebar box and this automatically triggers static sidebar.
Standard sidebar items like Archives, Links, Categories etc., are available by default. If you have some third party plugins/items on your sidebar then you may need to widgetize them. This is simple. All you need to do is to put two pieces of code inside functions.php file, which is located in theme folder. BTW, Widget plugin download page doesn’t say anything about updates or changes, but as I understand, they make some adjustments to the code. So if you had problems with Widget plugin, try downloading fresh zip.
I’m putting aside the procedure of enabling widgets and widgetizing your theme – this is explained in detail here.
Here is how I widgetized the call to my LazyestThumbsSlideshow plugin:
This is new widget function which I put inside functions.php (or widgets.php) file:
This is widget registration call which is required. Also goes in Functions.php file.
This method is not mentioned in widget plugin manual, but I found it easier. You just wrap the call to your plugin's function inside standard widget function, then put it in functions.php or widgets.php file and register it by calling register_sidebar_widget function. This means nothing changed in your Plugin including admin page for that plugin, but now you can move it around on a sidebar as all other widgets. The same trick worked with LiveShoutbox plugin (you can see it on my home page sidebar).
Developers describe the procedure of coding standalone widget and provide example widgets, well commented , so that coding new widget or redesigning existing is not difficult. I even did this with my plugin. But this requires redesign of plugin's internal structure. You can also add control panel to your widget to tune parameters there. The bad thing is that plugin will not be available without widget plugin, on which it depends.