WordPress has two functions that can be helpful when dealing with the final character of a URL, trailingslashit() and untrailingslashit(). I find it preferable to use untrailingslashit() for two reasons: 1. It does not break empty checks and 2. It makes my sprintf() statements more readable.
Recently, I was documenting the steps to reproduce a certain bug and the bug required the presence of an autosave (along with the “There is an autosave of this post that is more recent than the version below.” message). Rather than wait for an autosave to occur naturally, I wanted to speed things up and manually trigger one. This is the command I use to do that.
When working on projects, I often want to strictly control the version of WordPress that is running. However sometimes one of the other administrators on the site sees the “WordPress 5.9 is available! Please update now.” message and clicks it, thereby prematurely updating to a newer version of WordPress core. This notice can be disabled.
In Gutenberg (a.k.a. the WordPress Block Editor), keyboard shortcuts are displayed differently on Apple devices and other devices, e.g. ^H on an Apple device and Ctrl+H on other devices. This is accomplished with wp.keycodes.displayShortcut.
A common programming pattern when using WordPress filters is the early return pattern (also know as the “short-circuit” pattern). This pattern is useful when you want to allow a filter to override a value that is “expensive” to calculate.
When developing code related to the WordPress heartbeat, it is frustrating to make your code changes and then wait for the next heartbeat to occur. You can trigger the WordPress heartbeat in the browser manually to eliminate this delay.
While PHP namespaces allow you to refer to a function in file without using the fully qualified name, there is a catch when adding a WordPress hook or filter. The PHP __NAMESPACE__ magic constant can be helpful in this situation.
Recently on a project I wanted to migrate WordPress users with a certain role to a different role. This is the command I used.
The WordPress block editor (a.k.a. Gutenberg) communicates with the database via the WordPress REST API. We can read and write post meta from within the Gutenberg editor after we enable the specific post meta field in the WordPress REST API.