<div class="container">
    <div class="detail-blog-comments">
        <h4 class="title fw-bold text-center">
            <?php printf(esc_html__('نظرات %s', 'kavehTheme'), '<span class="fw-normal">' . esc_html__('کاربران', 'kavehTheme') . '</span>'); ?>
        </h4>
        <div class="detail-blog-comments-wrapper position-relative bg-white">
            <?php
            function kaveh_comment($comment, $args, $depth)
            {
                ?>
                <div class="comments">
                    <li>
                        <div class="content">
                            <div class="info d-flex align-items-center flex-column flex-sm-row">
                                <img class="rounded-circle text-center mb-3 mb-sm-0"
                                    src="<?php $avatar = get_avatar_url($comment->comment_author_email);
                                    echo esc_url($avatar) ?>">
                                <div
                                    class="detail d-flex align-items-center justify-content-between flex-column flex-sm-row">
                                    <div class="author-date text-center text-sm-right">
                                        <div class="author">
                                            <?php echo esc_html($comment->comment_author); ?>
                                        </div>
                                        <div class="date">
                                            <?php comment_date(); ?>
                                        </div>
                                    </div>
                                    <div class="star-position d-flex align-items-center flex-column flex-sm-row">
                                        <?php if ($comment->comment_approved == 0): ?>
                                            <em><?php esc_html_e('دیدگاه شما در انتظار بررسی است', 'kavehTheme'); ?></em>
                                        <?php endif; ?>
                                        <?php if (is_user_logged_in()): ?>
                                            <div class="position rounded-pill me-2">
                                                <?php edit_comment_link(esc_html__('ویرایش دیدگاه', 'kavehTheme')) ?></div>
                                        <?php endif; ?>
                                        <div class="position rounded-pill">
                                            <?php comment_reply_link(array('depth' => $depth, 'max_depth' => $args['max_depth'])) ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="box">
                                <p>
                                    <?php comment_text(); ?>
                                </p>
                            </div>
                        </div>
                    </li>
                </div>
                <?php
            }

            wp_list_comments(
                array(
                    'style' => 'ul',
                    'max_depth' => '5',
                    'callback' => 'kaveh_comment',
                )
            );
            ?>
            <!-- Start Send Comment -->
            <?php
            $user = wp_get_current_user();
            $commenter = wp_get_current_commenter();
            $req = get_option('require_name_email');
            $aria_req = ($req ? " aria-required='true'" : '');

            $fields = array(
                'author' => '<div class="col-12">
                        <div class="form-group position-relative">
                        <label for="author">' . esc_html__('نام شما', 'kavehTheme') . '</label>
                        <input type="text" name="author" id="subject" class="form-control rounded-pill" value="' . esc_attr($commenter['comment_author']) . '" ' . $aria_req . '>
                        </div>
                        </div>',
                'email' =>
                    '<div class="col-md-6">
                        <div class="form-group position-relative">
                        <label for="email">' . esc_html__('ایمیل', 'kavehTheme') . '</label>
                        <input type="text" name="email" id="strengths" class="form-control rounded-pill" value="' . esc_attr($commenter['comment_author_email']) .
                    '" ' . $aria_req . '/>
                        </div>
                        </div>',
                'url' =>
                    '<div class="col-md-6">
                        <div class="form-group position-relative">
                        <label for="url">' . esc_html__('سایت شما', 'kavehTheme') . '</label>
                        <input type="text" name="url" id="weak" class="form-control rounded-pill" value="' . esc_attr($commenter['comment_author_url']) .
                    '" />
                        </div>
                    </div>'
            );
            $args = array(
                'class_form' => 'send-comment row',
                'class_submit' => 'btn btn-primary rounded-pill p-0 w-100',
                'title_reply' => '<span>' . esc_html__('دیدگاهی بگذارید', 'kavehTheme') . '</span>',
                'title_reply_to' => esc_html__('پاسخ به دیدگاه %s', 'kavehTheme'),
                'cancel_reply_link' => esc_html__('لغو ارسال دیدگاه', 'kavehTheme'),
                'label_submit' => esc_html__('Post Comment', 'kavehTheme'),
                'format' => 'html5',
                'comment_field' => '<div class="col-12"><div class="form-group position-relative"><label for="comment">' . esc_html__('نظر شما', 'kavehTheme') . '</label><textarea name="comment" id="content" class="form-control" aria-required="true"></textarea></div></div>',
                'must_log_in' => '<p class="must-log-in">' .
                    sprintf(
                        esc_html__('شما باید حتما %s تا بتوانید نظر دهید.', 'kavehTheme'),
                        '<a class="cmouse" onclick="showPopup()">' . esc_html__('وارد شوید', 'kavehTheme') . '</a>'
                    ) . '</p>',
                'logged_in_as' => '<p class="logged-in-as">' .
                    sprintf(
                        esc_html__('وارد شده به عنوان <a href="%1$s">%2$s</a>. <a href="%3$s" title="از این اکانت خارج شوید">خروج؟</a>', 'kavehTheme'),
                        admin_url('profile.php'),
                        $user->user_nicename,
                        wp_logout_url(apply_filters('the_permalink', get_permalink()))
                    ) . '</p><br><br>',
                'comment_notes_before' => '<p class="comment-notes">' .
                    esc_html__('Your email address will not be published.', 'kavehTheme') .
                    '</p>',

                'fields' => apply_filters('comment_form_default_fields', $fields),
            );
            comment_form($args);
            ?>
            <!-- End Send Comment -->
        </div>
    </div>
</div>
<!-- End Comments -->