[wp-hackers] A new $comment_type?

Owen Winkler ringmaster at midnightcircus.com
Thu Jan 20 20:31:50 GMT 2005


Scott Reilly wrote:
> However, I do favor that get_comment_type() in
> wp-includes/comment-functions.php return 'comment' if the comment_type
> is '', rather than returning the  empty string for comments not
> explicitly noted to be 'comments'.  Shouldn't be any harm in that,
> right?  And saves from having to do the following if you want to know
> if a comment is a "comment":
> 
> $comment_type = get_comment_type();
> if ( '' == $comment_type || 'comment' == $comment_type ) { ... }
> 
> Especially for those not aware either case means "comment".
> 

And therein lies the answer to the original question:

>>>Right now, $comment_type can have  one of 3 values, comment, trackback,
>>>or pingback. I would like a 4th for page_comments -- here's why:

So the answer to both questions is to stuff this code into a plugin:

function odw_get_comment_type($comment_type) {
if(is_page()) return 'Feedback';
else if('' == $comment_type) return 'comment';
else return $comment_type;
}
add_filter('get_comment_type', 'odw_get_comment_type');

Ya gotta /look/ for da /hook/...  ;)

Owen





More information about the hackers mailing list