Comment Rating Pro

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
  • Voting by logged-in users only. This gives you the capability of running Comment Rating on a membership-based site.  Non-logged-in visitors  always see a gray icons and a message reminding them to log in or register.
  • Voting fraud detection by user ID. This is the strictest form of voting fraud prevention.  Only logged in users can vote and one vote per user ID.
  • Voting fraud detection by cookie. Votes are counted per cookie. This solves the problem that most of your readers are behind a NAT firewall. Cookie expiration can be set to a fix date or by days.
  • Disabling voting restrictions, i.e. disabling one-vote-per-IP-address and allow unrestricted voting.
  • Control where to  insert comment rating images: Posts, Pages or both, or on selected post IDs.
  • 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 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.

  1. 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”.
  2. Modify your theme’s “comments.php” file to change how comments are sorted.

If your theme uses the new wp_list_comments() function (see this post to understand what wp_list_comments() do), use the following code.

   if (function_exists(ckrating_get_comments)) {
      $post_id = $post->ID;
      $mycomments = ckrating_get_comments(
       "post_id=$post_id&status=approve&
        orderby=comment_karma&order=DESC");
   }
   else
      $mycomments = null;
   wp_list_comments(array(), $mycomments);

If your theme uses the old comment loop, 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;
   if (function_exists(ckrating_get_comments))
       $comments = ckrating_get_comments(
        "post_id=$post_id&status=approve&
        orderby=comment_karma&order=DESC");
   else
      $comments = get_comments(
        "post_id=$post_id&status=approve&
         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_content);
      // 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.


Comments

« Newer Posts - Older Posts »