Guest User

Structured data - one last error

a guest
Mar 30th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.65 KB | None | 0 0
  1. function x_renew_comment( $comment, $args, $depth ) {
  2.  
  3.     $GLOBALS['comment'] = $comment;
  4.     switch ( $comment->comment_type ) :
  5.       case 'pingback' :  // 1
  6.       case 'trackback' : // 1
  7.     ?>
  8.     <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
  9.       <p><?php _e( 'Pingback:', '__x__' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', '__x__' ), '<span class="edit-link">', '</span>' ); ?></p>
  10.     <?php
  11.         break;
  12.       default : // 2
  13.       GLOBAL $post;
  14.       if ( X_WOOCOMMERCE_IS_ACTIVE ) :
  15.         $rating = esc_attr( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) );
  16.       endif;
  17.       if ( x_is_product() ) {
  18.         $comment_avatar = get_avatar( $comment, 240 );
  19.       } else {
  20.         $comment_avatar = get_avatar( $comment, 120 );
  21.       }
  22.     ?>
  23.     <li id="li-comment-<?php comment_ID(); ?>" itemprop="review" itemscope itemtype="http://schema.org/Review" <?php comment_class(); ?>>
  24.       <article id="comment-<?php comment_ID(); ?>" class="comment">
  25.       <div class="visually-hidden" itemprop="itemReviewed" itemscope itemtype="http://schema.org/Product">
  26.           <span itemprop="name"><?php the_title(); ?></span>
  27.         </div>  
  28.         <?php
  29.         printf( '<div class="x-comment-img">%s</div>',
  30.           '<span class="avatar-wrap cf">' . $comment_avatar . '</span>'
  31.         );
  32.         ?>
  33.         <?php if ( ! x_is_product() ) : ?>
  34.         <div class="x-reply">
  35.           <?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply <span class="comment-reply-link-after"><i class="x-icon-reply" data-x-icon="&#xf112;"></i></span>', '__x__' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  36.         </div>
  37.         <?php endif; ?>
  38.         <div class="x-comment-wrap">
  39.           <header class="x-comment-header">
  40.             <?php
  41.             printf( '<cite class="x-comment-author" itemprop="author">%1$s</cite>',
  42.               get_comment_author_link()
  43.             );
  44.             if ( x_is_product() && get_option('woocommerce_enable_review_rating') == 'yes' ) : ?>
  45.               <div class="star-rating-container">
  46.                 <div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" class="star-rating" title="<?php echo sprintf( __( 'Rated %d out of 5', '__x__' ), $rating ) ?>">
  47.               <span style="width:<?php echo ( intval( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) ) / 5 ) * 100; ?>%"><strong itemprop="ratingValue"><?php echo intval( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) ); ?></strong> <?php _e( 'out of 5', '__x__' ); ?></span>
  48.               </div>
  49.             <?php endif;
  50.             printf( '<div><a href="%1$s" class="x-comment-time"><time itemprop="datePublished" datetime="%2$s">%3$s</time></a></div>',
  51.               esc_url( get_comment_link( $comment->comment_ID ) ),
  52.               get_comment_time( 'c' ),
  53.               sprintf( __( '%1$s at %2$s', '__x__' ),
  54.                 get_comment_date( 'm.d.Y' ),
  55.                 get_comment_time()
  56.               )
  57.             );
  58.             edit_comment_link( __( '<i class="x-icon-edit" data-x-icon="&#xf044;"></i> Edit', '__x__' ) );
  59.             ?>
  60.           </header>
  61.           <?php if ( '0' == $comment->comment_approved ) : ?>
  62.             <p class="x-comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', '__x__' ); ?></p>
  63.           <?php endif; ?>
  64.           <section class="x-comment-content" itemprop="description">
  65.             <?php comment_text(); ?>
  66.           </section>
  67.         </div>
  68.       </article>
  69.     <?php
  70.         break;
  71.     endswitch;
  72.  
  73.   }
Advertisement
Add Comment
Please, Sign In to add comment