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
- 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 cookie. Votes are counted per cookie. This solves the problem that most of your readers are behind a NAT firewall.
- 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 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.


[...] Allow customizing the CSS tags around the voting image/ratings. Done in the Pro version [...]
Well-loved. Like or Dislike:
70
29
How do you add comment numbers like you did on captionwit? I managed to order the comments by karma by editing comment-template in includes dir.
Well-loved. Like or Dislike:
34
15
[Reply]
BoB
Reply:
January 26th, 2010 at 12:34 pm
Hi there, thanks for your donation.
Captionwit.com has the what I call tight integration, where you disable the auto-insertion and place the function call in your theme. Please refer to the “Tight integration” section here: http://wealthynetizen.com/comment-rating-pro/
Hot debate. What do you think?
17
14
[Reply]
SO
Reply:
January 26th, 2010 at 11:20 pm
Thanks for the reply. I was talking about the number in front of the comments that tell you what place each comment is ranked. The 1, 2, 3, 4…
Well-loved. Like or Dislike:
22
5
[Reply]
I have a large site with lots of users commenting on posts. I was looking for a plugin like this. Made my life a bit easier. Thanks.
Well-loved. Like or Dislike:
11
6
[Reply]
When you say “Styling comment image” what exactly do you mean? I thought it would let me style the voting icon but it seems to be rendering the same way the standard plugin did. It uses an image with a bunch of inline styles that makes it almost impossible to style. What is the best path for completely changing the icon style? Is there a way to get the plugin to spit out a link (which could then be styled) instead of an inline image?
Well-loved. Like or Dislike:
8
3
[Reply]
Clark
androidandme.com Reply:
March 30th, 2010 at 7:42 pm
Right now the best way I can figure to style them is to replace the icons with something transparent, then use CSS to set a background image on the actual, transparent image. Which seems a bit like a hassle.
Well-loved. Like or Dislike:
12
3
[Reply]
BoB
Reply:
March 30th, 2010 at 10:31 pm
Hi Clark,
Thanks for your support.
What do you want to do in styling images? We can figure out the most convenient way together.
BoB
Hot debate. What do you think?
5
7
[Reply]
Clark
androidandme.com Reply:
March 31st, 2010 at 7:53 am
In the past I’d have to overwrite the images included with the plugin (which made updating a hassle). Is there a way you could include a CSS class or a wrapper (an anchor would be perfect) for each voting image?
Hot debate. What do you think?
7
8
[Reply]
Can you tell me if the 5 Star voting system (ala People of Walmart) is part of your Comment system, or a different plugin or widget?
Tx Jeff
Hot debate. What do you think?
5
3
[Reply]
BoB
Reply:
April 3rd, 2010 at 4:19 pm
No the 5 star voting is not part of Comment RAting.
Hot debate. What do you think?
5
4
[Reply]
Hi. For some reason it’s showing comments that have no votes at all here: http://oneword.com/staging/favorites/ Please advise.
Like or Dislike:
4
3
[Reply]
I’m thinking of getting the Pro version, just installed your free version and love it. but one thing I was hoping to find that I don’t see is a simple selection to let only registered users vote. By the way I’d also to see a fine tuning of that option that allows me to see that anyone can vote up, but only registered users can down down. An easier was to do this would be to hae two options: 1) Level required to vote up and 2) Level required to vote down. Then I could set it to 0 if I want to allow everyone to vote, 1 if I want any registered user only to vote, etc.
See, I run a high traffic political website and it just takes a handful of visitors “from the other side” to gang together and down vote every comment and really screw me.
If you can do that really soon, I’ll pay you double for the Pro, I promise.
Like or Dislike:
1
2
[Reply]
BoB
Reply:
May 10th, 2010 at 10:39 pm
Mark,
Thanks so much for your support.
I can add the feature that only logged in user can vote . It’s a little harder to restrict user’s capability to vote up or down based on whether they’re logged in or not.
I’d suggest that you allow democracy on your site. You can always change the positive/negative threshold to change the appearance of comments.
It’d be interesting to observe the social dynamics there.
Like or Dislike:
1
0
[Reply]
Mark
Reply:
May 10th, 2010 at 10:58 pm
I’m not sure what democracy is? I see there is a plugin, but that is for polls.
BTW, I sent the donation off a few hours ago. Happy to do it. But do I get a download link in an email?
Like or Dislike:
1
0
[Reply]
Okay, I’ll just buy the Pro as is…payment coming.
Like or Dislike:
0
0
[Reply]
I’ve been using the free comment rating on a client site for a couple of weeks now, and they wanted to turn off the IP screening. So I’ve donated and got Pro set up, but it no longer works. Everything shows up, but I can’t seem to register any ratings.
A second potential issue–will the Pro plugin preserve the ratings that were made by the original plugin? The client would prefer not to go back to zero. In fact, this is probably a deal-breaker if it doesn’t preserve the old ratings.
Like or Dislike:
0
0
[Reply]
BoB
Reply:
June 3rd, 2010 at 1:23 pm
The Pro version preserves all the previous data.
I assume that you have disable the standard version, and then enable the Pro version. You cannot have both version enabled.
If this is not the problem, let me know the url. I’ll take a look
Like or Dislike:
0
0
[Reply]
Mark
Reply:
June 3rd, 2010 at 2:16 pm
Thanks Bob. With the assurance that previous data would be preserved, I went ahead, and it’s working great.
My problem getting it to work before was, I think, related to the fact that my test install was on a local server. When I shifted everything to a remote, public server, it worked just great.
Just my $.02, but it seems like it would be better to do some other anti-spam check rather than IP. I changed this because the client’s internal people were getting upset because they couldn’t rate comments–they all have the same outgoing IP. Perhaps a session or cookie would be a better strategy so people with shared connections (the majority of office workers) can still rate comments.
Like or Dislike:
0
1
[Reply]
Mark
Reply:
June 3rd, 2010 at 2:40 pm
I’ve upgraded to the Pro version, but sadly I’m still waiting for a fix on the Pro Widget.
Like or Dislike:
0
0
[Reply]
BoB
Reply:
June 3rd, 2010 at 3:24 pm
Sorry, could you pls fill me in with the context?
Like or Dislike:
0
0
[Reply]
Mark
Reply:
June 3rd, 2010 at 5:12 pm
You and I had been working on this via email, and I have not received a reply from you in some time on it. Remember, plugin install failed.
Like or Dislike:
0
0
BoB
Reply:
June 3rd, 2010 at 7:35 pm
Did we fix the problem in the Thesis 1.7 theme? I don’t have any problem with either Comment Rating Widget Pro nor the standard, with the fixed Thesis 1.7 theme.
Do you encounter something else?
Like or Dislike:
0
1
BoB
Reply:
June 3rd, 2010 at 3:08 pm
I’m glad it worked smoothly. It’s the design intent. You’re right the IP based checking is rather rudimentary. I’ll add more capability later on.
Like or Dislike:
0
0
[Reply]
“Did we fix the problem in the Thesis 1.7 theme? I don’t have any problem with either Comment Rating Widget Pro nor the standard, with the fixed Thesis 1.7 theme.”
It doesn’t work on Thesis 1.6, WP 2.9.2. We had a long discussion on this via email, and you’ll see my last email to you on may 27.
Like or Dislike:
0
0
[Reply]
Hey Bob,
I am planning on donating to get the pro-version. But have a quick question I am hoping could be answered first. Is it possible to allow ONLY logged in users to rate comments – and do it only once per comment? So they can’t change their vote once it is cast?
Like or Dislike:
0
0
[Reply]
BoB
Reply:
June 10th, 2010 at 10:14 am
No this feature is on my next to-do list. I’ll let you know as soon as it’s done.
Like or Dislike:
0
0
[Reply]
My blog have a lot of comments (+250.000) and this plugin is taking a lot of resources in the database. Is there any way to optimize the database for this plugin? (Creating index or similar)
Like or Dislike:
0
0
[Reply]
BoB
Reply:
June 10th, 2010 at 2:35 pm
I’m glad to know your blog can have so many comments. Performance was a key consideration of the Coimment Rating design. If you look at the wp_comment_rating table, there’s an index on ck_comment_id. All search is based on ck_comment_id. I have also used DB caching to reduce duplicated DB queries to 0.
If you can let me know more about why you think Comment RAting takes a lot of resource in DB, I can have another look.
Like or Dislike:
1
0
[Reply]
hello,
i all ready bought the pro plugin, but now i want to sort the comments based on rating. i allready spend like 2.5 hours tryin to fix it, can i send you my comments.php file? thx
Like or Dislike:
3
0
[Reply]
I’m very interested in donating to the project, however was really hoping for the require-login to vote functionality. Also, any way you can lend a hand to us who, like the above poster want to sort comments by rating? Any idea when at least the register to vote option is going to be built in? Thanks!
Like or Dislike:
0
0
[Reply]
BoB
Reply:
July 11th, 2010 at 11:25 pm
It’s very close to completion. You know the Word Cup delays everything.
I’ve got the beta ready and doing some thorough testing. It’ll be available in a few days. Please check back again.
Like or Dislike:
0
0
[Reply]
BoB
Reply:
July 13th, 2010 at 9:46 pm
Ty, the vote by logged-in users only feature is done. http://wealthynetizen.com/comment-rating-pro-version-2-12-1/
Like or Dislike:
0
0
[Reply]
ty
Reply:
July 13th, 2010 at 10:00 pm
Woohoo, thanks!
Like or Dislike:
1
0
[Reply]
Excellent thanks! If you can throw auto-sort in there on refresh – you’ll be our hero.
Like or Dislike:
0
1
[Reply]
Bob,
I just got the pro-version. If I select the cookie based tracking the voting behaves how it should. However, if the ip-based tracking is selected, all buttons turn gray – even for the comments that have not been rated yet.
Like or Dislike:
0
0
[Reply]