Files
Landing/wp-content/themes/upstudy/learndash/tpl-part/review/review-box.php
T
2026-04-23 04:33:43 +03:30

171 lines
9.1 KiB
PHP

<?php
if ( ! defined( 'ABSPATH' ) ) exit; // If this file is called directly, abort.
if ( ! comments_open() ) :
return;
endif;
global $post;
$all_rating = Upstudy_LD_Course_Review::get_average_ratings( $post->ID );
$ratings = Upstudy_LD_Course_Review::get_detail_ratings( $post->ID );
$all = Upstudy_LD_Course_Review::get_all_reviews( $post->ID );
?>
<div id="reviews" class="tpc-course-review-content">
<h3 class="rating-title"><?php echo __( 'Course Rating', 'upstudy' ); ?></h3>
<?php
echo '<span class="tpc-rating-sub-title">' . esc_html( number_format( ( float ) $all_rating, 1, '.', '' ) );
echo ' ' . __( 'average rating based on', 'upstudy' ) . ' ';
$all ? printf( _n( '%1$s rating', '%1$s ratings', $all, 'upstudy' ), number_format_i18n( $all ) ) : esc_html_e( '0 rating', 'upstudy' );
echo '</span>';
?>
<div class="tpc-rating-detail-box">
<div class="upstudy-row">
<div class="upstudy-col-sm-4">
<div class="upstudy-rating-left-box">
<div class="course-rating-number"><?php echo number_format( ( float ) $all_rating, 1, '.', '' ); ?></div>
<div class="course-rating-star">
<?php Upstudy_LD_Course_Review::display_review( $all_rating ); ?>
</div>
<div class="course-all-rating">
<?php $all ? printf( _n( '%1$s review', '%1$s reviews', $all, 'upstudy' ), number_format_i18n( $all ) ) : esc_html_e( '0 review', 'upstudy' ); ?>
</div>
</div>
</div>
<div class="upstudy-col-sm-8">
<div class="upstudy-review-wrapper">
<?php for ( $i = 5; $i >= 1; $i -- ) :
echo '<div class="upstudy-each-review">';
echo '<div class="upstudy-rating-text">';
echo '<span class="number">' . esc_html( $i ) . '</span>';
echo '<i class="flaticon-star"></i>';
echo '</div>';
echo '<div class="tpc-rating-progress-bar-inner"><div class="tpc-rating-progress-bar-gray"></div><div class="tpc-rating-progress-bar-color" style="' . esc_attr( ( $all && ! empty( $ratings[$i]->quantity ) ) ? esc_attr( 'width: ' . number_format( ( $ratings[$i]->quantity / $all * 100 ), 0 ) . '%' ) : 'width: 0%' ) . '"></div></div>';
echo '<div class="upstudy-rating-value">';
echo trim( ( $all && ! empty( $ratings[$i]->quantity ) ) ? number_format( ( $ratings[$i]->quantity / $all * 100 ), 0 ) . '%' : '0%' );
echo '</div>';
echo '</div>';
endfor; ?>
</div>
</div>
</div>
</div>
<?php if ( have_comments() ) : ?>
<div id="comments" class="rating-comment comments-area upstudy-comments-area">
<h2 class="comments-title"><?php echo sprintf( _n( __( 'Review', 'upstudy' ) . ' <span class="total-ratings-received">(%s)</span>', __(' Reviews', 'upstudy' ) . ' <span class="total-ratings-received">(%s)</span>', $all ), $all ); ?></h2>
<ol class="upstudy-comment-list review-comment">
<?php wp_list_comments( array( 'callback' => array( 'Upstudy_LD_Course_Review', 'ld_course_comments' ) ) ); ?>
</ol>
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) :
echo '<nav class="upstudy-pagination-wrapper">';
paginate_comments_links( apply_filters( 'upstudy_comment_pagination_args', array(
'prev_text' => is_rtl() ? '&rarr;' : '&larr;',
'next_text' => is_rtl() ? '&larr;' : '&rarr;',
'type' => 'list',
) ) );
echo '</nav>';
endif; ?>
</div>
<?php endif; ?>
<?php $commenter = wp_get_current_commenter(); ?>
<div id="review_form_wrapper" class="comments-area upstudy-comments-area">
<div class="reply_comment_form hidden">
<?php
$comment_form = array(
'title_reply' => __( 'Reply comment', 'upstudy' ),
'title_reply_to' => __( 'Leave a Reply to %s', 'upstudy' ),
'comment_notes_before' => '',
'comment_notes_after' => '',
'fields' => array(
'author' => '<div class="upstudy-row"><div class="upstudy-col-lg-6"><div class="form-group">'.
'<input id="author" class="form-control" placeholder="' . esc_attr__( 'Name', 'upstudy' ) . '" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" aria-required="true" /></div></div>',
'email' => '<div class="upstudy-col-lg-6"><div class="form-group">' .
'<input id="email" placeholder="'.esc_attr__( 'Email', 'upstudy' ).'" class="form-control" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" aria-required="true" /></div></div>',
'url' => '<div class="upstudy-col-lg-6 upstudy-d-none"><div class="form-group"><label>'.__( 'Website', 'upstudy' ).'</label>
<input id="url" name="url" placeholder="'.esc_attr__( 'Your Website', 'upstudy' ).'" class="form-control" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" />
</div></div></div>',
),
'label_submit' => __( 'Submit Reply', 'upstudy' ),
'logged_in_as' => '',
'comment_field' => '',
'title_reply_before' => '<h4 class="title comment-reply-title">',
'title_reply_after' => '</h4>',
'class_form' => 'upstudy-comment-form',
'class_submit' => 'upstudy-comment-btn'
);
$comment_form['comment_field'] .= '<div class="form-group"><label class="your-feedback">' . esc_attr__( 'Your Reply', 'upstudy' ) . '</label><textarea placeholder="' . esc_attr__( 'Your Reply', 'upstudy' ) . '" id="comment" class="form-control" name="comment" cols="45" rows="5" aria-required="true" placeholder="' . esc_attr__( 'Your Reply', 'upstudy' ) . '"></textarea></div>';
$comment_form['must_log_in'] = '<p class="must-log-in">' . __( 'You must be logged in to reply this review.', 'upstudy' ) . '</p>';
upstudy_hidden_comment_form($comment_form);
?>
</div>
<div id="tpc-review-form" class="comments-area">
<?php
$comment_form = array(
'class_form' => 'upstudy-comment-form form media-body',
'class_submit' => 'upstudy-comment-btn',
'title_reply' => have_comments() ? __( 'Write a Review', 'upstudy' ) : sprintf( __( 'Be the first to review &ldquo;%s&rdquo;', 'upstudy' ), get_the_title() ),
'title_reply_to' => __( 'Leave a Reply to %s', 'upstudy' ),
'comment_notes_before' => '',
'comment_notes_after' => '',
'fields' => array(
'author' => '<div class="upstudy-row"><div class="upstudy-col-lg-6"><div class="form-group">'.
'<input id="author" placeholder="' . esc_attr__( 'Name', 'upstudy' ) . '" class="form-control" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" aria-required="true" /></div></div>',
'email' => '<div class="upstudy-col-lg-6"><div class="form-group">' .
'<input id="email" placeholder="' . esc_attr__( 'Email', 'upstudy' ) . '" class="form-control" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" aria-required="true" /></div></div>',
'url' => '<div class="upstudy-col-lg-6 upstudy-d-none"><div class="form-group"><label>'.__( 'Website', 'upstudy' ).'</label>
<input id="url" placeholder="'.esc_attr__( 'Your Website', 'upstudy' ).'" name="url" class="form-control" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" />
</div></div></div>',
),
'label_submit' => __( 'Submit Review', 'upstudy' ),
'logged_in_as' => '',
'comment_field' => '',
'title_reply_before' => '<h4 class="title comment-reply-title">',
'title_reply_after' => '</h4>',
);
$comment_form['comment_field'] = '
<div class="tpc-course-rating-content rating-with-label">
<label for="rating" class="rating-label">' . __( 'Rating Here', 'upstudy' ) .'</label>
<div class="tpc-course-review-wrapper">
<div class="tpc-custom-rating-form">
<ul class="tpc-course-review">
<li><span class="flaticon-star"></span></li>
<li><span class="flaticon-star"></span></li>
<li><span class="flaticon-star"></span></li>
<li><span class="flaticon-star"></span></li>
<li><span class="flaticon-star"></span></li>
</ul>
<ul class="tpc-course-review tpc-review-filled">
<li><span class="flaticon-star"></span></li>
<li><span class="flaticon-star"></span></li>
<li><span class="flaticon-star"></span></li>
<li><span class="flaticon-star"></span></li>
<li><span class="flaticon-star"></span></li>
</ul>
<input type="hidden" value="5" name="rating" id="upstudy_input_rating">
</div>
</div>
</div>';
$comment_form['must_log_in'] = '<div class="must-log-in">' . __( 'You must be logged in to post a review.', 'upstudy' ) . '</div>';
$comment_form['comment_field'] .= '<div class="form-group"><textarea id="comment" class="form-control" placeholder="' . esc_attr__( 'Review summary', 'upstudy' ) . '" name="comment" cols="45" rows="5" aria-required="true"></textarea></div>';
upstudy_hidden_comment_form( $comment_form );
?>
</div>
</div>
</div>