Years ago, I created the WordPress Widget Boilerplate aiming to be the following:

An organized, maintainable boilerplate for building widgets using WordPress best practices.

Since then, not much has changed regarding the Widgets API (which we’ll look at later in this post), but what I consider to be “best practices” has changed. Further, the degree to which I think this API is a solid example of introductory object-oriented programming in WordPress is high.

WordPress Widgets: The Widgets Boilerplate

It’s not because it uses a lot of object-oriented principles, it’s not because it uses modern standards (at least as far as modern PHP is concerned), but because it does use a few things that help us to recognize a few, say, signals regarding object-oriented programming in WordPress.

And this is something that shouldn’t be understated: If you’re looking for examples of object-oriented programming in WordPress, look for APIs that employ it.

Further, if you’re looking for ways to gauge you’re own level of evaluating a piece of code (let alone a code base) for the use of classes and some of the more advanced features of OOP, then why not have some sort of a litmus test to see how you’re doing?

WordPress Widgets: The Widgets API

And the Widgets API does just that.

Continue reading