Screencast: Coding a plugin, start to finish*

This screencast is an experiment I wanted to try and if well-received, I may do more in this style.

This recording is in realtime, not sped up (I may do a timelapsed version in the future), so you can see what I’m doing. I try to narrate it to make it easier to follow, but sometimes the cat in the background throws me off.

Unedited. Exporting and uploading took long enough as it is, as my first screencast of this type, consider it a rough draft.

The final result of this screencast can be found here:

However, the goal of this isn’t so much for the code at the end as the how I got there. Feedback and questions welcome.

Props to @dougal for the plugin idea. It might not be exactly what was had in mind, but that’s beside the point 🙂

* I know, plugins are never really finished

Removing ms-files.php Dependency

WordPress networks that were in place prior to the 3.5 update are dependent on wp-includes/ms-files.php and have that fun blogs.dir directory.

Upgrading your network to no longer have that dependency requires moving some files and making a whole bunch of database updates (mostly to reflect the changes from moving those files…)

This was my guide: And to reiterate what is said there, this is not something you have to do.

This post assumes certain technical ability and WordPress familiarity. Read everything, including the Half-Elf post, before proceeding to make sure you’re not going to get stuck partway through.

First, move (or copy, and delete later when you’re sure) your images from blogs.dir/BLOG_ID/files/ to /uploads/sites/BLOG_ID/.
Something like this

mkdir /path/to/wp-content/sites
cd /path/to/wp-content/sites

Then for each site

cp -r /path/to/wp-content/blogs.dir/BLOG_ID/files .
mv files BLOG_ID

For my 15-site network, doing this manually was fine. There is no doubt a script that can save you from doing this manually, but believe me when I say you don’t want me writing that for you.

Then you want to start making the database changes. Obvious are the image URLs, primarily in post_content, but also in other places, like theme_mods (custom headers, background images)

Then there are a couple other changes needed so that WordPress knows how to build the URLs, as well as where to put new uploads. So in each site’s options table, you can empty out upload_path, upload_url_path, and fileupload_url

And lastly, trip the ms_files_rewriting flag so that WordPress knows to stop treating your network like it still uses ms-files.php. ms_files_rewriting is a site option, so there’s only one place to set it (or insert it, since it may not be in the database already), and it should be false.

Once you’ve confirmed that nothing has exploded, you can remove the ms-files.php rules from your htaccess or nginx config files

To help out with the database edits, I wrote a plugin. It helped me get this network away from ms-files.php, but I haven’t done a fresh run on any other pre-3.5 network. READ THE SOURCE, USE WITH CAUTION, DON’T DO IT IN PRODUCTION LIKE ME.

Got it? I mean really. If you blow up your site, don’t come crying to me. Check it out on Github.

Using WordPress and P2 to Manage ALL THE THINGS!!

For the presentation I’m developing (which I may or may not actually give in public), I’m leaning toward discussing what I’ve learned about using WordPress and the P2 theme to coordinate interoffice communication.

“Using WordPress to Manage Clients, Projects, News, KB ALL THE THINGS!!”

  • Why?
    Needed a system to reduce clogged inboxes, avoid long hard-to-follow email threads, keep the conversations open so info can be found again, even by those not originally involved in the conversation.
  • The Setup
    Private team/dept blogs for discussion that would be irrelevant elsewhere. Multiple topical “public” (still private to the company) blogs (e.g. Company News, Ideas, Wiki, etc.). And CRM style functionality: managing clients and projects, which can be linked together.
  • The Plugins
    Some from P2 functions.php, and cover the custom plugins (@mention notifications, Facebook-esque “liking”, post subscriptions, cross-site post linking, etc.
  • “The Future”
    squash bugs, streamline the code, and maybe/hopefully release it

Of course, I still need to flesh things out, but I also need your help. I’d like to let the audience ask questions, but I don’t want to be caught completely off guard. Can you help me anticipate what questions might come up? From the obvious to the obscure, let me know what you might ask so I can better prepare.

WordPress Talk Ideas

Supposing I were to take the time to write up a talk on some WordPress subject (probably development related), and then supposing I were to actually give this talk in front of a group of people, what do you think it should be about?

I’m considering being prepared with a talk proposal for an upcoming WordCamp – but I need help with brainstorming. Please, please, please offer a recommendation in the comments, or hit me up on Twitter.

I can’t promise that I’ll actually end up giving a presentation – whether out of failure to submit a proposal or out of failure to bribe someone to accept mine – but I will choose a topic and make every effort to prepare a talk/tutorial/presentation and share it here on

Disable WYSIWYG Editor For Custom Post Types

If you need to make sure that your custom post type doesn’t have the ‘visual’ tab, you can easily diable it. Suppose you have a custom post type named ‘movie’:

add_filter( 'user_can_richedit', 'disable_for_cpt' );
function disable_for_cpt( $default ) {
	global $post;
	if ( 'movie' == get_post_type( $post ) )
		return false;
	return $default;