In English the rules we use for joining a list of items involves more work than a standard join in JavaScript. Here is JavaScript code to join an array of elements with commas and an “and”.
Dev Tips
Git alias to open Jira URL
As a developer, I spend a lot of time going back and forth between the command line and Jira tickets. I realized that since I always include the Jira ticket identifier (e.g. `sf-123`) in the branch name (in a reliable position), I could write a git alias to open the corresponding URL. This is how I implemented this behavior.
Why __() needs a hardcoded string in WordPress
When using a WordPress translation function, e.g. __(), you need to use a hardcoded string (not a variable).
JavaScript get Date in YYYYMMDD Format
Recently, I was working in JavaScript and I need to transform a date into the format YYYYMMDD, this is how I did it.
Code Standards Naming Styles
There are lots of ways to write variable names when programming. This is the list of ones I find myself using.
How to Add a Non-Breaking Space
A non-breaking space has a unicode value of `U+00A0` (a normal space has a unicode value of `U+0020`). This is how I add this character.
Add Gutenberg JavaScript Filter
WordPress PHP filters allow you make a value modifiable from outside of your code. With the WordPress Block Editor (a.k.a. Gutenberg), you can now do the same thing in JavaScript.
Revert to Old Version of WordPress Core
These are the two ways I have used to rollback WordPress to an earlier version. Using either technique, you should make a backup copy of your files and your database first!
Check WP_DEBUG
Recently I was talking to another developer about how to detect ‘WP_DEBUG’ being set on a WordPress installation. Here is the code I use.
Add a Blank line at the Beginning of Command Line Prompt
While there are many ways to customization your command line prompt, one that can help readability is adding a blank line at the beginning of each prompt.