Software Engineering in WordPress, PHP, and Backend Development

Category: Articles (Page 81 of 258)

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

Fix Valet, WordPress, Ajax, Bad Gateway

Some time ago, I went back to using Valet for local development, and I’ve been happy with it since. Up until sometime last week, I’d yet to run into any problems.

Fix Valet, WordPress, Ajax, Bad Gateway: Valet

But when working on a WordPress plugin that imports data using admin-ajax, I kept getting a curious message in the console no matter how large or small the data was. Specifically, I was getting an error about “502 (Bad Gateway).”

The server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request.

And if you try to diagnose it based on that definition, you won’t get very far. It’s not that it’s wrong, but it’s that you need to modify your server configuration.

Luckily, it’s easy. Or it’s likely easy.

Continue reading

WordPress-Focused Continuous Integration with CircleCI

Writing about continuous integration or continuous deployments seems a little funny to me given that I’ve done this before and given that I know a lot of developers already use this as part of their day-to-day.

But I also know that there are a lot of hobbyists, beginners, and those who are just starting out who are looking for ways to make sure they are setting up solid practices for their work.

For what it’s worth, it wasn’t until I started working with a few more people that we began to incorporate a wider set of tools in our deployment process.

And that’s the purpose of this post.

That is:

  1. introduce the whole idea behind WordPress-focused continuous integration,
  2. introducing CircleCI,
  3. getting ready to chat more about it.

With that said, here’s the run down on all of the above.

Continue reading

How To Use GitHub PR Templates

If you do any work – regardless of if it’s open source or closed source – (though I know most who use read this site are involved in open source), you likely use some source control, and it’s probably GitHub.

For many of you, you either follow a project, contribute to a project, or handle pull requests to a project. And what about those projects that you work on with a team?

Perhaps your workflow is something like this:

  • you create a branch to work on a feature,
  • you push the branch to detail the work you’ve done for a peer to review,
  • the review is merged,
  • you carry on.

But what do you put in the template for the pull request? Is it the same every time or is it different? What about if the content of the PR is related to something in Trello, Asana, Basecamp, or some other project management system?

That’s where GitHub PR templates come into play.

Continue reading

Using WP-CLI on Your Host (Regardless of Your Host)

At this point, I think most people who develop solutions WordPress on a regular basis are familiar with using WP-CLI. Installing it locally on your system is one thing, using it on your host is another (but it’s all the same once you’re connected).

Case in point: Lately, I’ve been spending a few evenings and times during the weekends working on this site and trying to get it ready for the upcoming redesign. Part of doing that includes using WP-CLI.

If you’re someone on SiteGround (or any host that support WP-CLI, really) and are looking for how to get started using WP-CLI on your host, here’s a quick primer that should provide you everything you need to know to get up and running.

Continue reading

What’s Too Much For Passing Data via Dependency Injection?

The topic of dependency injection is one that’s been around for some time in object-oriented programming circles. Sometimes we see it in WordPress; sometimes we don’t.

I’m a fan of it but, honestly, though, I’m not always sure how much information to inject into a class. I mean, let’s say that we’re given two classes, and one holds information the other needs.

  • Do we inject no class into another class?
  • Do we inject only a piece of information (be it a string, integer, data structure, or whatever) into the other class?

I don’t think there’s a hard and fast rule for this, but it’s probably safe to say that it’s better to inject just the data you need. But then this raises a question of how do prepare the data to inject into a given class?

  • Do you create a method in one class and pass it into another?
  • Do you pass a piece of private or protected information into it?

Then again, I think it depends on if anything has to happen to the information before it’s passed into a class.

Anyway, I could go back and forth on this for the rest of the post and never come to a conclusion so why not work through some source code until there’s something reasonable.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑