Author Archives: John P. Bloch

About John P. Bloch

Kansas boy transplanted to DC. English major transplanted to web development. Lover of things.

PSA: Don’t (necessarily) Trigger a Save from a Save in WordPress

I know what you’re thinking. John got caught in an endless loop, and now he’s sharing his stupidity with us.

Good guess. Normally you’d be right. This is not the case this time, though.

Say you need to process some data and it takes a while. Normally you’d render the data in a shortcode, but you don’t want to run all that churn on the front end while your readers are waiting. Makes sense to process the data and inject it on save so it’s just in the content, right?

Yeah, actually! That’s a great idea!

Maybe something like this?

NOOOOOOO. Don’t do that. I see you, thinking you’re clever, removing the function from its hook and re-adding it. Well your function might not be the only one hooked into a save. Now what do you think about that, huh? Not so smart, now, are we?

What you want is the wp_insert_post_data filter:

wp_insert_post_data runs before the database is updated and lets you modify post data before the update or insert happens. It has an optional 2nd argument containing the old post data as well, so you can check what’s been updated too, if necessary.

How I got Docker working on Windows 10 using Hyper-V

  • Create a directory at C:\docker
  • Add C:\docker to your PATH environment variable
  • Go directly download docker-machine and extract the executables into C:\docker. I used v0.5.0-rc2. If docker-machine-driver-hyperv.exe is not in the download, go find it somewhere and put it in C:\docker.
  • Go download the docker client and move it to C:\docker\docker.exe
  • Copy (not rename) docker-machine-driver-hyperv.exe to docker-machine-driver-hyper-v.exe
  • Go to your terminal and run docker-machine create -d hyperv dockervm
  • Run eval "$(docker-machine env dockervm)"
  • Run docker run hello-world
  • Ta-da!

Laravel Homestead on HyperV

Update: 2015-11-11 – I’ve finished porting over the PHP 7 branches of settler and homestead. If you want to use PHP 7, follow the instructions on the standard Laravel docs site and here, except use johnpbloch/homestead-7 as your box instead of laravel/homestead-7.

Somebody sent me an email this morning asking me a quick question regarding my recent work getting Homestead running on HyperV 1.

Hello my friend,

I see repository on github about hyperv configuration to vagrant up. What are the commands to start the new machine on HyperV?


I really can’t see any good reason not to share the info with the rest of the world too, so I figured I’d put it in a blog post for the edification of everybody. Continue reading


  1. HyperV is a native virtualization hypervisor for Windows Operating systems. It uses SMB shares by default for mounted directories, which are way faster than VBox shared directories. In general, it blows virtualbox out of the water in terms of performance.

    At some point, I’ll need to write about even using it with Vagrant at all.

Upcoming changes to my WordPress fork

As you’re likely to know, I maintain a fork of WordPress that adds composer support. I won’t really go into any of the background or reasoning behind the origins of this fork, although that would probably be a good topic for a future blog post.

wp-composerI’m mainly just announcing some changes that are coming down the pipeline for the fork. If you follow me on twitter, you may have already seen much of this, so you probably have an idea of most of what I’m going to say.

I’m planning on re-forking WordPress into a new repository (probably named wordpress-core with the same change to the composer package) and turning johnpbloch/wordpress into a meta package that requires both the core package and the core installer package. This will allow me to keep the fork clean of any implementation details, including assumptions about how and where the user wishes to install WordPress itself.

So what does this mean for the composer package if you’re already using it? Nothing, hopefully. The only difference will be that the core files will get moved into a sub-package.

I want to explain my reasons for this change a little bit.

First of all, why am I fixing something that doesn’t appear to be broken? Well, because it’s too brittle, which is sometimes just as bad as broken. When I set this up, I threw together a bash script to keep it up to date. This script runs every 15 minutes on my server. It is fairly complex and difficult to extend or fix. I also want to rewrite it to be much more targeted in its work.

I would like to change the repository to be a real fork of the upstream mirror at git:// This will allow me to simply use git’s built-in remotes functionality to fetch upstream changes without losing contributor information, etc. Some people have gotten the wrong idea in the past regarding my motivations for maintaining a fork of WordPress and even accused me of doing it primarily to improve my contributor graph on github 1. While it’s true that haters are going to hate, I’d rather distance myself from even appearing that way, even if I had a good reason for not doing a true fork the first time around. Now that I know my issues with doing a fork from the official source have been resolved, I’m happy to make that change.

Finally, I just don’t think it makes a whole lot of sense to tie my installer to the core package. Not everybody will need it for their installation profile and/or workflow, so it makes no sense to require it across the board.


  1. This is, of course, not true. I don’t even pay attention to my contributions graph. The vast majority of my work is done in private repos for work. I’ve never considered those graphs to be a worthwhile metric for that reason. Without my WordPress fork my public contributions graph would most likely be in the low hundreds while my private graph would still be in the thousands.

Javascript: The Bad Parts

Did you know:

var test = parseInt( 'hello', 10 ); // returns NaN
if ( test === NaN ) {
  alert( 'Well that made sense' );
} else if ( 'number' !== typeof test ) { // Should work, right? NaN means NOT A NUMBER
  alert( 'Should not have to come to this, but still makes sense' );
} else {
  alert( 'WAT' ); // Should have used isNaN()


Reminded me of this:

RabbitMQ and Upstart

A project I’m working on needs long running processes and I’m managing them with Upstart. It’s a fantastic tool and I can’t rave about it enough. It greatly simplifies the process of turning a script into a service.

One service depends on the RabbitMQ messaging queue server being up and running. Unfortunately, RabbitMQ uses SysV to manage the service rather than Upstart and it can be tricky to get the two to cooperate when one depends on the other. The common way to approach the problem is to remove the symlinks to the RabbitMQ SysV script from the rcX.d directories and use a custom upstart script for RabbitMQ. That solution is less than ideal because I want to leave RabbitMQ alone so I don’t cut off my upgrade path in the future.

I did some poking in the SysV file for RabbitMQ (/etc/init.d/rabbitmq-server) and found out that they already emit signals for service actions! So if I needed an upstart job to start and stop with RabbitMQ, all I have to do is this:

start on rabbitmq-server-running
stop on rabbitmq-server-stopped

Now I’m hoping that RabbitMQ eventually starts packaging an upstart script with their Debian package. Should they do that, I’d probably want to fall back to that for triggering my service. To do so, I only have to tweak things a bit:

start on (rabbitmq-server-running or started rabbitmq-server)
stop on (rabbitmq-server-stopped or stopping rabbitmq-server)

Using the signals emitted by the SysV script isn’t a perfect solution, and I’ll probably want to tweak things a bit to make sure the service is up (maybe in a pre-start exec call?). It also doesn’t emit a signal for any actions other than start and stop (including restart).

But for my purposes, this is pretty good.

Blogging More

Photo Credits: photosteve101, Flickr -

Photo Credits: photosteve101, Flickr

I want to write more on this blog. So… I guess I’m going to? Leave a comment if there’s something specific you want me to write about and I’ll see what I can do. I’m already working on some posts on unit testing and on Composer.

I will not be attempting to blog every day. I’d like to blog at least once per week, though. We’ll see if that happens.

This post is mostly to get Eric Mann off my back.

Say Hello to Meme Indicator

I use Ubuntu full time on all my computers, as you probably know if you read my infrequent posts here or have been unlucky enough to get caught in a conversation about computers with me.

I really like Ubuntu, 1 so naturally I want it to do well. Which will never happen until there’s a more robust ecosystem of user-oriented programs.

I have neither the time nor the skill to really make a dent in that problem, but I did recently put up my first desktop program for Ubuntu on a Launchpad-hosted PPA 2. It’s just a little something to make it easier for me to do something I very much enjoy: use unicode emoticons 3 in text.

meme-indicator-screenshot-2So I built a python application that adds to the system tray an icon with a dropdown menu of text items. Click an item and it’s copied to your clipboard.

It also has a preferences menu where the user can add, edit, or remove any item from the text snippets. Maybe you don’t know people who would provoke a ಠ_ಠ or maybe you never want to (╯°□°)╯︵ ┻━┻. That’s fine. You could add something you find yourself typing occasionally that you wish you could have in your clipboard 4.

Can’t decide what text to put in there? Why not (/) (°,,,°) (/)?

Anyway, if you want to install the program in Ubuntu, add my ppa to your software sources list:

sudo add-apt-repository ppa:johnpbloch/meme-indicator

And then simply install the package, either through the software center or on the command line:

sudo apt-get update
sudo apt-get install meme-indicator


  1. Yes, even Unity
  2. Personal Package Archive
  3. ಠ_ಠ
    (╯°□°)╯︵ ┻━┻
  4. I don’t, know, maybe a terminal command? Or a URL you need to type a lot in messages? There are probably things you could use it for

Netflix on Ubuntu Natively

I’ve written before on how to watch Netflix on Ubuntu, but that still required a VM running Windows 1. Not ideal.

Well now you can run Netflix as a native app. It appears to run on top of Wine and a modded copy of Firefox. Anyway, here’s the video tutorial I used:

This was on Ubuntu 12.10, but that PPA has packages for Precise and Raring too.


  1. free copy of Windows, but Windows nonetheless