I’ve been writing WordPress themes and plugins for about a decade and recently I’ve been putting more effort into curating a personal “boilerplate” folder for new themes and plugins. In reading through it, I can see what concepts and components have become habitual for me, regardless of the subject matter of the project.

  • Some `Constant` Companions

    I declare the following constants:

    The purpose of this block is to introduce some basic data about our project, into the global scope, in a concise convenient way, that cannot be altered.

  • Include Font Awesome

    It’s pretty much a given that any project will involve icons, and I prefer FontAwesome:

    https://gist.github.com/scofennell/463d6fef2eb10a296cd758d96ce82ad6

  • The State of States

    A huge part of my boilerplate is just providing a wide platform for presenting and handling form inputs. It seems a little odd, but I’ve not come up with a better strategy than to just include this in every project:

    God help me if a state ever secedes!

  • Very Classy

    I set up (php) classes to add (css) classes to both the body tag, and each post:

    This fits in well with my high regard for SMACSS.

  • Staying Up To Date with Updates

    I dislike the normal hook system for performing action on theme and plugin activation, so I instead have some code that executes everytime the version number increases (which it does upon first install):

    Because this adds an extra query, I only have this running for projects that register things in the database such as roles, or other various high-value routines like rewrites.

  • Agoification

    Human time diffs can be annoying, especially if you care about time zones. I don’t regret having this available in every project:

There are quite a few other things common to all of my new projects, but this is a good cross-section. I wish I was better about really capturing every lesson from every new project, but in reality I’m happy if I remember to curate just one. Over time it’s become a valuable library and it also inspires me to push the quality of my code on each project, in the hope that something does emerge as boilerplate worthy.