Chapter 7: The Anatomy of a WordPress Plugin

It goes without saying that plugins are different from themes, but they have a lot in common. You could say that when you’re adding functionality to your theme by adding code to the functions.php template file, you’re actually writing a plugin.

But there is a huge difference. Themes are there to display the WordPress site, using the tools available. Plugins, on the other hand, are used when you need to extend the WordPress functionality with additional features. You should remember that because bloating your theme’s functions.php with features isn’t always the best way to go.

In this chapter, you’ll look at plugins from a slightly different standpoint than you did in the themes chapters. The reason for this is simple: Your plugin can do anything. It is basically a way for you to add whatever functionality you want; compare that to doing funky stuff with a select few template tags, and you see the difference.

With plugins, it is not a matter of what you can do, it is more a question of why you would want to do it.

Different Types of Plugins

There are three primary types of plugins: regular plugins, which you’ve no doubt used a number of times; drop-in plugins, which are used to replace core functionality; and must-use plugins.

Regular Plugins

By regular plugins, I mean plugins that you are used to. These are the ones you download, install, activate, and just start using. Akismet (http://wordpress.org/extend/plugins/akismet) is what ...

Get Smashing WordPress: Beyond the Blog, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.