Software Engineering in WordPress, PHP, and Backend Development

Category: Articles (Page 79 of 258)

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

Download User Email Addresses via JSON in WordPress, Part 1

Say you’re working on a project in which you want to provide the user the ability to download all of the email addresses from the users that exist in the WordPress installation. Granted, this has a few requirements:

  • You only want administrators to do it,
  • It needs to be secure via nonce values,
  • The responses should be in JSON,
  • And you want to use JavaScript to send the file when it’s ready to download.

Each of the above concepts has likely been covered here before, but what if you’re looking to tie them all together? That is, what if you want to make it easy to download user email addresses via JSON within WordPress from, say, an administration menu or a submenu?

Download User Email Addresses via JSON in WordPress

An obligatory shot of where I’m working while writing this post.

Here’s one way to tackle that problem. Note that it does assume you have some knowledge of the above, but I’ll do what I can to cover each of the above.

Continue reading

For Quality, It’s Understanding Before Coding

Whenever you aim to blog about a series of different things all seeking to help out people write quality code (or write anything, really) to help improve their workflow, you’re bound to get feedback, right?

Don’t get me wrong. I welcome it. I think it helps to make for better writing in the future (that is, I ask, what can I do better).

And at the risk of looking like I’m “calling someone out” (which I am not), I want to share an [unattributed] tweet that I received last week:

your title “high-quality code” got me pumped for some hardcore stuffs, but dude ~99% narrative vs ~1% code?? *drops dead on his keyboard*

And I get it. There’s very little code in a post that is aiming to talk about code. But there are reasons for this, and it comes from a few years of both reading articles, writing articles, reading code, and writing code.

So I thought for others who have the same thoughts, it might be worth explaining why I take the approach I do.

Continue reading

How to Use PSR-4 Autoloading WordPress Plugins

Say that you’re working on a project for someone and you’ve scoped it out, tasks are delegated, you have all the libraries and tools you need to get started, and you’ve separated what will be the theme or presentation, and what will be the functionality or the plugins.

But rather than having a handful of individual plugins, what if there was a package of smaller functional plugins or micro-plugins or whatever you want to call them working to power the package?

PSR-4 Autoloading WordPress Plugins: Example Organization

Furthermore, these all of which are built on the same foundation but that also share code with one another and to make things more interesting, you opt to use a PSR-4 autoloader via Composer to take care of all of this?

Continue reading

Configuring Composer for WordPress, Part 2

In this post, I’ll wrap up what I began to share yesterday: Using the tools and libraries I’ve shared in conjunction with Composer to sniff your commits during development before the code hits the repository.

Ideally, you’re always going to want to see something like this in your terminal whenever you commit your code:

Composer for WordPress, Part 2: Configuring Sniffs

But that’s not always the case. As with most things, though, the more you practice, the more you’ll get used to writing code that will automatically pass the various sniffs put in place through the different rules (and their customizations).

Before doing that, though, you’ve got to get GrumPHP configured in your repository.

Continue reading

Configuring Composer for WordPress, Part 1

Okay, so after talking through all of the various libraries that can help improve the code quality of your work, it still raises a question:

How do we get these projects working against our code base?

In short, it requires Composer. If you’ve never used it, I’ve written briefly about it before, but I intend to provide the basics of what you need to get started using it and the aforementioned libraries in your work.

In both this post and the next, I’ll share how to set up everything locally in the most basic form and then how it integrates with Git so you can start using it in your day-to-day.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑