WP’s Backbone-like Templating Language

In yesterday’s post, I talked about fixing up old PHP code to be safer.

There’s another anti-pattern common in old PHP code, and that’s mixing the display logic with the output logic. While some of this is inevitable, nowadays, the rule is to use a templating system like Twig to separate out even small bits of HTML code from the logic.

WordPress does this on the front end via Underscore templates, but configured to use Handlebars-like syntax.

This is a PHP class that does the same thing with PHP. I wrote it so I could use the same, or similar, templates on both the client and server side.
Continue reading WP’s Backbone-like Templating Language

WordPress Customizer, Selective Refresh and Partials for Multiple Settings

There are several good references about how to set up the Customizer to avoid refreshing the entire page with each change. There’s one here, and there’s some deeper explanation here. What’s not described much is how to map several settings to a single area of the page (called a Partial).

This tutorial will go into updating Partials that use several settings. I assume you have already done the other tutorials.
Continue reading WordPress Customizer, Selective Refresh and Partials for Multiple Settings

/etc/resolv.conf, resolvconf, NetworkManager (and systemd-resolved?) Not Working

I ran some updates, and the name service stopped resolving. My LAN has a local nameserver to resolve domain names for virtual machines.

It turns out the /etc/resolv.conf file was overwritten, and a program called resolvconf had taken it over. resolvconf centralizes updating the resolv.conf file from several different programs that might want to change the file, like NetworkManager, ifup, ifdown, and dhclient.

There are a couple fixes. The one I chose was to replace resolv.conf.
Continue reading /etc/resolv.conf, resolvconf, NetworkManager (and systemd-resolved?) Not Working