Automattic 5k in Victorville, CA

Michelle and I did our 5+k a day or two early, and all we got were these geocaches.

To complete the 30 YEARS OF PACMAN and The Smiley Series geocaching “geoart” series, we:

  • Walked 14 miles in the desert,
  • Found 57 geocaches,
  • Suffered 95°F heat, and
  • Drank one metric ton of water.
Posted in Automattic | Tagged | 13 Comments

Automattic 5k in Pasadena, CA

Michelle and I walked our part of Automattic’s Worldwide WP 5k this afternoon.

Interestingly, despite the hundreds (thousands?) of people doing the 5k, “our part” was still five kilometers long. You’d think we could have split it up better or something.

Posted in Automattic | Tagged

WordPress __autoload() idea

PHP 5 introduces autoloading classes. The way WordPress is currently structured, I don’t think we’d get much benefit from switching to autoloading. There aren’t that many classes in core WordPress that don’t need to get loaded on every page load.

With some restructuring, though, we might be able to cut down on the number of bytes of code we load on every page (and we could get rid of some class_exists() and require_once calls).

We’d want an autoloader, though, that could handle plugin files as well as core files.

Read on for the idea.

Posted in WordPress | 21 Comments

Post Revisions in WordPress 2.6

Have you ever saved a post on your blog only to realize later that you accidentally erased a critical paragraph? Ever worked on a blog with multiple authors and needed to keep a log of who changed what and when?

WordPress should store a history of all your posts. You’d get protection from accidental changes, and you’d be able to see a clear timeline of the evolution of each of you posts.

Happily, WordPress is awesome! In the upcoming WordPress 2.6 release, the feature exists and rules!

:)

And check out the pretty colors!

Posted in WordPress | 173 Comments

Improved Post and Page management in WordPress

Managing thousands of posts and dozens of drafts will be much easier in the upcoming WordPress 2.3 thanks to some revamped backend code and admin interfaces.

First, the interface changes. In Manage -> Posts you can currently look for posts by search term, or browse by month or category, but only one of these things at a time.

In WordPress 2.3 (or currently on WordPress.com), you’ll be able to filter by search term, post type (draft, private, scheduled for future publishing, or published), author, month published, and category. You’ll also be able to combine any or all of those filters and do them all at once:

so you’ll be able to ask for all published posts written by Lion-O during May of 2007, filed in the “cartoons from the eighties” category, and matching the phrase “Mumm-Ra, the Ever-Living”. That was a hard list of posts to come by until 2.3.

Manage -> Pages will be getting a similar face lift; you’ll be able to filter by search term, author and page type (draft, private, or published).

Better draft management, in particular, has consistently been one of the most frequently requested improvements in WordPress, and these changes are a big piece of that.

Neat huh?

Secondly, the back end changes. The WP_Query class can now select posts by post_status (draft, future, private, publish). This makes it trivial to use query_posts() and wp() for such queries; no more need for kludgey filters and hacks.

WordPress 2.3 comin’, at you soon. Be there!

Posted in WordPress | 34 Comments

Hitting WordPress Attachment Handling

In debugging some stuff here on WordPress.com, I dived (once more) into the image handling guts of WordPress.

A while ago, I revamped WordPress’ inline uploading functionality to be more pluggable, cacheable, maintainable and (hopefully) intuitive. A hundred bugs later, it seems to be working pretty well.

This time around, the issue was not how WP displayed the data, but how it stores it.

In trying to make things leaner and meaner on WordPress.com, we reworked some of the behind-the-scenes directory structures on our servers. This should have been totally transparent to the user, but, of course, it wasn’t. It broke our image handling.

Each file uploaded to WordPress is stored as a special type of post called an “attachment”. In the post and postmeta tables, WordPress stores things like file URL, file path on the server, image dimensions, image thumbnail info, etc. So to figure out anything we want about an uploaded file, all we have to do is essentially get_post() and a few get_post_meta()s. Sounds great.

It’s not.

Two reasons:

  1. To answer a question like “Where is this file located on the server”, we have to get_post_meta() every time for the answer. With such a generic function, it’s impossible for plugins to filter that data on the fly even for this really simple question.
  2. WordPress stores the data in a really inconvenient way; everything is absolute: paths, urls, you name it.

Because of the absolute paths, lack of API, and the aforementioned directory restructuring, we had hardcoded into our DB tens of thousands (a blind guess) of incorrect file locations and no way to filter them. Doing DB updates across hundreds of thousands of tables (not a blind guess) replicated on dozens of servers was not an option.

Partial solution (now implemented in WordPress core): Write a basic API for getting and putting the data. wp_get_attachment_metadata(), wp_update_attachment_metadata(), get_attached_file(), update_attached_file() (the lack of parallelism between function names, and the ambiguity in those names is an historical artifact) are all nicely filterable.

Improvements that still could be made: Don’t store absolute data. This is better for portability too. (Exceptition: guid – but don’t use it for the URL).

Related improvements that could be made:

  • wp_get_attachment_url()
  • wp_get_thumbnail_file()
  • wp_get_thumbnail_url()
  • wp_attachment_is_image()
  • wp_mime_type_icon()
  • Rework get_attachment_icon() given the above
  • Kill reliance on or rework get_attachment_innerHTML() (see above)

Vaguely related improvements that could be made:

  • wp_handle_upload() is a little awkward (but nice and robust!). Maybe wrap it? That might be silly.
  • wp_generate_thumbnail_filename()
  • Make thumbnail creation hookable and provide above convenience function

Update: All of the “related improvements” noted above have been made in the recently released WordPress 2.1. Of the “vaguely related improvements” suggested, 2.1 offers hookable thumbnail creation.

Posted in note to self, WordPress, WordPress.com | 5 Comments

bbPress + AJAX = “oooh… pretty…”

bbPress has been getting an extreme AJAX makeover, and things are looking pretty good.

We’re still working on the best user interface, particularly for posting new posts. Firas mentioned the possibility of including a cute spinner à la Technorati. Perhaps a spinner over the post textbox would be best. Something like Owen‘s CanaryComment.

Posted in bbPress | 2 Comments