/**
  * Customize the review product tab
  *
  * Will replace the review tab title with a more generic
  * one if multiple contribution types are enabled, or
  * with a specific title, if only one type is enabled.
  *
  * @since 1.0.0
  * @param array $tabs
  * @return array
  */
 public function customize_review_tab($tabs)
 {
     global $post;
     if (isset($tabs['reviews'])) {
         $enabled_contribution_types = wc_product_reviews_pro()->get_enabled_contribution_types();
         // Do not take contribution_comments into account
         if (($key = array_search('contribution_comment', $enabled_contribution_types)) !== false) {
             unset($enabled_contribution_types[$key]);
         }
         // Hide reviews tab if none of the types are enabled
         if (empty($enabled_contribution_types)) {
             unset($tabs['reviews']);
         } elseif (count($enabled_contribution_types) == 1) {
             $type = $enabled_contribution_types[0];
             $contribution_type = wc_product_reviews_pro_get_contribution_type($type);
             $count = wc_product_reviews_pro_get_comments_number($post->ID, $type);
             $tabs['reviews']['title'] = $contribution_type->get_tab_title($count);
         } else {
             $count = wc_product_reviews_pro_get_comments_number($post->ID, $enabled_contribution_types);
             $contribution_type = wc_product_reviews_pro_get_contribution_type(null);
             $tabs['reviews']['title'] = $contribution_type->get_tab_title($count);
         }
     }
     return $tabs;
 }
Ejemplo n.º 2
0
</h2>

	<?php 
// Product ratings
?>
	<?php 
if ('yes' == get_option('woocommerce_enable_review_rating') && $product->get_rating_count()) {
    ?>
	<div class="product-rating">
		<div class="product-rating-summary">
			<h3><?php 
    printf(__('%s out of %d stars', WC_Product_Reviews_Pro::TEXT_DOMAIN), floatval($product->get_average_rating()), 5);
    ?>
</h3>
			<p><?php 
    printf(__('%d reviews', WC_Product_Reviews_Pro::TEXT_DOMAIN), wc_product_reviews_pro_get_comments_number($product->id, 'review'));
    ?>
</p>
		</div>
		<div class="product-rating-details">
			<table>
				<?php 
    foreach ($ratings as $rating) {
        ?>
					<?php 
        $count = wc_product_reviews_pro_get_product_rating_count($product->id, $rating);
        $percentage = $count / $total_rating_count * 100;
        $url = remove_query_arg('comment_filter', "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}");
        $filter = "comment_type=review&rating={$rating}";
        $url = add_query_arg('comments_filter', urlencode($filter), $url);
        ?>