http://thripp.com
This is a print version of Fixed WordPress calendar title formatting issue ($ak_title_separator) in cached pages by Richard X. Thripp on the Thripp.com network. Click here to print.
By Richard X. Thripp at 2008-08-20T02:41:27Z in News. 371 words.
I discovered an annoying issue with the calendar widget on my Thripp.com blog [1] today. I use the widget which is included in WordPress, WordPress MU, and Thripp.com, but for the Internet Explorer, Safari, and Camino browsers, it formats the pop-up titles with line breaks instead of commas. In Firefox it looks like this:

It’s pretty reasonable to use commas to separate post titles. But in Internet Explorer, WordPress generates the page using line breaks instead:

That makes sense, since Firefox can’t handle line breaks in title tags. Unfortunately, as you may know, I use WP Super Cache [2]. If the first visitor to a page is using Internet Explorer, his hit generates the cached copy. For later visitors in Firefox, the titles then look like this:

Bad bad bad. There’s no space or comma or line break or anything. It’s illegible.
The solution is to serve the same formatting to all browsers, so caching is a non-issue. I don’t care for the line breaks anyway; everything should have commas. I found the culprit in wp-includes/general-template.php. This is in WordPress MU 1.5.1, but it’s the same in WordPress 2.5.1 and the new 2.6 series:
if (strpos($_SERVER['HTTP_USER_AGENT'], ‘MSIE’) !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), ‘camino’) !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), ’safari’) !== false)
$ak_title_separator = “\n”;
else
$ak_title_separator = ‘, ‘;
Change that to this:
$ak_title_separator = ‘, ‘;
Simple. I’m surprised no one else is talking about it [3]. I guess I’m the only one who is annoyed enough.
If you want the best of both worlds, use this instead:
$ak_title_separator = ‘, \n’;
It’ll look right in Firefox and the same as before in Internet Explorer (line breaks), except with a comma after each title but before the line break.
The problem with this is that I’m hacking the core files, so I’ll have to re-apply the updates by hand when I upgrade WordPress MU. Thripp.com is on 1.5.1 now (2.5.1 in regular WP), but I’m skipping 2.6 to wait for 2.7 for Thripp.com. Hopefully the developers will have more bugs [4] worked out, with new ones to go along.
Surely there’s some way to do this with a plugin outside the core, but since it’s such a small thing I’m not going to look.
Your Thripp.com calendar widgets can now look nice for everyone. You can add one under Design > Widgets.
Printed from: http://thripp.com/blog/fixed-wordpress-calendar-title-formatting-issue-ak_title_separator-in-cached-pages-132
Short URL: r4ozm.th8.us
URLs in this entry:
[1] my Thripp.com blog: http://richardxthripp.thripp.com/
[2] WP Super Cache: http://ocaoimh.ie/wp-super-cache/
[3] talking about it: http://www.google.com/search?q=WordPress+ak_title_separator+Internet+Explorer+cache
[4] more bugs: http://wordpress.org/development/2008/08/wordpress-261/
Copyright © 2008 Richard X. Thripp.