WordPress/Akismet Hack 0.0.2

Do you run WP? Do you also have Akismet installed? Would you like a quick ref­er­ence on the Dash­board show­ing you some info from Akismet? I do and did want this. Since I have zero idea on how to set this up as a plu­gin; I sim­ply added the code into /wp-admin/index.php. I scanned through the file until I found the sec­tion of code which cre­ates the “Lat­est Activ­ity” box. Then between the sec­tions for “Blog Stats” and “Incom­ing Links“1, I added the fol­low­ing 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="http://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 ele­gant way of retriev­ing and dis­play­ing this infor­ma­tion. And for some­body who actu­ally writes PHP code reg­u­larly, this might even be a quick and easy plu­gin to cre­ate. Unfor­tu­nately, I’ve only read part of a book about PHP; so this is about as far as I can cur­rently take the hack. Unlike what some peo­ple think, Word­Press does not require you to be a PHP guru. It only requires a web­server with PHP, MySQL & a lit­tle 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 some­thing in WP or one of the plu­g­ins I use appears to have changed the first part of the PHP cod­ing from <? php to < ?php. I’m not sure what caused that, but to help peo­ple avoid get­ting errors; I’ve uploaded a text file con­tain­ing the code for the hack. You can down­load that file here.

Update #2: Fixed a typo in the pre­vi­ous update. Sorry about that Neto!

Update #3 2007-04-21: I’ve updated this hack to mod­ify the akismet plu­gin file (Akismet v2.0 for Word­Press 2.1.3) instead of one of the Word­Press core files. Read about it here.

1 Blog Stats ends at line 85 in my file and at the time of this writ­ing I am run­ning Word­Press 1.5.2.
2 This is true of every CMS that I’ve looked at.

Similar Posts

  • Dashboard Akismet Hack 0.0.3
    Akismet is a popular comment, trackback, pingback spam blocker. Originally it was developed for the ...
  • Comment Spam
    I've been reading the WordPress Support Forums and lately it seems the #1 thing people are posting a ...
  • Pukka’s Links of the Week
    Due to recent crackdowns at the office on Internet access, this is likely to be the last PLotW. Also ...
  • Funny Comment Spam
    Even though I run multiple plugins to block comment spam; some still makes it into my moderation que ...
  • Now-Reading Tweaks
    I use Rob Miller's excellent Now-Reading plugin to track all the books I've read and am reading here ...

About Mark McKibben

Mark works as a [REDACTED] for [REDACTED], currently residing in Iowa. CoffeeBear.net is a place for him to blather on about whatever strikes his fancy. He currently spends his "free" time working on a photography project, playing with his cat and attempting to keep his wife happy (not necessarily in that order).

9 Comments

  1. Mark says:
    November 24th, 2005 at 11:51 pm

    Today, Matt offi­cially announced ver­sion 1.11 of Akismet. The above hack was writ­ten using Word­Press 1.5.2 & Akismet 1.11.

  2. Neto Cury says:
    November 25th, 2005 at 12:22 am

    Hi,
    A lit­tle mis­take in te code:
    <?div>

    Akismet Stats

    < ?php
    In the last line, the error occurs because the blank space between < and ?
    Dont exist the blank space in there
    The cor­rect is:
    <?php<?/div>

  3. Neto Cury says:
    November 26th, 2005 at 4:45 am

    Hey! Thanks for the cita­tion, but cuRRy is an condi­ment LOL my name is Neto CuRy, with only one R :D
    Salute

  4. Paul Bauer says:
    January 15th, 2009 at 5:35 pm

    Do you know if Akismet is avail­able for Blogger?

  5. cnc math says:
    January 20th, 2009 at 12:23 pm

    blog­ger rarely gets as much spam as word­press and there is noth­ing to the extent of akim­set but there are spam block­ing options. nice php hack, i like the ease of use of php and the sup­port from the com­mu­nity, dont really under­stand all the neg­a­tiv­ity out there around it

Trackbacks/Pingbacks

  1. WordPress.com.br
  2. Neto Cury Blog » SUGESTÃO DE CORREÇÃO
  3. Dashboard Akismet Hack 0.0.3 | CoffeeBear.net

Leave a Reply

Notify me of followup comments via e-mail. You can also subscribe without commenting.