Software Engineering in WordPress, PHP, and Backend Development

Tag: WordPress (Page 60 of 219)

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

Rapid Prototyping with WordPress: From Concept To Plugin

I’ve talked about using WordPress as a tool for rapid application development in a past article.

But the longer I work with WordPress and the more code I see, the more potential I realize it has as both a platform for rapid prototyping and then taking those prototypes to fully developed applications.

These plugins can be web applications, plugins, themes, websites, whatever. For the purposes of this post, it doesn’t matter. Instead, what matters is that for example:

  • you have an idea for a plugin,
  • you want to see how it might work within WordPress,
  • you quickly put something together,
  • you begin refining it.

For many who are getting involved for more serious WordPress development, I thought it might be worth taking a look at what this looks like. Namely, I’ll take an idea for a plugin, prototype it, and then refine it into a well-organized, object-oriented plugin.

So in the next series of articles, I’m going to walk through that process.

Continue reading

What Are WordPress User Caches?

If you’ve ever worked on a project when you need to work with WordPress authentication cookies, then you’ve likely stumbled across the wp_set_auth_cookie function. In short, this function:

Sets the authentication cookies based User ID.

And when you use this function, you’re essentially creating a cookie that’s used to authenticate the user to log into WordPress.

WordPress User Caches

But if you’re looking to authenticate a user with WordPress programmatically, then there are a few extra steps required to do it properly especially if you’re working with caching plugins.

And that’s where WordPress user caches come into play.

Continue reading

Repository Pattern Benefits: Why We Should Consider It

Yesterday, I gave a primer on the repository pattern. In short, it’s one of those patterns that I think anyone working on middleware built on top of WordPress should understand.

When giving a primer on a pattern like this, it can be tough to do justice to the pattern when you need to:

  • introduce it,
  • explain how it works,
  • cover the benefits,
  • and give a small demo.

But the real advantage to the repository lies not only in abstracting the data layer away from the rest of the application but that it can (or should) be able to be easily swapped out with various data stores without changing the API.

For example, in one instance, you may need to retrieve data from the WordPress database, in other cases you may need to retrieve something from a third-party API, or perhaps there’s some other place from which you need to retrieve data.

Regardless, the idea behind the repository pattern is that whatever sits behind it doesn’t matter so long as the API it provides works for the layer of the application calling into it.

And since we’ve covered a primer on the repository pattern, let’s take a look at some of the repository pattern benefits and how we can implement it in the context of WordPress projects.

Continue reading

The Repository Pattern Primer

Whenever you’re working on a larger project that’s based on WordPress, the odds that you’re going to be working with more than a single data source – that is, the WordPress database – are higher than normal. For example, you may be working on a project that has to coordinate information from:

  • the WordPress database,
  • a help desk ticketing system,
  • a content importing system,
  • another third-party API,
  • and possible more.

And when this happens, it can become a bit cumbersome to write code that makes it easy to retrieve information from those different places. This what developers usually talk about when they refer to dealing with “layers” in their application. That is,

  • there are layers for presenting information to the user,
    layers for handling business logic (or domain logic),
  • layers for communicating with APIs,
  • and layers for storing data.

Honestly, you don’t have to have a variety of data stores to watch to create a layer that makes it easier to send and retrieve data from the database, that’s just when it’s more common. You can just as effectively work with a single data store, like the WordPress database, when implementing the repository pattern.

Regardless, if you’re building a larger website, web application, or plugin, implementing the repository pattern is something that can pay dividends in maintenance, clarity of code, and separation of concerns.

But how might this be implemented within WordPress? It’s not terribly challenging, but first, it’s worth reviewing a repository primer before jumping into any code.

Continue reading

How To Make MySQL Globally Accessible (From MAMP)

I recently walked through how to make WP-CLI globally accessible across your system (assuming you’re running macOS or a variation of Linux).

I’ve also talked about various things as it relates to using MAMP Pro for WordPress development. Naturally, one of those tools is also MySQL; however, it’s one that is often treated as a “set it and forget it” application.

But I’ve recently started working on a project that requires a bit of automation as it relates to syncing the development and the staging databases. And since this is scripted, it assumes that MySQL is globally available.

If the only way you’ve installed MySQL is via MAMP (or perhaps another similar package), then you’ll likely need to make MySQL globally accessible on your system.

Here’s how to do that.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑