Software Engineering in WordPress, PHP, and Backend Development

Category: Articles (Page 83 of 258)

Personal opinions and how-to’s that I’ve written both here and as contributions to other blogs.

Basic Coding Standards via PSR-1

Yesterday, I talked briefly about a rationale for using PSRs versus the WordPress Coding Standards and the when and why of both. But that doesn’t mean it’s not without its points of confusion especially if you’re just starting with them, right?

By that, I mean: Say you’ve been working with the WordPress Coding Standards for years (because I can relate) and now there’s this whole new set of rules and guidelines to follow. But it’s not like a simple matter of changing some white space and renaming files.

There are other points to follow, and each is outlined in a number, quite literally (PSR-1, PSR-2, and so on), of how something should work.

So when it comes to just the basic coding standards as outlined in PSR-1, what are some problematic areas that we may encounter as WordPress developers?

Continue reading

Using the PSRs (Versus the WordPress Coding Standards)

At this point, I don’t know how many articles I’ve written about the importance of the WordPress Coding Standards (enough to link to them here, here, and here, I guess, which counts for something).

But after doing enough projects for clients and working with developers who are far smarter and familiar with advanced tooling than I am, I’m at a place where I’m opting to start using PSRs in WordPress WordPress development.

Using PSRs in WordPress Development

Oh the drama, right?

Seriously, though. There are reasons for this, and there are times in which I think the WordPress Coding Standards should still be used, but I’m quickly becoming more convinced that building any modern project on top of WordPress should use more modern PHP tools (which I’ll briefly mention later).

Continue reading

Tonik WordPress Starter Theme: Modern WordPress Theme Development

When it comes to working with WordPress plugins, it’s not uncommon to see people using more modern tools such as Composer, front-end dependency management via tools such as Node, and so on.

In fact, I’d say the most popular is probably the Sage project from the Roots team. It’s great, but recently some friends and I stumbled across the Tonik WordPress Starter Theme, and I had the pleasure of talking with the lead of the project, Patryk.

So for those of you who are interested in more modern workflows, tools, and strategies and employing them within the context of theme development, I think Tonik is worth checking out.

It didn’t take me long to get an instance of the theme spun up on my local machine. But the point of this isn’t about my experience with it – it’s why I think it’s worth checking out.

Continue reading

Avoiding class_exists in Object-Oriented WordPress Code

If you write object-oriented code for WordPress (usually within the context of plugins), you’re likely to come across a class_exists check before initializing a class. But we should start avoiding class_exists in much of our code at this point (with a few exceptions that I’ll outline below).

Avoiding class_exists

Depending on the version of PHP you’re using, this makes sense. Or it did at one time. As of PHP 5.3.0, this isn’t necessary. Instead, it’s a better practice to use namespaces.

Continue reading

How to Display Recent Custom Post Types (Excluding the Current Post)

Let’s say you’re working on a page template and it’s going to include a partial that’s going to display recent custom post types (or maybe even the standard post type) of the post type you’re viewing.

For example, say you’re looking at the example of stories or something like that. And you’re looking at a single page for a given author. Then, perhaps in the sidebar, it reads Read More From Other Authors, and it retrieves stories from up to five other authors.

Display Recent Custom Post Types

Where additional custom post types may appear.

Writing a custom WP_Query, pulling back the five most recent posts, and dropping them into the selected area seems easy enough, right?

And it is. But there’s a gotcha.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑