Software Engineering in WordPress, PHP, and Backend Development

Author: Tom (Page 53 of 427)

Finding the Destination of a Redirect with PHP

Recently, I was working on a project that was communicating with a third-party API that, like many APIs, sends back a lot of data part of which includes a URL for the product associated with the API.

The thing about the API that was being returned was not the proper destination URL. Instead, it was a URL that ultimately redirected to another URL.

So imagine hitting, say, acme.site-info.com and having it direct to acme.com. We do this manually all the time, but I needed to get the actual – or the final – destination of the direct from the URL.

And finding the destination of a redirect with PHP is easy; however, this does assume there’s only a single redirect.

Nonetheless, here’s how to do it.

Continue reading

Time Off 2019: Part 1 of 4 of Social Media Sabbaticals

It’s been a while since I’ve published anything on a Monday (I don’t know if that’s notable or not but, as I’m writing this, it came to mind 🙃).

But since today officially starts the second quarter of the year it’s that time in which I also opt-out of social media, for the most part, and recap some of the things I’ve done and plan to do over the next month.

For those who haven’t read about this stuff before, you can see what I did last year in the following posts:

  1. The First Social Media Sabbatical of 2018
  2. The Second Social Media Sabbatical of 2018
  3. The Third Social Media Sabbatical of 2018

Every time I end up taking time off of social media in general, I never regret it. At the same time, I also find new things I want to do during that time.

And, this time, one of the things (among others I’ll discuss in a moment) is I want to work on really slimming down on the number of applications I have installed on my mobile device.

I’m already pretty good with managing my time (thanks to Screen Time and turning off notifications), but I have a good friend who said it like this:

I’m trying to Marie Kondo the number of apps on my phone.

And I liked that. So that’s part of what I’m planning to do over the coming month.

But that’s not all.

Continue reading

Privacy is Hard: Web Browsing

Two weeks ago, I started talking a bit about my concerns regarding privacy – which may be the same as yours – and decided I’d start running down a list of things that I’m trying, using, and doing to adhere more to privacy-centric software and services.

Here’s the thing though:

  • what I’m comfortable with using may not be the same for you (and vice versa),
  • and privacy and security are not terms that I use interchangeably.

Going into this series, I want to make sure I’m working off of a consistent definition of privacy. You can see the whole definition here but for the purpose of these articles, I’m going to be using the following:

Privacy grants us freedom from the public; concealed.

So any service that compromises that definition on any level would be something that violates privacy. Furthermore, it’s hard to find things that are purely private is near impossible so we have to make tradeoffs.

And I’m going to lead with that.

Continue reading

Tools for Writing Better WordPress Code: Introduction

Over the last few years, I’ve talked a lot about the nature of code quality and various tools, processes, and libraries that I recommend using when it comes to writing code for WordPress.

I’m also open that that majority of the work that I do is in backend development. This means that I work predominately on WordPress plugins using object-oriented programming and don’t work much with templates nor as much with front-end technologies.

It’s by choice, and I’m really happy with where I am. But I digress.

If you’re in the business of doing the same thing (or doing it as a hobby), it’s not just about writing the code. It’s about having proper tooling in place.

I’ve alluded to a few in these in previous posts, but I’ve not walked through the tools I use and the set up I use whenever I’m building a solution for myself or someone else.

At least not in an organized manner.

In this series, I’m going to do exactly that:

I’m going to cover the tools I use, the libraries I use, and how I use them.

Ultimately, the goal is that those of you who read this can incorporate them in your day-to-day work to write better code.

Continue reading

Considerations for Design Patterns for WordPress

The longer you work with a given platform, the more you begin to recognize certain ways to do something. And it’s very likely that you’ll begin to recognize two things these things can be done:

  • in a way that’s fast to develop, but harder to maintain or
  • in a way that’s slower to develop, but easier to maintain.

Of course, like any project, requirements, constraints, budgets, and time are all going to impact what you’re able to implement. But what I’m getting at is that regardless of how you implement a solution, you begin to get familiar for how to solve a given problem.

If a problem has to be solved quickly, then you know the tradeoffs, but you likely know how to do it quickly. Similarly, if you have a little more time (and budget), you can develop it another way, and you’ll know how to do it and possibly even wrap it up with test suites if the constraints allow for that.

Regardless of how you have to implement a solution, you know the ways that you can do it.

And this raises a question:

Are there design patterns specific to a given platform? And if so, what are some of the design patterns that may be available in WordPress?

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑