File: /mnt/data/dreamssalon-wp/wp-content/themes/dreamsalon/comments.php
<?php if (post_password_required())
return; ?>
<?php
if (!function_exists('dreamsalon_modern_comment')) {
function dreamsalon_modern_comment($comment, $args, $depth)
{
$tag = ($args['style'] === 'div') ? 'div' : 'li';
$avatar = get_avatar($comment, 300, '', '', ['class' => 'img-fluid']);
$comment_user_id = $comment->user_id;
if ( $comment_user_id ) {
$user = get_userdata( $comment_user_id );
if ( ! empty( $user->first_name ) ) {
$last_initial = ! empty( $user->last_name ) ? ' ' . $user->last_name : '';
$author = $user->first_name . $last_initial;
} else {
$author = $user->display_name;
}
} else {
$author = get_comment_author( $comment );
}
$comment_text = get_comment_text($comment);
$comment_link = get_comment_link($comment);
$comment_time = human_time_diff(get_comment_time('U'), current_time('timestamp')) . ' ago';
$is_child = ($depth > 1) ? 'reply-comment' : '';
?>
<<?php echo esc_html( $tag ); ?> id="<?php echo esc_attr( $tag . get_comment_ID() . $is_child ); ?>">
<div class="comments-box d-flex w-100 col-12 rightside-comment gap-0">
<div class="comments-avatar me-0">
<?php
$avatar = str_replace('<img', '<img class="img-fluid commentsection-img"', $avatar);
echo wp_kses_post($avatar);
?>
</div>
<div class="comments-text flex-grow-1">
<!-- Name & Date Row -->
<div class="avatar-name commentsection-author">
<h6 class="name mb-0"><?php echo esc_html($author); ?></h6>
<span class="date"><?php echo esc_html($comment_time); ?></span>
</div>
<p><?php echo wp_kses_post($comment_text); ?></p>
</div>
</div>
</<?php echo esc_attr($tag); ?>>
<?php
}
}
?>
<div class="blog-post-comment">
<!-- COMMENTS LIST -->
<?php if (have_comments()): ?>
<div class="comment-wrap">
<div class="comment-wrap-title">
<h3 class="mb-4"><?php esc_html_e('Comments', 'dreamsalon'); ?></h3>
</div>
<div class="latest-comments">
<ul class="list-wrap">
<?php wp_list_comments([
'callback' => 'dreamsalon_modern_comment',
'style' => 'ul'
]); ?>
</ul>
</div>
</div>
<!-- COMMENT PAGINATION -->
<?php if (get_comment_pages_count() > 1 && get_option('page_comments')): ?>
<footer class="navigation comment-navigation">
<div class="previous"><?php previous_comments_link(esc_html__('← Older Comments', 'dreamsalon')); ?></div>
<div class="next"><?php next_comments_link(esc_html__('Newer Comments →', 'dreamsalon')); ?></div>
</footer>
<?php endif; ?>
<?php endif; ?>
<div class="comment-respond">
<?php
$commenter = wp_get_current_commenter();
$req = get_option('require_name_email');
$aria_req = $req ? " aria-required='true'" : '';
$comment_form = [
'title_reply' => '<h3 class="comment-reply-title">' . esc_html__('Leave a reply', 'dreamsalon') . '</h3>',
'comment_notes_before' => '<p class="comment-notes">' . esc_html__('Your email address will not be published. Required fields are marked *', 'dreamsalon') . '</p>',
'comment_field' => '
<div class="row">
<div class="col-lg-12">
<div class="mb-4">
<label for="comment" class="form-label">' . esc_html__('Comments *', 'dreamsalon') . '</label>
<textarea id="comment" name="comment" class="form-control" rows="5" required></textarea>
</div>
</div>
</div>
',
'fields' => [
'author' => '
<div class="row">
<div class="col-lg-6">
<div class="mb-4">
<label class="form-label">' . esc_html__('Name *', 'dreamsalon') . '</label>
<input id="author" name="author" type="text" class="form-control"
value="' . esc_attr($commenter['comment_author']) . '" ' . $aria_req . '>
</div>
</div>
',
'email' => '
<div class="col-lg-6">
<div class="mb-4">
<label class="form-label">' . esc_html__('Email *', 'dreamsalon') . '</label>
<input id="email" name="email" type="email" class="form-control"
value="' . esc_attr($commenter['comment_author_email']) . '" ' . $aria_req . '>
</div>
</div>
</div>
'
],
'label_submit' => esc_html__('Post Comment', 'dreamsalon'),
'class_submit' => 'btn btn-md btn-primary',
'submit_button' => '<button type="submit" id="%2$s" class="%3$s">%4$s <i class="far fa-paper-plane"></i></button>',
];
comment_form($comment_form);
?>
</div>
</div>