• Hi everyone!

    I found this review plugin for wordpress, but the function to determine if the comment is positive or negative doesn’t work properly so I wanted to ask if someone here could help me fix it

    The function first

    function sb_get_post_negative_positive_ratings($post_id,$type) {
    
        global $wpdb,$sb_ratings_table, $sb_ratings_cats_table, $comment_table,$sb_cat_global_table;
        $category_id = sb_getCategoryByPostId($post_id);
        $sql = "SELECT * FROM <code>&quot; . $sb_ratings_table . &quot;</code> "
             . "INNER JOIN <code>&quot; . $comment_table . &quot;</code> "
             . "ON (<code>&quot; . $sb_ratings_table . &quot;</code>.<code>comment_id</code> = <code>&quot; . $comment_table . &quot;</code>.<code>comment_ID</code>) "
             . "INNER JOIN <code>&quot; . $sb_ratings_cats_table . &quot;</code> "
             . "ON (<code>&quot; . $sb_ratings_table . &quot;</code>.<code>rating_cat_id</code> = <code>&quot; . $sb_ratings_cats_table . &quot;</code>.<code>id</code>) "
             . "INNER JOIN <code>&quot; . $sb_cat_global_table . &quot;</code> "
             . "ON (<code>&quot; . $sb_ratings_table . &quot;</code>.<code>rating_cat_id</code> = <code>&quot; . $sb_cat_global_table . &quot;</code>.<code>id</code>) "
             . "WHERE <code>&quot; . $comment_table . &quot;</code>.<code>comment_post_ID</code> = " . $post_id . " "
             . "AND <code>&quot; . $sb_cat_global_table . &quot;</code>.<code>wp_cat_id</code> = {$category_id} "
             . "ORDER BY <code>&quot; . $sb_ratings_table . &quot;</code>.<code>comment_id</code> ASC";
        $sql_result = $wpdb->get_results($sql,'ARRAY_A');
        if (is_null($sql_result)) {
            $sql_result = array();
        }
    
        $score = array();
        foreach ($sql_result as $data) {
            if (!isset($data['comment_id'])) {
                $score[$data['comment_id']] = array();
            }
            $score[$data['comment_id']][] = array(
                                            'current' => ($data['rating_value'] / $data['scale_max']) * $data['weight'],
                                            'max'   => $data['weight']
                                             );
        }
    
        $negative = 0;
        $positive = 0;
        foreach ($score as $comment_id => $scores) {
    
            $allRatings = 0;
            $maxRatings = 0;
            $avgMax = 0;
            foreach ($scores as $d) {
                $allRatings += $d['current'];
                $maxRatings += $d['max'];
            }
            $avgMax = $maxRatings / (count($scores));
            if ($allRatings < $avgMax) {
                $negative++;
            } else {
                $positive++;
            }
        }
    
        if ($type == 'positive') {
            return $positive;
        } elseif($type == 'negative') {
            return $negative;
        }
    
        return 0;
    }

    Here is the link to the review site
    http://www.sourcebench.com/toolbox/sb_review-wordpress-review-plugin

    I really need to make this work, but unfortunately my php skills are limited

    Thanks for reading

Viewing 5 replies - 1 through 5 (of 5 total)
  • Since this plugin is old and hasn’t been updated in very long, you might consider WP Review Site instead, by the author of the plugin SB based his on.

    Just to note that this new plugin requires payment.

    There is a LOT better plugin than WP Review Site, it’s WF Review.

    [ [link moderated]]
    Take a peek at WFReview’s features, TOTALLY blows WPReview out of the water.

    Well I jusf found a 25% discount coupon for ReviewPluginForWordpress.com at [link moderated]

    The other really cool feature which I personally like is the importing of data from the local CSV files.

    We use ratingpress from ratingpress.com. We looked at WPreview and WFReview but they’re both essentially the same code, and very limited. RatingPress had more features (it’s the only one we could consider for a commercial site) and it’s half the price of the others.

    I think they also offer an Excel/CSV import tool…

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WordPress Review Plugin’ is closed to new replies.