Why are major WordPress plugins not bothering to fix their numerous PHP 8.1 deprecation notices?

I’m an early adopter for a lot of things, but new versions of PHP are generally not one of them. PHP 8.1 wasn’t really on my radar until I set up a new server running Ubuntu Linux 22.04, where PHP 8.1 is the default version.

Yeah, I’m a commercial WordPress plugin developer too, but my business is small. It’s easy to understand me not being 100% on top of this.

What I do not understand is how huge WordPress plugins like Jetpack, WooCommerce and Wordfence can get away with not being on top of it.

The general response these developers are giving when questioned on this is, “they’re only deprecation notices, everything should still be working.” Which is true.

But.

Are you a developer? Do you ever need to turn debugging on? Have you seen what happens when you have multiple plugins active, each of which generates 5-10 PHP deprecation notices on every page when debugging is turned on?

Aside from making the site, and especially the WordPress backend, borderline-to-entirely unusable (which, honestly, is a bigger problem than what I’m about to say), it also makes normal debugging impossible. It’s hard to find real issues when you have to wade through more than a screen’s worth of irrelevant deprecation notices. And the sheer volume of the notices breaks page layouts to a point where it’s impossible even to know what is or isn’t broken.

I actually blame PHP for this. I don’t know what they were thinking with some of these changes that are triggering all of the deprecation notices. I know “real” programming languages aren’t as loosely typed and lenient with sloppy coding as PHP is, but… well, it’s kind of too late to put that genie back in the bottle. I haven’t bothered to investigate exactly what the rationale is for no longer allowing null input to string handling functions. What I do know is that there’s a ton of code out there, written by competent, experienced developers, that is now triggering these warnings, because until now it was always fine to equate null and an empty string.

Anyway, principled arguments aside, I have a more practical frustration to deal with right now… I’m finding it hard to do my work, because other people haven’t done theirs.

Dolby Atmos through MacBook Pro speakers: DO NOT WANT

What are your thoughts on Dolby Atmos?

More specifically: what are your thoughts on Apple Music automatically playing songs in Dolby Atmos through laptop speakers?

My MacBook Pro has pretty great speakers (for built-in laptop speakers). I’m sitting here listening to Talking Heads’ Fear of Music, and I could tell immediately that there was some kind of surround effect going on. It was very disorienting — it created a physical sensation in my ears and almost started to give me a headache. Then I realized I could turn it off and instantly everything went back to normal.

I’m not entirely sure what kind of dark magic Dolby is employing with this (I’m sure it has something to do with reversing the polarity of the stereo channels or something nerdy like that), but I don’t understand why it’s being foisted upon us. It reminds me of the trend about a decade ago of every movie being made in 3-D, and even 3-D TVs that no one wanted. Eventually they caught on to the “no one wanted” part and now it’s not much of a thing. I hope Dolby Atmos on streaming services follows in short order!

Related: Why Your Atmos Mix Will Sound Different On Apple Music

You’re never too experienced to make a boneheaded mistake, especially when the action that initiates it looks extremely benign

A big scary warning message

That warning bar doesn’t exist. But if it did, I maybe wouldn’t have made the stupid mistake I made on Sunday morning.

The big mistake was actually the result of my hasty efforts to patch up a much smaller mistake. As it goes.

I had mistakenly deleted a bunch of WordPress themes on a multisite (but not Multisite; the difference is worth discussing in more detail at a later time) installation that Sara and I use for all of our blogs — including this one.

I didn’t want Sara to see that her themes had been trashed, so I quickly logged into my Digital Ocean account and attempted to restore a copy of the latest backup of the server. My intention was to spin up a new copy of the server, from the most recent backup, go in there to grab the theme files I had accidentally deleted, copy them into the live server, then destroy that temporary copy of the server.

Here are the options I was presented with:

Given that menu, what would you do? Never mind the fact that I’ve been a Digital Ocean client for over a decade and have dealt with this exact menu numerous times before. I should have known better. But I was in a hurry and not thinking clearly.

Did you select Restore Droplet? Congratulations. Just like me, you have now destroyed the live server.

Maybe all of this wouldn’t have been so bad, but the weekly backups on this particular server take place on Monday nights. Which means we were working from a 6-day-old backup. And wouldn’t you know it, both Sara and I (but especially Sara) had been unusually active on our blogs this past week.

So yeah, I clicked Restore Droplet, which immediately, without any additional warning or confirmation, completely and permanently wiped out the live version of the server and replaced it with the contents of that 6-day-old backup. A week’s worth of blog posts and site edits, vaporized with absolutely no possibility of recovery.

What was the correct action? As I already knew, it was to select Convert to snapshot, then navigate in the side menu to Snapshots and from there, create a new “Droplet” (Digital Ocean’s term for a virtual private server) from the snapshot. As I said, I’ve done this exact process many times over the past several years, when a client accidentally deleted something and I needed to help them recover it.

Ugh.

Anyway… if this blog happens to have any keen observers, you/they may have noticed that the two most recent blog posts had disappeared. No, this was not intentional. And they are gone forever. Fun.

Update: According to Digital Ocean support, the Restore Droplet option does present an additional warning before continuing, but (in my opinion) it is not nearly aggressive enough to make you stop what you’re doing if you’re being hasty like I was.

Making Bootstrap work with the WordPress Block Editor

tl;dr: You need to load Bootstrap’s CSS in the 'wp_enqueue_scripts' hook with a priority lower than 10.

Where do I begin with this one? First, some foundational details: I’m old school. I’ve been a professional web developer/designer since 1996. I’ve embraced new technologies as they come along, but I tend to bristle at things that are either a) not an open standard or b) need to be compiled.

I refused to use Flash. In the end I was proved right, as open web technologies supplanted it. Flash is dead, and the open web is not. I still refuse to use CSS preprocessors for a similar reason. They’re a non-standard workaround to limitations in the current standard. They fragment the landscape instead of pushing the standard forward. And as CSS variables have gained wide browser support, preprocessors are beginning to look as pointless as Flash.

Now the thing I hate is npm — or any similar tech that requires me to run shell scripts and compile anything. I’ve long since embraced server-side scripting, using open source libraries like jQuery, and even using a pre-built CMS (or CMS-ish system) like WordPress. (Yes, for many years I rolled my own CMSes.) The bottom line for me is, if it’s code I can download simply and treat as a “black box,” fine. But if it’s something I need to get my hands dirty in, I shouldn’t need anything to work with it but a text editor.

All of that to say, I am having a bit of a time with where things are going these days with Gutenberg, a.k.a. the WordPress Block Editor. And I haven’t exactly been quiet about it here.

This week I needed to extend the Block Editor by creating a carousel/slideshow block. Yep, I’ve rolled my own with these for many years as well, but this time around I decided I wanted to work with something pre-built, so I settled on the one in Bootstrap. I don’t really need all of Bootstrap (although I suspect over time I will need more of it), but customizing it requires using npm, so I decided to go ahead and include the entire pre-compiled package in my theme.

That’s when the problems began.

Oh, the carousel works great! But I spent a bunch of time yesterday trying to figure out why the custom background color and fonts defined in my theme.json file were being ignored… especially since they’re right there in the inline CSS inside the <head> of every page.

Don’t even get me started on inline CSS, or the way so many people in the industry seem to worship PageSpeed Insights. Once again we’re skating to where the puck is, instead of where it’s going, and to stretch the analogy to the limit, we’re melting all of the ice in front of it too. This is not the way to move web development forward intelligently.

Ah-hem.

Eventually I worked out what’s happening. WordPress, historically, was designed to allow you to define dependencies, so you could load CSS and JavaScript in a logical manner. Gutenberg/Block Editor throws all of this out the window with this inline CSS. Certain “critical” inline CSS for the Block Editor gets loaded immediately regardless of the dependencies you put into wp_enqueue_style(). The result being, styles defined (indirectly, in a way more convoluted way than vanilla CSS) in my theme.json file were appearing before the Bootstrap CSS file was loaded. And since I’m using the compiled Bootstrap instead of a custom npm build, there’s a bunch of “general” CSS it’s throwing in, including color and font definitions on the <body> tag that override Gutenberg’s earlier inline CSS.

Fortunately, someone else had the same problem and figured out a solution. But since, in 2022, spammers overrun any forum thread that’s left open too long, the thread was already locked and I couldn’t express my appreciation to the poster who shared it. So I’m writing this blog post instead.

The trick is to load any third-party CSS that you might need to override using a separate function called on the 'wp_enqueue_scripts' hook, with a low priority number (less than 10, since that’s the magic default).

Here’s a generalized version of the code I’m using:

function my_enqueue_scripts_early() {

    $ver = '1.0.0'; // Your theme version; could also be a class property, constant, global variable, etc.

    wp_enqueue_style('bootstrap-style', get_theme_file_uri('vendors/bootstrap/bootstrap.min.css'), array(), $ver);
    wp_enqueue_script('bootstrap', get_theme_file_uri('vendors/bootstrap/bootstrap.bundle.min.js'), array('jquery'), $ver);

}
add_action('wp_enqueue_scripts', 'my_enqueue_scripts_early', 8);

Is T-Mobile bypassing local ad blockers when using your hotspot?

I hate online ads.

That could be the end of the post, but sadly it’s not.

I understand that sites need ad revenue to function. But the online advertising ecosystem is so fundamentally broken that I refuse to participate in it, even to the detriment of the sites whose content I value. It’s possible to run a sustainable business through ads without ruining your site visitors’ experience.

There are various tools you can use to block the most obnoxious ads, but I’ve taken a very direct, hands-on approach. I’ve actually taken the time to view source on sites I visit that go overboard with ads, identify the domain names of the ad servers, and add them to my Mac’s /etc/hosts file so they resolve to localhost (127.0.0.1), effectively killing any ads from those sources.

And it works. I often see “broken image” icons, but all of those hideous animated ads screaming at my eyeballs are gone.

Except when I’m tethering to my phone’s hotspot.

Somehow, when I use my T-Mobile hotspot instead of my home wifi, all of those ads come flooding back. What. Is. Happening.

The only explanation I can think of is that T-Mobile is somehow using a proxy to bypass my local hosts file, but I though the local file always trumped anything else.

I don’t have an answer. But I don’t like it. And perhaps more importantly, if T-Mobile is doing this, what else is it doing with the data I’m sending and receiving over its network?