Software Engineering in WordPress, PHP, and Backend Development

Tag: WordPress (Page 183 of 219)

Articles, tips, and resources for WordPress-based development.

Some Thoughts on Design Patterns in WordPress

A few months ago, I did a series of articles on Design Patterns in WordPress that was meant to provide an introduction to object-oriented design patterns, and how they can be used when developing projects on top of WordPress.

When it comes to working with WordPress, code is normally written one of two ways:

  1. Procedural
  2. Object-oriented

For procedural programming, think of `functions.php` in theme development, and for object-oriented think of plugins. This isn’t to say that procedural programming isn’t used in plugins – it often is (case in point: Markdown Code For WordPress) – but so are object-oriented techniques (see the WordPress Plugin Boilerplate).

In short, decide patterns exist for a reason: They are proven solutions to common problems that appear in software development.

Yes, they may have to be tweaked a bit for a given situation, but the definition, structure, and so on remains the same. The thing is, I don’t often see many design patterns used throughout WordPress product development.

To be clear, I’m not talking about WordPress core, I’m talking about products built on top of WordPress. Perhaps I’ve just not done enough digging or paid enough attention to some of the work that’s out there, but I think if we – as developers – spent time working on implementing design patterns in our work, projects could have much more longevity rather than devolving into spaghetti code that’s so often found in WordPress work.

Continue reading

The Dangers of Using pre_get_posts in WordPress

In the previous post, I talked a bit about using `pre_get_posts` and how to efficiently exclude categories from the main loop.

Of course, in posts like that, the code is meant to be a point of reference or a starting place for which more advanced functionality can be written.

But one thing that I failed to mention about using `pre_get_posts` in WordPress is that it’s not limited to the public facing side of the site.

Continue reading

How To Efficiently Exclude Categories From The WordPress Loop

When it comes to writing custom queries in WordPress, `WP_Query` is the API to use. And I could be mistaken, but I do see a lot of people urging developers to avoiding using `query_posts` in WordPress in favor this newer-ish API.

But the thing is that `query_posts` still has its place in WordPress development namely in modifying the results of the data queried for The Loop when rendering blog content; however, one of the the biggest caveats is the performance that `query_posts` can have on the performance of the blog.

I’ve recently been working on a plugin where I needed to exclude posts from The Loop based on the category. At first, I was going to use `query_posts` but I ultimately hit a few snags, so here’s an alternative way to exclude categories from the WordPress Loop.

Continue reading

Unicode Characters, Regular Expressions, JavaScript, and WordPress

For those who have been into computer science for any amount of time, you’re likely familiar with Joel Spolsky, his blog Joel on Software, and/or perhaps any of his books.

A couple of years ago, I read an article called The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!).

I’m not ashamed to admit that, at the time, it wasn’t very applicable to me. Yes, it was interesting, yes, I cared, but I didn’t have a practical way to implement it simply because there was nothing that I was working that warranted the information in the article.

But here was one of my biggest takeaways:

If you completely forget everything I just explained, please remember one extremely important fact. It does not make sense to have a string without knowing what encoding it uses. You can no longer stick your head in the sand and pretend that “plain” text is ASCII.

Fast forward a couple of years and I was working at a place where every piece of application code that we rolled out had to be internationalized because it was accessible by a variety of countries all across the world – now it was more practical (and it’s not much different than WordPress, huh?).

And now, I’m finding myself working more with unicode characters in WordPress more than I ever have before.

Here’s the thing that few people talk about: Sites, themes, or HTML in general will specify a character set that can drastically affect how the content in your page is rendered.

Continue reading

A Few Thoughts on WordPress Affiliate Programs

A few months ago, a number of companies – ours included – began to suspend or completely end their WordPress affiliate programs.

Naturally, this created a bit of a backlash.

In all fairness, not all customers were particularly upset. Some were disappointed, sure, and rightly so but moved on with their blogs; others were far more upset about the apparent injustice that was served by companies opting to pull the plugin on the program.

Since news in WordPress opts to ebb and flow week to week, this has been something that’s passed, but I’ve begun to see some comments beginning to crop up again specifically around affiliate programs in the WordPress space.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑