<?php
defined('ABSPATH') || exit('No Access!');

global $labels, $options;

if (post_password_required()) {
    return;
}

add_filter('comment_form_defaults', function ($arg) {
    global $labels;
    $arg['comment_field'] = '<div><label for="comment">' . esc_html($labels->get_label('comment-text')) . ' <span class="required">*</span></label><textarea id="comment" name="comment" aria-required="true" rows="6"></textarea></div>';

    return $arg;
});

$commenter = wp_get_current_commenter();
$req = get_option('require_name_email');
$aria_req = ($req ? "aria-required='true'" : '');
$fields = array(
    'author' => '<div class="row"><div class="col-12 col-md-6"><label for="author">' . esc_html($labels->get_label('your-name')) . '</label> ' . ($req ? '<span class="required">*</span>' : '') . '<input id="author" name="author" type="text" value="' . esc_attr($commenter['comment_author']) . '" ' . $aria_req . ' ></div>',
    'email' => '<div class="col-12 col-md-6"><label for="email">' . esc_html($labels->get_label('your-email')) . '</label> ' . ($req ? '<span class="required">*</span>' : '') . '<input id="email" name="email" type="email" value="' . esc_attr($commenter['comment_author_email']) . '" ' . $aria_req . ' ></div></div>',
);
$comments_args = array(
    'fields' => $fields,
    'title_reply' => '',
    'label_submit' => esc_html($labels->get_label('send-comment')),
    'comment_notes_before' => '',
    'comment_notes_after' => '',
    'class_form' => '',
    'class_submit' => '',
    'must_log_in' => sprintf(
        '<p class="must-log-in">%s</p>',
        sprintf(
            __('You must be <a href="%s">logged in</a> to post a comment.'),
            $options->get_option('login-url')
        )
    ),
);

comment_form($comments_args);

if (have_comments()) {
    echo '<ol class="comment-list">';
    wp_list_comments('style=ol&callback=irk_comments_callback');
    echo '</ol>';
    if (get_comment_pages_count() > 1 && get_option('page_comments')) {
        echo ' <ul class="pagination">';
        paginate_comments_links(
            array(
                'prev_text' => '',
                'next_text' => '',
            )
        );
        echo '</ul>';
    }
}