<?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://codex.wordpress.org/Template_Hierarchy
 *
 * @package Positive_blog
 */

/*
 * 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="comments-area brick clearfix">

	<?php
	// You can start editing here -- including this comment!
	if ( have_comments() ) : ?>
		<h2 class="comments-title p-3">
			<?php
			$comment_count = get_comments_number();
			if ( 1 === $comment_count ) {
				printf(
					/* translators: 1: title. */
					esc_html_e( 'One comment on &ldquo;%1$s&rdquo;', 'positive-blog' ),
					'<span>' . get_the_title() . '</span>'
				);
			} else {
				printf( // WPCS: XSS OK.
					/* translators: 1: comment count number, 2: title. */
					esc_html( _nx( '%1$s comment on &ldquo;%2$s&rdquo;', '%1$s comments on &ldquo;%2$s&rdquo;', $comment_count, 'comments title', 'positive-blog' ) ),
					number_format_i18n( $comment_count ),
					'<span>' . get_the_title() . '</span>'
				);
			}
			?>
		</h2><!-- .comments-title -->

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



	<?php endif; // Check for have_comments(). ?>

	<div class="p-3">
		<?php the_comments_navigation();


		// 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.', 'positive-blog' ); ?></p></div>
		<?php
		else: ?>
		</div>
	<?php endif; ?>

	<?php

		$fields =  array(
			'author' =>
			    '<div class="form-group comment-form-author"><label for="author">' . __( 'Name', 'positive-blog' ) . '</label> ' .
			    '<span class="required">*</span>' .
			    '<input id="author" class="form-control" name="author" type="text" placeholder="' . esc_attr__( 'Your name', 'positive-blog' ) . '" size="30" aria-required="true" /></div>',

		  	'email' =>
			    '<div class="form-group comment-form-email"><label for="email">' . __( 'Email', 'positive-blog' ) . '</label> ' .
			    '<span class="required">*</span>' .
			    '<input id="email" class="form-control" name="email" type="text" placeholder="' . esc_attr__( 'Your email', 'positive-blog' ) . '" size="30" aria-required="true" /></div>',

		  	'url' =>
			    '<div class="form-group comment-form-url"><label for="url">' . __( 'Website', 'positive-blog' ) . '</label>' .
			    '<input id="url" class="form-control" name="url" type="text" placeholder="' . esc_attr__( 'Your website', 'positive-blog' ) . '" size="30" /></div>',

		);

		comment_form( $args = array(
        'id_form'           => 'commentform',  // that's the wordpress default value! delete it or edit it ;)
        'id_submit'         => 'commentsubmit',
        'class_submit'      => 'btn btn-dark float-right mb-3',
        'title_reply'       => __( 'Leave a Reply', 'positive-blog' ),  // that's the wordpress default value! delete it or edit it ;)
        'title_reply_to'    => __( 'Leave a Reply to %s', 'positive-blog' ),  // that's the wordpress default value! delete it or edit it ;)
        'cancel_reply_link' => __( 'Cancel Reply', 'positive-blog' ),  // that's the wordpress default value! delete it or edit it ;)
        'label_submit'      => __( 'Post Comment', 'positive-blog' ),  // that's the wordpress default value! delete it or edit it ;)

        'comment_field' =>  '<p><textarea placeholder="Start typing..." id="comment" class="form-control" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>',

        'fields' => apply_filters( 'comment_form_default_fields', $fields ),

        // So, that was the needed stuff to have bootstrap basic styles for the form elements and buttons

        // Basically you can edit everything here!
        // Checkout the docs for more: http://codex.wordpress.org/Function_Reference/comment_form
        // Another note: some classes are added in the bootstrap-wp.js - ckeck from line 1

    ));

	?>

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