Dashboard Hack 0.0.3

Akismet is a popular comment, trackback, pingback spam blocker. Originally it was developed for the WordPress blogging platform; it has since been extended to work on a variety of blogging and forums systems. However the only part of it I really care about is the WordPress plugin as it is one of the ways I protect this site from spammers. Akismet works great1 but there is one thing the developers of Akismet have never seen fit to do which drives me bonkers. Which is to say the only place the Akismet plugin shows you how many comments it has in the spam moderation queue is on the spam moderation queue page. And yet they put some stats for Akismet right there on the WordPress dashboard. In ages long past, I cobbled together a small hack to display those moderation numbers, when I upgraded my site to a more current version of WordPress my hack broke.

This morning I finally fixed it. People more clever than myself could make this into a full fledged plugin, but this little hack is good enough for me. To do this:

  1. Download a copy of the Akismet plugin for WordPress
  2. Decompress the zip file
  3. Open the akismet.php file in your favorite text editor2
  4. In akismet.php, search for “function akismet_stats()”. It should be around line 510.
  5. In the akismet_stats function, under the line reading echo '<h3>'.__('Spam').'</h3>'; add the following code:
    $spam_count = akismet_spam_count();
    $link = 'edit-comments.php';
    if ($spam_count) :
    print "<strong><a href="$link?page=akismet-admin" title="Click here to see the moderation queue">Spam in moderation ($spam_count)</a></strong>\n";
    endif;
  6. Save your changes.
  7. Uploaded your edited copy of akismet.php to http://yourblog.com/wp-content/plugins/akismet/ and then follow the normal instructions for installing/activating the Akismet plugin.

With this small hack in place, when Akismet traps some comment spam in its moderation queue the WordPress dashboard will display a link under the Spam in the Latest Activity box. The link will say “Spam in moderation (x)” where x is the number of items in the spam moderation queue. Since WordPress likes to occasionally mangle the display of code in posts, I’ve created a text file with my changes to the akismet_stats function. You download that file here.

Update 2007-04-22: As to be expected, it didn’t take the spammers long to generate some sample data for me to create a screenshot of my hack.  Enjoy!

1 Particularly with the Bad Behavior anti-spam plugin added to it.
2 E.g. Kate

Frequent visitors to this site1 will probably notice something a bit new over in my sidebar. Today I added a new “Sponsors” section to the site. This sponsors section is will be serving up text link adverts from Text Link Ads2.

For a long time I have resisted placing any form of advertising on this site. I just didn’t want to deal with the hassle of it and I wanted to keep CoffeeBear.net “pure”. However I realize now that is something of a very silly notion and decided to give Text Link Ads a chance to make this site pay for itself.

Does this mean I’ve sold out? Well I am trying to make a small amount of money from this site now; however CoffeeBear.net will not become some advert laden monstrosity with hundreds of annoying, flashing banners. Just two little links in the sidebar. So you’re free to think what you like, but I’m not thinking this counts as selling out.

1 Readers of my RSS feed will also eventually be seeing some text link ads as well. How long it takes depends on how quickly Text Link Ads sells the advert slots.
2 All links to Text Link Ads in this post are in fact affiliate links and if you use them to go to their site to sign up, then I am supposed to get 25 smackeroos. 🙂

On Easter Sunday, my wife and I went to her sister’s for lunch1. While we were there, the relatives sprang a couple of broken computers on me asking me to fix them2. Since we were getting really good grub3, I figured I could at least take a look. Of course, neither person with a broken machine had any useful CDs with them, though one did run home to see if she had any there (nope). I ended up taking both machines home and working on them in my spare time. Today, I finally fixed one of them and I fixed it by following the instructions I found in this article: Windows XP Crashed? Here’s Help. That worked really well in helping me fix the XP laptop dumped on me, but the other machine is an older WinME desktop. I’m still working on that one, but fortunately there’s no rush on the WinME box. Still I’m thrilled that I’ve got one of them fixed and can relax a bit4.

1 We had an extremely yummy lamb roast.
2 For the record, I’m a database guy these days not a support tech. *sigh*
3 And free, never forget free! *grin*
4 Yes, I’m still reading those wretched fun Wheel of Time books.