As a WordPress developer, I deal with lots of code indented with tabs (rather than spaces). By default when viewing these files in GitHub, each tab is rendered as 8 spaces. On my personal machine, I render each tab as 4 spaces. This difference makes it less pleasant to view code in GitHub, however, I just learned I can set my preferred tab rendering in GitHub!
Programming
Git Rebase and the Multiverse
In “Git Merge and the Multiverse” I looked at merging branches and how sometimes this results in a fast-forward merge and sometimes in the creation of a merge commit. Now let’s look at Git rebase (a.k.a. the power to rewrite history).
Git Merge and the Multiverse
If you’re a fan of science (or science fiction), you may be familiar with the concept of the “Multiverse”, the idea that there are multiple universes. In some science fiction stories, one universe can split, branching into multiple universes and then later collapse into a single universe, this is a surprisingly good analogy for Git and branching.
WordPress Multisite Skip Confirmation Email
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.
Why PHP require autoload.php should be wrapped in is_readable()
When using Composer for PHP class autoloading, it is a good practice to wrap your require statement with an is_readable() check. Here are some notes on why this is an important thing to do.
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.
How to Run Code in the Browser Console
As a developer, a trick I often use is running some JavaScript directly in the browser to confirm the behavior.
Prevent Dragging an HTML Element
Sometimes users accidentally drag an HTML element into an editable area. This can be prevented by adding draggable=”false” to the element.