Tom McFarlin

Software Engineering in WordPress, PHP, and Backend Development

Page 78 of 427

A Quick Note on Unit Testing Code in WordPress Projects

The more work I do in WordPress, the more I try to make unit testing as much a part of my development as building out the actual feature set. (It’s what all the professionals say we need to do, anyway.)

But seriously, it does improve the quality because, if for no other reason, something breaks, you’re able to see which test fails or even if you’ve missed coverage in some area.

I’m not of the mindset of some that you have to have 100% code coverage (and there are reasons for why I think this), but I do think it’s important to have as much code coverage as possible of code that is not directly to WordPress.

Continue reading

Resizing Images Programmatically in WordPress

If you’ve ever had to work with resizing images programmatically in WordPress, then you may have come across the image_resize function.

Resizing Images Programmatically: Deprecated Functions

Further, you may know it’s been deprecated (given that this appears at the top of the screen):

This function has been deprecated. Use wp_get_image_editor() instead.

And with its deprecation, as is true of all those who do a good job deprecating functionality, it’s not without its replacement.

In this case, we’re talking about the WP Image Editor. This is a class in WordPress that we can use to perform the same operations to go about resizing images programmatically that we once could with the original function.

Continue reading

Databases and Tools for the Independent WordPress Developer

Admittedly, the last post in this series was quite long. However, that’s not going to be how the overall series of posts articles are going to go.

Preparing a development environment is arguably one of the largest steps required, thus the need for having a lengthy, detailed guide for how to do it.

Remember that WordPress is a database-backed PHP-based web application.

This is all jargon for basically saying that it’s an application primarily written in PHP that needs a database to store its information.

As of the last post, we have the web server and PHP installed and set up, but we’re still missing the database. Luckily, the last post laid the foundation for what we need to get the database installed, set up, and ready for a local WordPress installation.

Independent WordPress Developer: MySQL Version

In addition to covering how to do that, though, I’m also going to outline tools that I find immensely useful when it comes to working with databases on your local machine.

Recall, though, that this series of articles is not meant to be theoretical, but practical. Furthermore, it’s meant to get you from having nothing to having everything you need to build high-quality, WordPress-based products in as little time as possible.

It just so happens that a lot of this time is spent getting the local development environment set up.

With that said, let’s continue and focus on what’s required to get the database set up and with how we can interact with the database server to begin creating what we need for our local WordPress installation.

Continue reading

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

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑