Last active
January 3, 2016 10:09
-
-
Save amdrew/8447714 to your computer and use it in GitHub Desktop.
Call this function on the single product page with <?php echo sumobi_custom_show_average_star_rating(); ?>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function sumobi_custom_show_average_star_rating() { | |
// make sure edd reviews is active | |
if ( ! function_exists( 'edd_reviews' ) ) | |
return; | |
$edd_reviews = edd_reviews(); | |
// get the average rating for this download | |
$average_rating = (int) $edd_reviews->average_rating( false ); | |
$rating = $average_rating; | |
ob_start(); | |
?> | |
<div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" class="star-rating"> | |
<div class="edd_reviews_rating_box" role="img" aria-label="<?php echo $rating . ' ' . __( 'stars', 'edd-reviews' ); ?>"> | |
<div class="edd_star_rating" style="width: <?php echo ( 19 * $rating ); ?>px"></div> | |
</div> | |
<div style="display:none" itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating"> | |
<meta itemprop="worstRating" content="1" /> | |
<span itemprop="ratingValue"><?php echo $rating; ?></span> | |
<span itemprop="bestRating">5</span> | |
</div> | |
</div> | |
<?php | |
$rating_html = ob_get_clean(); | |
return $rating_html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment