Software Engineering in WordPress, PHP, and Backend Development

Category: Notes (Page 11 of 49)

Notes on programming-related problems that I’ve encountered while working on various projects.

Custom Data Validation in WordPress

Custom data validation in WordPress is something that many who have built custom solutions for others have likely used.

In fact, anyone who has made a theme or a plugin has probably used some form of data validation even if it’s just escaping some attribute that will be part of the rendered markup.

Custom Data Validation

This is a major step in making sure that anything you’re creating is securely managing information coming from the database.

But whenever you’re working on a custom solution that requires you use various elements and attributes, how can you specify only the supported attributes?

Continue reading

Highlight a WordPress Admin Active Submenu

If you’re working on a theme or a plugin for WordPress and you want to highlight an active submenu item, then your implementation is going to vary based on where you want to highlight the actual item.

Active Submenu Items

An overexaggerated menu to help drive this point home.

This is one of those times where it’s helpful to have clear terminology for what you’re trying to modify:

  • Are you working on trying to highlight an active submenu in the admin menu,
  • Or are you working to highlight an active submenu on the front-end of the theme?

There’s no consistent way to do this. For what it’s worth, I don’t think they should be as they are two completely different entities (for lack of a better term). Perhaps having some semi-consistent filter names would be nice, but that’s about it.

Regardless, when you set out to highlight an active submenu item, it’s important to note which part of the project you’re working on and then go from there.

Continue reading

Using Console.app for Viewing PHP Logs

When working with PHP, there are some great libraries and tools that make it easy for logging notices, warnings, errors, and so on within our code.

For what it’s worth, I think PHP does a pretty good job of doing this on its own, but if you need to write your custom logging code, there are plenty of off-the-shelf libraries that are helpful.

But that’s not the gist of this post. Instead, just as I think it’s important to make sure we’re providing reliable logging information, I think it’s important that we’re able to view said logs, as well.

Continue reading

MySQL Admin Can’t Connect To Localhost

I’m going to have a significantly longer post (or series of posts) that go more into detail about setting up WP-CLI, proper unit testing of WordPress plugins, and so on.

Unit Testing with WP-CLI

But for those who are already working on setting all of this up and are hitting a couple of problems with trying to set up a temporary database using some of the provided WP-CLI shell scripts, I wanted to share the solution that I used to resolve this.

Continue reading

Syncing Atom Settings Between Computers

Syncing Atom settings between multiple machines is useful in that you’re able to maintain all of your packages, settings, and so on regardless of the machine you’re on.

And yes, I’ve been talking about Atom a bit more as of late. I’m clearly a fan. But that’s evident, right?

If you maintain more than one machine, then it’s usually nice to have the same development environment configured between the two of them.

Here’s a method for syncing Atom’s settings between though it does assume you use Dropbox. If not, any service you use for sharing files can be used, but your actual steps will vary.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑