All Good Things Must Come To An End

As you all know, I have been doing WordPress plugins and supporting it for the past 6 years. These 6 years of my life, I have been through my polytechnic education, my national service as well as my university education.

I just graduated from university in December 2009 and have been looking for full-time jobs. I am offered a full-time job and will be starting work on 1st February 2010.

I regret to say that I am NOT ABLE to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

However, I WILL still update my plugins whenever I can and you still can report bugs to me via email and I will try to fix it.

Author Topic: Making WP-PostRatings 1.50 Work With SuperCache Properly  (Read 22578 times)

0 Members and 1 Guest are viewing this topic.

Offline lokos

  • Newbie
  • *
  • Posts: 2
    • View Profile
Hi, Here is how you can make wp-postrating to always show the updated rating with supercache installed

The problem you describe above happen because when you vote your rating refresh via AJAX so you see the updated view count immediately but once the page is refreshed supercache show the cache page with the old rating.
The solution: Load the rating with AJAX

1. Add the AJAX function to get the rating into your theme's function.php file
Code: [Select]
function get_rating_ajax($id) {
$nonce = wp_create_nonce('my_rating');
?>

<div id="ratings-wrap-<?php echo $id;?>">
<img src="/wp-content/uploads/images/loading_rating.gif" />
</div>

<script type="text/javascript">
jQuery(document).ready(function($){
  $.ajax({
    type : "GET",
    url : "<?php echo get_option('home'); ?>/wp-content/plugins/wp-postratings/wp-postratings.php",
    data : { wp_ajaxaction : "jquery", post_id : <?php echo $id?> , _ajax_check : "<?php echo $nonce;?>"},
    success : function(response){$("#ratings-wrap-<?php echo $id?>").html(response);}
  });
});
</script><?php
}
?>


2. Add the function to return the rating via ajax on the wp-postrating.php file
Look for the line:
Code: [Select]
$wpdb->ratings = $wpdb->prefix.'ratings';and copy this code below it:
Code: [Select]
if ( $_GET['wp_ajaxaction'] == 'jquery' ) {

$nonce =$_REQUEST['_ajax_check'];
if (! wp_verify_nonce($nonce, 'my_rating') ) die('Security check');

$id = $wpdb->escape($_GET['post_id']);
the_ratings('div',$id);
    exit();
}
3. Use it.

Replace your normal <?php the_rating() ?> function in your theme for  <?php get_rating_ajax ($post->ID) ?>

Make sure jquery is on the page where you are using this.
You can update this <img src="/wp-content/uploads/images/loading_rating.gif" /> for the path of the loading image you want to show while the rating is being updated.
« Last Edit: 06 October 2009, 07:32 by GaMerZ »

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #1 on: 25 September 2009, 16:46 »
thanks, stickied.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Need_Help

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #2 on: 06 October 2009, 06:42 »
In which file and where shall I put the codes into?

Thanks.

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #3 on: 06 October 2009, 07:28 »
Read the first post carefully, it is all stated there.

Modified the post to make it more obvious

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Need_Help

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #4 on: 06 October 2009, 07:33 »
Thanks for making it clearer. At first, he just stated function.php (which I couldn't find in the plugin folder)

Thanks.

Offline Need_Help

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #5 on: 07 October 2009, 03:07 »
<div id="ratings-wrap-<?php echo $id;?>">
<img src="/wp-content/uploads/images/loading_rating.gif" />
</div>

If you want your site to be XHTML valid, the line in bold should include the alt="" tag, like :
<img src="/wp-content/uploads/images/loading_rating.gif" alt="Loading"/>

Thanks.

PS : Of course, you may put whatever you want between the " mark, or even leave it blank.

Offline japhy

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #6 on: 22 October 2009, 21:23 »
Hi!

I just tried your fix. But I got this error message:

arning: Cannot modify header information - headers already sent by (output started at .../functions.php:276) in .../wp-content/plugins/wp-postratings/wp-postratings.php on line 580

Warning: Cannot modify header information - headers already sent by (output started at .../functions.php:276) in .../wp-content/plugins/wp-postratings/wp-postratings.php on line 624

Any idea what I'm doing wrong?

Thank you!

regards,
Japhy

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #7 on: 23 October 2009, 06:02 »
Ensure that you do not have any white spaces after the
Code: [Select]
?>

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline eilrax

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #8 on: 27 October 2009, 10:47 »
not work for me :s

in post

"Fatal error: Call to undefined function get_ip_address()"

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #9 on: 27 October 2009, 11:00 »
Your error pasted has nothing to do with this. get_ip_address is not used. It is get_ipaddress() and not get_ip_address();

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline eilrax

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #10 on: 27 October 2009, 11:21 »
sorry xd

Fatal error: Call to undefined function get_ipaddress() in /home/admin/domains/.../public_html/wp-content/plugins/wp-postratings/wp-postratings.php on line 310


Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #11 on: 27 October 2009, 11:38 »
I am guessing you did not place the code properly. get_ipaddress() is defined on line 416. Re-download wp-postratings and try again or you can drop lokos an email or private message to send you the modified file.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline chuy ban

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #12 on: 14 November 2009, 17:36 »
Thanks for the code, it works great for me just like magic.

But there is a problem for rating that use embed other post ratings such as using [ratings id="1"] or [ratings id="1" results="true"].
The ratings still don't show real time result. It shows cached result instead.

It would be great and helpful, if you can make this work as well.

Offline chuy ban

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #13 on: 24 November 2009, 13:38 »
Hi GaMerZ and Everyone,

Any ideas about the problem for rating that use embed other post ratings such as using [ratings id="1"] or [ratings id="1" results="true"]. with SuperCache enable.
The ratings still don't show real time result. It shows cached result instead.

It would be great and helpful, if you can make this work as well.

Thanks!

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #14 on: 24 November 2009, 14:11 »
I am not using SuperCache but I am guessing that the shortcode will not work with it. because the shortcode will be translated to normal ratings when the supercache parse it, it will be cache. And also by embedding other ratings ID into the post containing ratings will screw up the ID making it not work as well.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Eyeez48

  • Newbie
  • *
  • Posts: 4
    • View Profile
  • WordPress Version: WordPress 2.8.x
  • Theme Name: Eyeez
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #15 on: 24 May 2010, 09:04 »
I visit this site daily to see if anything new has been added. You have a nice work in your all site! It looks that you are highly expert blogger. Your post is an excellent example of why I keep coming back after completing my project to read your excellent quality content that is forever updated. That was exactly what I needed to read today.


_____________________________________
free host..web design services..search engine marketing services..windows hosting

Offline eithel

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #16 on: 05 August 2010, 18:15 »
Hi, everyone.

I made the modifications that you describe and the iframe shows up ok, I can vote, but when I do it and the vote is registered, the voting box disappears instead of showing the updated status. I have checked the response using fiddler and everything seems ok with it. Has any of you had this issue and found a solution?

Thank you!
eithel

Offline TJA

  • Newbie
  • *
  • Posts: 3
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: Gallery Pro
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #17 on: 15 August 2010, 19:15 »
Where do I place the code for step one? 

Thanks.

Offline mkp

  • Newbie
  • *
  • Posts: 5
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: Crystal
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #18 on: 29 September 2010, 05:16 »
In fact I had a similar problem some days back. I was working with wp-postrating via Ajax and I got the same error message. I asked some of my friends to help me but they could not because they were not familiar with it. Finally I sought professional help. They told me to place the code properly. I deleted and re-downloaded the wp-postratings and it fixed the issue. I would advise Newbie to do that. I am sure that he will succeed. 

Offline oblivion

  • Newbie
  • *
  • Posts: 4
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: WPTube3
Re: Making WP-PostRatings 1.50 Work With SuperCache Properly
« Reply #19 on: 08 November 2010, 21:56 »
please help me! I have an error:

Parse error: syntax error, unexpected $end in /home/sites/domains/sites.com/public_html/wp-content/plugins/wp-postratings/wp-postratings.php on line 1315

What should I do? I did everything according to instructions but do not want to work  :(
For even earlier thanks for your help!