Software Engineering in WordPress, PHP, and Backend Development

Category: Articles (Page 100 of 258)

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

Xdebug, Visual Studio Code, and MAMP

Using Xdebug and Visual Studio Code is something that’s pretty easy to setup, but given that I’m still using Visual Studio Code should tell you something about how much I’m a fan of the IDE.

But here’s the thing:

If you’re a WordPress developer, debugging is something that you really need to learn. That is, don’t use print_r and var_dump if you can help it. Use a legitimate debugger. It will help you think as the interpreter thinks and it will help you learn a bit more about Core.

Now that I’m off my soapbox, getting the necessary tools installed is easy. The article assumes you’re using MAMP Pro (since that’s what I use), but if you have access to php.ini then you’re going to be able to follow along.

Continue reading

Using a WordPress Hook for Updating Options

Updating options within the WordPress admin is simple, right? It’s a matter of filling out a text field, checking a box, or swapping a radio button then clicking save.

But let’s say that you need to set up a hook that fires that also updates a secondary, related option whenever one is toggled.

Updating Options Hook

For example, given an option represented by a checkbox, let’s say that you want to set an option in the database whenever the checkbox is unchecked and then delete it whenever said option is set.

There’s an action specifically for doing this that makes it pretty easy.

Continue reading

Remote Requests with wp_safe_remote_get

Yesterday, I shared a post on how to use wp_remote_get but I left out an alternative function: wp_safe_remote_get. The original goal was to use the first post to show:

  1. What the original function accepts,
  2. How to use the original function,
  3. What the original function returns,
  4. What an implementation make look like.

And then I was going to take a look at wp_safe_remote_get. But there’s a challenge: I have smart friends. Shortly after I published the post, I get a response from Roy:

Thanks, Roy! (Be sure to say “Hi!” to him. :)

But seriously, the follow-up to yesterday’s post is exactly that: wp_safe_remote_get. And it’s how to determine the difference in the two functions and when you’d use one over the other.

Continue reading

Remote Requests with wp_remote_get

If you’re read any of my previous posts on retrieving remote files, then you know that old habits die hard as I often use file_get_contents rather than wp_remote_get.

So, as one does when blogging, I thought it would be helpful to share a simple example of how to use wp_remote_get in your day-to-day work.

wp_remote_get in the WordPress Developer Resources

The post below is merely a snippet of how to use it. That is, it won’t show how to designed, say, a class around it or a UI that allows users to upload a file. But this should be enough to get things started.

And I’ll include how to take the API documentation around it and understand how to leverage it when using a function like this.

Continue reading

Programmers Should Blog (Including You)

I’ve long held the belief that programmers should blog (if they feel so inclined, of course).

Granted, I write about how to do things programmatically using WordPress, and I plan to get back to doing that later this week with the new year back in full swing. But I stumbled across a post on The Practical Developer this morning that I couldn’t help but offer my thoughts on it.

The post, Untold Benefits of a Software Blog, is something that’s relevant to any of us in the programming space but I share it primarily for those of us in the WordPress space. (After all, that’s where I’m focused, right?)

Programmers Should Blog

And I share it because I thought I’d share a bit about what the blog has afforded me over the last few years of writing and sharing content on this site.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑