Extending WordPress: widgets, plugins or functions.php ?
- Date
- August 22nd, 2011
- Category
- Development
- Tags
- wordpress
- Discussion
- Leave a comment
As a developer using wordpress for all sorts of needs, you’ll be often faced with this question: should a particular functionality be implemented as an external plugin, as a function inside your theme’s functions.php or as a widget?
In my experience, the proper answer depends on the following aspects:
- should the functionality be available sitewide or only on specific parts of the website OR will it be a permanent feature of the website during its lifetime? If the answer is “yes”, you should definitely consider adding the functionality to functions.php
- should it be actionable by the website content manager, meaning: by the people who act on the WordPress installation as “Editor”? In such case, you should make it available via the WP-admin interface to the Editor, as a Widget
- should it be actionable by the website system administrator, meaning: by the people who act on the WordPress installation as “Administrator”? In this latter case, you should make it available on the WP-admin to the Administrator, either as a Widget or as a Plugin that can be desactivated.
- Layoutwise, should the functionality frontend display move around the frontend interface? That’s definitely something Widgets are designed for, so go for Widgets.
This short post was meant to clarify a frequent and important question in WordPress development. Note that WordPress is as flexible as a Eastern Europe athlete, so it’s more of a general rule but everything is pretty much possible. For instance, some plugins provide Widgets to give more control to the WP-admin users, WP roles can be tweaked so that Editors, or even Authors can have access to the plugin control interface, etc.