<?php
// Se il post è protetto da password, non visualizzare i commenti.
if ( post_password_required() ) {
    return;
}
?>

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

    <?php if ( have_comments() ) : ?>
        <h2 class="comments-title">
            <?php
            $comments_number = get_comments_number();
            if ( '1' === $comments_number ) {
                printf( _x( 'One comment', 'comments title', 'nexo' ) );
            } else {
                printf(
                    _nx(
                        '%1$s comment',
                        '%1$s comments',
                        $comments_number,
                        'comments title',
                        'nexo'
                    ),
                    number_format_i18n( $comments_number )
                );
            }
            ?>
        </h2>

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

        <?php the_comments_navigation(); ?>

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

    <?php
    // Se i commenti sono chiusi e ci sono commenti, mostra un messaggio
    if ( ! comments_open() && get_comments_number() ) :
        ?>
        <p class="no-comments"><?php _e( 'Comments are closed.', 'nexo' ); ?></p>
    <?php endif; ?>

    <?php comment_form(); ?>

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