Advertisement
Guest User

Untitled

a guest
May 29th, 2018
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.71 KB | None | 0 0
  1. @php
  2. if (post_password_required()) {
  3.   return;
  4. }
  5. @endphp
  6.  
  7. <?php
  8.  
  9. if ( ! defined( 'ABSPATH' ) ) {
  10.     exit; // Exit if accessed directly
  11. }
  12.  
  13. global $product;
  14.  
  15. if ( ! comments_open() ) {
  16.     return;
  17. }
  18.  
  19. ?>
  20. <div id="reviews" class="woocommerce-Reviews">
  21.     <div id="comments">
  22.         <h2 class="woocommerce-Reviews-title"><?php
  23.             if ( get_option( 'woocommerce_enable_review_rating' ) === 'yes' && ( $count = $product->get_review_count() ) ) {
  24.                 /* translators: 1: reviews count 2: product name */
  25.                 printf( esc_html( _n( '%1$s review for %2$s', '%1$s reviews for %2$s', $count, 'woocommerce' ) ), esc_html( $count ), '<span>' . get_the_title() . '</span>' );
  26.             } else {
  27.                 _e( 'Reviews', 'woocommerce' );
  28.             }
  29.         ?></h2>
  30.  
  31.         <?php if ( have_comments() ) : ?>
  32.  
  33.             <ol class="commentlist">
  34.                 <?php wp_list_comments( apply_filters( 'woocommerce_product_review_list_args', array( 'callback' => 'woocommerce_comments' ) ) ); ?>
  35.             </ol>
  36.  
  37.             <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) :
  38.                 echo '<nav class="woocommerce-pagination">';
  39.                 paginate_comments_links( apply_filters( 'woocommerce_comment_pagination_args', array(
  40.                     'prev_text' => '&larr;',
  41.                     'next_text' => '&rarr;',
  42.                     'type'      => 'list',
  43.                 ) ) );
  44.                 echo '</nav>';
  45.             endif; ?>
  46.  
  47.         <?php else : ?>
  48.  
  49.             <p class="woocommerce-noreviews"><?php _e( 'There are no reviews yet.', 'woocommerce' ); ?></p>
  50.  
  51.         <?php endif; ?>
  52.     </div>
  53.  
  54.     <?php if ( get_option( 'woocommerce_review_rating_verification_required' ) === 'no' || wc_customer_bought_product( '', get_current_user_id(), $product->get_id() ) ) : ?>
  55.  
  56.         <div id="review_form_wrapper">
  57.             <div id="review_form">
  58.                 <?php
  59.                     $commenter = wp_get_current_commenter();
  60.  
  61.                     $comment_form = array(
  62.                         'title_reply'          => have_comments() ? __( 'Add a review', 'woocommerce' ) : sprintf( __( 'Be the first to review &ldquo;%s&rdquo;', 'woocommerce' ), get_the_title() ),
  63.                         'title_reply_to'       => __( 'Leave a Reply to %s', 'woocommerce' ),
  64.                         'title_reply_before'   => '<span id="reply-title" class="comment-reply-title">',
  65.                         'title_reply_after'    => '</span>',
  66.                         'comment_notes_after'  => '',
  67.                         'fields'               => array(
  68.                             'author' => '<p class="comment-form-author">' . '<label for="author">' . esc_html__( 'Name', 'woocommerce' ) . ' <span class="required">*</span></label> ' .
  69.                                         '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" aria-required="true" required /></p>',
  70.                             'email'  => '<p class="comment-form-email"><label for="email">' . esc_html__( 'Email', 'woocommerce' ) . ' <span class="required">*</span></label> ' .
  71.                                         '<input id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" aria-required="true" required /></p>',
  72.                         ),
  73.                         'label_submit'  => __( 'Submit', 'woocommerce' ),
  74.                         'logged_in_as'  => '',
  75.                         'comment_field' => '',
  76.                     );
  77.  
  78.                     if ( $account_page_url = wc_get_page_permalink( 'myaccount' ) ) {
  79.                         $comment_form['must_log_in'] = '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a review.', 'woocommerce' ), esc_url( $account_page_url ) ) . '</p>';
  80.                     }
  81.  
  82.                     if ( get_option( 'woocommerce_enable_review_rating' ) === 'yes' ) {
  83.                         $comment_form['comment_field'] = '<div class="comment-form-rating"><label for="rating">' . esc_html__( 'Your rating', 'woocommerce' ) . '</label><select name="rating" id="rating" aria-required="true" required>
  84.                             <option value="">' . esc_html__( 'Rate&hellip;', 'woocommerce' ) . '</option>
  85.                             <option value="5">' . esc_html__( 'Perfect', 'woocommerce' ) . '</option>
  86.                             <option value="4">' . esc_html__( 'Good', 'woocommerce' ) . '</option>
  87.                             <option value="3">' . esc_html__( 'Average', 'woocommerce' ) . '</option>
  88.                             <option value="2">' . esc_html__( 'Not that bad', 'woocommerce' ) . '</option>
  89.                             <option value="1">' . esc_html__( 'Very poor', 'woocommerce' ) . '</option>
  90.                         </select></div>';
  91.                     }
  92.  
  93.                     $comment_form['comment_field'] .= '<p class="comment-form-comment"><label for="comment">' . esc_html__( 'Your review', 'woocommerce' ) . ' <span class="required">*</span></label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true" required></textarea></p>';
  94.  
  95.                     comment_form( apply_filters( 'woocommerce_product_review_comment_form_args', $comment_form ) );
  96.                 ?>
  97.             </div>
  98.         </div>
  99.  
  100.     <?php else : ?>
  101.  
  102.         <p class="woocommerce-verification-required"><?php _e( 'Only logged in customers who have purchased this product may leave a review.', 'woocommerce' ); ?></p>
  103.  
  104.     <?php endif; ?>
  105.  
  106.     <div class="clear"></div>
  107. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement