<?php
/**
 * The template for displaying Comments
 *
 * The area of the page that contains comments and the comment form.
 */

/*
 * 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;
}

$commenter     = wp_get_current_commenter();
$aria_required = get_option( 'require_name_email' ) ? " aria-required='true'" : '';
$permalink     = esc_url( get_permalink() );

$args = array(
	'id_form'              => 'addcomments',
	'id_submit'            => 'submit',
	'title_reply'          => __( '<strong>Join in:</strong> leave your comment', 'the-journal' ),
	/* translators: %s: comment author */
	'title_reply_to'       => esc_html__( 'Leave a Reply to %s', 'the-journal' ),
	'cancel_reply_link'    => esc_html__( 'Cancel Reply', 'the-journal' ),
	'label_submit'         => esc_html__( 'Submit Comment', 'the-journal' ),
	'comment_field'        => '<div class="right-side-comment">
		<p class="comment-form-comment">
			<label for="comment">' . esc_html__( 'Message', 'the-journal' ) . ' <span class="required-label">*</span></label>
			<textarea id="comment" name="comment" class="required" required></textarea>
		</p>
	</div>',
	/* translators: %s: author name */
	'must_log_in'          => '<p class="must-log-in">' . sprintf( esc_html__( 'You must be <a href="%s">logged in</a> to post a comment.', 'the-journal' ), wp_login_url( apply_filters( 'the_permalink', $permalink ) ) ) . '</p>',
	/* translators: %s: logged user */
	'logged_in_as'         => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>', 'the-journal' ), esc_url( admin_url( 'profile.php' ) ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', $permalink ) ) ) . '</p>',
	'comment_notes_before' => '',
	'comment_notes_after'  => '',
	'fields'               => apply_filters( 'comment_form_default_fields', array(
			'author' => '<div class="left-side-comment">
			<p class="comment-form-author">
				<label for="author">' . esc_html__( 'Display Name', 'the-journal' ) . ' <span class="required-label">*</span></label>
				<input type="text" id="author" name="author" class="required" ' . $aria_required . ' />
			</p>',
			'email'  => '
			<p class="comment-form-email">
				<label for="email">' . esc_html__( 'Email Address', 'the-journal' ) . ' <span class="required-label">*</span></label>
				<span class="optional">' . esc_html__( '(will not be shared)', 'the-journal' ) . '</span>
				<input type="email" id="email" name="email" class="required" ' . $aria_required . ' />
			</p>
		</div>',
		)
	),
);
?>
<?php the_journal_comments_before(); ?>

	<div class="fw-row">
		<div id="comments" class="comments-area <?php if ( is_user_logged_in() ) {
			echo 'user-is-logged';
		} ?>">
			<h3 class="comments-title">
				<strong><?php esc_html_e( 'Comments:', 'the-journal' ); ?></strong> <?php comments_number( esc_html__( 'no replies', 'the-journal' ), esc_html__( '1 reply added', 'the-journal' ), esc_html__( '% replies added', 'the-journal' ) ); ?>
			</h3>

			<?php if ( have_comments() ) : ?>
				<ol class="comment-list">
					<?php
					get_template_part( 'comments', 'template' );
					wp_list_comments( array( 'callback' => 'the_journal_comment' ) );
					?>
				</ol><!-- .comment-list -->

				<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : ?>
					<nav id="comment-nav-below" class="navigation paging-navigation comment-navigation"
						 role="navigation">
						<div class="pagination loop-pagination">
							<?php paginate_comments_links( array(
								'prev_text' => '<i class="fa fa-angle-left"></i><span>' . esc_html__( 'Previous', 'the-journal' ) . '</span>',
								'next_text' => '<i class="fa fa-angle-right"></i><span>' . esc_html__( 'Next', 'the-journal' ) . '</span>'
							) ); ?>
						</div>
					</nav>
				<?php endif; // Check for comment navigation. ?>

				<?php if ( ! comments_open() ) : ?>
					<p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'the-journal' ); ?></p>
				<?php endif; ?>
			<?php endif; // have_comments() ?>

			<?php comment_form( $args ); ?>
		</div>
		<!-- #comments -->
	</div><!-- /.row -->

<?php the_journal_comments_after();