Software Engineering in WordPress, PHP, and Backend Development

Tag: WordPress (Page 21 of 219)

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

Understanding Caching in WordPress, Part 1

Back in may, I wrote an article about using the WordPress Transients API. I summarize the article like this:

To simulate cookies and their feature of expiration, using WordPress transients may be a viable solution.

https://tommcfarlin.com/using-wordpress-transients/

Though the purpose of the article was to lay out a foundation for how we can design a class to work with the Transients API to simulate the behavior of cookies, one of the side effects of the article is that it didn’t do a good job of explaining how the Transients API (and, by proxy, how MySQL) works.

This was brought to my attention via email by David at UpDraft Plus.

So I thought it useful to talk about the concept of caching from a practical level, how it’s implemented in WordPress, then maybe look at we how to utilize plugins or newer technology to better power our sites and applications as well as have a better understanding.

Continue reading

Two Useful Tools for WordPress Development

Over the last few weeks, I’ve been blogging a bit less. This isn’t so much because I’ve nothing to say, it’s because I’ve been heads down on a number of different projects and trying to learn a couple of new technologies (all of which will contribute back to WordPress).

In the middle of doing this, I realized I’d not shared two useful tools for WordPress development – specifically, a REST API client and a database front-end.

Yes, there are a numerous tools out there are you probably already have your favorites. Here, though, are the two that I’ve been using the most.

Continue reading

Tools for Writing Better WordPress Code: Static Analysis

In the most recent post of this series (which is admittedly some time ago), I talked at length about Composer and its lock file.

I recommend reading the previous two articles because Composer is eventually going to play a role in this material that this and future posts are going to share. But if you opt not to catch up on them (or are already familiar with Composer) then the gist of the previous posts are, respectively, as follows:

I don’t recommend checking the vendor directory into your repository. That can become a huge directory later, and it can undermine the whole purpose of Composer.

Composer

The goal is to make sure that every one is running the same version of the dependencies of the project – not older versions, not newer versions – but the same version.

The Composer Lock File

With that said, there are numerous dependencies or packages that we can install that help us to make sure that we’re writing the highest quality code possible.

Sure, some of these may be in the form of something like coding standards, but those are really more rules than they are elements of writing high quality code (though I don’t think they should be left out of the discussion – just left out at this time 🙃).

Back to the tools in question: What are some tools that help write high quality WordPress code? I’m going to share a few of my favorites and them I’m going to talk about how we can run them all against a code base.

First, let’s take a look at static analysis with PHPStan.

Continue reading

Sending Authorization Headers with WordPress

Whenever we’re making remote requests with WordPress, we’re likely going to be using one of the following functions:

And, yes, sometimes we’ll be using cURL depending on the nature of the project, but that’s outside the content of this post.

For this article, I want to talk specifically about making remote requests and specifying headers against a third-party API.

Continue reading

Adding Multiple Coding Standards with Composer

It’s one thing to be using PHP CodeSniffer manually but if you’re using a utility such as GrumPHP to check your work before committing it to the repository, then you’re likely going to want to use the version that you’re installing with your project.

This assumes that:

  1. You are installing PHP CodeSniffer local to your project,
  2. You want to install a specific set of coding standards to run against your code.

Remember, this is also done in the context of wanting to run automated scripts during the commit process and in a local environment (versus a global setting) with Composer.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑