In response to my request, the indomitable Hamish Macpherson has created NeverForgetcerpt, a plugin for WordPress 2.5+ that will warn you if you’re about to publish a post that lacks an excerpt. I’m already using it on meyerweb and it’s working like a charm. He’s also expressed interest in the idea of a plugin that does that and also warns you if you forgot to add tags or categories, so stay tuned. Meantime, all hail Hamish!
I have another plugin request, but in this case I’m looking for help in modifying something I’ve already done. Or half-done, maybe.
I don’t know about you, but I get a lot of comment spam. As I type this sentence, Akismet has stopped 837,806 spam attempts in total. A false positive makes it past Akismet and my other defenses to land in the moderation queue about once every four days, on average.
Some of those false positives are really, really, really easy to spot, and they get marked as spam in order to help improve the recognition algorithms. Others are hard to evaluate just by looking at the comment. Many are trackbacks from sites in langauges I can’t read, and others that I can read look legit enough. In such cases, I usually go visit the author’s URL to see if it looks spammy or not.
Now, the way I used to do this was to right-click on the blog link, copy the URL of the target, open a new browser tab, and paste the URL into the address bar. Why? To prevent my WP admin URL from landing in the referer logs of a potentially unscrupulous site owner. But sometimes I forget to do all that, and just click. I figured, well, why not stop fighting the tendency to just click and write a plugin that routes all outbound links through a redirect service?
So I did. You can grab it for yourself if you want, but if you do, understand that it’s pretty clunky right now. Which is the part I’d like help fixing.
The heart of the plugin is simplicity itself:
if (is_admin_page()) {
add_filter('get_comment_author_url','_mw_obscurify',5);
}
function _mw_obscurify($url) {
if ($url) return 'http://google.com/url?q=' . $url;
}
There’s a little more to it than that (specifically, the routine is_admin_page()
, which I got from someone else’s plugin and wish now I could remember whose it was) but that’s the core. So any time the URL of a comment author is fetched, it’s prepended to turn it into a Google redirect.
That’s true for both href
values and displayed URLs, though, which is the clunky part. The end result is that on comments from the aforementioned mighty Hamish, for example, I get the following markup on the “Comments” page:
<a href="http://google.com/url?q=http://hamstu.com">
http://google.com/url?q=http://hamstu.com</a>
What I’d very much prefer is:
<a href="http://google.com/url?q=http://hamstu.com">
http://hamstu.com</a>
Or even:
<a href="http://google.com/url?q=http://hamstu.com">
hamstu.com</a>
So what I’d like to know is if there’s any way to make that happen short of rewriting and replacing get_comment_author_url
, which I’d prefer not to do since it could change in future versions of WordPress and I’m not particularly interested in turning a basic plugin into a continuing maintenance headache. I mean, I will if absolutely necessary, but I’d like to find a better way if there is one. Thus the request for help.
Also, are there better redirect strategies than using Google the way I have? It’s very slightly annoying that I have to click through the Google redirect page, and though I absolutely understand why they do that, I’d love to find an automatic redirect that wouldn’t expose my referer to the target site. Anyone know of one, or have a related sharp idea?