<?php
/**
 * The template for displaying comments
 *
 * @package ChaletMontagne
 * @since 1.0.0
 */

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

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

    <?php if (have_comments()) : ?>
        <h2 class="comments-title">
            <?php
            $comment_count = get_comments_number();
            printf(
                /* translators: 1: number of comments, 2: post title */
                esc_html(_nx(
                    '%1$s commentaire sur &laquo; %2$s &raquo;',
                    '%1$s commentaires sur &laquo; %2$s &raquo;',
                    $comment_count,
                    'comments title',
                    'chalet-montagne'
                )),
                number_format_i18n($comment_count),
                '<span>' . wp_kses_post(get_the_title()) . '</span>'
            );
            ?>
        </h2>

        <?php the_comments_navigation(); ?>

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

        <?php
        the_comments_navigation();

        if (!comments_open()) :
            ?>
            <p class="no-comments"><?php esc_html_e('Les commentaires sont fermés.', 'chalet-montagne'); ?></p>
        <?php endif; ?>

    <?php endif; ?>

    <?php comment_form(); ?>

</div>
