Digg Comments? Thumbs down. Paul on Web 2.0
Nov 15

Plugin Architecture: Simple, but watch out

Tech Add comments

I have been working with Wordpress and a bunch of plugins (there are more plugins than I have had hot dinners).

It is great that you have so much out there to plugin and play, but when you actually start using some of these plugins you see a lot of abuse by the plugin writers :)

Plugin Architecture

The plugin architecture in Wordpress is amazingly simple. You throw a single php file, or a directory, in the plugins directory.

The only other thing you need to do is put some comments in the file. These are read from the plugin admin interface.

Now, it is truly great how simple this is. Anyone can write a plugin!

The problem is that… anyone can write a plugin! :)


Since the plugin API is so loose, there isn’t a specific hook to enable/disable a plugin.

In a couple of plugins that I was using, I found that the setup code was running on EVERY REQUEST.

That’s right. Every page load caused “DESC sometable” to work out if an “ALTER TABLE” needs to run.

This doesn’t have to be the case of course. You can check for $_GET["activate"] explicitly (which gets passed in the plugin activation page) and just do the setup/destroy code there.

It would be nice if Wordpress had a nicer hook than this of course.

For most things you can hook into actions and filters via add_action('action_name', 'func_name'), so maybe there will be one for plugin activation.

Leave a Reply

Spam is a pain, I am sorry to have to do this to you, but can you answer the question below?

Q: What is the number before 3? (just put in the digit)