#nyc12: Hacking WordPress in the Newsroom

This morning, I gave the second of three CMA NYC sessions I’m leading this week:

You publish with WordPress, are comfortable with editing theme templates and making basic CSS changes, and you’re ready to take your site to the next level. Join Daniel Bachhuber, code wranger for Automattic’s WordPress.com VIP, to learn what you need to know. We’ll discuss topics like version control, performance and optimization, debugging, and other development best practices. This session will be geared towards the tech-savvy with a practical knowledge of WordPress.

It ended up being a little less ambitious. We started out with (the importance of) setting up a local environment, reviewed what makes a plugin, and introduced a few project ideas. Between a dozen and two dozen students attended; for almost all, the information was completely new.

The most important note on this subject: there are lots of jobs available.

Also, come hit us up with WordPress questions at our Happiness Bar!

Session notes are below the slides.

Continue reading

#wcphx: Five tenets to mastering WordPress development

Enlightenment is knowing what your code is doing and why. Thankfully, instead of having to depend on your inner calm, there are a number of tools and strategies you can use to better see what’s going on. We’ll survey a range of topics you should explore to turn your frustration into bliss.

Feeling better already? In this session, we’ll touch on everything from debugging to best practices to coding standards to version control to performance and optimization. You’ll hear the insights WordPress.com VIP shares every day.

Session notes are below the slides.

Continue reading

Pre-flighting your WXR files

Status

Thanks to a bunch of hard work by Thorsten and others, the open source CLI scripts we have for exporting and importing WordPress sites are getting better and better.

When exporting, the script gives you a summary of what will be included in your export file.

For importing, it would be nice if the script pre-flighted your data and told you how many total posts were to be imported, whether new tags were going to be created, identified the custom post types in your export file that were to be rejected by the site, etc.

Also, we should figure out a better way to make sure all of our internal scripts are regularly open sourced (and synced to most recent versions).

What makes a good commit message

There’s a useful conversation happening in an internal Automattic P2 I thought I’d take the liberty to share.

From Mike:

Consider the audience when you write a commit message. What is that audience? It’s at least two groups of people:

  • Your coworkers: You’re telling everyone else what you did. Commit messages are one to many, asynchronous and textual. Sounds like email, so write the commit message like an email. The first line should be a descriptive subject. The next line should be blank (as a separator). Then comes the body of the message. Write everything as if you’re describing it to Nikolay.
  • Your future self: Think back on the times you were fixing something and needed to understand why an old commit was made. How often was the commit message useful? How often was it your own useless commit message? The commit message should say what the problem was (repro steps?), how you fixed it (briefly – the code itself gives more details), and why you changed what you did. That way the shiny pants people of the future have the information they need to decide if they can safely change your code.

From Matt:

I think as a company we need better commit messages. Very often in our messages we say what is happening but not the why, and most importantly the context of the change. I’m going to pick on this changeset, but you could really pick almost anything:

[link to changeset]

4 lines changed, with the message:

“Fixing incorrect $blogid variable, should be $blog_id.
Check if $current_blog is === false before trying to reset it.”

First a good thing: it’s a multi-line message, which is nice. Commit messages can use as many lines as you like, and be as verbose as you like.

However if I were to come across this changeset 3 years from now, say if I were debugging a similar area in the code, I’d have no idea why this change happened. The message might as well be blank, since it doesn’t really say anything I couldn’t tell in 2 seconds from looking at the diff. Some useful context would be:

  • What bug did this code cause? (This is most important.) Why change it?
  • Is there a relevant discussion, either on a P2 or in Trac?
  • Who was involved in the fix, IE who else would have context for this change either because they reported the bug or reviewed the fix.

From Lance:

Good commit messages are my gospel. The actual syntax should vary by context, though. For theme commits, for example, we always start with the theme name up front.

But, the goal of giving context and pointing to related items is key.

I personally don’t think long commit messages are better. Instead, point to a Trac ticket or P2 post with all the gory details.

Status

Status

It should be much easier for developers to contribute code back to inactive or abandoned WordPress.org plugins.

For instance, Inline Google Spreadsheet Viewer is still a perfectly valid plugin, but hasn’t been updated since September 2010, has WP_DEBUG as true at the top of the file, and needs user input sanitization for it to be secure. These things I’ll fix for my own site; there should be an easy way to contribute these fixes back to the community.