/* Gold Plugins Aggregate Rating Edit */
function modify_easy_t_aggregate_rating( $output, $count_query ) {
//Valutato 4.67/5 in base a 3 recensioni
//calculate average review value
$total_rating = 0;
$total_rated_testimonials = 0;//only want to divide by the number of testimonials with actual ratings
$item_reviewed = get_option('easy_t_global_item_reviewed','');
foreach ($count_query->posts as $testimonial){
$testimonial_rating = get_post_meta($testimonial->ID, '_ikcf_rating', true);
if(intval($testimonial_rating) > 0){
$total_rated_testimonials ++;
$total_rating += $testimonial_rating;
}
}
$average_rating = $total_rating / $total_rated_testimonials;
$output = '
<div class="easy_t_aggregate_rating_wrapper" itemscope itemtype="http://schema.org/Product">
<span class="easy_t_aggregate_rating_item" itemprop="name">' . $item_reviewed . '</span>
<div class="easy_t_aggregate_rating" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">Valutato <span class="easy_t_aggregate_rating_top_count" itemprop="ratingValue">' . round($average_rating, 2) . '</span>/5 in base a <span itemprop="reviewCount" class="easy_t_aggregate_rating_review_count" >' . $total_rated_testimonials . '</span> recensioni</div>
</div>
';
return $output;
}
add_filter( 'easy_t_aggregate_rating', 'modify_easy_t_aggregate_rating', 10, 2 );