If you’ve ever built a plugin for WordPress, the chances are that you took a while to get the initial code base setup with the necessary plugin headers, class structure and basic instantiations. If you have built more than one plugin then there’s an even better chance that you copied that same code and reused it to start each subsequent one. But what if you had all of that code written before you even start? Wouldn’t that be great? That’s where starter plugins come in.
What is a starter plugin?
A starter plugin (also known as a boilerplate plugin, or a plugin template) is a framework rather than an actual plugin. It is designed to be a code framework that you can use to get started with a new plugin quickly and easily. There are a number of starter plugins available for you to use (more on that in a moment) and some of them come with useful scripts that help you generate a brand new plugin with your own plugin name so you can get going with your unique functionality in no time.
Using a starter plugin is in line with the DRY (don’t repeat yourself) development methodology – the idea is to eliminate the need to reproduce the same code many times over.
Why should I use a starter plugin?
Starter plugins enable you to get going with a new plugin quickly and easily without spending ages writing the same code over and over again. In that case, perhaps a better question is rather “Why shouldn’t I use a starter plugin?” The main concern with using a starter plugin is that you will be duplicating someone else’s code and you may not have a firm grasp of how it works exactly. Luckily for you, we’ve compiled a short list below of some of the better starter plugins available that are well written and reliable – if you select one to use regularly then you will quickly get to know the code structure and how to use it most effectively.
Where can I find starter plugins?
There are many starter plugins available for your use, but after doing some research of our own we can highly recommend these three solid and functional examples:
- Starter Plugin by our very own Matty Cohen – lean, mean and ready to go.
- WordPress Plugin Template by Hugh Lashbrooke (that’s me!) – includes a few built-in APIs for common functions.
- WordPress Plugin Boilerplate by Tom McFarlin – clear, consistent and organised.
There are a number of others out there of course, so if one of these doesn’t quite work for your coding style I’m sure you can find one that does. Some of these plugins come with scripts that enable you to duplicate the code and rename all the necessary strings in a few seconds, while others will require you to copy the files and rename everything yourself – either way, it’s a far sight quicker than writing everything from scratch every time you start a new plugin.