Using Gutenberg blocks in place of custom metaboxes in WordPress

Custom metaboxes are used extensively in WordPress for layout purposes as well as data structure. However, they don’t necessarily — in fact they rarely — save to the meta key’s array of objects when they’re added to the WordPress REST API and can’t be used by Gutenberg’s built in meta attribute.

How can we use Gutenberg with them? Should we look at how they work now and replicate that functionality exactly? It’s necessary to keep in mind that this data will be edited in the context of the editor where the user has no knowledge — and cannot be expected to need any knowledge — of how the data is stored or managed.

Continue reading “Using Gutenberg blocks in place of custom metaboxes in WordPress”

register_meta(), register_rest_field() and the WP REST API

There are two standard ways to add additional data into a post’s object in the WP REST API: register_meta() for post meta which is a string, number or boolean and register_rest_field()for everything else. There’s a bit on the difference between the two in the REST API docs. With Gutenberg, register_meta() is being used more widely and there’s some confusion about it, so let’s look at both in a little more depth.

Continue reading “register_meta(), register_rest_field() and the WP REST API”

Iterating over an array of objects which I desperately want to be reactive in Vue.js

[a note to my future self from my current self as of 17 April 2018: are you here again? Is there definitely a unique key on that loop? Are you sure? GO PUT ONE ON NOW. Use the uuid package, it’s easy. Then come back if it still doesn’t work.]

This took me a while yesterday to figure out. There were a couple of issues I had: how to keep the individual items reactive (spoiler: easy once I stopped being lazy) and how to make an array of objects reactive.

Continue reading “Iterating over an array of objects which I desperately want to be reactive in Vue.js”

“This block has been modified externally” notice of death in Gutenberg

This notice drove me insane, especially because I couldn’t quite figure out what was being compared. It turns out it’s that the save function in registerBlockType() compares its return value to whatever is between the block’s html comment tags in the database.

Continue reading ““This block has been modified externally” notice of death in Gutenberg”

The Mandelbrot set visualised in golang

[note on 07 April 2018: I wrote this in late September 2017 but never published it. I think it’s not finished but useful up until that point so I’m publishing it now]

This is a deeper dive into the Mandelbrot exercises in Chapter 3 of The Go Programming Language (Addison-Wesley Professional Computing Series) (that’s an affiliate link because I was going to link to it anyway so why not). Chapter 3 in the book deals with data types and the examples illustrate the various effects of using different types but I’m not going to go into those, instead I’ll work through the details of generating an image of the Mandelbrot set point by point.

Continue reading “The Mandelbrot set visualised in golang”

Using Select2 with ajax with CMB2 repeating groups

No idea if the title makes sense. I wanted a Select2 which uses a remote data source queried via ajax with a CMB2 repeating group so made a plugin to understand it better. It’s pretty heavily commented so I don’t forget why I did what I did. There are definitely a few if not many ways to do this, this is not the definitive guide.

Continue reading “Using Select2 with ajax with CMB2 repeating groups”

Bulk deleting users in WordPress multisite

So I have over 10,000 spam users and need to delete them1. The bulk delete in multisite only does 20 at a time and is somewhat slow so I wanted a better way to delete them all. This could be a massive mistake, if you are reading this because you need the same thing, you absolutely must thoroughly test it to see if it works for you. It’s unforgiving.

Continue reading “Bulk deleting users in WordPress multisite”

Gutenberg wish list

Ok, this is without really looking at it so maybe it has these.

  1. identifiable non-global blocks (so not these: because I want to maybe use postmeta with a block? I don’t know, I have this vague idea that I’m too lazy to articulate atm. ok this wasn’t bad, I’ve done this.
  2. the ability to limit blocks shown
  3. the ability to make templates which need to be filled in so the author has to stick to the blocks in the editor and can’t add or remove or whatever

These are mine. You might have different ones.  ☺️

edit (same day, a few hours later): Look at this for numbers 2 and 3 in the list! Whooo!

Improving Gravatar (the service)

The problem:

Gravatar hashes are somewhat easy to crack. Websites are super easy to scrape. Sites with Gravatar urls in the img-src or profile link make it trivial to generate lists of hashes to crack. Other data available on sites and in Gravatar profiles can be used to generate targeted wordlists which make cracking a large proportion of the hashes much quicker, in seconds rather than days.

Continue reading “Improving Gravatar (the service)”

Windstream compatible modem for a non-bonded connection

When my Windstream modem was repeatedly power cycling when trying to connect, tech support said this was the modem letting me know it was damaged and needed to be replaced. They offered to rent me a modem for $10/month but oh my god no, why would I do that? This one lasted me over 10 years.

Continue reading “Windstream compatible modem for a non-bonded connection”

A Slack bot that gets the last three posts from a WordPress site

This Glitch project grabs the latest three posts for WordPress sites which are using either the WP REST API or the version via Jetpack. It uses MongoDB for persistence. It’s not super exciting or well written but a fairly effective way to mindlessly try sites on Slack and see if they have the WP API somewhere when you’re a bit bored. (Try Glitch. It’s fun.)

Keeping your email address safe on Gravatar enabled sites (or if you don’t know if it is or not)

Do you consider your email address to be private information but use it to register and comment on WordPress powered sites? Many WordPress sites use Gravatar to provide the avatars on comments and user lists and this can be an issue if you do.

Continue reading “Keeping your email address safe on Gravatar enabled sites (or if you don’t know if it is or not)”

How does WordPress know if a pending post hasn’t been published yet?

If WordPress has a newly created pending post, when you publish it the timestamp on the post is set at the time of publishing. If you publish a post, then set the post status to pending, the timestamp does not update when you re-publish it. How does it know? And why does it matter?

Continue reading “How does WordPress know if a pending post hasn’t been published yet?”