Plugin: WordPress Gutenberg Hot Module Replacement Example

Gutenberg is coming to town, and we’re all excited to see what goodies we’re getting. Developing a Gutenberg block can mean a lot of page refreshing to see your updates to your interface elements. Here’s an example of how to use React’s hot module replacement for Gutenberg block development: no more death by a thousand cuts reloads.

Fork, create an issue or pull request on GitHub.

Plugin: Automatic submenu items

At some point our navigation menu started to mimic the hierarchical structure of the posts itself. Manually adding all items just seemed silly. This sounded like a good candidate for wp_list_pages(). Hardcoding the menu would mean losing flexibility, however. It would be nice if all child posts would be added automatically, with the option of overriding that behaviour by manually adding menu items.

With WordPress it’s like “Filter all the Things”, hence the Submenu 3000 plugin.

Continue reading “Plugin: Automatic submenu items”

Sublime Text Plugin: WordPress Coding Standards whitelist flags

Update: The native WPCS whitelist flags are deprecated in v3.0.0 in favour of the PHPCS // phpcs:ignore format. The plugin has been updated to use that format in stead.

A Sublime Text 2/3 autocomplete plug-in for WordPress Coding Standards whitelist flags.
Install the plugin via Sublime Text’s Package Control by searching for WPCS whitelist flags.


An autocomplete popup will open when you type `wpcs` or `phpcs`.

Fork, create an issue or pull request on GitHub

Plugin: Prevent automatically attaching unattached attachments when inserting into post

In an effort to keep things simple for the user (and to separately store the post content and its images), we decided to automatically create an image gallery from all images attached to a post. To add an image to a post’s image gallery, the user just needed to upload an image to that the post, without inserting it into the post content. Voilá, great for product pages and such.

As things go it turns out that this makes it impossible super inconvenient to also add images, say a sponsor logo, to the post content if you did not intend for that image to end up in the post’s gallery as well.

Curiously, when you insert an item into the post content via the media modal’s ‘Media Library’ tab: even when you did not upload that image via the current post edit screen, WordPress will mark that attachment as attached to that specific post if it was not already attached to another post. Now what?

Filters to the rescue

add_filter( 'wp_insert_post_parent', 'prefix_filter_insert_post_parent', 10, 2 );

function prefix_filter_insert_post_parent( $post_parent, $post_ID ) {

	// The 'send-attachment-to-editor' action is set when inserting attachments into the editor.
	if ( ! isset( $_REQUEST['action'] ) || 'send-attachment-to-editor' !== $_REQUEST['action'] ) {
		return $post_parent;

	$post_before = get_post( $post_ID );

	// If the attachment already has a parent, return its ID.
	if ( 0 !== $post_before->post_parent ) {
		return $post_parent;

	// Else, sadly, but convenient for us, the attachment needs to stay an orphan...
	return 0;

In the unlikely case you run into the same problem: the XQR-Z100A WordPress plugin takes care of that now.

Thanks for your help J.D.!

Plugin: Attachments Only

Sometimes you don’t need all the bells and whistles of the WordPress attachment media view. For instance when you’d want all media files related to a post to actually be attachments of that post. This plugin takes that to the extreme and replaces the default WordPress media uploader view with a simplified version: it only allows adding, removing and rearranging attachments to a post.

Download, fork, create an issue or pull request on GitHub.