When creating a new user on WordPress multisite there is a “Skip Confirmation Email” checkbox that is unchecked by default. This unchecked box results in a user being added to a temporary “signups list” when they are added to the site. The user is not fully added to the site until they complete the confirmation steps in the email they receive. For many sites, it is preferable to check this “Skip Confirmation Email” when adding a user. With some code you can set this checkbox to default to checked.
WordPress
How to Close and Re-Open WordPress Gutenberg Sidebar
The sidebar gets a lot of use in the WordPress Block Editor, a.k.a. Gutenberg, but I found myself in a situation where I needed to programmatically close the sidebar and then re-open it later. This is how I did it.
Get Last Modified Value of a WordPress Post
When reading an article online, I find it helpful to know when the article was last updated. Not all blogs display the last updated value however even when the last updated value is not displayed, the value is accessible via the WordPress REST API. This is how I retrieve the last modified value from the WordPress REST API.
Change Render Size of Featured Image in WordPress Gutenberg Block Editor
In the WordPress block editor (a.k.a. Gutenberg) the “Featured Image” is rendered at the WordPress ‘large’ image size by default. By adding a WordPress JavaScript filter to the ‘editor.PostFeaturedImage.imageSize’ hook, we can change this default rendering.
WordPress View Block Attributes
When developing a WordPress plugin that creates a Gutenberg block, it is invaluable to be able to view the attributes on the block. Here are some tricks I use to view this information.
trailingslashit() vs untrailingslashit()
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.
WordPress Gutenberg Trigger Autosave
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.
WordPress Gutenberg Notice in JavaScript
You can display four types of notices in the WordPress Block Editor (a.k.a. Gutenberg) using JavaScript: error, warning, info, and success. This blog post contains an example of each.
Disable Core WordPress Update Notice
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.
Display Keyboard Shortcut in WordPress Gutenberg
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.