There’s a problem we’re facing with namespaces and autoloading and that’s what we’re going to look at in this post.Read More
Object-Oriented Programming in WordPress
Once we have a Registry, we need to be able to access it throughout our plugin and we do that with custom hooks.
One problem that still exists in the code as it stands right now is that the WordPress widget’s constructor is registering functions and this isn’t a good thing.
Arguably, the biggest problem with the Boilerplate is that everything is encapsulated within a single class. So let’s change that with abstract classes.
Let’s take a look at the errors the code sniffer is throwing for the WordPress Widget Boilerplate and see if we can’t bring it up to more modern standards.
This will not only improve the code quality but also walk us through some object-oriented principles that we can apply when building our WordPress widgets.
One of the best ways to go about object-oriented programming is starting with standards and having tools to enforce them.
The goal is to arm you with everything you need to detect object-oriented practices both in this API and others.