My first WordPress Widget - Spam Popularity

I was deleting my Comment Spam caught by my spam filter this week and had the thought of creating a “Spam Popularity” widget. We could judge a blog’s popularity not by its subscribers but by how many spammers try to invade it daily. Ok so maybe Spam Popularity is not so great, but a visual spam counter does let me know when to go dump the comment spam so none of it seeps in.
I knew I wanted it in my sidebar but not too intrusive or attractive to spammers. So I began analyzing the sidebar widget code and found that I could easily modify the Google Search widget. That gave me the text but no counter. So from there I tapped into my Wordpress database and found the spam counter field that my filter is using. A simple include of a SQL query and my spam popularity widget is done.
And just to make it a little prettier I gave it its own class and a little CSS formatting. Scroll down to the admin section of the sidebar and you will see my little widget in action. Oh and for you comment spammers, this is not a challenge for you to run up my numbers, just a little something to let me know you came by. Legitimate comments are also moderated.