/** * Code for StarComments shortcode implementation * * @param array $atts */ function shortcode_starcomments($atts = array()) { $sett = shortcode_atts($this->default_shortcode_starcomments, $atts); if ($sett["post"] == 0) { global $post; $sett["post"] = $post->ID; } else { $post = get_post($sett["post"]); } $rating = ""; $sett["comments"] = $post->comment_count; if ($post->ID > 0) { $rows = gdsrBlgDB::get_comments_aggregation($sett["post"], $sett["show"]); $totel_comments = count($rows); $total_voters = 0; $total_votes = 0; $calc_rating = 0; foreach ($rows as $row) { switch ($sett["show"]) { default: case "total": $total_voters += $row->user_voters + $row->visitor_voters; $total_votes += $row->user_votes + $row->visitor_votes; break; case "users": $total_voters += $row->user_voters; $total_votes += $row->user_votes; break; case "visitors": $total_voters += $row->visitor_voters; $total_votes += $row->visitor_votes; break; } } if ($total_voters > 0) { $calc_rating = $total_votes / $total_voters; } $calc_rating = number_format($calc_rating, 1); $rating = GDSRRenderT2::render_car($sett["tpl"], array("votes" => $total_voters, "rating" => $calc_rating, "comments" => $sett["comments"], "star_style" => $this->is_ie6 ? $this->o["cmm_aggr_style_ie6"] : $this->o["cmm_aggr_style"], "star_size" => $this->o['cmm_aggr_size'], "star_max" => $this->o["cmm_stars"])); } return $rating; }