disable ratings option. Closes #1503.
This commit is contained in:
parent
5fcfe948d7
commit
e61c152a7c
|
@ -188,6 +188,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
* Localization - Romanian update by silviu-bucsa.
|
||||
* Localization - Dutch updates by Ramoonus.
|
||||
* Localization - Localized shortcode button.
|
||||
* Many other minor fixes and tweaks!
|
||||
|
||||
= 1.6.5.2 - 12/09/2012 =
|
||||
* Tweak - Extra validation for PayPal IPN.
|
||||
|
|
|
@ -12,40 +12,48 @@ global $woocommerce;
|
|||
|
||||
echo '<div id="comments">';
|
||||
|
||||
$count = $wpdb->get_var("
|
||||
SELECT COUNT(meta_value) FROM $wpdb->commentmeta
|
||||
LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID
|
||||
WHERE meta_key = 'rating'
|
||||
AND comment_post_ID = $post->ID
|
||||
AND comment_approved = '1'
|
||||
AND meta_value > 0
|
||||
");
|
||||
if ( get_option('woocommerce_enable_review_rating') == 'yes' ) {
|
||||
|
||||
$rating = $wpdb->get_var("
|
||||
SELECT SUM(meta_value) FROM $wpdb->commentmeta
|
||||
LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID
|
||||
WHERE meta_key = 'rating'
|
||||
AND comment_post_ID = $post->ID
|
||||
AND comment_approved = '1'
|
||||
");
|
||||
$count = $wpdb->get_var("
|
||||
SELECT COUNT(meta_value) FROM $wpdb->commentmeta
|
||||
LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID
|
||||
WHERE meta_key = 'rating'
|
||||
AND comment_post_ID = $post->ID
|
||||
AND comment_approved = '1'
|
||||
AND meta_value > 0
|
||||
");
|
||||
|
||||
if ( $count > 0 ) :
|
||||
$rating = $wpdb->get_var("
|
||||
SELECT SUM(meta_value) FROM $wpdb->commentmeta
|
||||
LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID
|
||||
WHERE meta_key = 'rating'
|
||||
AND comment_post_ID = $post->ID
|
||||
AND comment_approved = '1'
|
||||
");
|
||||
|
||||
$average = number_format($rating / $count, 2);
|
||||
if ( $count > 0 ) {
|
||||
|
||||
echo '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';
|
||||
$average = number_format($rating / $count, 2);
|
||||
|
||||
echo '<div class="star-rating" title="'.sprintf(__('Rated %s out of 5', 'woocommerce'), $average).'"><span style="width:'.($average*16).'px"><span itemprop="ratingValue" class="rating">'.$average.'</span> '.__('out of 5', 'woocommerce').'</span></div>';
|
||||
echo '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';
|
||||
|
||||
echo '<h2>'.sprintf( _n('%s review for %s', '%s reviews for %s', $count, 'woocommerce'), '<span itemprop="ratingCount" class="count">'.$count.'</span>', wptexturize($post->post_title) ).'</h2>';
|
||||
echo '<div class="star-rating" title="'.sprintf(__('Rated %s out of 5', 'woocommerce'), $average).'"><span style="width:'.($average*16).'px"><span itemprop="ratingValue" class="rating">'.$average.'</span> '.__('out of 5', 'woocommerce').'</span></div>';
|
||||
|
||||
echo '</div>';
|
||||
echo '<h2>'.sprintf( _n('%s review for %s', '%s reviews for %s', $count, 'woocommerce'), '<span itemprop="ratingCount" class="count">'.$count.'</span>', wptexturize($post->post_title) ).'</h2>';
|
||||
|
||||
else :
|
||||
echo '</div>';
|
||||
|
||||
} else {
|
||||
|
||||
echo '<h2>'.__('Reviews', 'woocommerce').'</h2>';
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
echo '<h2>'.__('Reviews', 'woocommerce').'</h2>';
|
||||
|
||||
endif;
|
||||
}
|
||||
|
||||
$title_reply = '';
|
||||
|
||||
|
|
|
@ -18,9 +18,13 @@ global $post;
|
|||
|
||||
<div class="comment-text">
|
||||
|
||||
<div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" class="star-rating" title="<?php echo esc_attr( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) ); ?>">
|
||||
<span style="width:<?php echo get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true )*16; ?>px"><span itemprop="ratingValue"><?php echo get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ); ?></span> <?php _e('out of 5', 'woocommerce'); ?></span>
|
||||
</div>
|
||||
<?php if ( get_option('woocommerce_enable_review_rating') == 'yes' ) : ?>
|
||||
|
||||
<div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" class="star-rating" title="<?php echo esc_attr( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) ); ?>">
|
||||
<span style="width:<?php echo get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true )*16; ?>px"><span itemprop="ratingValue"><?php echo get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ); ?></span> <?php _e('out of 5', 'woocommerce'); ?></span>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($GLOBALS['comment']->comment_approved == '0') : ?>
|
||||
<p class="meta"><em><?php _e('Your comment is awaiting approval', 'woocommerce'); ?></em></p>
|
||||
|
|
Loading…
Reference in New Issue