/home/moonrcjl/public_html/test/wp-content/themes/arsha/comments.php
<?php
// Check if comments are allowed
if (comments_open()) :
?>
<div id="comments" class="comments-area">
<?php
// Display the comments list
if (have_comments()) :
?>
<div class="mt-section-title-wrapper mb-40 mt-30">
<h2 class="mt-section-title mb-20 mt-fs-40">
<?php
$comment_count = get_comments_number();
echo esc_html($comment_count) . ' ' . _n('Comment', 'Comments', $comment_count, 'arsha');
?>
</h2>
</div>
<ul class="mt-postbox-comments">
<?php
wp_list_comments(array(
'style' => 'ul',
'short_ping' => true,
'callback' => 'custom_comment_list'
));
?>
</ul>
<?php
// Display comment pagination if needed
the_comments_pagination(array(
'prev_text' => esc_html__('Previous', 'arsha'),
'next_text' => esc_html__('Next', 'arsha'),
));
endif;
if ( is_user_logged_in() ) {
$cl = 'loginformuser';
} else {
$cl = '';
}
$commenter = wp_get_current_commenter();
$req = get_option('require_name_email');
$fields = array(
'author' => '<div class="row"><div class="col-xl-6 col-lg-6 col-md-6 col-12 mb-20"><div class="mtcontact__form-inputbox"><input type="text" name="author" id="author" placeholder="' . esc_attr__('Enter your name*', 'arsha') . '" value="' . esc_attr($commenter['comment_author']) . '" ' . ($req ? 'required' : '') . '></div>
</div>',
'email' => '<div class="col-xl-6 col-lg- col-md-6 col-12 mb-20">
<div class="mtcontact__form-inputbox">
<input type="email" name="email" id="email" placeholder="' . esc_attr__('Enter your email*', 'arsha') . '" value="' . esc_attr($commenter['comment_author_email']) . '" ' . ($req ? 'required' : '') . '>
</div>
</div>',
'url' => '<div class="col-12 mb-20">
<div class="mtcontact__form-inputbox">
<input type="text" name="url" id="url" placeholder="' . esc_attr__('Website', 'arsha') . '" value="' . esc_attr($commenter['comment_author_url']) . '">
</div>
</div></div>',
);
$defaults = [
'fields' => $fields,
'comment_field' => '<div class="col-12 mb-20 ' . $cl . '">
<div class="mtcontact__form-inputbox">
<textarea id="comment" name="comment" placeholder="' . esc_attr__('Your Comment Here...', 'arsha') . '" required></textarea>
</div>
</div>
',
'submit_button' => '<div class="col-12 mb-20">
<div class="postbox__comment-btn">
<button type="submit">
<span class="mt-btn">' . esc_html__('Submit Comment', 'arsha') . '</span>
<span class="mt-btn mt-btn-icon"><i class="fa-solid fa-arrow-right"></i></span>
</button>
</div>
</div>',
'cookies' => '<div class="col-12 mb-20">
<div class="postbox__comment-agree d-flex align-items-start mb-25">' .
'<input class="e-check-input" type="checkbox" id="e-agree" name="wp-comment-agree" value="1" checked>' .
'<label class="e-check-label" for="e-agree">' . esc_html__('Save my name, email, and website in this browser for the next time I comment.', 'arsha') . '</label></div>
</div>'
];
// Display the comment form
comment_form($defaults);
?>
</div><!-- .comments-area -->
<?php endif; ?>
<?php
// custom_comment_list
function custom_comment_list($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
if ($comment->comment_type == 'pingback' || $comment->comment_type == 'trackback') {
// Display pingbacks and trackbacks differently if needed
?>
<li class="pingback">
<p><?php esc_html_e('Pingback:', 'arsha'); ?> <?php comment_author_link(); ?></p>
</li>
<?php
} else {
// Display regular comments
?>
<li <?php comment_class('comment'); ?> id="comment-<?php comment_ID(); ?>">
<div class="mt-postbox-comments-box">
<div class="mt-postbox-comments-thumb br-50">
<?php echo get_avatar($comment, 80); ?>
</div>
<div class="mt-postbox-comments-text">
<h5 class="mt-postbox-comments-author mb-25"><?php comment_author(); ?></h5>
<?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
<?php if ($comment->comment_approved == '0') : ?>
<p><?php esc_html_e('Your comment is awaiting moderation.', 'arsha'); ?></p>
<?php endif; ?>
<?php comment_text(); ?>
<span><i></i></span>
<span> <?php comment_date(); ?></span>
<span><cite></cite></span>
</div>
</div>
<?php
}
}