I’ve finally upgraded CoffeeBear.net to WordPress 2.5. I’m in the process of getting everything settled in properly and at the moment my library is working quite so nicely. At the moment the link for the library at the top of the page does not work (you’ll get a blank page) however if you go to any of the books in my sidebar you’ll find a working link to the actual library page on the individual book page. Also the nicely rewritten links for the library aren’t working correctly either. *shrug* Not sure what’s going on there, but I’ll post again and/or update this post once I’ve sorted it out. If you happen to notice any other problems with this site, please leave a comment under this post so I know to look into it.

Thanks!

I’ve been working on some stuff behind the scenes here at CoffeeBear.net with the intention of eventually upgrading the site’s backend and developing a new theme for the site. In the process of doing all this behind the scenes works, I’ve been trying out new plugins and wanted a quick way to check my server’s setup without putting a page for just anybody to view (e.g. creating my own phpinfo page). I found this a plugin by Designpraxis which basically adds the output from phpinfo to WordPress’s admin panel. Unfortunately, it buries the page/info under the Options panel. So I hacked it up to move the output under the Dashboard panel. Then I thought, it would be great if it could also list off all the plugins my site uses and what version of those plugins. I already have the pluginsUsedPlugin installed but it didn’t support plain-text output. So I hacked it up to output in plain-text, hacked up Phpinfo to include that plain-text output and then there was much rejoicing.

I thought it only fair to share my hacks, so enjoy or not as you choose. I’m sure there’s a more elegant way to code these changes, but I am not a programmer so if you use these and don’t like how I changed them… Well, you just have to suffer then. :p Feel free to ask questions but keep in mind:

  • I’m not a programmer.
  • These plugins aren’t originally mine. I don’t know much about how they work. I only know enough to hack together my changes.
  • If my hacked versions don’t work for you, try the originals before asking me for help. The people who made the originals should have a better idea of why things work/don’t work.

CoffeeBear’s Hacked Plugins

Text-Link-Ads is a nice service which I use to help pay the bills for running this site. They just released a new version of their WordPress plugin which I use to put their adverts on this site, so I installed it but in doing so it overwrote a couple of changes I’d made to the old plugin. I had made those changes as I like the service and I definitely like the additional income1, but I don’t like how the plugin makes the ad links less than obviously ads. So my changes in the plugin add a specific class which I can then style via CSS. Since I don’t want to have to keep redoing my customizations from scratch each time they release the plugin; I’m posting the code changes I make here.

Under function outputHtmlAds(), I changed the following line of code from:
echo "\n<ul>\n";</ul>

to:
echo "\n<ul class=\"tla_sponsor_link\">\n";</ul>

Also under function returnPostAd($postId), I changed:
return "\n\n<em>".$prefixes[$prefixIndex].":</em> $ad->before_text <a href=\"$ad->url\">$ad->text</a> $ad->after_text";

to:
return "\n\n<div class=\"tla_sponsor_link\"><em>".$prefixes[$prefixIndex].":</em> $ad->before_text <a href=\"$ad->url\">$ad->text</a> $ad->after_text</div>";

Side note: TLA, you guys should change the Our Blog to be called something else as the link doesn’t actually take users to your blog.

1 I don’t make enough from these ads to get rich mind you. Just enough to cover the costs of running CoffeeBear.net and maybe a cup of good coffee from my local coffee shop.

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