<?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 Nextpage
 */

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

<div id="comments" class="blog-comment">

	<?php
	// You can start editing here -- including this comment!
	if ( have_comments() ) :
		?>
        <h3 class="section-title">
			<?php
			$nextpage_comment_count = get_comments_number();
			if ( '1' === $nextpage_comment_count ) {
				printf(
				/* translators: 1: title. */
					esc_html__( '1 Comment', 'nextpage' )

				);
			} else {
				printf( // WPCS: XSS OK.
				/* translators: 1: comment count number, 2: title. */
					esc_html( _nx( '%1$s Comments &ldquo;%2$s&rdquo;', '%1$s Comments ', $nextpage_comment_count, 'comments title', 'nextpage' ) ),
					number_format_i18n( $nextpage_comment_count )
				);
			}
			?>
        </h3><!-- .comments-title -->

        <div class="blog-comment-navigation">
			<?php the_comments_navigation(); ?>
        </div>
        <div class="clearfix"></div>
        <ul class="nextpage-comment-list">
			<?php
			wp_list_comments( array(
				'style'      => 'div',
				'callback'   => 'nextpage_comment_modification', // add you call back functions here
				'short_ping' => true,
			) );
			?>
        </ul><!-- .comment-list -->
        <div class="blog-comment-navigation">
			<?php the_comments_navigation(); ?>
        </div>
		<?php
		// 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_e( 'Comments are closed.', 'nextpage' ); ?></p>
		<?php
		endif;

	endif; // Check for have_comments(). ?>
    <div class="comment-form">
		<?php
		$fields = array(
			'author' => '<div class="row">
            <div class="col-lg-6 col-md-6 col-12">
                <div class="single-input-wrap input-group">
                    <input type="text" id="author" name="author" value="' . esc_attr( $commenter['comment_author'] ) . '" class="form-control" placeholder="' . esc_attr__( 'Your Full Name', 'nextpage' ) . '">
                    <div class="input-group-prepend">
                        <div class="input-group-text"><i class="fa fa-user"></i></div>
                    </div>
                </div>
            </div>',
			'email'  => '<div class="col-lg-6 col-md-6 col-12">
                <div class="single-input-wrap input-group">
                    <input type="text" name="email" id="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" class="form-control" placeholder="' . esc_attr__( 'Your Email', 'nextpage' ) . '">
                    <div class="input-group-prepend">
                        <div class="input-group-text"><i class="fa fa-envelope"></i></div>
                    </div>
                </div>
            </div></div>'
		);
		comment_form( array(
			'fields'               => apply_filters( 'nextpage_comment_form_default_fields', $fields ),
			'comment_notes_before' => '',
			'comment_notes_after'  => '',
			'title_reply'          => esc_html__( 'Leave A Comment', 'nextpage' ),
			'title_reply_to'       => esc_html__( 'Leave A Reply To %s', 'nextpage' ),
			'title_reply_before'   => '<div class="section-title mb-0"><h4 id="reply-title" class="mb-0">',
			'title_reply_after'    => '</h4></div>',
			'id_form'              => 'commentform',
			'class_form'           => 'contact-form-wrap',
			'id_submit'            => 'submit',
			'cancel_reply_link'    => '<i class="fa fa-window-close"></i>',
			'class_submit'         => 'btn btn-base',
			'label_submit'         => esc_html__( 'Post Comment', 'nextpage' ),
			'comment_field'        => '<div class="single-input-wrap input-group">
        <textarea name="comment" id="comment" class="form-control" rows="4" placeholder="' . esc_attr__( 'Write Comments', 'nextpage' ) . '"></textarea>
        <div class="input-group-prepend">
            <div class="input-group-text"><i class="fa fa-pencil-alt"></i></div>
        </div>
    </div>'
		) );
		?>
    </div> <!-- comment fomr -->
</div><!-- #comments -->