<?php
/**
 * The template for displaying comments
 */

if (post_password_required()) {
	return;
}
?>

<div id="comments" class="comments-area reading-container">

	<?php if (have_comments()): ?>
		<h2 class="comments-title">
			<?php
			$comment_count = get_comments_number();
			if ('1' === $comment_count) {
				printf(
					esc_html__('One thought on &ldquo;%1$s&rdquo;', 'wisdom1'),
					'<span>' . get_the_title() . '</span>'
				);
			} else {
				printf(
					esc_html(_nx('%1$s thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', $comment_count, 'comments title', 'wisdom1')),
					number_format_i18n($comment_count),
					'<span>' . get_the_title() . '</span>'
				);
			}
			?>
		</h2>

		<ol class="comment-list">
			<?php
			wp_list_comments(
				array(
					'style' => 'ol',
					'short_ping' => true,
					'avatar_size' => 60,
				)
			);
			?>
		</ol>

		<?php
		the_comments_navigation();

		// If comments are closed and there are comments, let's leave a little note, shall we?
		if (!comments_open()):
			?>
			<p class="no-comments"><?php esc_html__('Comments are closed.', 'wisdom1'); ?></p>
			<?php
		endif;

	endif; // Check for have_comments().
	
	$args = array(
		'class_form' => 'comment-form mt-4 p-4 rounded bg-white shadow-sm border',
		'class_submit' => 'btn btn-secondary fw-bold text-uppercase mt-3',
		'title_reply_before' => '<h2 id="reply-title" class="comment-reply-title h3 font-serif mb-4">',
		'title_reply_after' => '</h2>',
		'comment_field' => '<div class="comment-form-comment mb-3"><label for="comment" class="form-label fw-bold">Your Perspective <span class="text-danger">*</span></label><textarea id="comment" name="comment" cols="45" rows="6" maxlength="65525" required="required" class="form-control bg-light"></textarea></div>',
	);
	comment_form($args);
	?>

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