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?

Read More

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.

Read More

Easier Excerpts 1.5.0

Just shy of two years ago (almost to the day, even), I first released Easier Excerpts for WordPress. It was, and still is, one of those plugins that I built for myself and ultimately decided to release for others to use.

It’s small and serves a very small improvement to the excerpt field in the post editor, but it’s something that I still use every day.

But over time, WordPress changes and improves, one’s ability to write code and build their tools changes. And that’s a lot of what went into this particular version.

Read More

Developing Plugins and Themes Against WordPress Trunk

When developing plugins or themes for WordPress, one of the strategies that I often recommend is doing so against trunk (or the current snapshot of the code) of WordPress.

For those who are more experienced developers, you’re already on the up-and-up on the lingo and the caveats that come with doing this. But if you’re someone who is looking for ways to better their development practices, then perhaps this will help.

Remember that because WordPress is open source software, you can view the source code on the web at anytime.

Developing Against WordPress Trunk: trunk

Not only that, but you can download it to your local computer and work with it, as well. This will require certain pieces of software, and I’ll get into that momentarily; however, the ultimate purpose of this post is to talk about:

  • how to work with the current snapshot of code with WordPress,
  • how and why it may be beneficial to use this codebase when working on projects for others.

As stated above, there are caveats for doing this, and sometimes it’s a good idea to use the latest stable version of the codebase. And I’ll address that later in the article, as well.

Read More

Installing PHPUnit in Visual Studio Code

Once you’ve got the PHP Coding Standards set up in Visual Studio Code, I think it’s also important to make sure that you have PHPUnit installed so that you get in the practice of writing testable code.

If you wait to start doing this until after you’ve started a project, you’re far less likely to start doing it. I’m saying this both from experience and from working with other developers.

So before I start covering how to handle front-end linting and things like that, I want to walk through the process of setting up PHPUnit. If you’ve not yet read how we’re managing packages or how we’re using Visual Studio Code, I recommend catching up by reading the following articles:

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

Once you’re caught up, head back to this post.

Read More