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

<div id="comments" <?php echo 'class="' . 'blog_layouts_comments_layout_' . str_replace("-", "_", esc_attr(get_theme_mod('comments_layout', 'dark-cards'))) . '"'; ?>>

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

        <h2>
            <?php
            $blog_layouts_comments_number = get_comments_number();
            if ($blog_layouts_comments_number === 1) {
                printf(__('One Comment', 'blog-layouts'));
            } else {
                printf(__('%d Comments', 'blog-layouts'), $blog_layouts_comments_number);
            }
            ?>
        </h2>

        <ul class="blog_layouts_comment_list <?php if (!get_theme_mod('comments_image', true)) echo 'blog_layouts_comments_without_image'; ?>">
            <?php
            wp_list_comments(array(
                'style'       => 'ol',
                'short_ping'  => true,
                'avatar_size' => get_theme_mod('image_size_comments', 40),
            ));
            ?>
        </ul>

        <?php if (get_comment_pages_count() > 1 && get_option('page_comments')) : ?>
            <nav role="navigation">
                <div class="nav-previous"><?php previous_comments_link(__('Older Comments', 'blog-layouts')); ?></div>
                <div class="nav-next"><?php next_comments_link(__('Newer Comments', 'blog-layouts')); ?></div>
            </nav>
        <?php endif; ?>

    <?php endif; ?>

    <?php if (!comments_open() && get_comments_number() && post_type_supports(get_post_type(), 'comments')) : ?>
        <p><?php _e('Comments are closed.', 'blog-layouts'); ?></p>
    <?php endif; ?>

    <?php
    comment_form(array(
        'title_reply_before' => '<h2 class="blog_layouts_comment_reply_title">',
        'title_reply_after'  => '</h2>',
    ));
    ?>

</div>