PHIL KURTH

Email

October 2019

A PHP class for dumping data to a separate log file

Debugging can be a lot simpler with a nice set of tools. Ideally, breakpoints and stepping through code is the way to go but sometimes it is nice and easy just to dump stuff somewhere. Dumping to the DOM is usually fine but can obviously cause problems on the page render and it can be […]

October 2019

Use curl on the command line for some quick information on a URL

One neat trick I use a fair bit is hitting URLs on the command line using curl. The most common use case I have for it is checking redirects but if you start using the command you’ll see there’s actually a fair bit of information handed back to you when you type the following in […]

October 2019

Simplify WordPress updates using these sequential WP CLI commands

Updating WordPress can really start to grind on me. Everyone is constantly releasing updates for their plugins and the core team are pushing to release more and more core updates all the time. Seeing the update notification can be a real bummer. So, to keep it easy, I just bang through all updates using a […]

October 2019

How to set defer or async attributes on enqueued script tags in WordPress

If you get down to business with performance optimisation, you could find yourself looking at ways to defer your scripts or even load them asynchronously. As far as I’m aware, WordPress’ built-in functions wp_register_script() and wp_enqueue_script() don’t currently take arguments for defining these attributes. But, with WordPress being WordPress, there is usually a way and […]

October 2019

Working with empty jQuery objects to build dynamic selectors

This is one of those techniques that you don’t really think you need until you find yourself in a situation where you do. This definitely isn’t a hammer and more often than not, you can select what you need in a single selector via jQuery or through the use of the built-in .filter() method but […]

October 2019

How to customize the colour palette for WordPress’ Gutenberg block editor

Building on yesterday’s tip, I’m putting this up to show how easy it is to register a custom colour palette for WordPress’ block editor; AKA Gutenberg. It’s actually something we can register as a theme feature so it’s all doable on the PHP side and is very straight-forward. Here’s the code you need;

October 2019

How to customize the colour palette for ACF’s colour picker field

Ever found yourself wishing you could define an exact colour palette for ACF’s colour picker field? Good news! You totally can. Using the JavaScript API built right into Advanced Custom Fields we can use a very small snippet of code to specify exactly which colours appear in the palette of suggested colours. Now, in this […]

October 2019

Cache jQuery selectors for more efficient JavaScript

Having worked in collaborative and team contexts, I’ve had my fair share of situations where I’m working in amongst someone else’s code. There are plenty of things I could gab on about but one issue I commonly see is duplicate jQuery selectors. Now, for really small scripts, duplicate selectors won’t cause you much heartache. However, […]

October 2019

Customise ACF’s WYSIWYG field toolbars for a simpler admin experience

The ability to control exactly what buttons are available in a WYSIWYG field is a really neat point of customisation available in Advanced Custom Fields. The WYSIWYG field is definitely convenient but I often find myself needing to use it for no other reason than the most basic of formatting. Leaving too many options in […]

October 2019

Use WP CLI to tinker with your codebase via an interactive shell

If you have access to WP CLI I can’t recommend it enough. Since I picked it up it has saved me so much time during development. It helps me scaffold code, analyse the installation, update core and plugins, and it even helps me test code on the fly. Testing code on the fly with wp […]