On maintaining a WordPress plugin for 11 years

Eleven years in and I find myself in a curious surge of development on Redirection.

Let me prefix this with the statement that Redirection is old. I mean, you got that from the title right – 11 years. It’s quite a while. But more specifically I mean that it’s old code. It’s been around since WordPress 1.5 and PHP 4, and a lot of the code and reasons for the code, are based on things that have long since passed.

When I started the plugin it was to cover up some of the mistakes I made as a novice blogger. I released updates without a thought to who was using it. People offered suggestions for new features and I’d include those, also without a thought – why not, it’s all good.

Development of WordPress started increasing in pace. I found myself playing catchup just to keep the plugin working. A lot of code became redundant and technical debt started accumulating. At one point I think the plugin worked on WordPress from versions 1.5 through to 4. Now I only check the last three versions.

Then I became aware that a lot of people were using the plugin. Some 600k active installations, according to the stats. This made me horribly aware that small changes affect a lot of people. Big changes become hard, and I become reluctant to do anything.

And people. They sometimes get angry. In the early days of WordPress people were more forgiving. Maybe I was younger and didn’t notice.

Then I’m referred to as a team. Don’t I have support staff? Maybe I’m a company. Your support sucks, by the way. All of a sudden plugins are commercial enterprises with lots of money being exchanged and I’m trying to squeeze spare time in between work and family.

Some people sent donations. Some people sent $0.01. I was never sure if that was an insult or a misunderstanding.

I had a kid. That really eats into your time. Someone hacked my server via a WordPress vulnerability that I hadn’t updated while my daughter was being born. Nice.

For a long while not much happened with the plugin. I got some grey hair. The world went forward, then backwards. People complained. People suggested it had been abandoned. (Dodgy) people offered money to ‘buy’ it.

Gradually, though, I started trying to modernise it. Unit tests were introduced. Old features were phased out and I focussed on the things people were having problems with. The technical debt was slimmed down.

Recently I started replacing the UI with React. This started with a single page, then another, and soon it will be everything. I’m able to do things better and much faster, and all of a sudden inspiration is back.

Now I find myself compiling JavaScript. When the plugin started this would have been a horrible joke and yet the plugin is now full of build scripts and compilation steps. It’s the 90s returned. And you know what? I’m enjoying it again.

Eleven years. Huh.

Published
Categorized as Code

HTTPie as a cURL replacement

I’ve been giving HTTPie a try recently. It’s a command line HTTP client that aims to be simpler to use than cURL while providing a richer experience.

As an example, if you’re developing against a REST API it’s useful to send requests:

curl https://public-api.wordpress.com/rest/v1/sites/3584907/

curl-example

http https://public-api.wordpress.com/rest/v1/sites/3584907/

http_example

Now you can see what is happening! (although, it seems, I need a better terminal colour scheme)

You can certainly use tools such as jq to prettify cURL (or in the case of the WordPress.com API, pass ?pretty=1), but it’s built-in with HTTPie.

If it’s specifically JSON you want to see then you can use a Chrome extension such as JSONView may be easier still.

Although the above example is very simplistic, when you start digging into an API with HTTP verbs and authentication headers, HTTPie’s syntax is easier and less obscure than cURL.

How do you get this tool? Using brew you can just:

brew install httpie

MAMP Slow Queries

Ever wanted to track down slow SQL queries while developing with MAMP on OS X? From the MAMP control panel edit the my.cnf template:

Track down the section starting with [mysqld] and add the following highlighted lines:

# The MySQL server
[mysqld]
log_slow_queries=/Applications/MAMP/logs/mysql_slow.log
long_query_time=1

Restart MAMP and any slow queries (queries over 1 second, configurable via the long_query_time option above) will be logged to /Applications/MAMP/logs/mysql_slow.log.

Now I have no excuse to forget this.

Remote editing with Sublime Text 2

I’ve been quite taken with Sublime Text 2 recently, and I’ve been trying to find a way to introduce it into my daily work flow. While it’s perfect for editing files locally, it doesn’t have any built-in remote editing facilities such as Coda. As I work remotely, this is a pain.

I do have ExpanDrive, and depending on the speed of your server, this can work fairly well. However, you do miss out on some of the extra features of Sublime Text, such as ‘find in files’ and web development plugins.

I’ve experimented a bit with a mix of rsync and directory watches, but the best solution has been the simplest, and also a quick introduction into the world of Python.

Using the Sublime Text API, I wrote a plugin to monitor any changes to a file and simply scp (secure copy) it across to my remote server. All password details are already setup by dint of it going over SSH.

Close a frozen SSH session

Just a short one here, but I spend a lot of time using SSH to connect to a remote server and occassionally a session will freeze. Usually my solution is to close the terminal and start again, but there’s a neater way to just cancel the SSH session itself. Enter these keys, one after the other (not together):

[enter]
~
.

That is, the enter key, the tilde, and a period. Your SSH session should close and you can re-open it without starting a new terminal.

Related Thumbnails with YARPP

I’ve been using YARPP (Yet Another Related Posts Plugin) for some time to add a short list of related links to the end of all posts on this site. The plugin works great, and is written by the capable Mitcho (who gave a very good presentation at WordCamp San Francisco).

I was thinking about the post thumbnail feature of WordPress and wondered if I could get thumbnails to appear instead of text links. A bit of searching later and it seems I wasn’t the only one to think of this, but I thought I’d give my take on it, and explain how I ended up with something that looks like this: