Have you ever heard of a functionality plugin?
I stumbled onto this WordPress magic a few years ago and has served me well on many different web projects.
To put it simply, a functionality plugin is a way to separate what you would normally have in a Theme functions.php and place it in your Plugins. All those cool snippets that begin with “function” can be placed here.
Here is my general rule in deciding if a function should be placed in a functionality plugin or in the theme’s functions.php:
Is the function theme exclusive?
So, if you wan to use a temporary maintenance function (a real crowd favorite), you would want to create a functionality plugin for this. This is not theme specific and you would more than likely want this no matter what theme you’re using. In the case of a maintenance mode, it can be much easier to enable, as there’s no code to change–simply enable or disable it in your Plugins as needed.
If you’re creating a custom image size that’s theme specific, you won’t want this as a functionality plugin. Since it’s theme specific, you’ll want to keep this tucked away in your theme’s functions.php.
Admin modifications? No brainer. This belongs in a functionality plugin.
Custom post types? I think this is personal taste, as you usually have to make some theme edits when handling these. My personal preference is the functionality plugin, as I want my custom post types to carry over from theme to theme.
Organize these in a way that makes sense. If there are a standard set of functions you like to have on every site you’re building, you can create your own functionality plugin and add it to each project your working on. You can also keep a generic functionality plugin that you add all your snippets to that are not theme specific. Finally, in the case of the temporary maintenance mode, you will want to keep these types of functions all to themselves.
How-To Build Your Functionality Plugin
I must warn you that if you’ve never built a plugin before, you’re going to feel awesome after you create your own functionality plugin.
Here’s how to do it:
Create a folder and name it whatever you want, but make sure it doesn’t interfere with any of your plugins. The more personal you make it, the less likely that will happen.
Open your favorite code or text editor and create a new php file and drop this in:
/* Plugin Name: Your Site's Functionality Plugin Description: All of the important functionality of your site belongs in this. Version: 0.1 License: GPL Author: Your Name Author URI: yoururl */
Now, add what you would normally place in your functions.php.
Save it in your new folder and name it appropriately.
FTP your fancy new functionality plugin to your wp-content/plugins directory. Open your WordPress admin and take a look in your Plugins.
Now simply enable it when you’re ready. If your code is bad or you need to undo your change, simply disable the plugin and make your changes.