Tom McFarlin

Software Engineering in WordPress, PHP, and Backend Development

Page 213 of 427

Validating Input via the WordPress Settings API

This post is part of a series on Sanitization with the WordPress Settings API. Here is Part 4.

Up to this point, everything we’ve talked about regarding the WordPress Settings API and saving data to the database has been based around two ideas:

  1. We need to sanitize the input
  2. We haven’t been concerned with any particular fields being required

At this point though, we’re ready to start talking about how to tackle this particular issue. Since we’re already familiar with how to sanitize the data, we’re going to build off of the code that we already have.

An Example Settings Page

An Example Settings Page

That is, we’re going to look at how to validate the following fields:

  • Address 1
  • City
  • Postal Code

Furthermore, we’re going to see how to tackle this from an object-oriented approach, we’re going to look at what’s needed in order to add an error message if the required input is invalid, and we’re also going to look at how to prevent saving information to the database if it’s empty or invalid.

Continue reading

The Complexity of WordPress Solutions

Yesterday, I was talking with a friend of mine about WordPress and some of the annual revenue reports that have come out over the past few months (which tends to be the normal around the end of the year and on into the first quarter for our industry).

Though he’s no longer working in this particular economy, he mentioned something that I thought was interesting:

the work I’m working on right now is far more exciting and challenging BUT the opportunity to make stupid simple money is pretty large in the WP world

Before I go any further, I want to be clear that I am taking this quote out of context so it’s probably not presenting him in the best light. That isn’t my intent at all.

In fact, I actually think he makes a compelling point that I’ll talk about momentarily, but I also think that the problems that we opt to solve in and/or with WordPress are as challenging as we accept and as we allow them to be.

Continue reading

Mayer For WordPress By Reaktiv Studios

Over the past few years of working within the WordPress space, I’ve had a chance to meet a lot of really great people and teams, and I’ve had the chance to work on a lot of different types of projects. Some of these include commercial themes, commercial plugins, free themes, free plugins, custom web applications, and so on and so forth.

It’s a great time to be a developer in the WordPress economy, isn’t it?

One of the things that comes with running your own business is trying to figure out what you’re best at doing and what you’re fair at doing so you can not only streamline your work, but so you can also make sure you’re maximizing the amount of time you’re spending working on things that you enjoy the most.

So how are these related?

Continue reading

Refactoring Input Sanitization with The WordPress Settings API

This post is part of a series on Sanitization with the WordPress Settings API. Here is Part 3.

In continuing to work on sanitizing arrays of input with the WordPress Settings API, there are two things that we need to do:

  1. Refactor the existing code that we have so it’s as clean as possible
  2. Determine what fields we’re going to use to mark as required

In this particular article, we’re going to focus on both. This particular article is going to include the code necessary to tighten up our existing code and then we’ll begin laying the ground work for introducing a new class – a validation class – when we begin looking at the second step.

Continue reading

On Pause: The WordPress Settings API

This post is part of a series on Sanitization with the WordPress Settings API. Here is Part 2.

Whenever we’re in the process of teaching a new idea to someone – be it if you’re a teacher, a TA, maybe a professor (I have no idea what this is like) – I’ve found that it always helps to take the approach from the absolute base case and then work up to something more advanced.

In the series on the WordPress Settings API that I’m currently working through, that was the plan; however, after last week’s final set of comments, I think the series is either going to be a little bit longer than expected, or is going to result in more questions than expected.

This is a good thing – the comments I received thus far ended up pre-empting some of the material that I was going to cover.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑