Software Engineering in WordPress, PHP, and Backend Development

Author: Tom (Page 78 of 427)

Using Nullable Return Types in PHP

“One of the nicest features that PHP affords is type hinting specifically for those who are coming from an object-oriented programming background.

From the PHP manual:

Type declarations allow functions to require that parameters are of a certain type at call time. If the given value is of the incorrect type, then an error is generated: in PHP 5, this will be a recoverable fatal error, while PHP 7 will throw a TypeError exception.

The reason this is important is because it gives people who are going to use your code – specifcally those who will write code against your code – what types of parameters a given constructor or function will accept.

But there’s more to it than that because type hints are also applicable to the type of data a function can return.

Continue reading

The Demand for Gutenberg Is Not There. Yet.

I’ve been asked, on a few occasions, why I’ve not released anything that’s compatible with Gutenberg or why certain plugins aren’t compatible with the current version of the Gutenberg plugin.

Demand for Gutenberg Is Not There

In the WordPress economy, I’ve seen few things as divisive as this shift in WordPress (though it seems to be finally have chilled a bit). And I’m not interested in entertaining a position on it on this blog.

But when others ask why I’ve not bothered to write anything about it or make certain plugins compatible with it, I find that it’s worth talking about it at least to a certain degree.

Continue reading

Local Development for the Independent WordPress Developer

Last week, I said that I was going to be writing a series of posts explicitly focused on practical tools for freelance WordPress developers who are looking to improve their skills.

Specifically, I will be writing about the tools, processes, and more for the Independent WordPress Developer. Thus, the goal is to provide a series of content geared towards those of you who are freelancers or who work on a team of one but are looking to apply repeatable, solid tools and practices to your workflow.

In other words, it’s about using a set of tools designed to help you create the best solutions possible for your customers (and doing so with next-to-nothing in overhead cost).

The challenge that comes with doing something like this is two-fold:

  1. It’s a lot of content,
  2. There’s a [small] learning curve.

So, yes, technically you can go to different sites or areas and learn bits and pieces about these things, but the goal of the upcoming series of posts is simple:

Focus directly on the independent WordPress developer and do so in a practical, easy-to-understand, applicable way.

And that’s what I’m planning to do in the series starting today.

Continue reading

What’s The Simplest Thing That’s Needed?

There’s a quote often attributed to Albert Einstein that I quite like (and I’m sure most do):

Everything should be made as simple as possible, but no simpler.

There is some investigation as to if he said it or not, but the point remains regardless of who said it.

The Simplest Thing Possible: And No Simpler

It’s easy to take this idea and apply it to things that we do in everyday life that we don’t want to do, right?

  • I don’t want to clean my room, so I’ll tidy it up just enough.
  • I’ll do just enough work to satisfy the clients, and that’s enough.
  • I’ll fulfill [whatever responsibility] the to [lowest degree possible] and because Einstein [allegedly] said it, who am I to argue.

Even though I don’t agree with it (and the discussion for that is outside the scope of this post), I do consider this idea within the context of web development.

And to be clear, I’m not talking about web design. I’m not a designer. I don’t want to speak on behalf of something of which I’m not a part. But regarding providing solutions for people using software or, rather, web development, I’m far more inclined and positioned to talk about this.

Strictly speaking, I find myself often wondering if we’ve made web development more complicated (and why we’ve done so) and if using the simplest thing that’s needed is all that’s really needed when building solutions for others.

Continue reading

Sanitizing URLs in WordPress with Its API and Built-In PHP Functions

Working with user-centric fields in WordPress – such as input elements, textarea elements, or any type of field in which a user can supply their own values is a place that should always be a target of sanitization.

Sanitizing URLs in WordPress with Its API

Fortunately, the WordPress API provides a number of functions to help with this. Depending on your use case, you may need to do one of the following:

And those are all well and good but there are also ways in which you can work to sanitize the data using functions provided by PHP.

Sure, sometimes regular expressions are the way to go but, other times, you may want to use facilities that are built into the language, easier to understand, and easier to follow.

When writing my own code (and when reviewing others) I try to keep that in mind. So with that said, here’s a process that you can use that may make your efforts easier when working with URLs in WordPress.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑