Added microdata to products page + reviews
This commit is contained in:
parent
2a25293493
commit
c1c9358d3b
|
@ -763,7 +763,7 @@ class woocommerce_product {
|
|||
|
||||
if (sizeof($attributes)>0 || ($show_dimensions && $has_dimensions)) :
|
||||
|
||||
echo '<table cellspacing="0" class="shop_attributes">';
|
||||
echo '<table class="shop_attributes">';
|
||||
$alt = 1;
|
||||
|
||||
if (($show_dimensions && $has_dimensions)) :
|
||||
|
|
|
@ -24,16 +24,18 @@
|
|||
|
||||
$average = number_format($rating / $count, 2);
|
||||
|
||||
echo '<div class="hreview-aggregate">';
|
||||
echo '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';
|
||||
|
||||
echo '<div class="star-rating" title="'.sprintf(__('Rated %s out of 5', 'woothemes'),$average).'"><span style="width:'.($average*16).'px"><span class="rating">'.$average.'</span> '.__('out of 5', 'woothemes').'</span></div>';
|
||||
echo '<div class="star-rating" title="'.sprintf(__('Rated %s out of 5', 'woothemes'), $average).'"><span style="width:'.($average*16).'px"><span itemprop="ratingValue" class="rating">'.$average.'</span> '.__('out of 5', 'woothemes').'</span></div>';
|
||||
|
||||
echo '<h2>'.sprintf( _n('%s review for %s', '%s reviews for %s', $count, 'woothemes'), '<span class="count">'.$count.'</span>', '<span class="item fn">'.wptexturize($post->post_title).'</span>' ).'</h2>';
|
||||
echo '<h2>'.sprintf( _n('%s review for %s', '%s reviews for %s', $count, 'woothemes'), '<span itemprop="ratingCount" class="count">'.$count.'</span>', wptexturize($post->post_title) ).'</h2>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
else :
|
||||
|
||||
echo '<h2>'.__('Reviews', 'woothemes').'</h2>';
|
||||
|
||||
endif;
|
||||
|
||||
$title_reply = '';
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
|
||||
<?php do_action('woocommerce_before_single_product', $post, $_product); ?>
|
||||
|
||||
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
<div itemscope itemtype="http://schema.org/Product" id="product-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php do_action('woocommerce_before_single_product_summary', $post, $_product); ?>
|
||||
|
||||
<div class="summary">
|
||||
|
||||
<h1 class="product_title page-title"><?php the_title(); ?></h1>
|
||||
<h1 itemprop="name" class="product_title page-title"><?php the_title(); ?></h1>
|
||||
|
||||
<?php do_action( 'woocommerce_single_product_summary', $post, $_product ); ?>
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ class WooCommerce_Widget_Login extends WP_Widget {
|
|||
// Get redirect URL
|
||||
$redirect_to = apply_filters( 'woocommerce_login_widget_redirect', get_permalink(get_option('woocommerce_myaccount_page_id')) );
|
||||
?>
|
||||
<form method="post" action="">
|
||||
<form method="post">
|
||||
|
||||
<p><label for="user_login"><?php _e('Username', 'woothemes'); ?></label> <input name="log" value="<?php if (isset($_POST['log'])) echo esc_attr(stripslashes($_POST['log'])); ?>" class="input-text" id="user_login" type="text" /></p>
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ class WooCommerce_Widget_Price_Filter extends WP_Widget {
|
|||
|
||||
endif;
|
||||
|
||||
echo '<form method="get" action="">
|
||||
echo '<form method="get">
|
||||
<div class="price_slider_wrapper">
|
||||
<div class="price_slider"></div>
|
||||
<div class="price_slider_amount">
|
||||
|
|
|
@ -517,23 +517,26 @@ add_filter('preprocess_comment', 'woocommerce_check_comment_rating', 0);
|
|||
function woocommerce_comments($comment, $args, $depth) {
|
||||
$GLOBALS['comment'] = $comment; global $post; ?>
|
||||
|
||||
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
|
||||
<li itemprop="reviews" itemscope itemtype="http://schema.org/Review" <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
|
||||
<div id="comment-<?php comment_ID(); ?>" class="comment_container">
|
||||
|
||||
<?php echo get_avatar( $comment, $size='60' ); ?>
|
||||
|
||||
<div class="comment-text">
|
||||
<div class="star-rating" title="<?php echo esc_attr( get_comment_meta( $comment->comment_ID, 'rating', true ) ); ?>">
|
||||
<span style="width:<?php echo get_comment_meta( $comment->comment_ID, 'rating', true )*16; ?>px"><?php echo get_comment_meta( $comment->comment_ID, 'rating', true ); ?> <?php _e('out of 5', 'woothemes'); ?></span>
|
||||
|
||||
<div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" class="star-rating" title="<?php echo esc_attr( get_comment_meta( $comment->comment_ID, 'rating', true ) ); ?>">
|
||||
<span style="width:<?php echo get_comment_meta( $comment->comment_ID, 'rating', true )*16; ?>px"><span itemprop="ratingValue"><?php echo get_comment_meta( $comment->comment_ID, 'rating', true ); ?></span> <?php _e('out of 5', 'woothemes'); ?></span>
|
||||
</div>
|
||||
|
||||
<?php if ($comment->comment_approved == '0') : ?>
|
||||
<p class="meta"><em><?php _e('Your comment is awaiting approval', 'woothemes'); ?></em></p>
|
||||
<?php else : ?>
|
||||
<p class="meta">
|
||||
<?php _e('Rating by', 'woothemes'); ?> <strong class="reviewer vcard"><span class="fn"><?php comment_author(); ?></span></strong> <?php _e('on', 'woothemes'); ?> <?php echo get_comment_date('M jS Y'); ?>:
|
||||
<?php _e('Rating by', 'woothemes'); ?> <strong itemprop="author"><?php comment_author(); ?></strong> <?php _e('on', 'woothemes'); ?> <time itemprop="datePublished" time datetime="<?php echo get_comment_date('c'); ?>"><?php echo get_comment_date('M jS Y'); ?></time>:
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<div class="description"><?php comment_text(); ?></div>
|
||||
|
||||
<div itemprop="description" class="description"><?php comment_text(); ?></div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
|
|
|
@ -119,13 +119,13 @@ if (!function_exists('woocommerce_show_product_images')) {
|
|||
|
||||
echo '<div class="images">';
|
||||
|
||||
$thumb_id = 0;
|
||||
if (has_post_thumbnail()) :
|
||||
|
||||
$thumb_id = get_post_thumbnail_id();
|
||||
$large_thumbnail_size = apply_filters('single_product_large_thumbnail_size', 'shop_single');
|
||||
echo '<a href="'.wp_get_attachment_url($thumb_id).'" class="zoom" rel="thumbnails" title="'.get_the_title().'">';
|
||||
the_post_thumbnail($large_thumbnail_size);
|
||||
echo '</a>';
|
||||
|
||||
echo '<a itemprop="image" href="'.wp_get_attachment_url($thumb_id).'" class="zoom" rel="thumbnails">' . get_the_post_thumbnail($post->ID, $large_thumbnail_size) . '</a>';
|
||||
|
||||
else :
|
||||
echo '<img src="'.$woocommerce->plugin_url().'/assets/images/placeholder.png" alt="Placeholder" />';
|
||||
endif;
|
||||
|
@ -210,13 +210,13 @@ if (!function_exists('woocommerce_output_product_data_tabs')) {
|
|||
**/
|
||||
if (!function_exists('woocommerce_template_single_price')) {
|
||||
function woocommerce_template_single_price( $post, $_product ) {
|
||||
?><p class="price"><?php echo $_product->get_price_html(); ?></p><?php
|
||||
?><p itemprop="price" class="price"><?php echo $_product->get_price_html(); ?></p><?php
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('woocommerce_template_single_excerpt')) {
|
||||
function woocommerce_template_single_excerpt( $post, $_product ) {
|
||||
if ($post->post_excerpt) echo wpautop(wptexturize($post->post_excerpt));
|
||||
if ($post->post_excerpt) echo '<div itemprop="description">' . wpautop(wptexturize($post->post_excerpt)) . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ if (!function_exists('woocommerce_template_single_meta')) {
|
|||
function woocommerce_template_single_meta( $post, $_product ) {
|
||||
|
||||
?>
|
||||
<div class="product_meta"><?php if ($_product->is_type('simple') && get_option('woocommerce_enable_sku')=='yes') : ?><span class="sku"><?php _e('SKU:', 'woothemes'); ?> <?php echo $_product->sku; ?>.</span><?php endif; ?><?php echo $_product->get_categories( ', ', ' <span class="posted_in">'.__('Posted in', 'woothemes').' ', '.</span>'); ?><?php echo $_product->get_tags( ', ', ' <span class="tagged_as">'.__('Tagged as', 'woothemes').' ', '.</span>'); ?></div>
|
||||
<div class="product_meta"><?php if ($_product->is_type('simple') && get_option('woocommerce_enable_sku')=='yes') : ?><span itemprop="productID" class="sku"><?php _e('SKU:', 'woothemes'); ?> <?php echo $_product->sku; ?>.</span><?php endif; ?><?php echo $_product->get_categories( ', ', ' <span class="posted_in">'.__('Posted in', 'woothemes').' ', '.</span>'); ?><?php echo $_product->get_tags( ', ', ' <span class="tagged_as">'.__('Tagged as', 'woothemes').' ', '.</span>'); ?></div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
@ -284,13 +284,21 @@ if (!function_exists('woocommerce_simple_add_to_cart')) {
|
|||
// No price set - so no button
|
||||
if( $_product->get_price() === '') return;
|
||||
|
||||
if ($availability['availability']) : ?><p class="stock <?php echo $availability['class'] ?>"><?php echo $availability['availability']; ?></p><?php endif;
|
||||
if ($availability['availability']) : ?>
|
||||
<p class="stock <?php echo $availability['class'] ?>"><?php echo $availability['availability']; ?></p>
|
||||
<?php endif;
|
||||
|
||||
// Don't show cart if out of stock
|
||||
if (!$_product->is_in_stock()) return;
|
||||
if (!$_product->is_in_stock()) :
|
||||
echo '<link itemprop="availability" href="http://schema.org/OutOfStock">';
|
||||
return;
|
||||
endif;
|
||||
|
||||
echo '<link itemprop="availability" href="http://schema.org/InStock">';
|
||||
|
||||
do_action('woocommerce_before_add_to_cart_form');
|
||||
|
||||
?>
|
||||
<?php do_action('woocommerce_before_add_to_cart_form'); ?>
|
||||
|
||||
<form action="<?php echo esc_url( $_product->add_to_cart_url() ); ?>" class="cart" method="post">
|
||||
|
||||
<?php do_action('woocommerce_before_to_cart_button'); ?>
|
||||
|
@ -304,9 +312,10 @@ if (!function_exists('woocommerce_simple_add_to_cart')) {
|
|||
<?php do_action('woocommerce_after_add_to_cart_button'); ?>
|
||||
|
||||
</form>
|
||||
<?php
|
||||
|
||||
do_action('woocommerce_after_add_to_cart_form');
|
||||
|
||||
<?php do_action('woocommerce_after_add_to_cart_form'); ?>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
if (!function_exists('woocommerce_grouped_add_to_cart')) {
|
||||
|
@ -1063,7 +1072,7 @@ function woocommerce_upsell_display() {
|
|||
global $_product;
|
||||
$upsells = $_product->get_upsells();
|
||||
if (sizeof($upsells)>0) :
|
||||
echo '<div class="upsells products"><h2>'.__('You may also like…', 'woothemes').'</h2><ul>';
|
||||
echo '<div class="upsells products"><h2>'.__('You may also like…', 'woothemes').'</h2>';
|
||||
$args = array(
|
||||
'post_type' => 'product',
|
||||
'ignore_sticky_posts' => 1,
|
||||
|
|
Loading…
Reference in New Issue