Hi Lester,
I tried as you suggested, but I get this error message:
Warning: Missing argument 4 for wp_postratings_clear_fastest_cache()
so I’ve searched for “rate_post” hook in your plugin, and I found just this
do_action('rate_post', $rate_userid, $post_id, $ratings_value[$rate-1]);
that has actually 3 parameters instead of 4, so just removing the last parameter from the wp_postratings_clear_fastest_cache function seems to do the job.
Any hint would be appreciated.
thanks
Sorry I think is 3. The next version will have 4. My apologies.
No problem, I love your plugin 🙂
Hi- is there a similar piece of code for W3 Total Cache to do the same thing? Thanks!
“Crutches” for W3 Total Cache and othe Page Cashe.
1. In the page template add the code:
<script>
jQuery(document).ready(function() {
post_id=<?php echo $post->ID; ?>;
rate_post();
});
</script>
2. In plugin’s file wp-postratings.php before line 599 add:
if($rate == 0 && $post_id > 0 && check_allowtorate()) {
echo the_ratings( 'div', $post_id, false );
exit();
}
3.In plugin’s file postratings-js.js in function rate_post_success(a) swap the first two lines:
ratingsL10n.show_loading&&jQuery("#post-ratings-"+post_id+"-loading").hide();
jQuery("#post-ratings-"+post_id).html(a);
Dear Laster, make a real solution, pls! Many thanks for your greate plugin!!!
Correct solution to support Page caching (W3 Total Cache)
1. In plugin’s file wp-postratings.php before line 599 add:
if ( $rate == 0 && $post_id > 0 && check_allowtorate() ) {
echo the_ratings ( 'div', $post_id, false );
exit ();
}
2. In plugin’s file postratings-js.js add:
jQuery(document).ready(function() {
jQuery('.post-ratings').each (function(){
post_ratings_el=jQuery(this);
id=jQuery(post_ratings_el).attr('id');
post_id=id.substr(13);
post_ratings_nonce=jQuery(post_ratings_el).data("nonce");
if("undefined"==typeof post_ratings_nonce||null==post_ratings_nonce)post_ratings_nonce=jQuery(post_ratings_el).attr("data-nonce");
ratingsL10n.show_loading&&jQuery("#post-ratings-"+post_id+"-loading").show();
jQuery.ajax({
type:"POST",
xhrFields:{withCredentials:!0},
dataType:"html",
url:ratingsL10n.ajax_url,
data:"action=postratings&pid="+post_id+"&rate="+post_rating+"&postratings_"+post_id+"_nonce="+post_ratings_nonce,
cache:!1,
success:function (a) {
ratingsL10n.show_loading&&jQuery("#post-ratings-"+post_id+"-loading").remove();
jQuery("#post-ratings-"+post_id).replaceWith(a);
ratingsL10n.show_loading&&jQuery("#post-ratings-"+post_id+"-loading").hide();
ratingsL10n.show_fading?jQuery("#post-ratings-"+post_id).fadeTo("def",1,function(){set_is_being_rated(!1)}):set_is_being_rated(!1)
}
});
});
});
Hi Vadim, is there any way to implement your fixes in a way that won’t get overwritten when the plugin is updated?