WordPress “Edit This” Links via Ajax

Working on a WordPress customisation recently, I added an “Edit This” link which only logged-in people can see. To get caching right, the server always outputs the same thing – an invisible link – and only in the browser does the decision get made to show the link or not. This exemplifies the pattern I only ever identified as “Ajax as a Remedy for the Cacheability-Personalization Dilemma”, but which I will now call “Browser-Side Personalisation”.

In this case, the personalised content is not secret, so it’s fine to output it in the HTML, and simply make it invisible by default. And it’s not mission-critical either, so the app degrades nicely if Javascript isn’t present – it simply won’t be displayed and the user will have to go into the “Manage Posts” area and look up the post from there.

To output “Edit This” from the server, within a WordPress loop:


  1. <div class="editPostLink"><? edit_post_link() ?></div>

Links of this nature are rendered invisible within layout.css:

  1. .editPostLink { display: none; }

… but we switch them on if the user is logged in:


  1. var loggedIn = /wordpress_logged_in/.test(document.cookie);
  2.   if (loggedIn) $(".editPostLink").show(); // it's easy with JQuery

Thanks For Your Comments, Friends

I’ve been wondering why I haven’t received blog comments for a while now. Assumed there must be some spam issue, but only today did I investigate it – triggered by a Dugg article on Akizmet’s false positives. (Akizmet is the WordPress web-service-based spam filter.) Akizmet has done a great job at separating definites from possibles, but it hardly let any real comments all the way. So I ended up having to moderate 250-odd comments over the past month, with about 35 false positives.

I probably haven’t heard about these problems because (a) they were in moderation, not marked as spam; (b) who remembers to go back to comments they left? (I don’t have any of the commenter ID plugins installed; maybe I should?); (c) my mail is equally full of spam lately.

The most interesting post in this regard was my advocacy for tableless forms, which surprisingly to me, was overwhelmingly supported by commenters.

I don’t like this because I generally like to reply to comments. I’ll go hit a few now…

Captcha Impossibillis

(Update: Thanks ImageShack for deleting my images.)

I was wrong, the third character is apparently a nine.

There ought to be a Captcha gallery/blog for all these. Apparently I’m not the only one who feels that way. Oh well, blame the spammers.

But more to the point, what’s up with this Captcha brought to you by the letters “A…F”???? Hex captcha? Hey, why bother with letters at all, let’s just go with binary captcha.

Here’s how inaccessible Captcha should really be done. (My first in-blog form too :-)).

Your answer (in base 10, of course!):