Templating and Conditional Logic with OOP in WordPress

Templating is becoming more common in WordPress, and I consider that a good thing.

But that doesn’t mean that there aren’t projects that we manage that use a more traditional approach to displaying templates or partials. Furthermore, it also doesn’t mean that we’re exempt from maintaining codebases that use code that does not use a templating engine.

Though I think templating is good, I don’t think it’s always necessary. That’s content for another post, though.

Instead, I want to walk through the process of using the conditional logic of whether or not to display a partial within a template and do so using object-oriented programming.

Read More

Looking At Polymorphism In-Depth

When I started this series, I talked about the four pillars of object-oriented programming. Each of these topics is listed and linked below.

  1. Abstraction
  2. Encapsulation
  3. Inheritance
  4. Polymorphism

At this point, I’d normally want to begin moving on to the next topic. Before doing so, though, I’d like to spend one more post exploring the concept of polymorphism.

In my career, thus far, I’ve seen few topics give those getting into object-oriented programming more confusion and problems than polymorphism. So I’d like to discuss it a little more in-depth within the context of object-oriented programming and outside any particular framework or application (like WordPress).

In this post, I’ll do a quick review of what we’ve discussed thus far, then hop back into polymorphism.

Read More

Dynamically Centering an Element in a Container Using CSS

When it comes to writing about development, I don’t often talk about things beyond PHP and JavaScript mainly because I work with those languages more than others.

I mean, yeah, CSS is part of the deal as is HTML, but it’s expected these days, right?

So if there was ever a quick tip for me to offer regarding CSS, this is it (though maybe I should write more?). It’s hard when Chris does such an awesome job running CSS Tricks, but I digress.

Anyway, here’s the problem and the solution.

Read More

Working with Classes, Templates, and Partials in WordPress

When I sat down to begin this post, I planned to write something far more involved that I what I’m going to share. Initially, I wanted to walk through one of two things:

  • The Complete Guide To Setting Up a Development Environment,
  • Integrating Code Quality Tools into PhpStorm

The first would be focusing on a variety of other things I’ve talked about, tying them all together, and having a definitive reference. But this is something that I want to take time to put together to make sure it’s done right.

The second is one that I think is important but I’m in a bit of a transitional phase with some of my own tools. Until that’s done, I’d rather not write about it.

Even still, there’s always something to cover, right? So today I’ve opted for something simpler: Breaking down the use of classes, templates, and partials in WordPress plugins using a simple example.

Read More

Abstract Classes, Part 2 – Abstract Classes and Interfaces

In the previous post in this series, I walked through:

  • the basics of abstract classes,
  • how to implement them,
  • and provided working code examples.

And though I think understanding abstract classes are key in laying a strong foundation for object-oriented programming, I often see that it can be confusing when it comes to comparing them to interfaces and knowing when to use them.

Abstract Classes and Interfaces


Read More