Software Engineering in WordPress, PHP, and Backend Development

Category: Articles (Page 65 of 258)

Personal opinions and how-to’s that I’ve written both here and as contributions to other blogs.

Writing Unit Tests with PHPUnit, Part 1: The Set Up

Earlier this month, we began looking at installing PHPUnit in Visual Studio Code with the ultimate goal of learning how to write unit tests for our WordPress-based projects.

To that end, this post assumes that you’ve read the following posts and it assumes that you’ve caught up with a handful of previous posts:

  1. A WordPress Development Environment (Using a Package Manager)
  2. An IDE for WordPress Development
  3. Working with User Settings in Visual Studio Code

And, of course, installing PHPUnit in Visual Studio Code as linked above. Once that’s done, we’ll be ready to proceed. But one thing to keep in mind is that this will night be a traditional or a comprehensive course in writing unit tests.

Intalling PHPUnit in Visual Studio Code: Installing the PHPUnit Extension

Instead, it’s all about writing unit tests for WordPress projects.

Continue reading

How To Remove Special Characters from Permalinks

Whenever you’re working with WordPress and third-party APIs, there’s always a chance that you’re going to run into issues where the third-party API is not prepared to handle certain characters that exist in a permalink.

Depending on one’s permalink settings, though, this may or may not be an issue. For example, you may have your permalinks set to something like ?p=123 for each post. In that case, it’s not much of an issue.

But if you’re using “pretty permalinks” and your permalink includes something like a trademark symbol or a copyright symbol, then it may cause problems whenever you’re communicating with said third-party API.

Continue reading

Removing Duplicate Items with JavaScript

As ES6 becomes more and more popular in web development, we’re likely going to be seeing – and writing – less code using other libraries. When it comes to WordPress, jQuery is still very common.

Personally, I don’t think there’s anything inherently wrong with using jQuery (though you might not need it) but I also think it’s important to keep your skills sharp and up to date with newer technologies.

Removing Duplicate Items with JavaScript: You Might Not Need jQuery

But learning to write ES6 code is not the purpose of this post, nor is how to achieve something using ES6.

Instead, it’s still about WordPress and jQuery. I’ll come back to ES6 at the end of the post. One of the things I’d love to cover, though, is how to remove duplicate items from a list with a common property.

Continue reading

Gracefully Handle PHP Version Support in WordPress

As long as I’ve been working with WordPress, the conversation (and I do use this term loosely) around what versions of PHP it should or shouldn’t support has been ongoing.

  • The short of it is that some see it as an application as large and popular as WordPress that powers so much of the CMS-based websites should be able to use its clout to foster more innovative solutions.
  • Others see that people don’t often upgrade, are on budget hosts, or simply do not care (let alone bother to know) what version of PHP they are running.

These two points could yield a post and comments for days, but I’m not interested in that. Because my team and I are the business of building custom solutions for others, we have the flexibility of taking stock of where the users host their site or application, deploying it, and leveraging features of PHP offered by their hosts.

There are, however, times where I’ve encountered some people running versions of PHP as low as 5.3.

So what then?

Continue reading

How To Set Up JavaScript linting in Visual Studio Code

I’m obviously a big fan of using coding standards whenever you’re writing server-side code (regardless of it being WordPress, PSR2, or whatever else – as long as you’re using something, I think it’s a good thing).

But when it comes to writing client-side code, namely JavaScript for this post, we don’t see it discussed as much though I think of it as being as equally important. Same goes for CSS, Sass, or LESS, but that’s content for another post.

For recent projects, we’ve been using Airbnb JavaScript Style guide for our projects. I’m a fan and think it helps to write clean, readable JavaScript (that looks as if it’s been written by the same person – the ultimate goal of coding standards, right?).

JavaScript linting in Visual Studio Code: Airbnb Styleguide

In this post, I’ll walk through the process of getting it setup in Visual Studio Code.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑