<?php
/**
 * Comments Template
 *
 * This template displays comments and comment form for single posts
 *
 * @package Peblog
 */

// Security check.
if ( post_password_required() ) {
	return;
}
?>

<div class="comments-area" id="comments">
	<?php if ( have_comments() ) : ?>
		<h2 class="comments-title">
			<?php
			$comments_number = get_comments_number();
			if ( 1 === $comments_number ) {
				echo esc_html__( '1 Comment', 'peblog' );
			} else {
				/* translators: %d: number of comments */
				printf( esc_html__( '%d Comments', 'peblog' ), absint( $comments_number ) );
			}
			?>
		</h2>

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

		<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : ?>
			<nav class="comment-navigation">
				<div class="nav-previous">
					<?php previous_comments_link( esc_html__( '← Older Comments', 'peblog' ) ); ?>
				</div>
				<div class="nav-next">
					<?php next_comments_link( esc_html__( 'Newer Comments →', 'peblog' ) ); ?>
				</div>
			</nav>
		<?php endif; ?>

	<?php endif; ?>

	<?php
	// Comment form.
	comment_form(
		array(
			'title_reply'       => esc_html__( 'Leave a Comment', 'peblog' ),
			/* translators: %s: Author name */
			'title_reply_to'    => esc_html__( 'Leave a Reply to %s', 'peblog' ),
			'cancel_reply_link' => esc_html__( 'Cancel Reply', 'peblog' ),
			'label_submit'      => esc_html__( 'Post Comment', 'peblog' ),
			'submit_button'     => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />',
			'submit_field'      => '<div class="form-submit">%1$s %2$s</div>',
			'format'            => 'html5',
		)
	);
	?>
</div>

