<?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.
 *
 * @package ComRepair
 */

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

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

	<?php if ( have_comments() ) : ?>

		<h2 class="comments-title">
			<?php
			$comments_number = get_comments_number();
			printf(
				/* translators: %s: number of comments */
				esc_html( _nx(
					'%s Comment',
					'%s Comments',
					$comments_number,
					'comments title',
					'comrepair'
				) ),
				esc_html( number_format_i18n( $comments_number ) )
			);
			?>
		</h2><!-- .comments-title -->

		<ol class="comments-list">
			<?php
			wp_list_comments( array(
				'avatar_size' => 64,
				'style'       => 'ol',
				'short_ping'  => true,
				'max_depth'   => 2,
				'callback'    => 'comrepair_render_comment',
				'reply_text'  => esc_html__( 'Reply', 'comrepair' ),
			) );
			?>
		</ol><!-- .comments-list -->

		<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : ?>
			<nav class="comments-nav">
				<?php
				/* translators: %s is an arrow left symbol */
				$prev_label = sprintf( esc_html__( '%s Older Comments', 'comrepair' ), '<span class="typcn typcn-arrow-left-thick"></span>' );
				if ( $prev_link = get_previous_comments_link( $prev_label ) ) {
					echo '<div class="comments-nav-prev">' . wp_kses_post( $prev_link ) . '</div>';
				}
				/* translators: %s is an arrow right symbol */
				$next_label = sprintf( esc_html__( 'Newer comments %s', 'comrepair' ), '<span class="typcn typcn-arrow-right-thick"></span>' );
				if ( $next_link = get_next_comments_link( $next_label ) ) {
					echo '<div class="comments-nav-next">' . wp_kses_post( $next_link ) . '</div>';
				}
				?>
			</nav><!-- .comments-nav -->
		<?php endif; ?>

	<?php endif; ?>

	<?php if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) : ?>
		<p class="comments-closed"><?php echo esc_html__( 'Comments are closed.', 'comrepair' ); ?></p>
	<?php endif; ?>

	<?php comment_form( array( 'class_submit' => 'submit btn btn-secondary' ) ); ?>

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