[wp-hackers] a plugin of a theme's own

Andy Skelton skeltoac at gmail.com
Tue Sep 20 15:40:36 GMT 2005


Methinks this discussion has become a kind of new-feature-bash. Has
anyone here used a theme with a functions.php or tried writing one?
I'll share my experiences for the benefit of those who have none.

I'm working on an improvement for the default theme, Kubrick. It takes
advantage of the new add_theme_page function to give me this options
page:
http://www.andyskelton.com/picture_library/kubrick_options.png

This functionality is created in functions.php, but it could also have
been done with a plugin. Let's weigh the two options here:
functions.php:
* automatically activated and deactivated when the theme is changed
* saves conditional statements because the theme author KNOWS it's activated
* the user doesn't have to think about matching plugins to themes
* the user doesn't even need access to the Plugins page (N.B. MU users)

File in plugin dir:
* must be activated and deactivated when the theme is changed
* vestigial admin panels appear when users forget to deactivate the
theme's plugin
* theme must call all functions conditionally because the plugin might
be off or missing
* Aunt Bessie is confused because she has to copy more files and
activate some thingy
* plugins are not always accessible (e.g. wordpress.com users) so the
theme would not be very portable
* theme author must include special instructions for installation and switching
* is this supposed to make life easier for somebody?

You can tell I'm in favor of functions.php support. Why anyone would
try to stop it is a huge mystery to me.

On 9/20/05, David Chait <davebytes at comcast.net> wrote:
> If it makes it conceptually easier for people, why not have a
> [theme]/plugins/ optional subfolder?  If there are files there, treat them
> as 'second pass' plugins during the plugin-load process.  I think that's the
> proper 'container' direction (aside from moving to an actual container, i.e.
> zipped format of some sort...).  And it makes more sense than some file
> named 'functions.php' in the theme folder (there's already a ton of php
> files).  People would understand a folder named 'plugins', I'd think!

David, functions.php is not a plugin. It is a file that contains
functions that the theme author can use in the theme and/or in admin
panels. It helps one separate logic and presentation. It is not meant
to supplant use of plugins such as Gravatars, support for which can be
included safely in any theme by using conditional function calls.

Andy


More information about the wp-hackers mailing list