<?php
/*
Plugin Name: MW Comments/Trackbacks
Plugin URI: http://www.meyerweb.com/eric/tools/wordpress/mw_comments_trackbacks.html
Description: This plugin contains two functions.  The first, <code>mw_comments</code>, returns the comments for a given post, or else a count of how many there are, depending on the parameter you pass it.  The second function, <code>mw_trackbacks</code>, does the same for trackbacks and pingbacks.  The counting capability makes it easy to do MT-style comment/trackback counts on a post (i.e., "C:1 T:3").
Version: 1.0.1
Date: 24 July 2004
Author: Eric A. Meyer
Author URI: http://meyerweb.com/
*/

/*
Version history:
1.0.1 (24 July 2004)
  - Added 'comment_approved' check to prevent unapproved comments from being counted/returned.
1.0 (10 May 2004)
  - Initial release.
*/

function mw_comments($param = '') {
	global $wpdb, $tablecomments, $post;
	$comments = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_post_ID = $post->ID AND comment_content NOT LIKE '%<trackback />%' AND comment_content NOT LIKE '%<pingback />%' AND comment_approved = '1'");
	if ('count' == $param) {
		echo count($comments);
	} else {
		return $comments;
	}
}

function mw_trackbacks($param = '') {
	global $wpdb, $tablecomments;
	$trackbacks = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_content LIKE ('%<trackback />%') AND comment_approved = '1'");
	if ('count' == $param) {
		echo count($trackbacks);
	} else {
		return $trackbacks;
	}
}


?>