WordPress.org

Ready to get started?Download WordPress

Forums

GD Star Rating
[resolved] Bugfix for wp_gdsr_rating_comment function (1 post)

  1. renet
    Member
    Posted 1 year ago #

    Hi everyone,

    as some may have encountered already (and as some have already posted here: http://wordpress.org/support/topic/plugin-gd-star-rating-how-to-get-comment-thumbs-count) there is a problem with the wp_gdsr_rating_comment function for getting the comments rating information. The thumbs votes always count 0, even though some thumbs votes have already been made. As I needed this to work, I did a little research and this is what I found out:

    The problem exists due to an error in the GDSRCommentRating class, which can be found in [plugin's-folder]/code/cls/results.php (lines 115 to 166).

    To fix this, simply replace all occurrences of $post_data in the GDSRCommentRating function of this class with $comment_data. This should do the job.

    The fixed class should look like this:

    class GDSRCommentRating {
        var $comment_id;
        var $post_id;
        var $review;
        var $user_votes;
        var $visitor_votes;
        var $votes;
        var $user_rating;
        var $visitor_rating;
        var $rating;
        var $thumbs_user_rating = 0;
        var $thumbs_visitor_rating = 0;
        var $thumbs_rating = 0;
        var $thumbs_user_votes;
        var $thumbs_user_votes_plus;
        var $thumbs_user_votes_minus;
        var $thumbs_visitor_votes;
        var $thumbs_visitor_votes_plus;
        var $thumbs_visitor_votes_minus;
        var $thumbs_votes;
        var $thumbs_votes_plus;
        var $thumbs_votes_minus;
    
        /**
         * Class constructor.
         *
         * @param object $comment_data input data
         */
        function GDSRCommentRating($comment_data) {
            $this->comment_id = $comment_data->comment_id;
            $this->post_id = $comment_data->post_id;
            $this->review = $comment_data->review;
            $this->user_votes = $comment_data->user_voters;
            $this->visitor_votes = $comment_data->visitor_voters;
            $this->votes = $this->user_votes + $this->visitor_votes;
            if ($comment_data->user_voters > 0) $this->user_rating = number_format($comment_data->user_votes / $comment_data->user_voters, 1);
            if ($comment_data->visitor_voters > 0) $this->visitor_rating = number_format($comment_data->visitor_votes / $comment_data->visitor_voters, 1);
            if ($this->votes > 0) $this->rating = number_format(($comment_data->visitor_votes + $comment_data->user_votes) / ($comment_data->visitor_voters + $comment_data->user_voters), 1);
            $this->thumbs_votes = $comment_data->user_recc_plus + $comment_data->user_recc_minus + $comment_data->visitor_recc_plus + $comment_data->visitor_recc_minus;
            $this->thumbs_rating = $comment_data->user_recc_plus - $comment_data->user_recc_minus + $comment_data->visitor_recc_plus - $comment_data->visitor_recc_minus;
            $this->thumbs_votes_plus = $comment_data->user_recc_plus + $comment_data->visitor_recc_plus;
            $this->thumbs_votes_minus = $comment_data->user_recc_minus + $comment_data->visitor_recc_minus;
            $this->thumbs_visitor_votes = $comment_data->visitor_recc_plus + $comment_data->visitor_recc_minus;
            $this->thumbs_visitor_rating = $comment_data->visitor_recc_plus - $comment_data->visitor_recc_minus;
            $this->thumbs_visitor_votes_plus = $comment_data->visitor_recc_plus;
            $this->thumbs_visitor_votes_minus = $comment_data->visitor_recc_minus;
            $this->thumbs_user_votes = $comment_data->user_recc_plus + $comment_data->user_recc_minus;
            $this->thumbs_user_rating = $comment_data->user_recc_plus - $comment_data->user_recc_minus;
            $this->thumbs_user_votes_plus = $comment_data->user_recc_plus;
            $this->thumbs_user_votes_minus = $comment_data->user_recc_minus;
        }
    }

    I'm working with the version 1.9.21 of the plugin. I hope this helps some people.

    Regards,
    René

    http://wordpress.org/extend/plugins/gd-star-rating/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic