TL;DR: I’m going to be working on a series that looks how to achieve a useful task with taxonomies, likely categories, then refector it into an object-oriented plugin that will serve as a utility plugin for taxonomies, in general.
A Brief History of OOP Posts
Some time ago, I did a lengthy series about the principles of object-oriented programming (and tried to share an amount as to how to achieve certain things within the context of WordPress).
I’ve also written a bunch of articles about the whole paradigm over the years for those who are interested in catching up on some of those articles.
And thus, as I’ve been thinking about various topics to write about (after taking an admittedly longer period time off than I planned), though that it might be worth talking about practical things we can do with normal APIs and hooks and then refactor that into a type of utility plugin.
TL;DR: Don’t avoid writing a kludge of code when the situation necessitates it. Sometimes, factors outside of our control dictate how quickly we can turn a solution around. At the minimum, leave a code comment that explains what the code does and optionally why it’s not included in a way that’s as consistent with the rest of the module in which you’re working.
When I first started in my career (as I imagine most people in our industry do), I was bent on writing the best solutions possible to the problems that I was given.
Nevermind that fact that I may not have had the experience of my peers, managers, or so on. I was bent on making sure that given the level of information I had, I was going to write the best code possible and aim to both prove myself but to show what I was capable of doing.
I was young. 🤷🏻♂️
Fast-forward over a decade, and things have changed.
And for anyone who has read Coding Horror within the last decade or so, you’re likely familiar with Atwood’s Law:
macOS is still shipping with PHP (though how this looks for future versions of the OS is likely going to change in some way.).
Anyway, imagine you’re in a situation where you’re working on a project that requires three different components:
A set of coding standards,
PHP CodeSniffer that work with said coding standards,
The inability to properly see results of sniffing the code either in your terminal or your IDE.
When this happens, this is almost always a result of a version of PHP, the version of the various dependencies, and making sure they all play well together.
In short, it’s about making sure the tools like PHP CodeSniffer work well with the same version of PHP you have installed. And in this case, the latest and greatest isn’t necessarily the best course of action.
It is, however, close. And in the following steps, you should be able to get everything working exactly as needed for your specific set up.