If you’ve not read the first post in this series, I recommend it, as we’re starting to get into writing object-oriented code for WordPress through the use of the Widgets API.
The series is going to capture a few things:
- show you the basic skeleton of a widget and why it’s object-oriented,
- discuss what things you should be able to notice and why
- update the Widget Boilerplate directly on this site first and then push it out to GitHub,
- build a widget using the API with the boilerplate as the foundation for our work.
But before doing that, I want to make sure that everyone reading this is caught up on the core principles of object-oriented programming and has everything needed to build out an object-oriented solution for WordPress.
To that end, I recommend the following:
- Two Pillars of Object-Oriented Programming: Part 1 of 2
- Two Pillars of Object-Oriented Programming: Part 2 of 2
- Abstract Classes, Part 1 – Abstracting Behavior
- Abstract Classes, Part 2 – Abstract Classes and Interfaces
- The Independent WordPress Developer
If you’ve read all of that content, great. You’re going to be well-prepared for this post and the upcoming posts. If not, there may be some holes in the rest of what you’re about to read, but the gist of the post should be clear enough.
What’s The Deal, Exactly?
Here’s the thing: Last week, I shared a bit of code along with some information about the Widgets API. I’m going to be revisiting that a little bit more in this post before we get into the more coding intensive part for two reasons:
- I want everyone reading this to be on the same page as it relates to writing object-oriented code (at the very least, in this context),
- I recognize that people are coming from different backgrounds and I want to make sure we’re all on the same page as much as possible before proceeding.
If you have experience with writing object-oriented code, especially in an advanced capacity, this may seem simpler to you; otherwise, I hope this is going to arm you with everything you need to detect object-oriented practices not only concerning this API but when reading others’ code, too.
How to Detect Object-Oriented Programming
Perhaps a natural first question is why do we need to be able to detect, read, or understand object-oriented programming before actually writing it?
At this point, we should all be on the same page as it relates to object-oriented code. At least as far as we can get through a series of blog posts.
Starting in the next post, we’re going to get back to writing code.
That is, we’ll revisit the WordPress Widget Boilerplate and I’m going to be refactoring it in its current state to adopt more modern PHP standards.
I’m going to share the changes I’m making, the justifications as to why, and then I’ll also talk about the type of widget we’re going to be building based on the boilerplate (and we can do so).