<?php

/**
 * The template for displaying comments
 *
 * This is the template that displays the area of the page that contains both the current comments
 * and the comment form.
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package Glamer
 * @since 1.0.0
 *
 */

/*
 * 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;
}
echo'<div id="comments" class="comments-area post-box">';
	if (have_comments()){
		echo'<div class="comment-title-and-comment-list">';
			echo'<h2 class="comments-title">';
				$glamer_comment_count = get_comments_number();
				if ('1' === $glamer_comment_count) {
					printf(
						/* translators: 1: title. */
						esc_html__('1 Comment', 'glamer'),
						'<span>' . get_the_title() . '</span>'
					);
				} else {
					printf( // WPCS: XSS OK.
						/* translators: 1: comment count number, 2: title. */
						esc_html(_nx('%1$s Comments', '%1$s Comments', $glamer_comment_count, 'comments title', 'glamer')),
						number_format_i18n($glamer_comment_count),
						'<span>' . get_the_title() . '</span>'
					);
				}
				echo'</h3>';
				echo'<ol class="comment-list">';
					wp_list_comments(array(
						'style'      	=> 'ol',
						'short_ping' 	=> true,
						'avatar_size' 	=> 100,
						'format' 		=> 'html5',
						'reply_text'    => esc_html__('Reply', 'glamer'),
					));
					
				echo'</ol><!-- .comment-list -->';
		echo'</div>';
		glamer_comments_pagination();
		// If comments are closed and there are comments, let's leave a little note, shall we?
		if (!comments_open()){
			echo'<p class="no-comments">'.esc_html__('Comments are closed.', 'glamer').'</p>';
		}
	} // Check for have_comments().
	comment_form();
echo'</div><!-- #comments -->';