WordPress Review Plugin
-
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>" . $sb_ratings_table . "</code> " . "INNER JOIN <code>" . $comment_table . "</code> " . "ON (<code>" . $sb_ratings_table . "</code>.<code>comment_id</code> = <code>" . $comment_table . "</code>.<code>comment_ID</code>) " . "INNER JOIN <code>" . $sb_ratings_cats_table . "</code> " . "ON (<code>" . $sb_ratings_table . "</code>.<code>rating_cat_id</code> = <code>" . $sb_ratings_cats_table . "</code>.<code>id</code>) " . "INNER JOIN <code>" . $sb_cat_global_table . "</code> " . "ON (<code>" . $sb_ratings_table . "</code>.<code>rating_cat_id</code> = <code>" . $sb_cat_global_table . "</code>.<code>id</code>) " . "WHERE <code>" . $comment_table . "</code>.<code>comment_post_ID</code> = " . $post_id . " " . "AND <code>" . $sb_cat_global_table . "</code>.<code>wp_cat_id</code> = {$category_id} " . "ORDER BY <code>" . $sb_ratings_table . "</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-pluginI 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)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘WordPress Review Plugin’ is closed to new replies.