K2 1.1 RC1 is up
The first (and hopefully only) release candidate for the latest K2 is up and about, and it’s a milestone.
Est. 2003
The blog of one Michael Heilemann, expatriated Dane coming to you out of New York City. Half machine, half grapefruit, Interface director at Squarespace, design lover, film enthusiast, Star Wars historian, creator of the Kubrick and K2 themes, and holder of opinions, many of which are shared on his Twitter account.
The first (and hopefully only) release candidate for the latest K2 is up and about, and it’s a milestone.
I love the engineers behind iPhone OS. They’re head, neck, shoulders and torso ahead of everyone else. It’s kind of scary in a way, as it probably shows just goes to show how far behind everything else is in contrast.
Not to pick on WordPress, I’ve just spent a good deal of time with it over the last few days, and it struck me again yesterday how, as I was testing a slew of role management plugins (argh, by the way), that I would activate a plugin, and subsequently not have the faintest clue where to look for any new UI inserted by it. Some put a single options page under Users, others inserted whole bundles of pages, some put them where I least expected it…
Contrasted with the iPhone, where when you install or update an app, from the phone itself, it will actually exit the app store and take you to the screen where the icon is, and show you that it’s being installed/updated. This usually takes 10-20 seconds, and you’re good to go; it’s right there ready for you.
It’s a small thing, and in the cases where you’d prefer to stay in the store it may be mildly annoying, but on a larger scale it means a lot less frustration and searching, even in a system as simple as the iPhone.
I could pull out a plethora of reasons why the media manager in WordPress needs to be the focus of the next major release after WordPress 3.0, but honestly, this particular issue seems to say everything there is to say on the subject.
Seriously now; did anyone even bother testing it? How long has it been like that?
I love WordPress; I actually really do, but you can’t just throw the first media manager that crosses your path into WordPress core and think that’s that… And I’m not just talking about this either. I’ve looked at the code; I’ve reverse-engineered the code. It’s not pretty, but more importantly, it’s symptomatic of a whole heap of problems in WordPress in general.
A Snow Leopard-esque release would do wonders; though I have to wonder if it won’t break the back of those who take it upon themselves to try it?
And thus ends another era in my life. 2010 is turning out to be quite the year.
A complete guide to using Thickbox in the WordPress admin, despite the ingenious traps laid by the developers of the media manager and Thickbox itself. With this guide in hand, you too can shout out ‘Spaaaartaaaaa’ and kick bad code into a big-ass hole in the ground.
Anyway, I knew that WordPress shipped with Thickbox, for use with the media manager, and I wanted to use it to rewrite a pop-up window solution in a plugin for Wordy into using the iframe functionality of Thickbox. You know, the kind of thing that sounds easy until you start digging, right? Now, I could have gone with one of the newer Thickboxesque projects, but I wanted to have the plugin feel like it was a part of WordPress, and since the WordPress admin uses Thickbox, that’s the way to go.
Well, the first thing I learnt was how Thickbox is less than well-documented (not to mention stagnant since 2007), and after a short while of trying to make head and tail of the code, I found out that the version shipping with WP actually contains a bug. Nonetheless, I soon found a way to get it up and running to a point where I had only two major problems facing me.
First of all, most JS in the admin is loaded using load-scripts.php, which basically rolls up all the default JS and loads it in one big file at the end of the file, just before </body>, which in turn means that when Thickbox and its load-scripts bretheren queue up some initialization code using .ready(), it will inevitably come after any code I can enqueue, and thus my code can’t be sure that Thickbox has even been initialized when it’s run, which is compounded by the fact that Thickbox doesn’t leave behind any obvious signs of having been initialized.
Ugh.
There is a work-around however, because Thickbox attaches an event to certain elements with the ‘thickbox’ class. We can go in and find that event, and when it exists—which means Thickbox has initialized—run our stuff. We do this by going through the click event stack for the first found a.thickbox, turning it into a string, removing newlines, tabs and spaces from it and comparing it to what we know Thickbox puts there. Rince, lather, repeat until we find what we’re looking for, and we’re good to go (though, just to be sure, we force it to happen after 2 seconds regardless).
It ain’t purdy, but it works:
/**
* Checks the first found a.thickbox element to see if Thickbox has attached a click event.
*/
function checkThickboxInit() {
jQuery.each( jQuery(‘a.thickbox:first’).data(‘events’)[‘click’], function(i, event) {
var thisEvent = event.toString().replace(/\n/g, ‘’).replace(/\t/g, ‘’).split(’ ‘).join(’‘);
var TBEvent = ‘function(){vart=this.title||this.name||null;vara=this.href||this.alt;varg=this.rel||false;tb_show(t,a,g);this.blur();returnfalse;}’;
if (thisEvent == TBEvent) {
clearTimeout(forcePayment);
clearInterval(checkThickboxInitInterval);
postThickboxInit();
return;
}
})
}
function postThickboxInit() {
/* Thickbox-related code can now be run */
}
checkThickboxInitInterval = setInterval(checkThickboxInit, 50);
forcePayment = setTimeout(‘clearInterval(checkThickboxInitInterval); postThickboxInit();’, 2000);
The second problem is much bigger. Mostly because it’s much stupider. Thickbox was added to WordPress along with the media manager, and whoever wrote that apparently decided that Thickbox wasn’t going to be used by anyone else anyway, so they might as well go ahead and break its core functionality. Get this. In media-upload.js, the tb_position() function, which is what Thickbox uses to control the size and position of a Thickbox window, is replaced in its entirety with a function meant to be used only with the media manager, which comes with hardcoded widths and which is attached to the window.resize event.
That took me a while to figure out.
Why this was necessary I have no idea; Thickbox allows you to set the size you want through URL parameters, which you’d think would be good enough for the media manager as well, but apparently not.
So we fight in the shade…
/**
* Add ‘sparta’ class to the Thickbox window. Called from inside the TB iframe.
*/
function sparta_iframe_loaded() {
jQuery(’#TB_window’).addClass(‘sparta’)
}
/**
* Checks how to resize the TB window. Called on window.resize.
*/
function sparta_window_resize() {
if (jQuery(’#TB_window’).hasClass(‘sparta’))
sparta_resize_thickbox();
else
tb_position();
}
/**
* Resizes the TB window our way, not the highway.
*/
function sparta_resize_thickbox() {
var SpartaWidth = 1000;
var TB_newWidth = jQuery(window).width() < (SpartaPaymentWidth + 40) ? jQuery(window).width() – 40 : SpartaPaymentWidth;
var TB_newHeight = jQuery(window).height() – 70;
var TB_newMargin = (jQuery(window).width() – SpartaPaymentWidth) / 2;
jQuery(’#TB_window’).css({‘marginLeft’: -(TB_newWidth / 2)})
jQuery(’#TB_window, #TB_iframeContent’).width(TB_newWidth).height(TB_newHeight)
}
jQuery(document).ready(function() {
/**
* Cast the media managers window.resize event into the fire.
*/
jQuery.each( jQuery(window).data(‘events’)[‘resize’], function(i, event) {
var thisEvent = event.toString().replace(/\n/g, ‘’).replace(/\t/g, ‘’).split(’ ‘).join(’‘);
var expectedEvent = ‘function(){tb_position()}’;
if (thisEvent == expectedEvent) {
delete jQuery(window).data(‘events’)[‘resize’][i];
jQuery(window).bind(‘resize.ournamespace’, sparta_window_resize)
}
})
// Open a Thickbox window
tb_show(‘This is Sparta’, ‘sparta.html?TB_iframe=true’);
}
Now create sparta.html and at the bottom of it, in a script block, insert the folllwing, so we can attach our own class to the TB window:
parent.sparta_iframe_loaded();
And there you have it. A letter-opener.
Update: A belorussian translation of this article.
While WordPress ships with jQuery, it’s often a few updates behind the latest version. Since jQuery 1.4 is just out, I wanted to use it with K2. That in and of itself is fairly easy, and a simply matter of deregistering the ‘jquery’ script and registering a new one. While looking for a proper solution I came across this rather crude way of going about it quite a lot, and it’s a horribly way of going about this, and will (and has probably) undoubtedly result in old plugins and themes blindly overwriting newer version of jQuery with their own, once new hotness, now old and busted version of jQuery.
Ugh.
This PHP code snippet checks to see if the passed version is later than the one currently registered, and makes sure we’re not in the admin (just to be sure).
If our version is indeed newer than the one currently registered, we go ahead and grab the idol… eh, swap jQuery’s.
/**
* Register a later version of jQuery if it’s later than the one currently in WordPress
*
* @param {String} our_version The version of jQuery we want to upgrade to if needed.
*/
function upgrade_jquery( our_version ) {
// We want to use the latest version of jQuery, but it may break something in
// the admin, so we only load it on the actual site.
global $wp_scripts;
if ( ( version_compare(our_version, $wp_scripts -> registered[jquery] -> ver) == 1 ) && !is_admin() ) :
wp_deregister_script(‘jquery’);
wp_register_script(‘jquery’,
get_bloginfo(‘template_directory’) . ‘/js/jquery.js’,
false, our_version);
endif;
}
add_action( ‘wp_head’, upgrade_jquery( ’1.4.1’ ) );
It sure would be neat if this was built straight into WordPress’ wp_register_script.
I’m lucky enough to have force-fed myself enough roleplaying games and science fiction comics to have picked up English to a level where I’m often more fluent in it, than I am in my mothertongue. And for the purposes of of blogging about those two particular subjects, whatever grammar, puntuation and structure snafus that happen to find their way onto this blog are less a real worry than they merely distracting (and at times embarrassing).
But if one were to take writing more seriously, be it for personal, academic or straight-up professional reasons, a friend of a friend of mine recently started a site that’ll do just that, hassle-free.
I don’t generally plug things on this site unless I truly like them. And until I tried Wordy, I honestly didn’t know what use I could have for it. But listen, Wordy gets it.
It’s on-demand copy-editing, and it’s ultra slick. No hassles, no clutter, no crap. I took it for a test-run on a chapter from a book another friend of mine is writing, and the experience couldn’t have been better. If for nothing else, you should check it out just to marvel at the elegance of how they’ve set up the site and how clear their process and goal is.
Particularly interesting to some of us, is that they’re working specifically on a WordPress plugin, which should make it even easier to use. They’ve also got a blog (in Danish).
Now if you’ll excuse me, I’ve got some K2 code to clean up.

I met up for an interview with the gracious Tina Daunt in Santa Monica (oh wonderful Santa Monica) during our US roadtrip, first slated for the LA Times, before they started firing people left and right, now up at Huffington Post.
The new 2010 theme is slowly starting to take shape, and I’m very much looking forward to seeing what that’ll be about. Meanwhile my, until recently, neglected second child, K2—a spiritual followup of sorts to Kubrick—just went 1.0 before the holidays, and we’re well on our way towards a great 1.1 release.
I’ve got a couple of other projects I should have started a long time ago coming in 2010, and I can’t wait to unveil them as we get nearer to summer. Yes, one of them is a new WordPress theme.
It was great, while it lasted, honestly pretty crazy for a while, and I very much enjoyed it; but its retirement is timely, if not overdue.
Kubrick, by the way, was born in the summer of 2004, which makes it almost five six years old this year. I would never have thought it could have lived for this long.
Thanks Stanley. And sorry.
Even though I intended to blog some more over the holidays, I instead spent most of the time glued to the computer working in various capacities on K2.
I feel I squandered the trust of the community, by having been too casual about K2 in the past. K2 has been first with a whole bunch of features and functionality, we had a rather large and very active community and a solid codebase, yet mostly due to me having other priorities it’s atrophied somewhat.
The good news is that we put out our 1.0 and subsequently our 1.0.2 over the holidays.
And the great news is we’re already up to having nine languages
Meanwhile, it’s been a while since I did any web design of significance, and I think I’d forgotten a little bit how fun it is (as long as Internet Explorer isn’t invited to the party that is). This has also meant getting reacquainted with the tools of the trade, old and new, and where I used to use TextMate for pretty much everything, I tried switching to Coda (I had a license, even though I’d hardly ever used it), and I’m now a full convert. Those Panic guys know a thing or two about software.
Cinch is another little app that’s been making my life a lot easier, especially since Chrome for OS X still doesn’t have the same functionality that the Windows version has had for a year or more, and since Apple refuses to acknowledge the need for a maximize button.
Now if only I could find a great app for resizing windows in a sane manner.
It took long enough, but K2 just went 1.0. Oh what a feeling. Now to get the localization effort in a row and ready for 1.1.
K2 has been a fun project for a number of reasons, but most of all I’ve been happily surprised at how the entirely lax and cell-like development process has worked out. I recently picked up the reins again and started going through our bugs, weeding out where I could and organizing what was left, in an effort to get to a 1.0 release as soon as possible. So now’s the time to tell us if something’s broken or missing.
Read more over at the K2 site.
It’s not that I’m embarrassed by my younger self, but… I’d prefer it if my blog continually contained mostly things that feel contemporary to me. Thus, employing government-sanctioned reality distortion field technology, I once again got Brian to do the heavy lifting and build me The Amazing ContemporizerOther names suggested were ‘I was young, I needed the money’, ‘It’s not that I’m embarrassed, but…’ ‘Youthful Folly’ and ‘The Ice Floe’. while I kicked back, drank piña colada’s and cackled at my cat.
The Amazing Contemporizer is a plugin for WordPress which automatically sets posts older than X to private, causing a wave of privacy to flow over your older and perhaps less… refined, past as a blogger.
PS: Backup you blog before using. Seriously. No… Seriously!
It being Kubrick appreciation week, it seems fitting Matt let me know that somebody went ahead and named their dog after Kubrick. Not the man though, but the WordPress theme I did!
Kubrick is named after the default Wordpress theme, Kubrick! It’s a really nerdy way of naming our new pup, but my husband wanted to name him with something that’s related to web design and development. #
Alright, listen up. Binary Bonsai has been powered by WordPress literally since its very first release. And as a consequence, I’ve been pretty involved with the WordPress community over time, especially these last few years with K2 (which is still in production I might add). But, while it has served me well for all of that time, to kick the carcase of the dead horse that is the girlfriend metaphor; we’ve grown apart. And today, I’m moving out of the apartment. So it’s goodbye WordPress and…
Hello Habari.
Mmm. Sweet, sensual, built Habari. Don’t get me wrong; this isn’t a pitch for you to do the same (though, please, take it for a spin; you never know). It’s simply me celebrating that I’ve finally gotten on with my online life, and getting even more involved with a project that has so far been both incredibly rewarding and ditto challenging.
And it wasn’t that WordPress and I were in a painful relationship; at least not in last year or so. It was more one of those courteous ones where we had both made peace with the fact that we weren’t meant for each other. That over time, we had grown apart. And… Alright, alright; enough of this blasted girlfriend metaphor; it’s creeping me out!
Seriously though, I’m really happy to finally move in with Habari. I’ve long had a keen interest in interface design and blogging tools, and my involvement with Habari has allowed me to follow up on both of those, and hopefully in the process creating a blogging tool that others will find exciting as well.
As a writer, if anyone would stoop so low as to call me that (thank you), what happens behind the scenes doesn’t really interest me. I do most of my writing in Textmate and then copy/paste it anyway. And after I’ve turned off comments, I don’t even see the whole admin section that often. But just because you only use the car to go down to the supermarket, why shouldn’t you be driving a black Countach?
I thought so too.
But please, have some patience with the design (which is new, and very much in progress), the archives and the feed (new permanent address, I’ll try and do some clever rewriting to get the old links to work). I’m working on getting all my ducks in a neat little row, and hopefully everything will settle down within a few days.
Well, except for the design.
I’m calling it Kalamari.
Largely thanks to Steve’s hard work, you can now pick up release 6 of K2.
The second in the series, this time considerably shorter at a mere 12 minutes (felt like 2 when I was recording; man brevity is hard!) about the Write Page in WordPress.
You can comment on the Viddler page or download the fullsize quicktime, if you’re so inclined.
Spent half an hour recording the first in an impromptu series of screencasts about interface design. This episode takes a look at the WordPress dashboard and why it ought to be discarded immediately. There’s also a short look at the WordPress widget system and why that isn’t entirely up to snuff either.
You can comment on the Viddler page or download the fullsize 374mb quicktime file, if you’re so inclined.
PS: With a face for radio and a voice for TV, I should’ve probably just written it; but hey…
When in the future, bound to the wheelchair by an injury sustained in the Chrome Wars, I look back at 2007, I will see Kane & Lynch: Dead Men.
It’s not that I consider my other endeavors insignificant. I’m very happy with K2, even if we didn’t ship a 1.0 as I’d hoped. And I’m already very proud of the little work I’ve been able to contribute to Habari so far. Furthermore, both Rikke and I were able to chalk off Paris and New York from the ‘must travel to before impending death’-list.
But Kane & Lynch definitively marks the end of me wanting to make computer games for a living, and me having made making computer games for a living. And dammit, I’ll wear that chip on my shoulder and parade it around town like nobody’s business. It’s my party, and I’ll cry if I want to!... Look what you made me do.
2007 will also go down as the year I spent an excessive amount of money on a whole range of (fantastic) new Star Wars books, it being after all the 30th anniversary and all. And yes, I’m still a sucker for that stuff; you wanna start a fight or something? You a trekkie? Huh? Huh?!
Furthermore, this will be the last year Binary Bonsai will be brandishing WordPress. I’m a-shippin’ out and a-joinin’ Habari. It was fun, smell you later.
2008 will be the year where I leave the quantity of content to Tumblr, Twitter, Flickr and the seemingly never ending onslaught of something-r, and instead turn my focus on quality for this here site.
Proper writing, or at least, more attentive writing. Which is to say, if you enjoy reading about Russ Meyer and thinking about whether or not Chris Foss planted the seed for the Star Destroyers, then gosh darnit, you’re in luck Lucy, cuz that just about sets the style.
And proper writing, unlike this whole piece and this segue in particular, is exactly what 2008 will be tagged, bagged and sold as.
I love film. I work with games, but honestly, I can’t deny that my love is with film. And sure enough, the ‘I could do that better blindfolded!’-bravado is abound, but the actual product? It has yet to be manifested.
I’ve pseudo-dabbled in creative writing, and even half seriously discussed with Rikke the option of moving to New York for a stint, leading a bohemian life as a writer, living off of the wonderful New York deli’s and churning out socially subversive, but mostly un-produced scripts (that last part is a lie; it would be pulp sci-fi; you know that).
So this is the year where I, creatively, bend down to check whether I have a pair or not. And if I do, great, who knows what it might lead to? If I don’t? Well, shit.
So that’s it for 2008; you can go home now.
PS: This entry by the way, is the last entry to brandish comments. The spammers are too clever, they’ve won. But they can’t cross the bridge, if there is no bridge, so… Boom.
Catch me on twitter if you need me.
Early this year, I spent some time with a bunch of other people setting up a direction for Habari’s administration interface. It was mostly blue-skying, but loving interface design as I do, it felt like time well-spent.
In fact, it felt good.
It was a little early to start implementing stuff like that, when the platform itself hardly even existed at the time. So I went off and spent most of my time on K2 instead. But now that K2 is nearly done, I’ve started working on Habari designs again, and just submitted my first major patch (with no assurance it will be accepted of course).
Habari is like the promised land in terms of the kind of interaction design I’ve wanted to see in WordPress for years. It’s like a digital catharsis to finally apply these thoughts and frustrations.
It’s based on, and comes pretty damn close to these reference mockups, and looks like this in motion (Full resolution):
Whether all of this will work in practice, no one knows, but it sure feels good.
Because WordPress chokes on the comments, I’m referring any further comments on my Die Hard 4.0 review to this entry.