File: /var/www/html/wp-content/plugins/ethnic-single-post-layout/comments.php
<?php
/**
* Comments template for the custom Ethnic single post layout.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( post_password_required() ) {
return;
}
if ( ! function_exists( 'ethnic_single_post_layout_comment_item' ) ) {
function ethnic_single_post_layout_comment_item( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
$tag = 'div' === $args['style'] ? 'div' : 'li';
$comment_id = (int) $comment->comment_ID;
$author = get_comment_author( $comment );
$initial = function_exists( 'mb_substr' ) ? mb_substr( $author, 0, 1 ) : substr( $author, 0, 1 );
$reply_args = array_merge(
$args,
array(
'add_below' => 'div-comment',
'depth' => $depth,
'max_depth' => $args['max_depth'],
'before' => '',
'after' => '',
'reply_text'=> esc_html__( 'Reply', 'thegem' ),
)
);
?>
<<?php echo tag_escape( $tag ); ?> <?php comment_class( 'ethnic-single-post-comments__item', $comment ); ?> id="comment-<?php echo esc_attr( (string) $comment_id ); ?>">
<article id="div-comment-<?php echo esc_attr( (string) $comment_id ); ?>" class="ethnic-single-post-comments__card">
<div class="ethnic-single-post-comments__avatar" aria-hidden="true">
<?php echo esc_html( strtoupper( $initial ) ); ?>
</div>
<div class="ethnic-single-post-comments__body">
<header class="ethnic-single-post-comments__header">
<div class="ethnic-single-post-comments__meta">
<h3 class="ethnic-single-post-comments__author">
<?php echo esc_html( $author ); ?>
</h3>
<a class="ethnic-single-post-comments__date" href="<?php echo esc_url( get_comment_link( $comment_id ) ); ?>">
<time datetime="<?php echo esc_attr( get_comment_time( 'c', false, false, $comment_id ) ); ?>">
<?php echo esc_html( get_comment_date( 'M j, Y', $comment_id ) . ' at ' . get_comment_time( 'g:i A', false, true, $comment_id ) ); ?>
</time>
</a>
</div>
<?php
$reply_link = get_comment_reply_link( $reply_args, $comment_id );
if ( $reply_link ) {
echo str_replace( 'comment-reply-link', 'comment-reply-link ethnic-single-post-comments__reply', $reply_link ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
</header>
<?php if ( '0' === $comment->comment_approved ) : ?>
<p class="ethnic-single-post-comments__moderation">
<?php esc_html_e( 'Your comment is awaiting moderation.', 'thegem' ); ?>
</p>
<?php endif; ?>
<div class="ethnic-single-post-comments__content">
<?php comment_text( $comment_id ); ?>
</div>
</div>
</article>
<?php
}
}
$commenter = wp_get_current_commenter();
$current_user = wp_get_current_user();
$require_email = (bool) get_option( 'require_name_email' );
$required_attr = $require_email ? ' aria-required="true" required' : '';
$required_mark = $require_email ? ' *' : '';
$cookie_field = '';
if ( has_action( 'set_comment_cookies', 'wp_set_comment_cookies' ) && get_option( 'show_comments_cookies_opt_in' ) ) {
$consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"';
$cookie_field = '<p class="col-md-12 col-xs-12 comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" class="gem-checkbox" type="checkbox" value="yes"' . $consent . ' />' .
'<label for="wp-comment-cookies-consent">' . esc_html__( 'Save my name, email, and website in this browser for the next time I comment.', 'thegem' ) . '</label></p>';
}
$comment_form_args = array(
'class_form' => 'comment-form ethnic-single-post-comments__form',
'comment_notes_before' => '',
'comment_notes_after' => '',
'title_reply' => esc_html__( 'Leave a comment', 'thegem' ),
'title_reply_to' => esc_html__( 'Reply to %s', 'thegem' ),
'cancel_reply_link' => esc_html__( 'Cancel reply', 'thegem' ),
'label_submit' => esc_html__( 'Send Comment', 'thegem' ),
'class_submit' => 'gem-button gem-button-size-medium submit',
'submit_button' => '<button name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s">%4$s</button>',
'submit_field' => '%1$s<div class="form-submit gem-button-position-inline">%2$s</div>',
'must_log_in' => '<p class="comment-form-message">' . sprintf(
wp_kses(
/* translators: %s: login URL. */
__( 'You must be <a href="%s">logged in</a> to post a comment.', 'thegem' ),
array(
'a' => array(
'href' => array(),
),
)
),
esc_url( wp_login_url( get_permalink() ) )
) . '</p>',
'logged_in_as' => '<p class="comment-form-message">' . sprintf(
wp_kses(
/* translators: 1: profile URL, 2: user name, 3: logout URL. */
__( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s">Log out</a>', 'thegem' ),
array(
'a' => array(
'href' => array(),
),
)
),
esc_url( get_edit_user_link() ),
esc_html( $current_user->display_name ),
esc_url( wp_logout_url( get_permalink() ) )
) . '</p>',
'comment_field' => '<div class="row"><div class="col-xs-12"><textarea name="comment" id="comment" cols="58" rows="8" placeholder="' . esc_attr__( 'Message *', 'thegem' ) . '" aria-required="true" required></textarea></div></div>',
'fields' => array(
'author' => '<div class="col-md-4 col-xs-12 comment-author-input"><input type="text" name="author" id="comment-author" value="' . esc_attr( $commenter['comment_author'] ) . '" size="22" placeholder="' . esc_attr__( 'Name', 'thegem' ) . esc_attr( $required_mark ) . '"' . $required_attr . ' /></div>',
'email' => '<div class="col-md-4 col-xs-12 comment-email-input"><input type="email" name="email" id="comment-email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="22" placeholder="' . esc_attr__( 'Mail', 'thegem' ) . esc_attr( $required_mark ) . '"' . $required_attr . ' /></div>',
'url' => '<div class="col-md-4 col-xs-12 comment-url-input"><input type="url" name="url" id="comment-url" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="22" placeholder="' . esc_attr__( 'Website', 'thegem' ) . '" /></div>',
'cookies' => $cookie_field,
),
);
?>
<div id="comments" class="comments-area ethnic-single-post-comments">
<?php if ( have_comments() ) : ?>
<div class="ethnic-single-post-comments__head">
<h2 class="ethnic-single-post-comments__title">
<?php esc_html_e( 'Comments', 'thegem' ); ?>
<span class="ethnic-single-post-comments__count">(<?php echo esc_html( number_format_i18n( get_comments_number() ) ); ?>)</span>
</h2>
</div>
<ol class="ethnic-single-post-comments__list">
<?php
wp_list_comments(
array(
'style' => 'ol',
'short_ping' => true,
'avatar_size' => 52,
'callback' => 'ethnic_single_post_layout_comment_item',
)
);
?>
</ol>
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : ?>
<nav id="comment-nav-below" class="ethnic-single-post-comments__navigation" aria-label="<?php esc_attr_e( 'Comment navigation', 'thegem' ); ?>">
<div class="ethnic-single-post-comments__navigation-prev"><?php previous_comments_link( esc_html__( 'Previous comments', 'thegem' ) ); ?></div>
<div class="ethnic-single-post-comments__navigation-next"><?php next_comments_link( esc_html__( 'Next comments', 'thegem' ) ); ?></div>
</nav>
<?php endif; ?>
<?php if ( ! comments_open() ) : ?>
<p class="ethnic-single-post-comments__closed"><?php esc_html_e( 'Comments are closed.', 'thegem' ); ?></p>
<?php endif; ?>
<?php endif; ?>
<div class="ethnic-single-post-comments__respond">
<?php comment_form( $comment_form_args ); ?>
</div>
</div>