A Template for your Functionality Plugin

WordPress code

I think I’ve made some good progress in trying to get people to convert from using their theme’s functions.php file for placing their code snippets to putting them in a unique functionality plugin.

There’s many good reasons for doing this, but high up on the list is portability (keep your snippets when you change themes, or sites) and retaining your code snippets if you ever need to upgrade your theme. If you want to read more, check out create a functionality plugin.

Well, if you want to go ahead and use a functionality plugin, but are scared about the code behind it, I’ve put a template together to make things exceptionally easy.

Install the plugin

All you need to do is download this plugin that I’ve put together and upload it to your site by going to Plugins > Add New > Upload. Once you’ve uploaded it, activate it (it will be called Functionality Plugin for SITENAME in your plugin list).

Personalise it for your site

Obviously, the plugin needs to be unique for your site, so you’ll need to customise it now. Go to Plugins > Editor and select Functionality Plugin for SITENAME.

Once you pull up the editor, you’ll see the header information already in place. All you’ll want to do is change SITENAME to your actual site name so that it’s clear what site it is for.

Then you’ll see a simple template for putting your snippets into. The way I like to do it, so that things are well organized and easy to sort through, is to put several line spaces between titles and snippets.

Keep your snippet titles capitalised so that they stand out when scrolling through the file. Remember, that since this is a PHP file, you must keep the titles commented (in between sets of //).

Also, if you ever want to disable a snippet, don’t delete it – change the title to include (DISABLED) and then comment out the snippet by putting /* before the snippet and */ after the snippet, as shown by example in the second snippet space in the template.

Does this help? Are you now more likely to use a functionality plugin? Help to spread the word!

Download the functionality plugin template

3 thoughts on “A Template for your Functionality Plugin”

  1. Obaidul says:

    You raise a great point, Dave. It becomes really difficult to gather all those inserted codes when we decide to re-design a blog or upload a new theme. I believe the functionality plugin that you’re talking about can quickly remove our headaches.

    And the best part about it is that you can easily tailor the plugin to your specific requirements, as your site demands.

    Thanks for the useful share.

  2. Carrie Dils says:

    That makes a lot of sense. A single misplaced semi-colon in functions.php can kill your site, so seems like another benefit to your plugin is that you can quickly correct syntax errors (or whatever errors) without having to scramble to FTP a fresh functions.php file to the server. :)

    Nicely done.

    1. A very fair point! All the more reason to leave functions.php alone

Leave a Reply