Object-Oriented Programming in WordPress: An Introduction

One of the things that people love (and hate, but that's another series) about WordPress is its low barrier of entry. 

That is to say that for the average programmer, it's pretty easy to pick up and begin building projects on top of it especially if you're someone who is comfortable with front end development.

Of course, if you're interested into extending WordPress through plugins, widgets, or even opting to pursue building a web application on top of WordPress, then it's a little bit tougher to learn the ropes. In fact, when it comes to building widgets, you generally have to use object-oriented programming if you follow the template provided in the Codex. Additionally, it's becoming more common to see object-oriented programming used for larger plugins, as well.

This paradigm - though not the silver bullet some would have you believe - is popular for a number of reasons, but before we cover that, it's important to understand the purpose of this series and where we're headed over the next few weeks.

"Where Do I Start?"

For anyone remotely interested in learning a new language, tool, or framework, it's relatively easy to get started, especially if you have a background in programming.

But those who have been at it for a significant amount of time often forget what it was like when originally trying to figure out how to decipher code, understand why something was written the way that it was, how the author knew to use what function and where, and determine the rationale behind certain implementation decisions.

We've all been there at some point, right? We've looked at the code, tried to figure out the flow of control, and at one time asked "where do I even start?"

And the purpose of this series is to answer that question.

Object-Oriented Programming For Beginners

Specifically, this series is going to focus solely on those who are wanting to learn to build more complex solutions with WordPress. You may be someone who is comfortable with building themes and/or simple plugins, but are looking to advance your skill set by learning object-oriented programming.

The challenge, of course, is learning where to start. Sure, there's a lot of material that's available on the web and in books in terms of the basic concepts of object-oriented programming, but I believe that it's often easiest to learn a new paradigm within the context of an actual foundation or framework.

So over the next few articles, we're going to start from the ground up by looking at object-oriented programming within the context of WordPress.

We'll be covering topics such as:

  • classes
  • attributes
  • constructors
  • functions
  • scope
  • interfaces
  • abstract classes
  • abstract functions
  • ...and much more.

By the end of the series, you be well-equipped to at least have a working understanding, and a solid reference that you can look back to throughout your time with WordPress.

What's Next?

Ultimately, we want to work on not only understanding how object-oriented programming works, but also work on putting it to practical use by building a working plugin. So as we cover the basics of object-oriented programming within the context of WordPress, we're going to work on building a plugin to demonstrate the features of the paradigm.

With that said, we're ready to get started. 

In the next article, we're going to start by looking at the fundamental building block of object-oriented programming: Classes.



Related Articles