<?php
/**
 * The template for displaying comments.
 *
 * The area of the page that contains both current comments
 * and the comment form.
 *
 * @package thim
 */
/*
 * If the current post is protected by a password and
 * the visitor has not yet entered the password we will
 * return early without loading the comments.
 */
if ( post_password_required() ) {
	return;
}

if (
	have_comments() &&
	!( !comments_open() && '0' != get_comments_number() && post_type_supports( get_post_type(), 'comments' ) )
) {
	$class_has_comments = " has-comments";
} else {
	$class_has_comments = "";
}
?>

<div id="comments" class="comments-area<?php echo esc_attr( $class_has_comments ); ?>">
	<?php // You can start editing here -- including this comment!  ?>
	<?php if ( have_comments() ) : ?>
		<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through  ?>
			<nav id="comment-nav-above" class="comment-navigation" role="navigation">
				<h1 class="screen-reader-text"><?php esc_attr_e( 'Comment navigation', 'cakeart' ); ?></h1>

				<div class="nav-previous"><?php previous_comments_link( esc_html__( '&larr; Older Comments', 'cakeart' ) ); ?></div>
				<div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments &rarr;', 'cakeart' ) ); ?></div>
			</nav><!-- #comment-nav-above -->
		<?php endif; // check for comment navigation  ?>


		<div class="comment-list-inner">
			<h2 class="comments-title">
				<?php
				printf( _nx( '1 comment for &ldquo;%2$s&rdquo;', esc_html__('%1$s comments for &ldquo;%2$s&rdquo;','cakeart'), get_comments_number(), 'comments title', 'cakeart' ), number_format_i18n( get_comments_number() ), '<span>' . esc_html( get_the_title() ) . '</span>' );
				?>
			</h2>
			<ol class="comment-list">
				<?php wp_list_comments( 'style=li&type=comment&avatar_size=60&callback=thim_comment' ); ?>
			</ol>
			<!-- .comment-list -->

		</div>

		<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through  ?>
			<nav id="comment-nav-below" class="comment-navigation" role="navigation">
				<h1 class="screen-reader-text"><?php esc_attr_e( 'Comment navigation', 'cakeart' ); ?></h1>

				<div class="nav-previous"><?php previous_comments_link( esc_html__( '&larr; Older Comments', 'cakeart' ) ); ?></div>
				<div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments &rarr;', 'cakeart' ) ); ?></div>
			</nav><!-- #comment-nav-below -->
		<?php endif; // check for comment navigation  ?>
	<?php endif; // have_comments() ?>
	<?php
	// If comments are closed and there are comments, let's leave a little note, shall we?
	if ( !comments_open() && '0' != get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) :
		?>
		<?php esc_attr_e( 'Comments are closed.', 'cakeart' ); ?>
	<?php endif; ?>
	<div class="comment-respond-area">
		<?php if ( get_post_type() == 'recipe' ) { ?>
			<?php if ( is_plugin_active( 'comment-rating-stars/comment-star-reviews.php' ) ) { ?>
				<?php comment_form( array(
					'title_reply'   => esc_html__( 'Post a comment', 'cakeart' ),
					'label_submit'  => esc_html__( 'SUBMIT', 'cakeart' ),
					'comment_field' => '<div class="comment-form-comment">' . csr_get_rating_star_form() . '<br><label for="comment">' . esc_html__( 'Comment', 'cakeart' ) . '</label><br /><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></div>',

				) );
			} else {
				comment_form( array( 'title_reply' => esc_html__( 'Post a comment', 'cakeart' ), 'label_submit' => esc_html__( 'SUBMIT', 'cakeart' ) ) );
			}?>
		<?php
		} else {
			comment_form( array( 'title_reply' => esc_html__( 'Post a comment', 'cakeart' ), 'label_submit' => esc_html__( 'SUBMIT', 'cakeart' ) ) );
		}
		?>
	</div>
	<div class="clear"></div>

</div><!-- #comments -->