Recently, I was working in JavaScript and I need to transform a date into the format YYYYMMDD, this is how I did it.
JavaScript
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.
WordPress Gutenberg import versus Destructuring Global wp
When creating a block for the WordPress block editor (a.k.a. Gutenberg), you are often using existing components. WordPress makes these components available under the global JavaScript variable ‘wp’ as well as available as npm packages. Which is the better way to make a component available in your code?
WordPress REST API call to Update Post Status Fails Silently
Recently, I was trying to update the post status of a post from ‘future’ to ‘publish’ publish` with the WordPress REST API and while the submission appeared to work, the value was not modified.
Test WordPress REST API Endpoints from the Browser with jQuery
You can make WordPress REST API calls from the browser console. Here is one way I work with WordPress REST API endpoints in the browser using jQuery.
Gutenberg JS
My notes on JavaScript available methods in Gutenberg.
Speed Up Video in Iframe
My wife has to watch some videos as part of an online course. These videos do not have speed controls, however she would like to watch the video at an increased rate (e.g. 1.5x the normal speed). The problem is the video appears in an iframe (which is in itself in an iframe) so targeting the video to change the speed with JavaScript is a little tricky. Here is how I did it.
WordPress JavaScript async defer
When loading JavaScript on a webpage with the “script” tag, there are additional attributes you can add to tell the browser how and when to load the JavaScript (‘async’ and ‘defer’). In WordPress, there is not a native way to add these attributes but this code snippet does the trick.
Introduction to Arrow functions
I’ve been spending more time working with modern JavaScript (including learning about arrow functions) and I wanted to make some notes here regarding arrow functions (since some details about them were not intuitive to me at first).
Why Learn jQuery
A friend of mine, who is not a developer by trade but deals with websites a lot, asked me recently about learning JavaScript. The short version of my recommendation is to learn jQuery. It is already installed on the sites he is working on and using it he can get results quickly.