So far I’ve only written one plugin for WordPress, Comment Analysis, which provides a suite of functions for displaying various statistics about the comments on your blog. Full details for it are below. When I get around to writing more plugins I’ll add them here.

Lorelle has suggested that plugin users should show their love by giving plugin authors money, the virtual equivalent of taking them out to dinner. This is a noble and appreciated sentiment, but I’m happy with just an occasional “Hey, thanks for doing this, you rock” comment or email. If you really feel the need to part with some of your money then it would make me really happy if you made a donation to the WWF or the Sierra Club.

Comment Analysis

This plugin contains a suite of functions which examine the comments on your blog. The plugin is now hosted in the wordpress.org repository, here:

Installation

  1. Download the appropriate version using the above link
  2. Put it into your /wp-content/plugins/ directory.
  3. Activate the plugin from your WordPress admin ‘Plugins’ page.
  4. Make use of the functions in your template (see examples below).

Function Reference

ca_comment_count()

Show total count of comments for your blog, excluding pingbacks and trackbacks.

ca_pingback_count()

Show total count of pingbacks for your blog.

ca_trackback_count()

Show total count of trackbacks for your blog.

ca_spam_count()

Show total count of comments marked as spam. (Version 2.1 only)

ca_comment_last ($format=”)

Show date of last comment. The optional parameter allows you to format the date using standard date formatting.

ca_pingback_last ($format=”)

Show date of last pingback. The optional parameter allows you to format the date using standard date formatting.

ca_trackback_last ($format=”)

Show date of last trackback. The optional parameter allows you to format the date using standard date formatting.

ca_commentor_latest ($count=10, $exclude=”, $before=’<li>’, $after=’</li>’)

Shows latest $count commentors, with links to their websites if provided. $exclude is a comma separated list of commentors not to include in the list. $before and $after define the tags which will be output at the start and end of each line.

ca_commentor_most ($count=10, $exclude=”, $before=’<li>’, $after=’</li>’, $before_count=’(‘, $after_count=’)')

Show the top $count commentors, with links. $exclude is a comma separated list of commentors not to include in the list. $before and $after define the tags which will be output at the start and end of each line. $before_count and $after_count define the text which will appear around the comment comment count.

ca_comment_latest ($count=10, $length=60, $before=’<li>’, $after=’</li>’, $linktext=’Go’)

Shows the first $length chars of the latest $count comments. $before and $after define the tags which will be output at the start and end of each line. $linktext defines the text of the link which takes the user to the full comment.

ca_comment_latest_posts ($count=10, $show_count=’yes’, $before=’<li>’, $after=’</li>’, $before_count=’(‘, $after_count=’)')

Show the latest $count posts with comments (with a count of comments if $show_count is not no. $before and $after define the tags which will be output at the start and end of each line. $before_count and $after_count define the text which will appear around the comment comment count.

ca_comment_most($count=10, $show_count=’yes’, $before=’<li>’, $after=’</li>’, $before_count=’(‘, $after_count=’)')

Show the top $count commented posts (with a count of comments if $show_count is not no. $before and $after define the tags which will be output at the start and end of each line. $before_count and $after_count define the text which will appear around the comment comment count.

ca_author_most ($count=10, $exclude=”, $before=’<li>’, $after=’</li>’, $before_count=’(‘, $after_count=’)')

Show the top $count authors on your blog (with a count of posts written). I realise this isn’t comment related, but someone asked for it and I was too lazy to write a new plugin for it. $before_count and $after_count define the text which will appear around the comment comment count.

Example

To add lots of comment data to your sidebar you could edit your sidebar.php and add the following code:

<ul>
<li>Total comments: <?php ca_comment_count(); ?></li>
<li>Total pingbacks: <?php ca_pingback_count(); ?></li>
<li>Total trackbacks: <?php ca_trackback_count(); ?></li>
<li>Last comment: <?php ca_comment_last(); ?></li>
<li>Last pingback: <?php ca_pingback_last(); ?></li>
<li>Last trackback: <?php ca_trackback_last(); ?></li>
<li>Latest comments
<ul><?php ca_comment_latest(10,23); ?></ul>
</li>
<li>Latest commented posts
<ul><?php ca_comment_latest_posts(10); ?></ul>
</li>
<li>Most commented posts
<ul><?php ca_comment_most(10); ?></ul>
</li>
</ul>