Software Engineering in WordPress, PHP, and Backend Development

Author: Tom (Page 77 of 427)

Split Strings and Integers in PHP Using Regular Expressions

Working with strings, numbers, and regular expressions in PHP is relatively easy given the vast number of functions the language provides.

There are times, though, where figuring out how to split on certain criteria may not be immediately clear, or it may be clear what you need to do but not how to best do it.

Split Strings and Integers in PHP Using Regular Expressions

Photo by Agê Barros on Unsplash

For example, let’s say that you have a string that’s mixed with both numbers and digits. For this post, let’s say that a given string:

  • includes hours and minutes,
  • when the minutes are at 60,
  • the string should increase the value of the of the hours by one
  • the value of the minutes is reset to zero.

An example, problematic string, then, may be of the form T3H60M. How then might we split the string into strings and integers and properly rebuild it?

Continue reading

Installing WordPress for Local Development

So far, we’ve covered some things all of which lead us in setting up our local development environment. If you’ve not yet caught up, I recommend reading the previous articles:

  1. Local Development for the Indie WordPress Developer
  2. Databases and Tools for the Indie WordPress Developer

In the final article, I state the following:

Next, it’s time to get WordPress installed. It’s extremely easy, so if you’ve come this far, I’d state with confidence that the toughest part is over.

This is usually the easiest part (really), but there are two ways in which you can manage this, and I’m going to cover both. For those curious, it breaks down like this:

  • installing the latest stable version of WordPress,
  • installing the most recent nightly build of WordPress

There are reasons that you may want to use one versus the other. I tend to favor the latter when building out my own solutions for reasons I’ll cover later in the article but note that both of the above are covered in this post.

So with that said, let’s get started.

Continue reading

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

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑