disable ratings option. Closes #1503.

This commit is contained in:
Mike Jolley 2012-09-21 21:21:50 +01:00
parent 5fcfe948d7
commit e61c152a7c
3 changed files with 49 additions and 36 deletions

View File

@ -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.

View File

@ -11,41 +11,49 @@ global $woocommerce;
<?php if ( comments_open() ) : ?><div id="reviews"><?php
echo '<div id="comments">';
if ( get_option('woocommerce_enable_review_rating') == 'yes' ) {
$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
");
$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'
");
if ( $count > 0 ) :
$average = number_format($rating / $count, 2);
echo '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';
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 '<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>';
else :
$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
");
$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'
");
if ( $count > 0 ) {
$average = number_format($rating / $count, 2);
echo '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';
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 '<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>';
} else {
echo '<h2>'.__('Reviews', 'woocommerce').'</h2>';
}
} else {
echo '<h2>'.__('Reviews', 'woocommerce').'</h2>';
endif;
}
$title_reply = '';

View File

@ -17,10 +17,14 @@ global $post;
<?php echo get_avatar( $GLOBALS['comment'], $size='60' ); ?>
<div class="comment-text">
<?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>
<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>