/** * Add the Star Rating to the download information at the top of the page, * as well in the download grid. * * @since Marketify 1.0 * * @return void */ function marketify_download_entry_meta_rating($comment_id = null) { if (!class_exists('EDD_Reviews')) { return; } global $post; if (!$comment_id) { $rating = edd_reviews()->average_rating(false); } else { $rating = get_comment_meta($comment_id, 'edd_rating', true); } if (0 == $rating || did_action('marketify_product_details_before')) { return; } ?> <div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" class="star-rating"> <?php for ($i = 1; $i <= $rating; $i++) { ?> <i class="icon-star"></i> <?php } ?> <?php for ($i = 0; $i < 5 - $rating; $i++) { ?> <i class="icon-star2"></i> <?php } ?> <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 }
/** * widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ function widget($args, $instance) { if ($this->get_cached_widget($args)) { return; } ob_start(); global $post; extract($args); $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } ?> <div class="item-stats"> <div class="item-stat"> <?php echo edd_get_download_sales_stats($post->ID); ?> <small><?php echo _n('Purchase', 'Purchases', edd_get_download_sales_stats($post->ID), 'mashshare-edd'); ?> </small> </div> <?php if (!class_exists('EDD_Reviews')) { ?> <div class="item-stat"> <a href="#comments"> <?php echo get_comments_number(); ?> <small><?php echo _n('Comment', 'Comments', get_comments_number(), 'mashshare-edd'); ?> </small> </a> </div> <?php } else { ?> <div class="item-stat"> <?php edd_reviews()->average_rating(); ?> <small><?php _e('Average Rating', 'mashshare-edd'); ?> </small> </div> <?php } ?> </div> <?php echo $after_widget; $content = ob_get_clean(); echo $content; $this->cache_widget($args, $content); }
/** * widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ function widget($args, $instance) { if ($this->get_cached_widget($args)) { return; } global $post; ob_start(); extract($args); $reviews = get_comments(apply_filters('edd_reviews_average_rating_query_args', array('post_id' => $post->ID))); $total_ratings = 0; foreach ($reviews as $review) { $rating = get_comment_meta($review->comment_ID, 'edd_rating', true); $total_ratings += $rating; } $total = wp_count_comments($post->ID)->total_comments; if (0 == $total) { $total = 1; } $average = $total_ratings / $total; $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); $reviews = edd_reviews(); echo $before_widget; if ($title) { echo '<h1 class="section-title"><span>' . $title . '</span></h1>'; } ?> <div class="download-product-review-details"> <h1 class="download-single-widget-title"><?php _e('Buyer Ratings', 'marketify'); ?> </h1> <?php $rating = $reviews->average_rating(false); ?> <div class="download-ratings"> <strong> <?php for ($i = 1; $i <= $rating; $i++) { ?> <i class="icon-star"></i> <?php } ?> <?php for ($i = 0; $i < 5 - $rating; $i++) { ?> <i class="icon-star2"></i> <?php } ?> </strong> </div> <p><?php printf(__('%s average based on %d reviews.', 'marketify'), sprintf("%0.2f", $average), wp_count_comments($post->ID)->total_comments); ?> </p> <?php echo $reviews->maybe_show_review_breakdown(); ?> </div> <?php echo $after_widget; $content = ob_get_clean(); echo $content; $this->cache_widget($args, $content); }
?> <div id="comments" class="comments-area row"> <section class="<?php echo !is_active_sidebar('sidebar-download-single-comments') || !is_singular('download') ? 'col-xs-12' : 'col-sm-8 col-xs-12'; ?> "> <h2 class="comments-title section-title"><span> <?php if (class_exists('EDD_Reviews') && is_singular('download')) { ?> <?php $reviews = edd_reviews(); $reviews->reviews_title($reviews->average_rating(false)); ?> <?php } else { ?> <?php _e('Comments', 'marketify'); ?> <?php } ?> </span></h2> <?php if (have_comments()) {
function dcs_star_ratings() { // 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(); ?> <?php /* Only show the ratings if there are indeed ratings */ if ('0' != $rating) { ?> <div itemprop="reviewRating" class="reviewRating clearfix"> <div class="edd_reviews_rating_box stars<?php echo esc_attr($rating); ?> clearfix"> <div><?php _e('Average Rating', 'designcrumbs'); ?> </div> <?php for ($i = 1; $i <= $rating; $i++) { ?> <span class="icon-star icon-star-full"></span> <?php } for ($i = 0; $i < 5 - $rating; $i++) { ?> <span class="icon-star icon-star-empty"></span> <?php } ?> </div> <div style="display:none" > <meta itemprop="worstRating" content="1" /> <span itemprop="ratingValue"><?php echo esc_attr($rating); ?> </span> <span itemprop="bestRating">5</span> </div> </div> <?php } ?> <?php $rating_html = ob_get_clean(); return $rating_html; }
/** * Review breakdown for single download sidebar * * @since 1.0 */ function checkout_reviews_breakdown() { if (class_exists('EDD_Reviews') && is_singular('download')) { global $post; $reviews = edd_reviews(); $total = wp_count_comments($post->ID)->total_comments; if ($total > 0) { echo $reviews->maybe_show_review_breakdown(); } } }