How To Load the Latest Version of jQuery in WordPress

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.

A Word About Wordy

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.

Where Were We?

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 languagesDanish, german, spanish, latvian, norwegian, dutch, polish, swedish and turkish, with a russian translation on the way. We’re still looking for more, so if you’re interested, read this and give me a shout. in our new localization repository which puts us well on our way towards the 1.1 release which is of course geared towards localization. We’ve got some pretty cool ideas in the pipeline for the roadmap after that, but more on that later.

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.

Moving in on K2 1.0

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.

Aaaand We're Back. Again.

I’m sorry for this past week’s permission-problem-outage, but despite having vacation, it’s been everything but quiet around here. And before we get on to other business, let me just take one more opportunity to congratulate Rasmus and Anna-Vera on their wedding this weekend, it was fantastic!

R+AV

Now, down to business.

I think I’ll try and upgrade BB to WP 2.6 one of the next few days, just to have the chance to play around with it properly, before finally taking the leap up to the just release Habari 0.5. I don’t know if you’ve had the chance to play around with it yet, but I’m so very proud to have been a part of that project so far. The work we’ve done these last few months is really something. There’s also a new project site, which is quite an improvement already.

So that’s coming along strong. I can’t wait to get it up and running on BB; I’m really just waiting for Chris to do the textile plugin he promised me… (nudge nudge, eh eh?).

Now, I’ve got some drafts for various entries I didn’t get to post over the last week, but now that the weather in Copenhagen has turned from LA to Seattle, what else is there to do but honker down and get some writing done?

Well, there’s watching movies, reading books and cooking food, but… Well, I’ll get them written, alright? I get enough whine from my friends about the activity-level on here already, so I guess I need to pick it up a bit, eh?

In the meanwhile, Steve Lam has been working quietly behind the scenes, and just released a new release candidate (haha… We just like the sound of it) of K2 yesterday, all 2.6 ready and everything. Knock yourself out!

And in closing: Twitter killed the blog. It’s true.

Habari Design

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.

Welcome WordPress 2.1

A big congratulations to Matt and company with the release of WordPress 2.1. I’m uploading it to the site as I’m writing this.

K2 is right behind it, and will see a new release as soon as humanly possible. I’m extremely busy this week, but I’ll see if I can’t slot it in somewhere later today so you have something new and shiny to play with.

WordPress 2.1 actually contains a couple of things that are of interest to K2, such as the inclusion of the Prototype and Scriptaculous javascript libraries directly in the core. And while it doesn’t look like WP gzip’s its JS libraries, it nonetheless is great for us to be able to rely on WP’s inclusion of those libraries, rather than shipping them with K2.

Also there is some interesting new header stuff, which should also make for some new niceties.

Today also sees the release of the 2.0 version of Akismet, a plugin that has done more for the world of blogging than any other plugin.

Prototype 1.5 Released

Yeah, so I’m still at home, eating oat meal and yoghurt very slowly. Very carefully. Which by the way, for those of you keeping track, means I missed out on the burgers at work today. Which sucks, because they are legendary burgers. And free.

Anyway, it does give me an opportunity to mindlessly check my feeds when I’m not feeding myself with painkillers. And as luck would have it, Prototype 1.5 was released today, complete with a new site and brand-spanking new documentation! Shiny!

I’ve already updated our K2 SVN repository, which by the way is as near as I can tell ready for the imminent release of WordPress 2.1.

K2 Beta Two r157

Fixing the broken AJAX (file-name mismatch) and a batch of other bugs from the bug tracker, r157 is now available from the usual place.

And on a related note, Dave has updated his FlickrRSS plugin to v3.0, which K2 of course supports.

And let me again chime in with a plea: If you encounter any bugs or if you’re planning on doing something with our code and there’s some way we can help you by making changes to the core, then please, let us know. The easiest way is to file a bug report, which you can be certain we look at, and then we’ll take it from there. I’ve already helped several people who’ve requested minor changes to the code, to make it easier for them to create their custom styles. And now is the time, before we get too close to the final release.

As usual, support questions, tips and tricks, general shenanigans and the talk of fairies go in the support forum.

Update: Fixed the missing authors on entries in r157.

K2 Beta Two

We won’t be able to deliver to you a 1.0 before the new year, as I had promised. But that’s okay, because I’m pretty proud of this Beta Two to be quite honest. It has seen some significant strides lately, and by and large I consider it a very stable product.

For Beta Two, there’s a new button in the options panel, which lets you quickly and easily set the options of Arnaud’s Extended Live Archives, try it out. Also, you’ll notice the inclusion of several Fam Fam Fam Silk Icons, which I personally love.

Chris went into some of the javascript files and bled them down to the bare essentials, and I finally got around to putting the ShowUtils and HideUtils functions into their own file (k2/js/k2functions.js). You may have noticed those two functions showing up in pingbacks and trackbacks all over the place; well that was my fault, and I’m really sorry. I hope Matt and the guys do something about it in Kubrick for 2.1.

There’s lots of other stuff as well, most of which you probably won’t notice, but trust us, it’s better.

If your favorite bug remains unfixed, head on over to the bug tracker and submit or resubmit a bug report, and you can be sure we’ll check it out. As usual, many tips and tricks can be found in the support forums, where you can also share your customizations and check out other people struttin’ their stuff. For a little taster, check out “Tauquil’s offering”:http://tauquil.com/.

So from Chris and I, a happy new year.

Download K2 Beta Two (for WordPress 2.0)

Revision 156

Symphonic Hyperbole

So I’m looking at Symphony, a new CMS of sorts, and I almost choke on my own spit as I read their header. I’m sorry guys, but I’m going to have to call you on your hyperbole:

The biggest thing to hit web publishing since the keyboard

Bull. Shit.

Being a gamer, following the games industry, I’ve seen a fair amount of hyperbole (Daikatana, Duke Nukem Forever anyone?), and it never did any good to anyone. I don’t mean to pound on Twentyone Degrees... but I’m going to anyway. So I went to their site, where I found this little remark:

It will have a level of support never before seen for such an application.

Listen puppies, launch the product, let it do its thing. If you rock, the rockness of you and your product will turn people in much the same way as a vile virus unleashed by a secret government project turns people into brain-craving zombies.

Anyway, I’ve thought up a few new taglines for K2:

  • The biggest thing to hit you since your abusive parents.
  • The biggest thing to hit archeological diggings since sand…!?
  • The biggest thing to hit life, the universe and everything since the rise of molecular structures.

Feel free to throw in your own ideas.

Oh yeah, almost forgot, it’s a cool name for an app. Symphony. Nice.