<?php

if (post_password_required()) {
    return;
}

$comments_list_title = pzy_get_option('comments_list_title')??esc_html__('نظرات', 'pezeshkyar');

?>

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

    <?php if (have_comments()) : ?>
        <div class="pzy-section">
            <header>
                <div class="pzy-header-title">
                    <?php echo $comments_list_title ?>
                </div>
                <div class="pzy-header-divider"></div>
            </header>
            <div class="pzy-section-content">
                <ol class="comment-list">
                    <?php
                    wp_list_comments(array(
                        'style' => 'ul',
                        'short_ping' => true,
                        'avatar_size' => 75,
                        'type' => 'comment',
                        'callback' => 'pzy_comments_callback',
                    ));
                    ?>
                </ol>

                <?php if (get_comment_pages_count() > 1 && get_option('page_comments')) : ?>
                    <nav class="navigation comment-navigation" role="navigation">
                        <h1 class="screen-reader-text section-heading"><?php esc_html_e('پیمایش نظرات', 'pezeshkyar'); ?></h1>
                        <div class="comment-pagination pzy-pagination-links">
                            <?php
                            paginate_comments_links(array(
                                'prev_text'    => __('« قبلی', 'pezeshkyar'), // Text for the previous page
                                'next_text'    => __('بعدی »', 'pezeshkyar'), // Text for the next page
                                'type'         => 'plain', // Output plain links
                            ));
                            ?>
                        </div>
                    </nav><!-- .comment-navigation -->
                <?php endif; // Check for comment navigation ?>

                <?php if (!comments_open() && get_comments_number()) : ?>
                    <p class="no-comments"><?php _e('امکان ثبت دیدگاه وجود ندارد.', 'pezeshkyar'); ?></p>
                <?php endif; ?>


            </div>
        </div>

    <?php endif; // have_comments() ?>

    <?php
    $rating_text = do_shortcode('[ratemypost id="' . get_the_ID() . '"]');
    comment_form([
        'fields' => [
            'author' => '<div class="comment-form-row comment-form-author"><div class="input-append"><input placeholder="' . __('نام:', 'pezeshkyar') . '" id="author" name="author" type="text" value="' . esc_attr($commenter['comment_author']) . '" size="30"' . 'aria-required="true"' . ' required /><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
  <path d="M5 21C5 17.134 8.13401 14 12 14C15.866 14 19 17.134 19 21M16 7C16 9.20914 14.2091 11 12 11C9.79086 11 8 9.20914 8 7C8 4.79086 9.79086 3 12 3C14.2091 3 16 4.79086 16 7Z" stroke="#ED6BAD" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg></div></div>',
            'email' => '<div class="comment-form-row comment-form-email"><div class="input-append"><input placeholder="' . __('آدرس ایمیل:', 'pezeshkyar') . '" id="email" name="email" type="text" value="' . esc_attr($commenter['comment_author_email']) . '" size="30"' . 'aria-required="true"' . ' required /><i data-feather="mail"></i></div></div>',
        ],
        'comment_field' => '<div class="comment-form-comment"><textarea id="comment" name="comment" class="span12" rows="5" aria-required="true"></textarea></div>',
        'submit_field' => '<div class="comment-form-submit-box"><div class="pzy-rate-box"><span class="pzy-rate-title">' . __('امتیاز شما', 'pezeshkyar') . '</span>' . $rating_text . '</div><p class="form-submit">%1$s %2$s</p></div>',
        'title_reply' => __('دیدگاه شما', 'pezeshkyar'),
        'title_reply_after' => '<p class="title_reply_after"></p></span>',
    ]);
    ?>

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