Wire Zibll-style board sort tabs, shared topic rows, page-template URLs, forum asset enqueue on home/plate, home synthesis load-more, and topic last_reply meta for last-reply ordering. No dual-read.
674 lines
43 KiB
PHP
674 lines
43 KiB
PHP
<?php
|
||
/**
|
||
* Forum topic template.
|
||
*
|
||
* @package AKSRT
|
||
*/
|
||
|
||
defined('ABSPATH') || exit;
|
||
|
||
get_header();
|
||
|
||
if (!have_posts()) {
|
||
get_template_part('templates/parts/content', 'none');
|
||
get_footer();
|
||
return;
|
||
}
|
||
|
||
the_post();
|
||
|
||
$forum = class_exists('AKSRT_Forum') ? AKSRT_Forum::get_instance() : null;
|
||
$current_user_id = get_current_user_id();
|
||
$topic_id = get_the_ID();
|
||
$view = $forum ? $forum->get_topic_view($topic_id, $current_user_id) : [
|
||
'topic' => null,
|
||
'board' => null,
|
||
'permissions' => [],
|
||
'board_options' => [],
|
||
'visibility_options' => [],
|
||
'review_options' => [],
|
||
];
|
||
|
||
$topic = $view['topic'] ?? null;
|
||
$board = $view['board'] ?? null;
|
||
$permissions = $view['permissions'] ?? [];
|
||
$board_options = $view['board_options'] ?? [];
|
||
$visibility_options = $view['visibility_options'] ?? [];
|
||
$review_options = $view['review_options'] ?? [];
|
||
|
||
// Forum settings for names, breadcrumbs, reply
|
||
$forum_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_forum_settings() : [];
|
||
$forum_names = $forum_settings['names'] ?? [];
|
||
$forum_bc = $forum_settings['post_page'] ?? [];
|
||
$reply_settings = $forum_settings['reply'] ?? [];
|
||
$show_breadcrumbs = $forum_bc['breadcrumbs'] ?? true;
|
||
$bc_show_home = $forum_bc['breadcrumbs_bbs_home'] ?? true;
|
||
$bc_forum_name = $forum_bc['breadcrumbs_bbs_home_name'] ?: ($forum_names['forum'] ?? __('论坛', 'aksrt'));
|
||
$reply_placeholder = $reply_settings['placeholder'] ?? __('写下你的回复…', 'aksrt');
|
||
$name_sticky = $forum_names['posts'] ?? __('置顶', 'aksrt');
|
||
$name_featured = $forum_names['topic'] ?? __('精华', 'aksrt');
|
||
$name_reply = $forum_names['comment'] ?? __('回复', 'aksrt');
|
||
|
||
if (!$topic) {
|
||
get_template_part('templates/parts/content', 'none');
|
||
get_footer();
|
||
return;
|
||
}
|
||
|
||
if (empty($topic['can_view'])) :
|
||
$deny_vis = $topic['visibility']['key'] ?? '';
|
||
$credits_cost = (int) get_post_meta($topic_id, '_aksrt_credits_cost', true);
|
||
$pay_price = get_post_meta($topic_id, '_aksrt_pay_price', true);
|
||
?>
|
||
<main id="main-content" class="site-main content-shell" tabindex="-1">
|
||
<div class="aksrt-forum-topic container">
|
||
<div class="aksrt-forum-topic__denied">
|
||
<i class="fas fa-eye-slash"></i>
|
||
<h1><?php esc_html_e('当前主题暂不可访问', 'aksrt'); ?></h1>
|
||
<?php if ($deny_vis === 'login') : ?>
|
||
<p><?php esc_html_e('该主题仅限登录用户查看,请先登录后重试。', 'aksrt'); ?></p>
|
||
<a href="<?php echo esc_url(wp_login_url(get_permalink($topic_id))); ?>" class="aksrt-forum-topic__primary-btn"><?php esc_html_e('登录查看', 'aksrt'); ?></a>
|
||
<?php elseif ($deny_vis === 'comment') : ?>
|
||
<p><?php esc_html_e('评论后即可查看该主题的完整内容。', 'aksrt'); ?></p>
|
||
<?php elseif ($deny_vis === 'role') : ?>
|
||
<p><?php esc_html_e('你当前的角色无权查看此主题。', 'aksrt'); ?></p>
|
||
<?php elseif ($deny_vis === 'credits' && $credits_cost > 0) : ?>
|
||
<p><?php printf(esc_html__('查看该主题需要 %d 积分。', 'aksrt'), $credits_cost); ?></p>
|
||
<?php if (is_user_logged_in()) : ?>
|
||
<button type="button" class="aksrt-forum-topic__primary-btn js-aksrt-unlock-topic"
|
||
data-topic-id="<?php echo esc_attr((string) $topic_id); ?>"
|
||
data-cost="<?php echo esc_attr((string) $credits_cost); ?>">
|
||
<i class="fas fa-unlock"></i> <?php printf(esc_html__('使用 %d 积分解锁', 'aksrt'), $credits_cost); ?>
|
||
</button>
|
||
<span class="aksrt-forum-topic__unlock-feedback js-aksrt-action-feedback" aria-live="polite"></span>
|
||
<?php else : ?>
|
||
<a href="<?php echo esc_url(wp_login_url(get_permalink($topic_id))); ?>" class="aksrt-forum-topic__primary-btn"><?php esc_html_e('登录后解锁', 'aksrt'); ?></a>
|
||
<?php endif; ?>
|
||
<?php elseif ($deny_vis === 'pay') : ?>
|
||
<p><?php esc_html_e('该主题为付费内容,请购买后查看。', 'aksrt'); ?></p>
|
||
<?php if (!empty($pay_price)) : ?>
|
||
<span class="aksrt-forum-topic__pay-price"><?php printf(esc_html__('价格:¥%s', 'aksrt'), esc_html((string) $pay_price)); ?></span>
|
||
<?php endif; ?>
|
||
<?php else : ?>
|
||
<p><?php esc_html_e('该主题当前处于受限可见或审核状态。', 'aksrt'); ?></p>
|
||
<?php endif; ?>
|
||
</div>
|
||
</div>
|
||
</main>
|
||
<?php
|
||
get_footer();
|
||
return;
|
||
endif;
|
||
|
||
if ($forum) {
|
||
$forum->increment_view_count($topic_id);
|
||
$topic['views'] = (int) ($topic['views'] ?? 0) + 1;
|
||
}
|
||
|
||
$is_locked = !empty($topic['locked']);
|
||
$comments_enabled = !empty($permissions['can_reply']);
|
||
?>
|
||
|
||
<main id="main-content" class="site-main content-shell" tabindex="-1">
|
||
|
||
<?php if (function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs(); } ?>
|
||
|
||
<div class="aksrt-forum-topic container">
|
||
<?php if ($show_breadcrumbs) : ?>
|
||
<div class="aksrt-forum-topic__breadcrumb">
|
||
<?php if ($bc_show_home) : ?>
|
||
<a href="<?php echo esc_url(aksrt_get_forum_home_url()); ?>"><?php echo esc_html($bc_forum_name); ?></a>
|
||
<?php endif; ?>
|
||
<?php if ($board) : ?>
|
||
<?php if ($bc_show_home) : ?><span class="aksrt-forum-topic__sep">/</span><?php endif; ?>
|
||
<a href="<?php echo esc_url((string) ($board['url'] ?? '#')); ?>"><?php echo esc_html((string) ($board['name'] ?? '')); ?></a>
|
||
<?php endif; ?>
|
||
<span class="aksrt-forum-topic__sep">/</span>
|
||
<span><?php echo esc_html((string) ($topic['title'] ?? '')); ?></span>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<div class="aksrt-forum-topic__shell">
|
||
<header class="aksrt-forum-topic__header">
|
||
<div class="aksrt-forum-topic__header-top">
|
||
<h1 class="aksrt-forum-topic__title">
|
||
<?php
|
||
$sticky_level = (int) ($topic['sticky_level'] ?? 0);
|
||
$sticky_label = (string) ($topic['sticky_label'] ?? '');
|
||
if ($sticky_level > 0 && $sticky_label !== '') :
|
||
$sticky_mod = $sticky_level >= 3 ? 'global' : ($sticky_level === 2 ? 'super' : 'plate');
|
||
?>
|
||
<span class="aksrt-forum-topic__badge aksrt-forum-topic__badge--sticky aksrt-forum-topic__badge--sticky-<?php echo esc_attr($sticky_mod); ?>">
|
||
<?php echo esc_html($sticky_label); ?>
|
||
</span>
|
||
<?php endif; ?>
|
||
<?php if (!empty($topic['featured'])) : ?><span class="aksrt-forum-topic__badge aksrt-forum-topic__badge--featured"><?php esc_html_e('精华', 'aksrt'); ?></span><?php endif; ?>
|
||
<?php if ($is_locked) : ?><span class="aksrt-forum-topic__badge aksrt-forum-topic__badge--locked"><?php esc_html_e('已锁定', 'aksrt'); ?></span><?php endif; ?>
|
||
<?php if (($topic['visibility']['key'] ?? 'public') !== 'public') : ?><span class="aksrt-forum-topic__badge aksrt-forum-topic__badge--visibility"><?php echo esc_html((string) ($topic['visibility']['label'] ?? '')); ?></span><?php endif; ?>
|
||
<?php if (($topic['bbs_type'] ?? 'standard') === 'question') : ?>
|
||
<?php $q_status = (int) ($topic['question_status'] ?? 0); ?>
|
||
<span class="aksrt-forum-topic__badge aksrt-forum-topic__badge--question<?php echo $q_status === 1 ? ' aksrt-forum-topic__badge--solved' : ''; ?>">
|
||
<?php echo $q_status === 1 ? esc_html($forum_names['question_ok_badge'] ?? __('已解决', 'aksrt')) : esc_html($forum_names['question_badge'] ?? __('提问', 'aksrt')); ?>
|
||
</span>
|
||
<?php endif; ?>
|
||
<?php echo esc_html((string) ($topic['title'] ?? '')); ?>
|
||
</h1>
|
||
|
||
<div class="aksrt-forum-topic__meta">
|
||
<span class="aksrt-forum-topic__board-link-wrap">
|
||
<i class="fas fa-layer-group"></i>
|
||
<a class="aksrt-forum-topic__board-link" href="<?php echo esc_url((string) ($board['url'] ?? aksrt_get_forum_home_url())); ?>"><?php echo esc_html((string) ($board['name'] ?? $bc_forum_name)); ?></a>
|
||
</span>
|
||
<span class="aksrt-forum-topic__author">
|
||
<?php if (!empty($topic['author']['avatar_url'])) : ?>
|
||
<img src="<?php echo esc_url((string) $topic['author']['avatar_url']); ?>" alt="" width="24" height="24">
|
||
<?php endif; ?>
|
||
<?php echo esc_html((string) ($topic['author']['display_name'] ?? '')); ?>
|
||
</span>
|
||
<span><i class="fas fa-clock"></i> <?php echo esc_html((string) ($topic['date'] ?? '')); ?></span>
|
||
<span><i class="fas fa-eye"></i> <?php echo esc_html(number_format_i18n((int) ($topic['views'] ?? 0))); ?></span>
|
||
<span><i class="fas fa-comment"></i> <?php echo esc_html(number_format_i18n((int) ($topic['comment_count'] ?? 0))); ?></span>
|
||
<?php if (!empty($topic['review_status']['label'])) : ?>
|
||
<span><i class="fas fa-shield-check"></i> <?php echo esc_html((string) $topic['review_status']['label']); ?></span>
|
||
<?php endif; ?>
|
||
<?php if (($topic['score'] ?? 0) !== 0) : ?>
|
||
<span class="aksrt-forum-topic__score-badge"><i class="fas fa-star"></i> <?php echo esc_html(number_format_i18n((int) $topic['score'])); ?></span>
|
||
<?php endif; ?>
|
||
<?php if (($topic['favorite_count'] ?? 0) > 0) : ?>
|
||
<span><i class="fas fa-bookmark"></i> <?php echo esc_html(number_format_i18n((int) $topic['favorite_count'])); ?></span>
|
||
<?php endif; ?>
|
||
</div>
|
||
|
||
<div class="aksrt-forum-topic__quick-actions">
|
||
<a class="aksrt-forum-topic__quick-action aksrt-forum-topic__quick-action--primary" href="#aksrt-forum-replies">
|
||
<i class="fas fa-reply"></i>
|
||
<?php esc_html_e('参与讨论', 'aksrt'); ?>
|
||
</a>
|
||
<?php if (is_user_logged_in()) : ?>
|
||
<button type="button" class="aksrt-forum-topic__quick-action js-aksrt-report-trigger"
|
||
data-target-type="post"
|
||
data-target-id="<?php echo esc_attr((string) $topic_id); ?>"
|
||
data-target-title="<?php echo esc_attr((string) ($topic['title'] ?? '')); ?>">
|
||
<i class="far fa-flag"></i>
|
||
<?php esc_html_e('举报', 'aksrt'); ?>
|
||
</button>
|
||
<?php endif; ?>
|
||
<?php if (is_user_logged_in()) : ?>
|
||
<?php $is_fav = !empty($topic['is_favorited']); ?>
|
||
<button type="button"
|
||
class="aksrt-forum-topic__quick-action js-aksrt-topic-favorite"
|
||
data-topic-id="<?php echo esc_attr((string) $topic_id); ?>"
|
||
data-favorited="<?php echo $is_fav ? '1' : '0'; ?>">
|
||
<i class="<?php echo $is_fav ? 'fas' : 'far'; ?> fa-bookmark"></i>
|
||
<span class="js-aksrt-favorite-label"><?php echo $is_fav ? esc_html__('已收藏', 'aksrt') : esc_html__('收藏', 'aksrt'); ?></span>
|
||
</button>
|
||
<?php endif; ?>
|
||
<?php if (!empty($permissions['can_edit'])) : ?>
|
||
<a href="<?php echo esc_url(add_query_arg('edit', '1', get_permalink($topic_id))); ?>" class="aksrt-forum-topic__quick-action">
|
||
<i class="fas fa-edit"></i>
|
||
<?php esc_html_e('编辑主题', 'aksrt'); ?>
|
||
</a>
|
||
<?php endif; ?>
|
||
|
||
<?php if (!empty($permissions['can_moderate'])) : ?>
|
||
<a href="#aksrt-topic-moderation" class="aksrt-forum-topic__quick-action">
|
||
<i class="fas fa-tools"></i>
|
||
<?php esc_html_e('治理动作', 'aksrt'); ?>
|
||
</a>
|
||
<?php endif; ?>
|
||
</div>
|
||
</header>
|
||
|
||
<aside class="aksrt-forum-topic__sidebar">
|
||
<?php if ($board) : ?>
|
||
<section class="aksrt-forum-topic__sidebar-card aksrt-forum-topic__sidebar-card--board">
|
||
<h2><?php esc_html_e('所属版块', 'aksrt'); ?></h2>
|
||
<a class="aksrt-forum-topic__sidebar-link" href="<?php echo esc_url((string) ($board['url'] ?? '#')); ?>">
|
||
<strong><?php echo esc_html((string) ($board['name'] ?? '')); ?></strong>
|
||
<?php if (!empty($board['description'])) : ?>
|
||
<span><?php echo esc_html((string) $board['description']); ?></span>
|
||
<?php endif; ?>
|
||
</a>
|
||
</section>
|
||
<?php endif; ?>
|
||
|
||
<section class="aksrt-forum-topic__sidebar-card aksrt-forum-topic__sidebar-card--author">
|
||
<h2><?php esc_html_e('作者信息', 'aksrt'); ?></h2>
|
||
<div class="aksrt-forum-topic__sidebar-author">
|
||
<?php if (!empty($topic['author']['avatar_url'])) : ?>
|
||
<img src="<?php echo esc_url((string) $topic['author']['avatar_url']); ?>" alt="" width="48" height="48">
|
||
<?php endif; ?>
|
||
<div>
|
||
<strong><?php echo esc_html((string) ($topic['author']['display_name'] ?? '')); ?></strong>
|
||
<span><?php echo esc_html((string) ($topic['date'] ?? '')); ?></span>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</aside>
|
||
|
||
<div class="aksrt-forum-report-modal" id="aksrt-report-modal" hidden>
|
||
<div class="aksrt-forum-report-modal__backdrop js-aksrt-report-close"></div>
|
||
<div class="aksrt-forum-report-modal__dialog" role="dialog" aria-modal="true" aria-labelledby="aksrt-report-title">
|
||
<div class="aksrt-forum-report-modal__head">
|
||
<h2 id="aksrt-report-title"><?php esc_html_e('提交举报', 'aksrt'); ?></h2>
|
||
<button type="button" class="aksrt-forum-report-modal__close js-aksrt-report-close" aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>">×</button>
|
||
</div>
|
||
<p class="aksrt-forum-report-modal__target js-aksrt-report-target"></p>
|
||
<form class="aksrt-forum-report-modal__form js-aksrt-report-form">
|
||
<input type="hidden" name="target_type" value="post">
|
||
<input type="hidden" name="target_id" value="<?php echo esc_attr((string) $topic_id); ?>">
|
||
<div class="aksrt-forum-topic__field">
|
||
<label for="aksrt-report-category"><?php esc_html_e('举报分类', 'aksrt'); ?></label>
|
||
<select id="aksrt-report-category" name="category">
|
||
<option value="spam"><?php esc_html_e('垃圾信息', 'aksrt'); ?></option>
|
||
<option value="abuse"><?php esc_html_e('人身攻击', 'aksrt'); ?></option>
|
||
<option value="copyright"><?php esc_html_e('版权投诉', 'aksrt'); ?></option>
|
||
<option value="other"><?php esc_html_e('其他问题', 'aksrt'); ?></option>
|
||
</select>
|
||
</div>
|
||
<div class="aksrt-forum-topic__field">
|
||
<label for="aksrt-report-reason"><?php esc_html_e('举报说明', 'aksrt'); ?></label>
|
||
<textarea id="aksrt-report-reason" name="reason" rows="4" required placeholder="<?php esc_attr_e('请尽量描述清楚问题,以便管理员处理。', 'aksrt'); ?>"></textarea>
|
||
</div>
|
||
<div class="aksrt-forum-report-modal__actions">
|
||
<button type="submit" class="aksrt-forum-topic__primary-btn"><?php esc_html_e('提交举报', 'aksrt'); ?></button>
|
||
<span class="aksrt-forum-report-modal__feedback js-aksrt-action-feedback" aria-live="polite"></span>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
|
||
<?php if (!empty($topic['cover'])) : ?>
|
||
<div class="aksrt-forum-topic__cover aksrt-forum-topic__cover--<?php echo esc_attr($topic['cover']['type']); ?>">
|
||
<?php if ($topic['cover']['type'] === 'video') : ?>
|
||
<div class="aksrt-forum-topic__cover-player" data-src="<?php echo esc_url((string) $topic['cover']['url']); ?>" data-poster="<?php echo esc_url((string) ($topic['cover']['poster'] ?? '')); ?>">
|
||
<?php if (!empty($topic['cover']['poster'])) : ?>
|
||
<img src="<?php echo esc_url((string) $topic['cover']['poster']); ?>" alt="" class="aksrt-forum-topic__cover-poster">
|
||
<?php endif; ?>
|
||
<button type="button" class="aksrt-forum-topic__cover-play-btn"><i class="fas fa-play-circle"></i></button>
|
||
</div>
|
||
<?php elseif ($topic['cover']['type'] === 'slide') : ?>
|
||
<div class="aksrt-forum-topic__cover-slides">
|
||
<?php foreach (($topic['cover']['images'] ?? []) as $slide_url) : ?>
|
||
<img src="<?php echo esc_url((string) $slide_url); ?>" alt="" loading="lazy">
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<?php else : ?>
|
||
<img src="<?php echo esc_url((string) ($topic['cover']['url'] ?? '')); ?>" alt="" class="aksrt-forum-topic__cover-img">
|
||
<?php endif; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<?php if (!empty($topic['special_topic']) || !empty($topic['tags']) || !empty($topic['topic_cat'])) : ?>
|
||
<div class="aksrt-forum-topic__taxonomy">
|
||
<?php if (!empty($topic['topic_cat'])) : ?>
|
||
<a class="aksrt-forum-topic__chip aksrt-forum-topic__chip--topic-cat" href="<?php echo esc_url((string) ($topic['topic_cat']['url'] ?? '#')); ?>">
|
||
<?php echo esc_html((string) ($topic['topic_cat']['name'] ?? '')); ?>
|
||
</a>
|
||
<?php endif; ?>
|
||
|
||
<?php if (!empty($topic['special_topic'])) : ?>
|
||
<span class="aksrt-forum-topic__chip aksrt-forum-topic__chip--special"><?php echo esc_html((string) $topic['special_topic']); ?></span>
|
||
<?php endif; ?>
|
||
|
||
<?php foreach (($topic['tags'] ?? []) as $tag) : ?>
|
||
<a class="aksrt-forum-topic__chip" href="<?php echo esc_url((string) ($tag['url'] ?? '#')); ?>">
|
||
#<?php echo esc_html((string) ($tag['name'] ?? '')); ?>
|
||
</a>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<article class="aksrt-forum-topic__content">
|
||
<?php the_content(); ?>
|
||
</article>
|
||
|
||
<?php
|
||
$score_extra_max = (int) ($forum_settings['post_page']['score_extra_max'] ?? 5);
|
||
$score_deduct_max = (int) ($forum_settings['post_page']['score_deduct_max'] ?? 3);
|
||
$current_score = (int) ($topic['score'] ?? 0);
|
||
?>
|
||
<?php if (is_user_logged_in() && (int) ($topic['author_id'] ?? 0) !== get_current_user_id()) : ?>
|
||
<div class="aksrt-forum-topic__score-actions" data-topic-id="<?php echo esc_attr((string) $topic_id); ?>">
|
||
<span class="aksrt-forum-topic__score-total">
|
||
<i class="fas fa-star"></i>
|
||
<span class="js-aksrt-score-value"><?php echo esc_html(number_format_i18n($current_score)); ?></span>
|
||
<?php esc_html_e('分', 'aksrt'); ?>
|
||
</span>
|
||
<?php if ($score_extra_max > 0) : ?>
|
||
<button type="button" class="aksrt-forum-topic__score-btn aksrt-forum-topic__score-btn--up js-aksrt-topic-score" data-amount="1" title="<?php esc_attr_e('加分', 'aksrt'); ?>">
|
||
<i class="fas fa-plus"></i>
|
||
</button>
|
||
<?php endif; ?>
|
||
<?php if ($score_deduct_max > 0) : ?>
|
||
<button type="button" class="aksrt-forum-topic__score-btn aksrt-forum-topic__score-btn--down js-aksrt-topic-score" data-amount="-1" title="<?php esc_attr_e('减分', 'aksrt'); ?>">
|
||
<i class="fas fa-minus"></i>
|
||
</button>
|
||
<?php endif; ?>
|
||
<span class="aksrt-forum-topic__score-feedback js-aksrt-action-feedback" aria-live="polite"></span>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<?php if (!empty($topic['vote']['enabled'])) : ?>
|
||
<?php
|
||
$vote_type = $topic['vote']['vote_type'] ?? 'standard';
|
||
$vote_expired = !empty($topic['vote']['expired']);
|
||
$vote_display = $topic['vote']['display_mode'] ?? 'percent';
|
||
$vote_expiry = (int) ($topic['vote']['expiry_days'] ?? 0);
|
||
$vote_disabled = $vote_expired || !empty($topic['vote']['has_voted']);
|
||
?>
|
||
<section class="aksrt-forum-topic__vote<?php echo $vote_type === 'pk' ? ' aksrt-forum-topic__vote--pk' : ''; ?><?php echo $vote_expired ? ' aksrt-forum-topic__vote--expired' : ''; ?>">
|
||
<div class="aksrt-forum-topic__vote-head">
|
||
<h2><?php echo esc_html((string) ($topic['vote']['title'] ?: __('参与投票', 'aksrt'))); ?></h2>
|
||
<span>
|
||
<?php printf(esc_html__('%d 人已投票', 'aksrt'), (int) ($topic['vote']['total_votes'] ?? 0)); ?>
|
||
<?php if ($vote_type === 'pk') : ?>
|
||
<span class="aksrt-forum-topic__vote-type-badge"><?php esc_html_e('PK', 'aksrt'); ?></span>
|
||
<?php endif; ?>
|
||
<?php if ($vote_expired) : ?>
|
||
<span class="aksrt-forum-topic__vote-expired-badge"><?php esc_html_e('已结束', 'aksrt'); ?></span>
|
||
<?php elseif ($vote_expiry > 0) : ?>
|
||
<span class="aksrt-forum-topic__vote-expiry-info"><?php printf(esc_html__('%d 天有效期', 'aksrt'), $vote_expiry); ?></span>
|
||
<?php endif; ?>
|
||
</span>
|
||
</div>
|
||
|
||
<form class="aksrt-forum-topic__vote-form js-aksrt-topic-vote-form" data-topic-id="<?php echo esc_attr((string) $topic_id); ?>" data-multiple="<?php echo !empty($topic['vote']['multiple']) ? '1' : '0'; ?>">
|
||
<div class="aksrt-forum-topic__vote-options">
|
||
<?php foreach (($topic['vote']['options'] ?? []) as $option) :
|
||
$selected = !empty($option['selected']);
|
||
$count = (int) ($option['count'] ?? 0);
|
||
$total_votes = max(1, (int) ($topic['vote']['total_votes'] ?? 0));
|
||
$ratio = (int) round(($count / $total_votes) * 100);
|
||
?>
|
||
<label class="aksrt-forum-topic__vote-option<?php echo $selected ? ' is-selected' : ''; ?>">
|
||
<input
|
||
type="<?php echo !empty($topic['vote']['multiple']) ? 'checkbox' : 'radio'; ?>"
|
||
name="option_ids[]"
|
||
value="<?php echo esc_attr((string) ($option['id'] ?? '')); ?>"
|
||
<?php checked($selected); ?>
|
||
<?php disabled($vote_disabled); ?>
|
||
>
|
||
<span class="aksrt-forum-topic__vote-label"><?php echo esc_html((string) ($option['label'] ?? '')); ?></span>
|
||
<span class="aksrt-forum-topic__vote-count">
|
||
<?php if ($vote_display === 'number') : ?>
|
||
<?php echo esc_html(number_format_i18n($count)); ?>
|
||
<?php else : ?>
|
||
<?php echo esc_html(number_format_i18n($count)); ?> / <?php echo esc_html((string) $ratio); ?>%
|
||
<?php endif; ?>
|
||
</span>
|
||
</label>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
|
||
<div class="aksrt-forum-topic__vote-actions">
|
||
<?php if ($vote_expired) : ?>
|
||
<span class="aksrt-forum-topic__vote-feedback is-error"><?php esc_html_e('投票已结束。', 'aksrt'); ?></span>
|
||
<?php elseif (!empty($topic['vote']['has_voted'])) : ?>
|
||
<span class="aksrt-forum-topic__vote-feedback is-success"><?php esc_html_e('你已经参与过本次投票。', 'aksrt'); ?></span>
|
||
<?php else : ?>
|
||
<button type="submit" class="aksrt-forum-topic__primary-btn"><?php esc_html_e('提交投票', 'aksrt'); ?></button>
|
||
<span class="aksrt-forum-topic__vote-feedback js-aksrt-action-feedback" aria-live="polite"></span>
|
||
<?php endif; ?>
|
||
</div>
|
||
</form>
|
||
</section>
|
||
<?php endif; ?>
|
||
|
||
<?php if (!empty($permissions['can_moderate'])) : ?>
|
||
<section id="aksrt-topic-moderation" class="aksrt-forum-topic__moderation">
|
||
<div class="aksrt-forum-topic__moderation-head">
|
||
<h2><?php esc_html_e('主题治理', 'aksrt'); ?></h2>
|
||
<p><?php esc_html_e('支持审核、移动版块、可见性调整以及置顶/精华/锁定等治理动作。', 'aksrt'); ?></p>
|
||
</div>
|
||
|
||
<?php if (!empty($topic['moderation_note'])) : ?>
|
||
<div class="aksrt-forum-topic__moderation-note">
|
||
<strong><?php esc_html_e('最近治理备注:', 'aksrt'); ?></strong>
|
||
<span><?php echo esc_html((string) $topic['moderation_note']); ?></span>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<form class="aksrt-forum-topic__moderation-form js-aksrt-topic-moderation-form" data-topic-id="<?php echo esc_attr((string) $topic_id); ?>">
|
||
<div class="aksrt-forum-topic__moderation-grid">
|
||
<div class="aksrt-forum-topic__field">
|
||
<label for="aksrt-topic-moderation-action"><?php esc_html_e('治理动作', 'aksrt'); ?></label>
|
||
<select id="aksrt-topic-moderation-action" name="action" class="js-aksrt-moderation-action" required>
|
||
<option value="review"><?php esc_html_e('审核状态', 'aksrt'); ?></option>
|
||
<option value="move_board"><?php esc_html_e('移动版块', 'aksrt'); ?></option>
|
||
<option value="visibility"><?php esc_html_e('修改可见性', 'aksrt'); ?></option>
|
||
<option value="sticky"><?php esc_html_e('置顶切换', 'aksrt'); ?></option>
|
||
<option value="featured"><?php esc_html_e('精华切换', 'aksrt'); ?></option>
|
||
<option value="locked"><?php esc_html_e('锁定切换', 'aksrt'); ?></option>
|
||
<option value="close"><?php esc_html_e('关闭帖子', 'aksrt'); ?></option>
|
||
<option value="hide"><?php esc_html_e('隐藏帖子', 'aksrt'); ?></option>
|
||
<option value="delete"><?php esc_html_e('删除到回收站', 'aksrt'); ?></option>
|
||
<?php if (get_post_status($topic_id) === 'trash') : ?>
|
||
<option value="undelete"><?php esc_html_e('撤销删除', 'aksrt'); ?></option>
|
||
<?php endif; ?>
|
||
<?php if (($topic['bbs_type'] ?? 'standard') === 'question') : ?>
|
||
<option value="question_status"><?php esc_html_e('提问状态', 'aksrt'); ?></option>
|
||
<?php endif; ?>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="aksrt-forum-topic__field js-aksrt-moderation-field" data-field="review">
|
||
<label for="aksrt-topic-review-status"><?php esc_html_e('审核结果', 'aksrt'); ?></label>
|
||
<select id="aksrt-topic-review-status" name="review_status">
|
||
<?php foreach ($review_options as $option) : ?>
|
||
<option value="<?php echo esc_attr((string) ($option['value'] ?? '')); ?>" <?php selected((string) (($topic['review_status']['key'] ?? '')) === (string) ($option['value'] ?? '')); ?>>
|
||
<?php echo esc_html((string) ($option['label'] ?? '')); ?>
|
||
</option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="aksrt-forum-topic__field js-aksrt-moderation-field" data-field="move_board" hidden>
|
||
<label for="aksrt-topic-target-board"><?php esc_html_e('目标版块', 'aksrt'); ?></label>
|
||
<select id="aksrt-topic-target-board" name="target_board_id">
|
||
<?php foreach ($board_options as $option) : ?>
|
||
<option value="<?php echo esc_attr((string) ($option['id'] ?? '')); ?>" <?php selected((int) ($board['id'] ?? 0), (int) ($option['id'] ?? 0)); ?>>
|
||
<?php echo esc_html((string) ($option['name'] ?? '')); ?>
|
||
</option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="aksrt-forum-topic__field js-aksrt-moderation-field" data-field="visibility" hidden>
|
||
<label for="aksrt-topic-visibility"><?php esc_html_e('可见性', 'aksrt'); ?></label>
|
||
<select id="aksrt-topic-visibility" name="visibility">
|
||
<?php foreach ($visibility_options as $option) : ?>
|
||
<option value="<?php echo esc_attr((string) ($option['value'] ?? '')); ?>" <?php selected((string) (($topic['visibility']['key'] ?? '')) === (string) ($option['value'] ?? '')); ?>>
|
||
<?php echo esc_html((string) ($option['label'] ?? '')); ?>
|
||
</option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="aksrt-forum-topic__field js-aksrt-moderation-field js-aksrt-visibility-extra" data-field="visibility" data-visibility-field="credits" hidden>
|
||
<label for="aksrt-topic-credits-cost"><?php esc_html_e('积分价格', 'aksrt'); ?></label>
|
||
<input id="aksrt-topic-credits-cost" name="credits_cost" type="number" min="1" max="99999" value="<?php echo esc_attr((string) ((int) get_post_meta($topic_id, '_aksrt_credits_cost', true))); ?>">
|
||
</div>
|
||
|
||
<div class="aksrt-forum-topic__field js-aksrt-moderation-field js-aksrt-visibility-extra" data-field="visibility" data-visibility-field="pay" hidden>
|
||
<label for="aksrt-topic-pay-price"><?php esc_html_e('付费价格(¥)', 'aksrt'); ?></label>
|
||
<input id="aksrt-topic-pay-price" name="pay_price" type="number" min="0.01" step="0.01" max="99999" value="<?php echo esc_attr((string) get_post_meta($topic_id, '_aksrt_pay_price', true)); ?>">
|
||
</div>
|
||
|
||
<div class="aksrt-forum-topic__field js-aksrt-moderation-field js-aksrt-visibility-extra" data-field="visibility" data-visibility-field="role" hidden>
|
||
<label for="aksrt-topic-visibility-roles"><?php esc_html_e('允许角色', 'aksrt'); ?></label>
|
||
<?php $current_visibility_roles = (array) get_post_meta($topic_id, '_aksrt_visibility_roles', true); ?>
|
||
<select id="aksrt-topic-visibility-roles" name="visibility_roles[]" multiple>
|
||
<?php foreach (wp_roles()->get_names() as $role_slug => $role_name) : ?>
|
||
<option value="<?php echo esc_attr($role_slug); ?>" <?php selected(in_array($role_slug, $current_visibility_roles, true)); ?>>
|
||
<?php echo esc_html(translate_user_role($role_name)); ?>
|
||
</option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="aksrt-forum-topic__field js-aksrt-moderation-field" data-field="sticky" hidden>
|
||
<label for="aksrt-topic-sticky"><?php esc_html_e('置顶级别', 'aksrt'); ?></label>
|
||
<select id="aksrt-topic-sticky" name="sticky_value">
|
||
<?php
|
||
$current_sticky = (int) ($topic['sticky_level'] ?? 0);
|
||
$sticky_levels = [
|
||
0 => __('不置顶', 'aksrt'),
|
||
1 => __('版块置顶', 'aksrt'),
|
||
2 => __('超级置顶', 'aksrt'),
|
||
3 => __('全局置顶', 'aksrt'),
|
||
];
|
||
foreach ($sticky_levels as $level => $label) :
|
||
?>
|
||
<option value="<?php echo esc_attr((string) $level); ?>" <?php selected($current_sticky, $level); ?>>
|
||
<?php echo esc_html($label); ?>
|
||
</option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="aksrt-forum-topic__field js-aksrt-moderation-field" data-field="featured" hidden>
|
||
<label for="aksrt-topic-featured"><?php esc_html_e('精华状态', 'aksrt'); ?></label>
|
||
<select id="aksrt-topic-featured" name="featured_value">
|
||
<option value="1" <?php selected(!empty($topic['featured'])); ?>><?php esc_html_e('设为精华', 'aksrt'); ?></option>
|
||
<option value="0" <?php selected(empty($topic['featured'])); ?>><?php esc_html_e('取消精华', 'aksrt'); ?></option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="aksrt-forum-topic__field js-aksrt-moderation-field" data-field="locked" hidden>
|
||
<label for="aksrt-topic-locked"><?php esc_html_e('锁定状态', 'aksrt'); ?></label>
|
||
<select id="aksrt-topic-locked" name="locked_value">
|
||
<option value="1" <?php selected(!empty($topic['locked'])); ?>><?php esc_html_e('锁定主题', 'aksrt'); ?></option>
|
||
<option value="0" <?php selected(empty($topic['locked'])); ?>><?php esc_html_e('解除锁定', 'aksrt'); ?></option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="aksrt-forum-topic__field js-aksrt-moderation-field" data-field="close" hidden>
|
||
<label for="aksrt-topic-close"><?php esc_html_e('关闭状态', 'aksrt'); ?></label>
|
||
<select id="aksrt-topic-close" name="close_value">
|
||
<option value="1"><?php esc_html_e('关闭帖子', 'aksrt'); ?></option>
|
||
<option value="0"><?php esc_html_e('重新开放', 'aksrt'); ?></option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="aksrt-forum-topic__field js-aksrt-moderation-field" data-field="hide" hidden>
|
||
<label for="aksrt-topic-hide"><?php esc_html_e('隐藏状态', 'aksrt'); ?></label>
|
||
<select id="aksrt-topic-hide" name="hide_value">
|
||
<option value="1"><?php esc_html_e('隐藏帖子', 'aksrt'); ?></option>
|
||
<option value="0"><?php esc_html_e('恢复显示', 'aksrt'); ?></option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="aksrt-forum-topic__field js-aksrt-moderation-field" data-field="delete" hidden>
|
||
<label for="aksrt-topic-delete-confirm"><?php esc_html_e('删除确认', 'aksrt'); ?></label>
|
||
<select id="aksrt-topic-delete-confirm" name="delete_value">
|
||
<option value="1"><?php esc_html_e('确认删除到回收站', 'aksrt'); ?></option>
|
||
</select>
|
||
<small><?php esc_html_e('删除后作者会收到通知,主题可在回收站中恢复。', 'aksrt'); ?></small>
|
||
</div>
|
||
|
||
<div class="aksrt-forum-topic__field js-aksrt-moderation-field" data-field="undelete" hidden>
|
||
<label for="aksrt-topic-undelete-confirm"><?php esc_html_e('恢复确认', 'aksrt'); ?></label>
|
||
<select id="aksrt-topic-undelete-confirm" name="undelete_value">
|
||
<option value="1"><?php esc_html_e('确认恢复主题', 'aksrt'); ?></option>
|
||
</select>
|
||
</div>
|
||
|
||
<?php if (($topic['bbs_type'] ?? 'standard') === 'question') : ?>
|
||
<div class="aksrt-forum-topic__field js-aksrt-moderation-field" data-field="question_status" hidden>
|
||
<label for="aksrt-topic-question-status"><?php esc_html_e('提问状态', 'aksrt'); ?></label>
|
||
<select id="aksrt-topic-question-status" name="question_status_value">
|
||
<option value="0" <?php selected((int) ($topic['question_status'] ?? 0), 0); ?>><?php esc_html_e('未解决', 'aksrt'); ?></option>
|
||
<option value="1" <?php selected((int) ($topic['question_status'] ?? 0), 1); ?>><?php esc_html_e('已解决', 'aksrt'); ?></option>
|
||
</select>
|
||
</div>
|
||
<?php endif; ?>
|
||
</div>
|
||
|
||
<div class="aksrt-forum-topic__field">
|
||
<label for="aksrt-topic-moderation-note"><?php esc_html_e('治理备注', 'aksrt'); ?></label>
|
||
<textarea id="aksrt-topic-moderation-note" name="note" rows="3" placeholder="<?php esc_attr_e('记录处理原因,便于后续审计和沟通。', 'aksrt'); ?>"></textarea>
|
||
</div>
|
||
|
||
<div class="aksrt-forum-topic__moderation-actions">
|
||
<button type="submit" class="aksrt-forum-topic__primary-btn"><?php esc_html_e('执行治理动作', 'aksrt'); ?></button>
|
||
<span class="aksrt-forum-topic__moderation-feedback js-aksrt-action-feedback" aria-live="polite"></span>
|
||
</div>
|
||
</form>
|
||
</section>
|
||
<?php endif; ?>
|
||
|
||
<section class="aksrt-forum-topic__replies" id="aksrt-forum-replies"
|
||
data-topic-id="<?php echo esc_attr((string) $topic_id); ?>"
|
||
data-nonce="<?php echo esc_attr(wp_create_nonce('aksrt_public_nonce')); ?>">
|
||
|
||
<div class="aksrt-forum-replies__header">
|
||
<h2 class="aksrt-forum-topic__replies-title">
|
||
<i class="fas fa-comments"></i>
|
||
<?php
|
||
printf(esc_html__('%1$d 条%2$s', 'aksrt'), (int) get_comments_number(), esc_html($name_reply));
|
||
?>
|
||
</h2>
|
||
<div class="aksrt-forum-replies__tabs">
|
||
<button type="button" class="aksrt-forum-replies__tab is-active" data-sort="newest"><?php esc_html_e('最新', 'aksrt'); ?></button>
|
||
<button type="button" class="aksrt-forum-replies__tab" data-sort="oldest"><?php esc_html_e('最早', 'aksrt'); ?></button>
|
||
<button type="button" class="aksrt-forum-replies__tab" data-sort="hottest"><?php esc_html_e('最热', 'aksrt'); ?></button>
|
||
<label class="aksrt-forum-replies__filter">
|
||
<input type="checkbox" class="aksrt-forum-replies__author-toggle" value="1">
|
||
<?php esc_html_e('只看楼主', 'aksrt'); ?>
|
||
</label>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="aksrt-forum-replies__list js-aksrt-forum-replies-list">
|
||
<?php
|
||
if ($forum) {
|
||
$reply_data = $forum->get_forum_comments($topic_id, 'newest', false, 1, 30);
|
||
$forum->render_forum_comments($reply_data['comments'], $topic_id, $reply_data['adopted_id']);
|
||
$reply_max_pages = $reply_data['max_pages'];
|
||
$reply_total = $reply_data['total'];
|
||
} else {
|
||
$reply_max_pages = 1;
|
||
$reply_total = 0;
|
||
}
|
||
?>
|
||
</div>
|
||
|
||
<?php if ($reply_max_pages > 1) : ?>
|
||
<div class="aksrt-forum-replies__load-more">
|
||
<button type="button" class="aksrt-forum-replies__more-btn js-aksrt-forum-load-more"
|
||
data-page="1" data-max="<?php echo esc_attr((string) $reply_max_pages); ?>">
|
||
<i class="fas fa-chevron-down"></i> <?php esc_html_e('加载更多回复', 'aksrt'); ?>
|
||
</button>
|
||
</div>
|
||
<?php endif; ?>
|
||
</section>
|
||
|
||
<?php if ($comments_enabled) : ?>
|
||
<section class="aksrt-forum-topic__reply-form">
|
||
<h2><i class="fas fa-reply"></i> <?php esc_html_e('发表评论', 'aksrt'); ?></h2>
|
||
<?php
|
||
comment_form([
|
||
'title_reply' => '',
|
||
'comment_notes_before' => '',
|
||
'comment_field' => '<div class="aksrt-forum-topic__reply-field"><textarea name="comment" rows="5" required placeholder="' . esc_attr($reply_placeholder) . '"></textarea></div>',
|
||
'submit_button' => '<button type="submit" class="aksrt-forum-topic__reply-btn"><i class="fas fa-paper-plane"></i> %s</button>',
|
||
'submit_field' => '<div class="aksrt-forum-topic__reply-actions">%1$s %2$s</div>',
|
||
]);
|
||
?>
|
||
</section>
|
||
<?php elseif ($is_locked) : ?>
|
||
<div class="aksrt-forum-topic__locked-notice">
|
||
<i class="fas fa-lock"></i>
|
||
<?php esc_html_e('当前主题已锁定,暂不接受新的回复。', 'aksrt'); ?>
|
||
</div>
|
||
<?php else : ?>
|
||
<div class="aksrt-forum-topic__login-notice">
|
||
<a href="<?php echo esc_url(wp_login_url(get_permalink())); ?>"><?php esc_html_e('登录后参与回复', 'aksrt'); ?></a>
|
||
</div>
|
||
<?php endif; ?>
|
||
</div>
|
||
</main>
|
||
|
||
<?php get_footer(); ?>
|