Do you run WP? Do you also have Akismet installed? Would you like a quick reference on the Dashboard showing you some info from Akismet? I do and did want this. Since I have zero idea on how to set this up as a plugin; I simply added the code into /wp-admin/index.php. I scanned through the file until I found the section of code which creates the “Latest Activity” box. Then between the sections for “Blog Stats” and “Incoming Links”1, I added the following code:
<h3><a href="http://akismet.com/" title="Stop Comment Spam and Trackback Spam « Akismet">Akismet</a> Stats</h3>
<? php
$deadspam = get_option('akismet_spam_count');
$livespam = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam'");
$sitelink = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_id = '1'");
print "Killed Spam Count: $deadspam\n";
if ($livespam == 0) {
print "Your spam queue is empty!";
} else {
print "<strong>Possible Spam Count: <a href="https://coffeebear.net/wp-admin/$sitelink/wp-admin/edit.php?page=akismet.php" title="Click here to see the moderation queue">$livespam</a></strong>\n";
}
?>
There’s undoubtably a more elegant way of retrieving and displaying this information. And for somebody who actually writes PHP code regularly, this might even be a quick and easy plugin to create. Unfortunately, I’ve only read part of a book about PHP; so this is about as far as I can currently take the hack. Unlike what some people think, WordPress does not require you to be a PHP guru. It only requires a webserver with PHP, MySQL & a little patience2.
NOTE: THIS IS A CORE WORDPRESS FILE! EDIT AT YOUR OWN RISK! I AM NOT RESPONSIBLE IF YOU HOSE YOUR BLOG, SERVER, LIFE, THE UNIVERSE, AND EVERYTHING! BACKUP EVERYTHING BEFORE YOU EVEN CONSIDER ATTEMPTING THIS! ONLY ATTEMPT THIS HACK IF YOU FEEL COMFORTABLE EDITING CORE WORDPRESS FILES.
Update: Neto Cury was kind enough to point out an error in the above code. Though to be fair it’s not entirely my fault. I pasted into this post the exact code I used in my file, but something in WP or one of the plugins I use appears to have changed the first part of the PHP coding from <? php to < ?php. I’m not sure what caused that, but to help people avoid getting errors; I’ve uploaded a text file containing the code for the hack. You can download that file here.
Update #2: Fixed a typo in the previous update. Sorry about that Neto!
Update #3 2007-04-21: I’ve updated this hack to modify the akismet plugin file (Akismet v2.0 for WordPress 2.1.3) instead of one of the WordPress core files. Read about it here.
1 Blog Stats ends at line 85 in my file and at the time of this writing I am running WordPress 1.5.2.
2 This is true of every CMS that I’ve looked at.