Software Engineering in WordPress, PHP, and Backend Development

Category: Notes (Page 11 of 50)

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

Displaying Custom Messages in WordPress, Part 2

In the previous post, I started walking through what we need to do to display custom messages in WordPress. This is specifically in the case of when we are opting to use something other than the Settings API.

Custom Messages in WordPress

In the previous post, I covered the following:

  • Looking at what happens when you use a safe redirect via one of the available WordPress functions,
  • Serializing custom error messages
  • Saving them to the database

To follow-up with what was previously covered, I’ll show how to render these messages – regardless of if they are error messages, notices, or success messages – on the administration page.

Continue reading

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

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑