Comment Rating Pro
Dec 30th, 2009 by BoB
Comment Rating Pro WordPress plugin is the advanced version of the popular Comment Rating plugin. The Pro version was created to help those demanding for more features and customization flexibility. It has all the functionality of the standard version, and the following features.
- Styling comment image and text with a CSS class
- Disabling voting restrictions, i.e. disabling one-vote-per-IP-address and allow unrestricted voting
- Additional functions to retrieve comments ordered by their ratings
- Additional icons to make your blog unique
For the same reasons, I also created Comment Rating Widget Pro with the feature:
- Allows ordering comments by Comment Rating in the last X days on a sidebar.
To obtain both Comment Rating Pro and Comment Rating Widget Pro plugins, please donate $20. After donation, please follow the Paypal link returning to my site for the download page.
The Pro version option page can be seen here.
- Comment Rating Pro option page
- Comment Rating Widget Pro option page
Comment Rating Pro Customization Guide
This is a brief guide to customize using the Comment Rating Pro’s internal functions. These functions are accessible globaly as soon as the plugin is enabled.
CSS based styling
If you want to style the comment images and text, you can define a CSS class in your theme style file (style.css) with “CommentRating” class. For example, the following will show the comment rating images and text on the right.
.CommentRating {
text-align: right;
float: right;
}
To access the ratings of a comment
To avoid duplicated database access, Comment Rating use an cache “$ck_cache” hash array, defined as,
$ck_cache = array('ck_ips'=>"",
'ck_comment_id'=>0,
'ck_rating_up'=>0,
'ck_rating_down'=>0);
You should use it as a global variable. Here’s the sample code.
global $ck_cache;
ckrating_get_rating($comment_ID);
Then, all the related content will be accessible.
$ck_cache['ck_comment_id']
$ck_cache['ck_ips']
$ck_cache['ck_rating_up']
$ck_cache['ck_rating_down']
Tight integration
If you want to do tight integration with your theme in placement and style, you will need to insert the following line into your theme “comments.php” file within the comment loop.
<?php if(function_exists(ckrating_display_karma))
{ ckrating_display_karma(); } ?>
Order comments by their ratings
If you want to be adventurous in displaying comments in a post, you can use comment rating value to order the comments. This is done sorting based on the “comment_karma” field in the Wordpress “comment” table. Two things need to be done.
- Choose the comment rating value. The value for “comment_karma” field can take three options, i.e. Likes, Dislikes or Both. This is configured in “Comment Rating Pro Options” page, “Advanced Options”.
- Modify your theme’s “comments.php” file to change how comments are sorted.
If your theme does NOT use the new wp_list_comments() function (see this post
to understand what wp_list_comments() do). Then use the Comment Rating Pro’s function ckrating_get_comment() to retrieve comments in a certain sorting order for the current post.
$post_id = $post->ID;
$comments = ckrating_get_comments(
"post_id=$post_id&orderby=comment_karma&order=DESC");
foreach($comments as $comm) :
// Now display the comment detail. Here in a grossly simplified way echo($comm->comment_author);
echo($comm->comment_time);
echo($comm->comment_text);
// etc. etc. ...
endforeach;
If your theme uses wp_list_comments(), I haven’t figure out how to modify it. The flexibility offered by wp_list_comments() is too limited to allow customization.





