74 lines
2.2 KiB
PHP
74 lines
2.2 KiB
PHP
<?php
|
|
/**
|
|
* Comments — WP native, threaded, paginated, accessible.
|
|
*
|
|
* @package XShop
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
if (post_password_required()) {
|
|
echo '<p class="xshop-notice">' . esc_html__('This post is password protected. Enter the password to view comments.', 'xshop') . '</p>';
|
|
return;
|
|
}
|
|
|
|
$hasComments = have_comments();
|
|
$commentsOpen = comments_open();
|
|
$commentsNumber = get_comments_number();
|
|
?>
|
|
<section id="comments" class="xshop-comments" aria-label="<?php esc_attr_e('Comments', 'xshop'); ?>">
|
|
<?php if ($hasComments): ?>
|
|
<h2 class="xshop-comments__title">
|
|
<?php
|
|
printf(
|
|
esc_html(_n('%s Comment', '%s Comments', (int) $commentsNumber, 'xshop')),
|
|
esc_html(number_format_i18n((int) $commentsNumber))
|
|
);
|
|
?>
|
|
</h2>
|
|
|
|
<ol class="xshop-comment-list">
|
|
<?php
|
|
wp_list_comments([
|
|
'style' => 'ol',
|
|
'short_ping' => true,
|
|
'avatar_size' => 40,
|
|
'max_depth' => (int) get_option('thread_comments_depth', 5),
|
|
]);
|
|
?>
|
|
</ol>
|
|
|
|
<?php
|
|
the_comments_pagination([
|
|
'prev_text' => is_rtl() ? esc_html__('Next', 'xshop') : esc_html__('Previous', 'xshop'),
|
|
'next_text' => is_rtl() ? esc_html__('Previous', 'xshop') : esc_html__('Next', 'xshop'),
|
|
'class' => 'xshop-pagination',
|
|
]);
|
|
?>
|
|
|
|
<?php if (!$commentsOpen): ?>
|
|
<p class="xshop-notice"><?php esc_html_e('Comments are closed.', 'xshop'); ?></p>
|
|
<?php endif; ?>
|
|
|
|
<?php else: ?>
|
|
<?php if ($commentsOpen): ?>
|
|
<h2 class="xshop-comments__title"><?php esc_html_e('Leave a comment', 'xshop'); ?></h2>
|
|
<?php else: ?>
|
|
<?php if (!is_page()): ?>
|
|
<p class="xshop-notice"><?php esc_html_e('Comments are closed.', 'xshop'); ?></p>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
|
|
<?php
|
|
comment_form([
|
|
'title_reply_before' => '<h3 id="reply-title" class="xshop-comments__title">',
|
|
'title_reply_after' => '</h3>',
|
|
'class_submit' => 'xshop-btn xshop-btn--primary',
|
|
'submit_button' => '<button name="%1$s" type="submit" id="%2$s" class="%3$s">%4$s</button>',
|
|
]);
|
|
?>
|
|
</section>
|