feat: remove forum feature (Phase 1)
This commit is contained in:
1 parent
f3e4cdd9cf
commit
2bbd7c01a3
173 files changed
+51
-27360
No files matched your search
@@ -1,155 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Forum board template (legacy taxonomy archive).
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
get_header();
|
||||
|
||||
$forum = class_exists('\AKSRT\Forum\Forum') ? \AKSRT\Forum\Forum::get_instance() : null;
|
||||
$current_user_id = get_current_user_id();
|
||||
$board = get_queried_object();
|
||||
$board_id = $board ? (int) $board->term_id : 0;
|
||||
$paged = max(1, (int) get_query_var('paged', 1));
|
||||
$forum_sort = isset($_GET['forum_sort']) ? sanitize_key(wp_unslash((string) $_GET['forum_sort'])) : '';
|
||||
|
||||
$view = $forum ? $forum->get_board_view($board_id, [
|
||||
'user_id' => $current_user_id,
|
||||
'paged' => $paged,
|
||||
'orderby' => $forum_sort,
|
||||
]) : [
|
||||
'board' => null,
|
||||
'topics' => [],
|
||||
'sticky_topics' => [],
|
||||
'moderators' => [],
|
||||
'pagination' => ['page' => 1, 'max_pages' => 1, 'total' => 0],
|
||||
'permissions' => [],
|
||||
'application' => null,
|
||||
'board_options' => [],
|
||||
'tabs' => [],
|
||||
'active_sort' => 'date',
|
||||
'top_info' => true,
|
||||
'compose_url' => function_exists('aksrt_get_forum_compose_url') ? aksrt_get_forum_compose_url() : home_url('/'),
|
||||
];
|
||||
|
||||
$board_data = $view['board'] ?? null;
|
||||
$topics = $view['topics'] ?? [];
|
||||
$sticky_topics = $view['sticky_topics'] ?? [];
|
||||
$moderators = $view['moderators'] ?? [];
|
||||
$permissions = $view['permissions'] ?? [];
|
||||
$tabs = is_array($view['tabs'] ?? null) ? $view['tabs'] : [];
|
||||
$active_sort = sanitize_key((string) ($view['active_sort'] ?? 'date'));
|
||||
$top_info = !isset($view['top_info']) || !empty($view['top_info']);
|
||||
$compose_url = (string) ($view['compose_url'] ?? aksrt_get_forum_compose_url(['board' => $board_id]));
|
||||
$board_url = !empty($board_data['url']) ? (string) $board_data['url'] : (is_wp_error(get_term_link($board)) ? '' : (string) get_term_link($board));
|
||||
$nonce = wp_create_nonce('aksrt_public_nonce');
|
||||
$max_pages = (int) ($view['pagination']['max_pages'] ?? 1);
|
||||
|
||||
$forum_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_forum_settings() : [];
|
||||
$forum_names = $forum_settings['names'] ?? [];
|
||||
$name_topic = $forum_names['posts'] ?? __('主题', 'aksrt');
|
||||
$name_reply = $forum_names['comment'] ?? __('回复', 'aksrt');
|
||||
?>
|
||||
|
||||
<main id="main-content" class="site-main content-shell content-shell--stream content-shell--forum" tabindex="-1">
|
||||
<div class="content-wrap container">
|
||||
<div class="content-layout content-layout--no-sidebar">
|
||||
<div class="content-layout__primary">
|
||||
|
||||
<?php if (function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs(); } ?>
|
||||
|
||||
<div class="aksrt-forum-board"
|
||||
data-board-id="<?php echo esc_attr((string) $board_id); ?>"
|
||||
data-nonce="<?php echo esc_attr($nonce); ?>"
|
||||
data-active-sort="<?php echo esc_attr($active_sort); ?>">
|
||||
|
||||
<?php if ($top_info) : ?>
|
||||
<div class="aksrt-forum-board__header">
|
||||
<div class="aksrt-forum-board__info">
|
||||
<h1 class="aksrt-forum-board__title"><?php echo esc_html((string) ($board_data['name'] ?? ($board->name ?? ''))); ?></h1>
|
||||
<?php if (!empty($board_data['description'])) : ?>
|
||||
<p class="aksrt-forum-board__desc"><?php echo esc_html((string) $board_data['description']); ?></p>
|
||||
<?php endif; ?>
|
||||
<div class="aksrt-forum-board__meta">
|
||||
<span><i class="fas fa-list-alt"></i> <?php printf(esc_html__('%1$d 个%2$s', 'aksrt'), (int) ($board_data['topic_count'] ?? 0), esc_html($name_topic)); ?></span>
|
||||
<span><i class="fas fa-comments"></i> <?php printf(esc_html__('%d 条%s', 'aksrt'), (int) ($board_data['reply_count'] ?? 0), esc_html($name_reply)); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="aksrt-forum-board__actions">
|
||||
<?php if (!empty($permissions['can_compose'])) : ?>
|
||||
<a href="<?php echo esc_url($compose_url); ?>" class="aksrt-forum-board__compose-btn">
|
||||
<i class="fas fa-pen"></i> <?php esc_html_e('发布新主题', 'aksrt'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($sticky_topics)) : ?>
|
||||
<div class="aksrt-forum-board__sticky">
|
||||
<h3><i class="fas fa-thumbtack"></i> <?php esc_html_e('置顶主题', 'aksrt'); ?></h3>
|
||||
<?php foreach ($sticky_topics as $topic) : ?>
|
||||
<a href="<?php echo esc_url((string) ($topic['permalink'] ?? '#')); ?>" class="aksrt-forum-board__sticky-item">
|
||||
<span class="aksrt-forum-board__sticky-badge"><?php echo esc_html((string) ($topic['sticky_label'] ?? __('置顶', 'aksrt'))); ?></span>
|
||||
<span class="aksrt-forum-board__sticky-title"><?php echo esc_html((string) ($topic['title'] ?? '')); ?></span>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($tabs)) : ?>
|
||||
<nav class="aksrt-forum-board__tabs" aria-label="<?php esc_attr_e('版块栏目', 'aksrt'); ?>">
|
||||
<?php foreach ($tabs as $tab) :
|
||||
$sort = sanitize_key((string) ($tab['sort'] ?? 'date'));
|
||||
$label = (string) ($tab['label'] ?? $sort);
|
||||
$tab_url = add_query_arg('forum_sort', $sort, $board_url);
|
||||
$is_active = $sort === $active_sort;
|
||||
?>
|
||||
<a class="aksrt-forum-board__tab js-aksrt-board-sort-tab<?php echo $is_active ? ' is-active' : ''; ?>"
|
||||
href="<?php echo esc_url($tab_url); ?>"
|
||||
data-sort="<?php echo esc_attr($sort); ?>">
|
||||
<?php echo esc_html($label); ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="aksrt-forum-board__topics">
|
||||
<div class="aksrt-forum-topics__list js-aksrt-board-topic-list">
|
||||
<?php if (!empty($topics) && $forum) : ?>
|
||||
<?php foreach ($topics as $topic) { $forum->render_topic_row($topic); } ?>
|
||||
<?php else : ?>
|
||||
<div class="aksrt-forum-board__empty aksrt-forum__empty">
|
||||
<i class="fas fa-comments"></i>
|
||||
<p><?php esc_html_e('内容空空如也', 'aksrt'); ?></p>
|
||||
<?php if (!empty($permissions['can_compose'])) : ?>
|
||||
<a href="<?php echo esc_url($compose_url); ?>"><?php esc_html_e('发布第一个主题', 'aksrt'); ?></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if ($max_pages > 1) : ?>
|
||||
<div class="aksrt-forum-board__pagination">
|
||||
<?php
|
||||
echo paginate_links([
|
||||
'total' => $max_pages,
|
||||
'current' => $paged,
|
||||
'prev_text' => '<i class="fas fa-chevron-left"></i>',
|
||||
'next_text' => '<i class="fas fa-chevron-right"></i>',
|
||||
'add_args' => $active_sort !== '' ? ['forum_sort' => $active_sort] : [],
|
||||
]);
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php get_footer(); ?>
|
||||
@@ -1,463 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Template Name: 论坛发帖
|
||||
* Template Post Type: page
|
||||
*
|
||||
* §7.4 — wp_editor rich editor + sidebar panels + server-side draft + capability gates.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
get_header();
|
||||
|
||||
if (!is_user_logged_in()) {
|
||||
$login_url = function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(get_permalink());
|
||||
wp_safe_redirect($login_url);
|
||||
exit;
|
||||
}
|
||||
|
||||
$forum_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_forum_settings() : [];
|
||||
if (empty($forum_settings['enabled'])) {
|
||||
wp_safe_redirect(home_url('/'));
|
||||
exit;
|
||||
}
|
||||
|
||||
$forum = class_exists('\AKSRT\Forum\Forum') ? \AKSRT\Forum\Forum::get_instance() : null;
|
||||
$current_user_id = get_current_user_id();
|
||||
$board_id = isset($_GET['board']) ? (int) $_GET['board'] : 0;
|
||||
$draft_id = isset($_GET['draft']) ? (int) $_GET['draft'] : 0;
|
||||
|
||||
$view = $forum ? $forum->get_compose_view($current_user_id, ['board_id' => $board_id]) : [
|
||||
'boards' => [],
|
||||
'selected_board_id' => 0,
|
||||
'visibility_options' => [],
|
||||
'publish_mode' => 'pending',
|
||||
'draft_count' => 0,
|
||||
'drafts' => [],
|
||||
'capabilities' => [],
|
||||
];
|
||||
|
||||
$forum_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_forum_settings() : [];
|
||||
$title_placeholder = $forum_settings['other']['t_placeholder'] ?? __('请输入标题', 'aksrt');
|
||||
$content_placeholder = $forum_settings['other']['c_placeholder'] ?? __('请输入内容', 'aksrt');
|
||||
$title_maxlen = max(5, min(100, (int) ($forum_settings['other']['title_strlen_limit'] ?? 30)));
|
||||
$vote_max = (int) ($forum_settings['other']['vote_max'] ?? 8);
|
||||
$forum_name = $forum_settings['names']['forum'] ?? __('论坛', 'aksrt');
|
||||
|
||||
$boards = $view['boards'] ?? [];
|
||||
$visibility_options = $view['visibility_options'] ?? [];
|
||||
$publish_mode = (string) ($view['publish_mode'] ?? 'pending');
|
||||
$draft_count = (int) ($view['draft_count'] ?? 0);
|
||||
$drafts = $view['drafts'] ?? [];
|
||||
$caps = $view['capabilities'] ?? [];
|
||||
$nonce = wp_create_nonce('aksrt_forum_compose');
|
||||
|
||||
// Load draft data if resuming
|
||||
$draft_data = null;
|
||||
if ($draft_id > 0 && $forum) {
|
||||
$draft_data = $forum->load_draft_data($current_user_id, $draft_id);
|
||||
if ($draft_data) {
|
||||
$board_id = (int) ($draft_data['board_id'] ?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
$initial_content = $draft_data ? $draft_data['content'] : '';
|
||||
?>
|
||||
|
||||
<main id="main-content" class="site-main container" tabindex="-1">
|
||||
|
||||
<div class="aksrt-forum-compose container">
|
||||
<div class="aksrt-forum-compose__header">
|
||||
<div>
|
||||
<h1><i class="fas fa-pen-fancy"></i> <?php esc_html_e('发布新主题', 'aksrt'); ?></h1>
|
||||
<p class="aksrt-forum-compose__notice">
|
||||
<?php
|
||||
echo $publish_mode === 'publish'
|
||||
? esc_html__('你在当前版块具备直接发布权限。', 'aksrt')
|
||||
: esc_html__('普通用户发帖将进入审核流程,审核通过后才会公开展示。', 'aksrt');
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<a href="<?php echo esc_url(aksrt_get_forum_home_url()); ?>" class="aksrt-forum-compose__back">
|
||||
<i class="fas fa-arrow-left"></i> <?php printf(esc_html__('返回%s', 'aksrt'), esc_html($forum_name)); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?php if ($draft_count > 0) : ?>
|
||||
<div class="aksrt-forum-compose__draft-notice">
|
||||
<i class="fas fa-file-alt"></i>
|
||||
<?php printf(
|
||||
esc_html__('您有 %d 篇草稿。', 'aksrt'),
|
||||
$draft_count
|
||||
); ?>
|
||||
<button type="button" class="aksrt-forum-compose__draft-toggle js-aksrt-draft-toggle">
|
||||
<?php esc_html_e('查看草稿', 'aksrt'); ?>
|
||||
<i class="fas fa-chevron-down"></i>
|
||||
</button>
|
||||
<div class="aksrt-forum-compose__draft-list" id="compose-draft-list" hidden>
|
||||
<?php foreach ($drafts as $d) : ?>
|
||||
<div class="aksrt-forum-compose__draft-item" data-draft-id="<?php echo esc_attr((string) $d['id']); ?>">
|
||||
<a href="<?php echo esc_url(add_query_arg('draft', $d['id'], get_permalink())); ?>" class="aksrt-forum-compose__draft-title">
|
||||
<?php echo esc_html($d['title']); ?>
|
||||
</a>
|
||||
<span class="aksrt-forum-compose__draft-meta">
|
||||
<?php echo esc_html($d['board_name'] ?: __('未选版块', 'aksrt')); ?> ·
|
||||
<?php echo esc_html(human_time_diff(strtotime($d['date']), current_time('timestamp'))); ?><?php esc_html_e('前', 'aksrt'); ?>
|
||||
</span>
|
||||
<button type="button" class="aksrt-forum-compose__draft-delete js-aksrt-delete-draft" data-draft-id="<?php echo esc_attr((string) $d['id']); ?>" title="<?php esc_attr_e('删除草稿', 'aksrt'); ?>">
|
||||
<i class="fas fa-trash-alt"></i>
|
||||
</button>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form
|
||||
id="aksrt-forum-compose-form"
|
||||
class="aksrt-forum-compose__form aksrt-forum-compose__layout js-aksrt-forum-compose-form"
|
||||
data-ajax="<?php echo esc_url(admin_url('admin-ajax.php')); ?>"
|
||||
data-nonce="<?php echo esc_attr($nonce); ?>"
|
||||
data-publish-mode="<?php echo esc_attr($publish_mode); ?>"
|
||||
data-vote-max="<?php echo esc_attr((string) $vote_max); ?>"
|
||||
data-draft-id="<?php echo esc_attr((string) ($draft_data['draft_id'] ?? 0)); ?>"
|
||||
>
|
||||
<!-- ═══ Main content area ═══ -->
|
||||
<div class="aksrt-forum-compose__main">
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<label for="compose-title"><?php esc_html_e('主题标题', 'aksrt'); ?> <span class="required">*</span></label>
|
||||
<input type="text" id="compose-title" name="title" required
|
||||
maxlength="<?php echo esc_attr((string) $title_maxlen); ?>"
|
||||
placeholder="<?php echo esc_attr($title_placeholder); ?>"
|
||||
value="<?php echo esc_attr($draft_data['title'] ?? ''); ?>"
|
||||
data-aksrt-maxlength="<?php echo esc_attr((string) $title_maxlen); ?>">
|
||||
<span class="aksrt-forum-compose__char-counter" id="compose-title-counter">
|
||||
<span class="js-aksrt-counter-current"><?php echo esc_html((string) mb_strlen($draft_data['title'] ?? '')); ?></span> / <?php echo esc_html((string) $title_maxlen); ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__field aksrt-forum-compose__editor-wrap">
|
||||
<label><?php esc_html_e('主题内容', 'aksrt'); ?> <span class="required">*</span></label>
|
||||
<?php
|
||||
$editor_settings = [
|
||||
'textarea_name' => 'content',
|
||||
'textarea_rows' => 18,
|
||||
'media_buttons' => !empty($caps['can_upload_image']) || !empty($caps['can_upload_video']) || !empty($caps['can_upload_file']),
|
||||
'teeny' => false,
|
||||
'quicktags' => true,
|
||||
'tinymce' => [
|
||||
'toolbar1' => 'formatselect,bold,italic,underline,strikethrough,blockquote,bullist,numlist,alignleft,aligncenter,alignright,link,unlink,wp_more,fullscreen',
|
||||
'toolbar2' => 'pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help',
|
||||
'plugins' => 'paste,link,lists,fullscreen,wordpress,wplink,charmap',
|
||||
],
|
||||
];
|
||||
|
||||
if (empty($caps['can_upload_image']) && empty($caps['can_upload_video']) && empty($caps['can_upload_file'])) {
|
||||
$editor_settings['tinymce']['toolbar1'] = str_replace(',wp_more', '', $editor_settings['tinymce']['toolbar1']);
|
||||
}
|
||||
|
||||
wp_editor($initial_content, 'compose-content', $editor_settings);
|
||||
?>
|
||||
<?php if (!empty($caps['can_set_hide']) || !empty($caps['can_set_paid'])) : ?>
|
||||
<div class="aksrt-forum-compose__shortcode-tools">
|
||||
<?php if (!empty($caps['can_set_hide'])) : ?>
|
||||
<button type="button" class="but" data-insert-shortcode="hide"><i class="fas fa-eye-slash"></i> <?php esc_html_e('登录可见', 'aksrt'); ?></button>
|
||||
<button type="button" class="but" data-insert-shortcode="reply"><i class="fas fa-comment-dots"></i> <?php esc_html_e('回复可见', 'aksrt'); ?></button>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($caps['can_set_paid'])) : ?>
|
||||
<button type="button" class="but" data-insert-shortcode="payshow"><i class="fas fa-lock"></i> <?php esc_html_e('付费可见', 'aksrt'); ?></button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ═══ Sidebar panels ═══ -->
|
||||
<div class="aksrt-forum-compose__sidebar">
|
||||
|
||||
<!-- Panel: Submit / Status -->
|
||||
<div class="aksrt-forum-compose__panel">
|
||||
<h3 class="aksrt-forum-compose__panel-title"><i class="fas fa-paper-plane"></i> <?php esc_html_e('发布', 'aksrt'); ?></h3>
|
||||
<div class="aksrt-forum-compose__panel-body">
|
||||
<p class="aksrt-forum-compose__status-line">
|
||||
<i class="fas fa-info-circle"></i>
|
||||
<span id="compose-status-text">
|
||||
<?php echo $publish_mode === 'publish'
|
||||
? esc_html__('状态:直接发布', 'aksrt')
|
||||
: esc_html__('状态:待审核', 'aksrt'); ?>
|
||||
</span>
|
||||
</p>
|
||||
<div class="aksrt-forum-compose__actions">
|
||||
<button type="submit" class="aksrt-forum-compose__submit" id="compose-submit">
|
||||
<i class="fas fa-paper-plane"></i> <?php esc_html_e('提交主题', 'aksrt'); ?>
|
||||
</button>
|
||||
<button type="button" class="aksrt-forum-compose__draft" id="compose-draft">
|
||||
<i class="fas fa-save"></i> <?php esc_html_e('保存草稿', 'aksrt'); ?>
|
||||
</button>
|
||||
</div>
|
||||
<span class="aksrt-forum-compose__feedback js-aksrt-action-feedback" aria-live="polite"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Panel: Board selector -->
|
||||
<div class="aksrt-forum-compose__panel">
|
||||
<h3 class="aksrt-forum-compose__panel-title"><i class="fas fa-th-large"></i> <?php esc_html_e('版块', 'aksrt'); ?></h3>
|
||||
<div class="aksrt-forum-compose__panel-body">
|
||||
<div class="aksrt-forum-compose__field aksrt-remote-select" data-search-action="aksrt_forum_search_boards">
|
||||
<input type="hidden" id="compose-board" name="board_id" value="<?php echo esc_attr((string) $board_id); ?>">
|
||||
<input type="text" class="aksrt-remote-select__input js-aksrt-remote-input"
|
||||
placeholder="<?php esc_attr_e('搜索版块…', 'aksrt'); ?>"
|
||||
autocomplete="off"
|
||||
value="<?php
|
||||
if ($board_id > 0) {
|
||||
foreach ($boards as $b) {
|
||||
if (((int) ($b['id'] ?? 0)) === $board_id) {
|
||||
echo esc_attr((string) ($b['name'] ?? ''));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>">
|
||||
<div class="aksrt-remote-select__dropdown" hidden></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Panel: Post type -->
|
||||
<div class="aksrt-forum-compose__panel">
|
||||
<h3 class="aksrt-forum-compose__panel-title"><i class="fas fa-tag"></i> <?php esc_html_e('类型 & 分类', 'aksrt'); ?></h3>
|
||||
<div class="aksrt-forum-compose__panel-body">
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<label for="compose-bbs-type"><?php esc_html_e('帖子类型', 'aksrt'); ?></label>
|
||||
<select id="compose-bbs-type" name="bbs_type">
|
||||
<option value="standard" <?php selected($draft_data['bbs_type'] ?? '', 'standard'); ?>><?php esc_html_e('标准帖子', 'aksrt'); ?></option>
|
||||
<option value="question" <?php selected($draft_data['bbs_type'] ?? '', 'question'); ?>><?php esc_html_e('提问', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<label for="compose-special"><?php esc_html_e('专题/系列', 'aksrt'); ?></label>
|
||||
<input type="text" id="compose-special" name="special_topic" maxlength="80"
|
||||
placeholder="<?php esc_attr_e('例如:站点重构周报', 'aksrt'); ?>"
|
||||
value="<?php echo esc_attr($draft_data['special_topic'] ?? ''); ?>">
|
||||
</div>
|
||||
|
||||
<?php if (taxonomy_exists('aksrt_forum_topic_cat')) : ?>
|
||||
<div class="aksrt-forum-compose__field aksrt-remote-select" data-search-action="aksrt_forum_search_topics">
|
||||
<label><?php esc_html_e('话题', 'aksrt'); ?></label>
|
||||
<input type="hidden" name="topic_cat" value="<?php echo esc_attr($draft_data['topic_cat'] ?? ''); ?>">
|
||||
<input type="text" class="aksrt-remote-select__input js-aksrt-remote-input"
|
||||
placeholder="<?php esc_attr_e('搜索话题…', 'aksrt'); ?>"
|
||||
autocomplete="off"
|
||||
value="<?php echo esc_attr($draft_data['topic_cat'] ?? ''); ?>">
|
||||
<div class="aksrt-remote-select__dropdown" hidden></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Panel: Tags -->
|
||||
<div class="aksrt-forum-compose__panel">
|
||||
<h3 class="aksrt-forum-compose__panel-title"><i class="fas fa-tags"></i> <?php esc_html_e('标签', 'aksrt'); ?></h3>
|
||||
<div class="aksrt-forum-compose__panel-body">
|
||||
<div class="aksrt-forum-compose__field aksrt-tag-input" data-search-action="aksrt_forum_search_tags" data-max="5">
|
||||
<input type="hidden" id="compose-tags" name="tags" value="<?php echo esc_attr($draft_data['tags'] ?? ''); ?>">
|
||||
<div class="aksrt-tag-input__tokens" id="compose-tag-tokens"></div>
|
||||
<input type="text" class="aksrt-tag-input__input js-aksrt-tag-search"
|
||||
placeholder="<?php esc_attr_e('输入标签名,回车添加', 'aksrt'); ?>"
|
||||
autocomplete="off" maxlength="30">
|
||||
<div class="aksrt-tag-input__dropdown" hidden></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Panel: Visibility -->
|
||||
<div class="aksrt-forum-compose__panel">
|
||||
<h3 class="aksrt-forum-compose__panel-title"><i class="fas fa-eye"></i> <?php esc_html_e('可见性', 'aksrt'); ?></h3>
|
||||
<div class="aksrt-forum-compose__panel-body">
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<select id="compose-visibility" name="visibility">
|
||||
<?php foreach ($visibility_options as $option) : ?>
|
||||
<option value="<?php echo esc_attr((string) ($option['value'] ?? '')); ?>"
|
||||
<?php selected($draft_data['visibility'] ?? 'public', $option['value'] ?? ''); ?>>
|
||||
<?php echo esc_html((string) ($option['label'] ?? '')); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__visibility-extra" id="compose-credits-cost-field" style="display:none;">
|
||||
<label for="compose-credits-cost"><?php esc_html_e('积分价格', 'aksrt'); ?></label>
|
||||
<input type="number" id="compose-credits-cost" name="credits_cost" min="1" max="99999"
|
||||
value="<?php echo esc_attr((string) ($draft_data['credits_cost'] ?? '')); ?>"
|
||||
placeholder="<?php esc_attr_e('查看需要的积分数', 'aksrt'); ?>">
|
||||
<label for="compose-credits-vip1" class="mt10"><?php esc_html_e('VIP1 积分价', 'aksrt'); ?></label>
|
||||
<input type="number" id="compose-credits-vip1" name="credits_vip1" min="0" max="99999"
|
||||
value="<?php echo esc_attr((string) ($draft_data['credits_vip1'] ?? '')); ?>"
|
||||
placeholder="<?php esc_attr_e('留空=不设', 'aksrt'); ?>">
|
||||
<label for="compose-credits-vip2" class="mt10"><?php esc_html_e('VIP2 积分价', 'aksrt'); ?></label>
|
||||
<input type="number" id="compose-credits-vip2" name="credits_vip2" min="0" max="99999"
|
||||
value="<?php echo esc_attr((string) ($draft_data['credits_vip2'] ?? '')); ?>"
|
||||
placeholder="<?php esc_attr_e('留空=不设;0=免费', 'aksrt'); ?>">
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__visibility-extra" id="compose-pay-price-field" style="display:none;">
|
||||
<label for="compose-pay-price"><?php esc_html_e('付费价格(¥)', 'aksrt'); ?></label>
|
||||
<input type="number" id="compose-pay-price" name="pay_price" min="0.01" step="0.01" max="99999"
|
||||
value="<?php echo esc_attr((string) ($draft_data['pay_price'] ?? '')); ?>"
|
||||
placeholder="<?php esc_attr_e('查看需要的金额', 'aksrt'); ?>">
|
||||
<label for="compose-pay-vip1" class="mt10"><?php esc_html_e('VIP1 价格(¥)', 'aksrt'); ?></label>
|
||||
<input type="number" id="compose-pay-vip1" name="pay_vip1_price" min="0" step="0.01" max="99999"
|
||||
value="<?php echo esc_attr((string) ($draft_data['pay_vip1_price'] ?? '')); ?>"
|
||||
placeholder="<?php esc_attr_e('留空=不设', 'aksrt'); ?>">
|
||||
<label for="compose-pay-vip2" class="mt10"><?php esc_html_e('VIP2 价格(¥)', 'aksrt'); ?></label>
|
||||
<input type="number" id="compose-pay-vip2" name="pay_vip2_price" min="0" step="0.01" max="99999"
|
||||
value="<?php echo esc_attr((string) ($draft_data['pay_vip2_price'] ?? '')); ?>"
|
||||
placeholder="<?php esc_attr_e('留空=不设;0=免费', 'aksrt'); ?>">
|
||||
<label class="aksrt-forum-compose__checkbox mt10">
|
||||
<input type="checkbox" name="pay_hide_part" value="1" <?php checked(!empty($draft_data['pay_hide_part'])); ?>>
|
||||
<span><?php esc_html_e('仅隐藏部分内容(正文用 [payshow] 包裹)', 'aksrt'); ?></span>
|
||||
</label>
|
||||
<label class="aksrt-forum-compose__checkbox mt6">
|
||||
<input type="checkbox" name="topic_coupon_s" value="1" <?php checked(!empty($draft_data['topic_coupon_s'])); ?>>
|
||||
<span><?php esc_html_e('允许优惠码', 'aksrt'); ?></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__visibility-extra" id="compose-role-field" style="display:none;">
|
||||
<label for="compose-visibility-roles"><?php esc_html_e('允许的角色', 'aksrt'); ?></label>
|
||||
<?php $selected_roles = $draft_data['visibility_roles'] ?? []; ?>
|
||||
<select id="compose-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 echo in_array($role_slug, $selected_roles, true) ? 'selected' : ''; ?>>
|
||||
<?php echo esc_html(translate_user_role($role_name)); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Panel: Cover -->
|
||||
<?php if (!empty($caps['can_set_cover'])) : ?>
|
||||
<div class="aksrt-forum-compose__panel">
|
||||
<h3 class="aksrt-forum-compose__panel-title"><i class="fas fa-image"></i> <?php esc_html_e('封面', 'aksrt'); ?></h3>
|
||||
<div class="aksrt-forum-compose__panel-body">
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<select id="compose-cover-type" name="cover_type">
|
||||
<option value="" <?php selected($draft_data['cover_type'] ?? '', ''); ?>><?php esc_html_e('无封面', 'aksrt'); ?></option>
|
||||
<?php if (!empty($caps['can_set_cover_image'])) : ?>
|
||||
<option value="image" <?php selected($draft_data['cover_type'] ?? '', 'image'); ?>><?php esc_html_e('图片封面', 'aksrt'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($caps['can_set_cover_slide'])) : ?>
|
||||
<option value="slide" <?php selected($draft_data['cover_type'] ?? '', 'slide'); ?>><?php esc_html_e('幻灯片封面', 'aksrt'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($caps['can_set_cover_video'])) : ?>
|
||||
<option value="video" <?php selected($draft_data['cover_type'] ?? '', 'video'); ?>><?php esc_html_e('视频封面', 'aksrt'); ?></option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__cover-upload" id="compose-cover-image-field" style="display:none;">
|
||||
<input type="hidden" name="cover_image" id="compose-cover-image" value="<?php echo esc_attr($draft_data['cover_image'] ?? ''); ?>">
|
||||
<div class="aksrt-forum-compose__cover-preview" id="compose-cover-preview">
|
||||
<?php if (!empty($draft_data['cover_image'])) : ?>
|
||||
<img src="<?php echo esc_url($draft_data['cover_image']); ?>" alt="">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<button type="button" class="aksrt-forum-compose__cover-btn" id="compose-cover-upload-btn"><?php esc_html_e('选择图片', 'aksrt'); ?></button>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__cover-upload" id="compose-cover-slide-field" style="display:none;">
|
||||
<input type="hidden" name="featured_slide" id="compose-featured-slide"
|
||||
value="<?php echo esc_attr(!empty($draft_data['featured_slide']) ? wp_json_encode($draft_data['featured_slide']) : ''); ?>">
|
||||
<div class="aksrt-forum-compose__cover-preview" id="compose-slide-preview">
|
||||
<?php if (!empty($draft_data['featured_slide'])) : foreach ($draft_data['featured_slide'] as $su) : ?>
|
||||
<img src="<?php echo esc_url($su); ?>" alt="">
|
||||
<?php endforeach; endif; ?>
|
||||
</div>
|
||||
<button type="button" class="aksrt-forum-compose__cover-btn" id="compose-slide-upload-btn"><?php esc_html_e('选择图片', 'aksrt'); ?></button>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__cover-upload" id="compose-cover-video-field" style="display:none;">
|
||||
<input type="url" name="featured_video" id="compose-featured-video"
|
||||
value="<?php echo esc_attr($draft_data['featured_video'] ?? ''); ?>"
|
||||
placeholder="<?php esc_attr_e('https://...mp4', 'aksrt'); ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Panel: Vote -->
|
||||
<div class="aksrt-forum-compose__panel">
|
||||
<h3 class="aksrt-forum-compose__panel-title">
|
||||
<label class="aksrt-forum-compose__checkbox">
|
||||
<input type="checkbox" id="compose-vote-enabled" name="vote_enabled" value="1"
|
||||
<?php checked(!empty($draft_data['vote_enabled'])); ?>>
|
||||
<span><i class="fas fa-poll"></i> <?php esc_html_e('投票', 'aksrt'); ?></span>
|
||||
</label>
|
||||
</h3>
|
||||
<div class="aksrt-forum-compose__panel-body aksrt-forum-compose__vote-fields" <?php echo empty($draft_data['vote_enabled']) ? 'hidden' : ''; ?>>
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<label for="compose-vote-title"><?php esc_html_e('投票标题', 'aksrt'); ?></label>
|
||||
<input type="text" id="compose-vote-title" name="vote_title" maxlength="120"
|
||||
value="<?php echo esc_attr($draft_data['vote_title'] ?? ''); ?>"
|
||||
placeholder="<?php esc_attr_e('你更希望改造哪个模块?', 'aksrt'); ?>">
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<label class="aksrt-forum-compose__checkbox">
|
||||
<input type="checkbox" id="compose-vote-multiple" name="vote_multiple" value="1"
|
||||
<?php checked(!empty($draft_data['vote_multiple'])); ?>>
|
||||
<span><?php esc_html_e('允许多选', 'aksrt'); ?></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<label for="compose-vote-type"><?php esc_html_e('投票类型', 'aksrt'); ?></label>
|
||||
<select id="compose-vote-type" name="vote_type">
|
||||
<option value="standard" <?php selected($draft_data['vote_type'] ?? '', 'standard'); ?>><?php esc_html_e('标准投票', 'aksrt'); ?></option>
|
||||
<option value="pk" <?php selected($draft_data['vote_type'] ?? '', 'pk'); ?>><?php esc_html_e('PK 双选', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<label for="compose-vote-expiry"><?php esc_html_e('投票有效期', 'aksrt'); ?></label>
|
||||
<select id="compose-vote-expiry" name="vote_expiry_days">
|
||||
<option value="0" <?php selected((int) ($draft_data['vote_expiry_days'] ?? 0), 0); ?>><?php esc_html_e('永久', 'aksrt'); ?></option>
|
||||
<option value="1" <?php selected((int) ($draft_data['vote_expiry_days'] ?? 0), 1); ?>><?php esc_html_e('1 天', 'aksrt'); ?></option>
|
||||
<option value="7" <?php selected((int) ($draft_data['vote_expiry_days'] ?? 0), 7); ?>><?php esc_html_e('7 天', 'aksrt'); ?></option>
|
||||
<option value="30" <?php selected((int) ($draft_data['vote_expiry_days'] ?? 0), 30); ?>><?php esc_html_e('30 天', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<label for="compose-vote-options"><?php printf(esc_html__('选项(最多 %d 项)', 'aksrt'), (int) $vote_max); ?></label>
|
||||
<textarea id="compose-vote-options" name="vote_options" rows="4"
|
||||
placeholder="<?php esc_attr_e("每行一个选项", 'aksrt'); ?>"><?php echo esc_textarea($draft_data['vote_options'] ?? ''); ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (is_active_sidebar('bbs_new_posts_sidebar_top') || is_active_sidebar('bbs_new_posts_sidebar_bottom')) : ?>
|
||||
<div class="aksrt-forum-widget-zone">
|
||||
<?php
|
||||
if (is_active_sidebar('bbs_new_posts_sidebar_top')) {
|
||||
dynamic_sidebar('bbs_new_posts_sidebar_top');
|
||||
}
|
||||
if (is_active_sidebar('bbs_new_posts_sidebar_bottom')) {
|
||||
dynamic_sidebar('bbs_new_posts_sidebar_bottom');
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div><!-- /.aksrt-forum-compose__sidebar -->
|
||||
</form>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php get_footer(); ?>
|
||||
@@ -1,362 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* 论坛帖子编辑模板
|
||||
*
|
||||
* §7.4 — Full-field AJAX editing with wp_editor, matching compose capabilities.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if (!is_user_logged_in()) {
|
||||
wp_safe_redirect(wp_login_url(get_permalink()));
|
||||
exit;
|
||||
}
|
||||
|
||||
$topic_id = get_the_ID();
|
||||
$user_id = get_current_user_id();
|
||||
$forum = class_exists('\AKSRT\Forum\Forum') ? \AKSRT\Forum\Forum::get_instance() : null;
|
||||
|
||||
if (!$forum || !$forum->can_edit_topic($user_id, $topic_id)) {
|
||||
wp_safe_redirect(get_permalink($topic_id));
|
||||
exit;
|
||||
}
|
||||
|
||||
$topic = get_post($topic_id);
|
||||
|
||||
// Board
|
||||
$board_id = 0;
|
||||
$board_name = '';
|
||||
if ($forum->is_plate_cpt_active()) {
|
||||
$board_id = (int) get_post_meta($topic_id, '_aksrt_plate_id', true);
|
||||
if ($board_id > 0) {
|
||||
$board_name = get_the_title($board_id);
|
||||
}
|
||||
} else {
|
||||
$terms = wp_get_post_terms($topic_id, 'aksrt_forum_board', ['fields' => 'all']);
|
||||
if (!is_wp_error($terms) && !empty($terms)) {
|
||||
$board_id = (int) $terms[0]->term_id;
|
||||
$board_name = (string) $terms[0]->name;
|
||||
}
|
||||
}
|
||||
|
||||
// Tags
|
||||
$tags = wp_get_post_terms($topic_id, 'aksrt_forum_tag', ['fields' => 'names']);
|
||||
$tag_str = !is_wp_error($tags) && !empty($tags) ? implode(', ', $tags) : '';
|
||||
|
||||
// Topic category
|
||||
$topic_cat = '';
|
||||
if (taxonomy_exists('aksrt_forum_topic_cat')) {
|
||||
$cats = wp_get_post_terms($topic_id, 'aksrt_forum_topic_cat', ['fields' => 'names']);
|
||||
if (!is_wp_error($cats) && !empty($cats)) {
|
||||
$topic_cat = $cats[0];
|
||||
}
|
||||
}
|
||||
|
||||
// Post meta
|
||||
$visibility = get_post_meta($topic_id, '_aksrt_visibility', true) ?: 'public';
|
||||
$bbs_type = get_post_meta($topic_id, '_aksrt_bbs_type', true) ?: 'standard';
|
||||
$special_topic = get_post_meta($topic_id, '_aksrt_special_topic', true) ?: '';
|
||||
$cover_type = get_post_meta($topic_id, '_aksrt_cover_type', true) ?: '';
|
||||
$cover_image = get_post_meta($topic_id, '_aksrt_cover_image', true) ?: '';
|
||||
$featured_slide = get_post_meta($topic_id, '_aksrt_featured_slide', true) ?: [];
|
||||
$featured_video = get_post_meta($topic_id, '_aksrt_featured_video', true) ?: '';
|
||||
$credits_cost = (int) get_post_meta($topic_id, '_aksrt_credits_cost', true);
|
||||
$pay_price = get_post_meta($topic_id, '_aksrt_pay_price', true) ?: '';
|
||||
$visibility_roles = get_post_meta($topic_id, '_aksrt_visibility_roles', true) ?: [];
|
||||
$vote_enabled = get_post_meta($topic_id, '_aksrt_vote_enabled', true) === '1';
|
||||
$vote_title = get_post_meta($topic_id, '_aksrt_vote_title', true) ?: '';
|
||||
$vote_multiple = get_post_meta($topic_id, '_aksrt_vote_multiple', true) === '1';
|
||||
$vote_type = get_post_meta($topic_id, '_aksrt_vote_type', true) ?: 'standard';
|
||||
$vote_expiry_days = (int) get_post_meta($topic_id, '_aksrt_vote_expiry_days', true);
|
||||
$vote_options_raw = get_post_meta($topic_id, '_aksrt_vote_options', true) ?: [];
|
||||
$vote_options_text = is_array($vote_options_raw) ? implode("\n", array_column($vote_options_raw, 'label')) : '';
|
||||
|
||||
// Settings & capabilities
|
||||
$forum_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_forum_settings() : [];
|
||||
$title_maxlen = max(5, min(100, (int) ($forum_settings['other']['title_strlen_limit'] ?? 30)));
|
||||
$vote_max = (int) ($forum_settings['other']['vote_max'] ?? 8);
|
||||
$caps = $forum->get_compose_capabilities($user_id);
|
||||
$visibility_options = $forum->get_visibility_options();
|
||||
$nonce = wp_create_nonce('aksrt_forum_compose');
|
||||
|
||||
get_header();
|
||||
?>
|
||||
|
||||
<main id="main-content" class="site-main container" tabindex="-1">
|
||||
|
||||
<div class="aksrt-forum-compose container">
|
||||
<div class="aksrt-forum-compose__header">
|
||||
<div>
|
||||
<h1><i class="fas fa-edit"></i> <?php esc_html_e('编辑帖子', 'aksrt'); ?></h1>
|
||||
</div>
|
||||
<a href="<?php echo esc_url(get_permalink($topic_id)); ?>" class="aksrt-forum-compose__back">
|
||||
<i class="fas fa-arrow-left"></i> <?php esc_html_e('返回帖子', 'aksrt'); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<form
|
||||
id="aksrt-forum-compose-form"
|
||||
class="aksrt-forum-compose__form aksrt-forum-compose__layout js-aksrt-forum-edit-form"
|
||||
data-ajax="<?php echo esc_url(admin_url('admin-ajax.php')); ?>"
|
||||
data-nonce="<?php echo esc_attr($nonce); ?>"
|
||||
data-topic-id="<?php echo esc_attr((string) $topic_id); ?>"
|
||||
data-vote-max="<?php echo esc_attr((string) $vote_max); ?>"
|
||||
>
|
||||
<!-- ═══ Main content area ═══ -->
|
||||
<div class="aksrt-forum-compose__main">
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<label for="compose-title"><?php esc_html_e('主题标题', 'aksrt'); ?> <span class="required">*</span></label>
|
||||
<input type="text" id="compose-title" name="title" required
|
||||
maxlength="<?php echo esc_attr((string) $title_maxlen); ?>"
|
||||
value="<?php echo esc_attr($topic->post_title); ?>"
|
||||
data-aksrt-maxlength="<?php echo esc_attr((string) $title_maxlen); ?>">
|
||||
<span class="aksrt-forum-compose__char-counter" id="compose-title-counter">
|
||||
<span class="js-aksrt-counter-current"><?php echo esc_html((string) mb_strlen($topic->post_title)); ?></span> / <?php echo esc_html((string) $title_maxlen); ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__field aksrt-forum-compose__editor-wrap">
|
||||
<label><?php esc_html_e('主题内容', 'aksrt'); ?> <span class="required">*</span></label>
|
||||
<?php
|
||||
wp_editor($topic->post_content, 'compose-content', [
|
||||
'textarea_name' => 'content',
|
||||
'textarea_rows' => 18,
|
||||
'media_buttons' => !empty($caps['can_upload_image']) || !empty($caps['can_upload_video']) || !empty($caps['can_upload_file']),
|
||||
'teeny' => false,
|
||||
'quicktags' => true,
|
||||
'tinymce' => [
|
||||
'toolbar1' => 'formatselect,bold,italic,underline,strikethrough,blockquote,bullist,numlist,alignleft,aligncenter,alignright,link,unlink,wp_more,fullscreen',
|
||||
'toolbar2' => 'pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help',
|
||||
'plugins' => 'paste,link,lists,fullscreen,wordpress,wplink,charmap',
|
||||
],
|
||||
]);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ═══ Sidebar panels ═══ -->
|
||||
<div class="aksrt-forum-compose__sidebar">
|
||||
|
||||
<!-- Panel: Submit -->
|
||||
<div class="aksrt-forum-compose__panel">
|
||||
<h3 class="aksrt-forum-compose__panel-title"><i class="fas fa-save"></i> <?php esc_html_e('保存', 'aksrt'); ?></h3>
|
||||
<div class="aksrt-forum-compose__panel-body">
|
||||
<div class="aksrt-forum-compose__actions">
|
||||
<button type="submit" class="aksrt-forum-compose__submit" id="compose-submit">
|
||||
<i class="fas fa-save"></i> <?php esc_html_e('保存修改', 'aksrt'); ?>
|
||||
</button>
|
||||
<a href="<?php echo esc_url(get_permalink($topic_id)); ?>" class="aksrt-forum-compose__draft">
|
||||
<?php esc_html_e('取消', 'aksrt'); ?>
|
||||
</a>
|
||||
</div>
|
||||
<span class="aksrt-forum-compose__feedback js-aksrt-action-feedback" aria-live="polite"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Panel: Board (read-only in edit mode) -->
|
||||
<div class="aksrt-forum-compose__panel">
|
||||
<h3 class="aksrt-forum-compose__panel-title"><i class="fas fa-th-large"></i> <?php esc_html_e('版块', 'aksrt'); ?></h3>
|
||||
<div class="aksrt-forum-compose__panel-body">
|
||||
<p class="aksrt-forum-compose__readonly"><?php echo esc_html($board_name ?: __('未分配', 'aksrt')); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Panel: Type & Classification -->
|
||||
<div class="aksrt-forum-compose__panel">
|
||||
<h3 class="aksrt-forum-compose__panel-title"><i class="fas fa-tag"></i> <?php esc_html_e('类型 & 分类', 'aksrt'); ?></h3>
|
||||
<div class="aksrt-forum-compose__panel-body">
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<label for="compose-bbs-type"><?php esc_html_e('帖子类型', 'aksrt'); ?></label>
|
||||
<select id="compose-bbs-type" name="bbs_type">
|
||||
<option value="standard" <?php selected($bbs_type, 'standard'); ?>><?php esc_html_e('标准帖子', 'aksrt'); ?></option>
|
||||
<option value="question" <?php selected($bbs_type, 'question'); ?>><?php esc_html_e('提问', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<label for="compose-special"><?php esc_html_e('专题/系列', 'aksrt'); ?></label>
|
||||
<input type="text" id="compose-special" name="special_topic" maxlength="80"
|
||||
value="<?php echo esc_attr($special_topic); ?>">
|
||||
</div>
|
||||
|
||||
<?php if (taxonomy_exists('aksrt_forum_topic_cat')) : ?>
|
||||
<div class="aksrt-forum-compose__field aksrt-remote-select" data-search-action="aksrt_forum_search_topics">
|
||||
<label><?php esc_html_e('话题', 'aksrt'); ?></label>
|
||||
<input type="hidden" name="topic_cat" value="<?php echo esc_attr($topic_cat); ?>">
|
||||
<input type="text" class="aksrt-remote-select__input js-aksrt-remote-input"
|
||||
placeholder="<?php esc_attr_e('搜索话题…', 'aksrt'); ?>"
|
||||
autocomplete="off"
|
||||
value="<?php echo esc_attr($topic_cat); ?>">
|
||||
<div class="aksrt-remote-select__dropdown" hidden></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Panel: Tags -->
|
||||
<div class="aksrt-forum-compose__panel">
|
||||
<h3 class="aksrt-forum-compose__panel-title"><i class="fas fa-tags"></i> <?php esc_html_e('标签', 'aksrt'); ?></h3>
|
||||
<div class="aksrt-forum-compose__panel-body">
|
||||
<div class="aksrt-forum-compose__field aksrt-tag-input" data-search-action="aksrt_forum_search_tags" data-max="5">
|
||||
<input type="hidden" id="compose-tags" name="tags" value="<?php echo esc_attr($tag_str); ?>">
|
||||
<div class="aksrt-tag-input__tokens" id="compose-tag-tokens"></div>
|
||||
<input type="text" class="aksrt-tag-input__input js-aksrt-tag-search"
|
||||
placeholder="<?php esc_attr_e('输入标签名,回车添加', 'aksrt'); ?>"
|
||||
autocomplete="off" maxlength="30">
|
||||
<div class="aksrt-tag-input__dropdown" hidden></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Panel: Visibility -->
|
||||
<?php if (!empty($caps['can_set_visibility'])) : ?>
|
||||
<div class="aksrt-forum-compose__panel">
|
||||
<h3 class="aksrt-forum-compose__panel-title"><i class="fas fa-eye"></i> <?php esc_html_e('可见性', 'aksrt'); ?></h3>
|
||||
<div class="aksrt-forum-compose__panel-body">
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<select id="compose-visibility" name="visibility">
|
||||
<?php foreach ($visibility_options as $option) : ?>
|
||||
<option value="<?php echo esc_attr((string) ($option['value'] ?? '')); ?>"
|
||||
<?php selected($visibility, $option['value'] ?? ''); ?>>
|
||||
<?php echo esc_html((string) ($option['label'] ?? '')); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__visibility-extra" id="compose-credits-cost-field" style="display:none;">
|
||||
<label for="compose-credits-cost"><?php esc_html_e('积分价格', 'aksrt'); ?></label>
|
||||
<input type="number" id="compose-credits-cost" name="credits_cost" min="1" max="99999"
|
||||
value="<?php echo esc_attr((string) $credits_cost); ?>">
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__visibility-extra" id="compose-pay-price-field" style="display:none;">
|
||||
<label for="compose-pay-price"><?php esc_html_e('付费价格(¥)', 'aksrt'); ?></label>
|
||||
<input type="number" id="compose-pay-price" name="pay_price" min="0.01" step="0.01" max="99999"
|
||||
value="<?php echo esc_attr($pay_price); ?>">
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__visibility-extra" id="compose-role-field" style="display:none;">
|
||||
<label for="compose-visibility-roles"><?php esc_html_e('允许的角色', 'aksrt'); ?></label>
|
||||
<select id="compose-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 echo in_array($role_slug, $visibility_roles, true) ? 'selected' : ''; ?>>
|
||||
<?php echo esc_html(translate_user_role($role_name)); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Panel: Cover -->
|
||||
<?php if (!empty($caps['can_set_cover'])) : ?>
|
||||
<div class="aksrt-forum-compose__panel">
|
||||
<h3 class="aksrt-forum-compose__panel-title"><i class="fas fa-image"></i> <?php esc_html_e('封面', 'aksrt'); ?></h3>
|
||||
<div class="aksrt-forum-compose__panel-body">
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<select id="compose-cover-type" name="cover_type">
|
||||
<option value="" <?php selected($cover_type, ''); ?>><?php esc_html_e('无封面', 'aksrt'); ?></option>
|
||||
<?php if (!empty($caps['can_set_cover_image'])) : ?>
|
||||
<option value="image" <?php selected($cover_type, 'image'); ?>><?php esc_html_e('图片封面', 'aksrt'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($caps['can_set_cover_slide'])) : ?>
|
||||
<option value="slide" <?php selected($cover_type, 'slide'); ?>><?php esc_html_e('幻灯片封面', 'aksrt'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($caps['can_set_cover_video'])) : ?>
|
||||
<option value="video" <?php selected($cover_type, 'video'); ?>><?php esc_html_e('视频封面', 'aksrt'); ?></option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__cover-upload" id="compose-cover-image-field" style="display:none;">
|
||||
<input type="hidden" name="cover_image" id="compose-cover-image" value="<?php echo esc_attr($cover_image); ?>">
|
||||
<div class="aksrt-forum-compose__cover-preview" id="compose-cover-preview">
|
||||
<?php if ($cover_image) : ?>
|
||||
<img src="<?php echo esc_url($cover_image); ?>" alt="">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<button type="button" class="aksrt-forum-compose__cover-btn" id="compose-cover-upload-btn"><?php esc_html_e('选择图片', 'aksrt'); ?></button>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__cover-upload" id="compose-cover-slide-field" style="display:none;">
|
||||
<input type="hidden" name="featured_slide" id="compose-featured-slide"
|
||||
value="<?php echo esc_attr(is_array($featured_slide) && !empty($featured_slide) ? wp_json_encode($featured_slide) : ''); ?>">
|
||||
<div class="aksrt-forum-compose__cover-preview" id="compose-slide-preview">
|
||||
<?php if (is_array($featured_slide)) : foreach ($featured_slide as $su) : ?>
|
||||
<img src="<?php echo esc_url($su); ?>" alt="">
|
||||
<?php endforeach; endif; ?>
|
||||
</div>
|
||||
<button type="button" class="aksrt-forum-compose__cover-btn" id="compose-slide-upload-btn"><?php esc_html_e('选择图片', 'aksrt'); ?></button>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__cover-upload" id="compose-cover-video-field" style="display:none;">
|
||||
<input type="url" name="featured_video" id="compose-featured-video"
|
||||
value="<?php echo esc_attr($featured_video); ?>"
|
||||
placeholder="<?php esc_attr_e('https://...mp4', 'aksrt'); ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Panel: Vote -->
|
||||
<?php if (!empty($caps['can_set_vote'])) : ?>
|
||||
<div class="aksrt-forum-compose__panel">
|
||||
<h3 class="aksrt-forum-compose__panel-title">
|
||||
<label class="aksrt-forum-compose__checkbox">
|
||||
<input type="checkbox" id="compose-vote-enabled" name="vote_enabled" value="1"
|
||||
<?php checked($vote_enabled); ?>>
|
||||
<span><i class="fas fa-poll"></i> <?php esc_html_e('投票', 'aksrt'); ?></span>
|
||||
</label>
|
||||
</h3>
|
||||
<div class="aksrt-forum-compose__panel-body aksrt-forum-compose__vote-fields" <?php echo !$vote_enabled ? 'hidden' : ''; ?>>
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<label for="compose-vote-title"><?php esc_html_e('投票标题', 'aksrt'); ?></label>
|
||||
<input type="text" id="compose-vote-title" name="vote_title" maxlength="120"
|
||||
value="<?php echo esc_attr($vote_title); ?>">
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<label class="aksrt-forum-compose__checkbox">
|
||||
<input type="checkbox" id="compose-vote-multiple" name="vote_multiple" value="1"
|
||||
<?php checked($vote_multiple); ?>>
|
||||
<span><?php esc_html_e('允许多选', 'aksrt'); ?></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<label for="compose-vote-type"><?php esc_html_e('投票类型', 'aksrt'); ?></label>
|
||||
<select id="compose-vote-type" name="vote_type">
|
||||
<option value="standard" <?php selected($vote_type, 'standard'); ?>><?php esc_html_e('标准投票', 'aksrt'); ?></option>
|
||||
<option value="pk" <?php selected($vote_type, 'pk'); ?>><?php esc_html_e('PK 双选', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<label for="compose-vote-expiry"><?php esc_html_e('投票有效期', 'aksrt'); ?></label>
|
||||
<select id="compose-vote-expiry" name="vote_expiry_days">
|
||||
<option value="0" <?php selected($vote_expiry_days, 0); ?>><?php esc_html_e('永久', 'aksrt'); ?></option>
|
||||
<option value="1" <?php selected($vote_expiry_days, 1); ?>><?php esc_html_e('1 天', 'aksrt'); ?></option>
|
||||
<option value="7" <?php selected($vote_expiry_days, 7); ?>><?php esc_html_e('7 天', 'aksrt'); ?></option>
|
||||
<option value="30" <?php selected($vote_expiry_days, 30); ?>><?php esc_html_e('30 天', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-compose__field">
|
||||
<label for="compose-vote-options"><?php printf(esc_html__('选项(最多 %d 项)', 'aksrt'), (int) $vote_max); ?></label>
|
||||
<textarea id="compose-vote-options" name="vote_options" rows="4"><?php echo esc_textarea($vote_options_text); ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div><!-- /.aksrt-forum-compose__sidebar -->
|
||||
</form>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php get_footer(); ?>
|
||||
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Plate category (分区) archive template.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
get_header();
|
||||
|
||||
$forum = class_exists('\AKSRT\Forum\Forum') ? \AKSRT\Forum\Forum::get_instance() : null;
|
||||
$term = get_queried_object();
|
||||
$cat_id = $term ? (int) $term->term_id : 0;
|
||||
|
||||
$forum_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_forum_settings() : [];
|
||||
$forum_names = $forum_settings['names'] ?? [];
|
||||
$forum_name = $forum_names['forum'] ?? __('论坛', 'aksrt');
|
||||
|
||||
$plates = [];
|
||||
if ($forum && $cat_id > 0) {
|
||||
$plates = $forum->get_sorted_plates('menu_order', 'ASC', 100);
|
||||
$plates = array_filter($plates, static function ($plate) use ($cat_id): bool {
|
||||
return isset($plate['plate_cat']['id']) && (int) $plate['plate_cat']['id'] === $cat_id;
|
||||
});
|
||||
$plates = array_values($plates);
|
||||
}
|
||||
|
||||
$cat_moderator_ids = get_term_meta($cat_id, '_aksrt_cat_moderator', true);
|
||||
$cat_moderators = [];
|
||||
if (is_array($cat_moderator_ids)) {
|
||||
foreach ($cat_moderator_ids as $uid) {
|
||||
$user = get_userdata((int) $uid);
|
||||
if ($user) {
|
||||
$cat_moderators[] = [
|
||||
'id' => (int) $user->ID,
|
||||
'name' => $user->display_name,
|
||||
'avatar' => function_exists('aksrt_get_avatar_url') ? aksrt_get_avatar_url($user->ID, 36) : get_avatar_url($user->ID, ['size' => 36]),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<main id="main-content" class="site-main content-shell content-shell--stream content-shell--forum" tabindex="-1">
|
||||
<div class="content-wrap container">
|
||||
<div class="content-layout content-layout--no-sidebar">
|
||||
<div class="content-layout__primary">
|
||||
|
||||
<?php if (function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs(); } ?>
|
||||
|
||||
<div class="aksrt-forum-plate-cat">
|
||||
<div class="aksrt-forum-plate-cat__header">
|
||||
<h1><?php echo esc_html($term ? $term->name : ''); ?></h1>
|
||||
<?php if ($term && $term->description) : ?>
|
||||
<p><?php echo esc_html($term->description); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($cat_moderators)) : ?>
|
||||
<div class="aksrt-forum-plate-cat__moderators">
|
||||
<span><?php esc_html_e('分区版主:', 'aksrt'); ?></span>
|
||||
<?php foreach ($cat_moderators as $mod) : ?>
|
||||
<span class="aksrt-forum-plate-cat__moderator">
|
||||
<?php if (!empty($mod['avatar'])) : ?>
|
||||
<img src="<?php echo esc_url($mod['avatar']); ?>" alt="" width="24" height="24">
|
||||
<?php endif; ?>
|
||||
<?php echo esc_html($mod['name']); ?>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-plate-cat__plates">
|
||||
<?php if (!empty($plates)) : ?>
|
||||
<?php foreach ($plates as $plate) : ?>
|
||||
<a href="<?php echo esc_url((string) ($plate['url'] ?? '#')); ?>" class="aksrt-forum-plate-cat__plate-card">
|
||||
<?php if (!empty($plate['cover_url'])) : ?>
|
||||
<img class="aksrt-forum-plate-cat__plate-cover" src="<?php echo esc_url($plate['cover_url']); ?>" alt="" loading="lazy">
|
||||
<?php elseif (!empty($plate['icon'])) : ?>
|
||||
<div class="aksrt-forum-plate-cat__plate-icon"><i class="<?php echo esc_attr($plate['icon']); ?>"></i></div>
|
||||
<?php endif; ?>
|
||||
<div class="aksrt-forum-plate-cat__plate-info">
|
||||
<h3><?php echo esc_html((string) ($plate['name'] ?? '')); ?></h3>
|
||||
<p><?php echo esc_html((string) ($plate['description'] ?? '')); ?></p>
|
||||
<div class="aksrt-forum-plate-cat__plate-meta">
|
||||
<span><?php printf(esc_html__('%d 主题', 'aksrt'), (int) ($plate['post_count'] ?? 0)); ?></span>
|
||||
<span><?php printf(esc_html__('%d 关注', 'aksrt'), (int) ($plate['follow_count'] ?? 0)); ?></span>
|
||||
<?php if (!empty($plate['is_hot'])) : ?>
|
||||
<span class="aksrt-forum-plate-cat__hot-badge"><?php esc_html_e('热门', 'aksrt'); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
<?php else : ?>
|
||||
<div class="aksrt-forum-plate-cat__empty">
|
||||
<p><?php esc_html_e('该分区暂无版块。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-plate-cat__back">
|
||||
<a href="<?php echo esc_url(aksrt_get_forum_home_url()); ?>">
|
||||
<i class="fas fa-arrow-left"></i> <?php printf(esc_html__('返回%s', 'aksrt'), esc_html($forum_name)); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php get_footer(); ?>
|
||||
@@ -1,331 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Plate CPT single template (§7.2 板块独立页面).
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
get_header();
|
||||
|
||||
$forum = class_exists('\AKSRT\Forum\Forum') ? \AKSRT\Forum\Forum::get_instance() : null;
|
||||
$current_user_id = get_current_user_id();
|
||||
$plate_id = get_queried_object_id();
|
||||
$paged = max(1, (int) get_query_var('paged', 1));
|
||||
$forum_sort = isset($_GET['forum_sort']) ? sanitize_key(wp_unslash((string) $_GET['forum_sort'])) : '';
|
||||
|
||||
$view = $forum ? $forum->get_board_view($plate_id, [
|
||||
'user_id' => $current_user_id,
|
||||
'paged' => $paged,
|
||||
'orderby' => $forum_sort,
|
||||
]) : [
|
||||
'board' => null,
|
||||
'topics' => [],
|
||||
'sticky_topics' => [],
|
||||
'moderators' => [],
|
||||
'pagination' => ['page' => 1, 'max_pages' => 1, 'total' => 0],
|
||||
'permissions' => [],
|
||||
'application' => null,
|
||||
'board_options' => [],
|
||||
'tabs' => [],
|
||||
'active_sort' => 'date',
|
||||
'top_info' => true,
|
||||
'compose_url' => function_exists('aksrt_get_forum_compose_url') ? aksrt_get_forum_compose_url() : home_url('/'),
|
||||
];
|
||||
|
||||
$board_data = $view['board'] ?? null;
|
||||
$topics = $view['topics'] ?? [];
|
||||
$sticky_topics = $view['sticky_topics'] ?? [];
|
||||
$moderators = $view['moderators'] ?? [];
|
||||
$permissions = $view['permissions'] ?? [];
|
||||
$application = $view['application'] ?? null;
|
||||
$tabs = is_array($view['tabs'] ?? null) ? $view['tabs'] : [];
|
||||
$active_sort = sanitize_key((string) ($view['active_sort'] ?? 'date'));
|
||||
$top_info = !isset($view['top_info']) || !empty($view['top_info']);
|
||||
$compose_url = (string) ($view['compose_url'] ?? (function_exists('aksrt_get_forum_compose_url') ? aksrt_get_forum_compose_url(['board' => $plate_id]) : home_url('/')));
|
||||
$plate_url = !empty($board_data['url']) ? (string) $board_data['url'] : (string) get_permalink($plate_id);
|
||||
$nonce = wp_create_nonce('aksrt_public_nonce');
|
||||
|
||||
$forum_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_forum_settings() : [];
|
||||
$forum_names = $forum_settings['names'] ?? [];
|
||||
$name_topic = $forum_names['posts'] ?? __('主题', 'aksrt');
|
||||
$name_reply = $forum_names['comment'] ?? __('回复', 'aksrt');
|
||||
$is_followed = $forum && $current_user_id > 0 ? $forum->is_user_following_plate($current_user_id, $plate_id) : false;
|
||||
$max_pages = (int) ($view['pagination']['max_pages'] ?? 1);
|
||||
?>
|
||||
|
||||
<main id="main-content" class="site-main content-shell content-shell--stream content-shell--forum" tabindex="-1">
|
||||
<?php if (is_active_sidebar('bbs_plate_top_fluid')) { echo '<div class="aksrt-fluid-widget aksrt-fluid-widget--forum">'; dynamic_sidebar('bbs_plate_top_fluid'); echo '</div>'; } ?>
|
||||
<div class="content-wrap container">
|
||||
<div class="content-layout content-layout--with-sidebar">
|
||||
<div class="content-layout__primary">
|
||||
|
||||
<?php if (function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs(); } ?>
|
||||
|
||||
<?php if (!empty($permissions['access_denied'])) : ?>
|
||||
<div class="aksrt-forum-board">
|
||||
<div class="aksrt-forum-board__access-denied">
|
||||
<i class="fas fa-lock"></i>
|
||||
<h2><?php esc_html_e('访问受限', 'aksrt'); ?></h2>
|
||||
<p><?php
|
||||
$reason = $permissions['access_reason'] ?? 'login';
|
||||
if ($reason === 'login') {
|
||||
esc_html_e('请登录后访问此版块。', 'aksrt');
|
||||
} elseif ($reason === 'follow') {
|
||||
esc_html_e('请先关注此版块后才能浏览内容。', 'aksrt');
|
||||
} elseif ($reason === 'role') {
|
||||
esc_html_e('你当前的角色无权访问此版块。', 'aksrt');
|
||||
}
|
||||
?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
|
||||
<div class="aksrt-forum-board container"
|
||||
data-plate-id="<?php echo esc_attr((string) $plate_id); ?>"
|
||||
data-nonce="<?php echo esc_attr($nonce); ?>"
|
||||
data-active-sort="<?php echo esc_attr($active_sort); ?>">
|
||||
|
||||
<?php if ($top_info) : ?>
|
||||
<div class="aksrt-forum-board__header">
|
||||
<div class="aksrt-forum-board__info">
|
||||
<?php if (!empty($board_data['cover_url'])) : ?>
|
||||
<img class="aksrt-forum-board__cover" src="<?php echo esc_url((string) $board_data['cover_url']); ?>" alt="" loading="lazy">
|
||||
<?php endif; ?>
|
||||
<h1 class="aksrt-forum-board__title"><?php echo esc_html((string) ($board_data['name'] ?? '')); ?></h1>
|
||||
<?php if (!empty($board_data['description'])) : ?>
|
||||
<p class="aksrt-forum-board__desc"><?php echo esc_html((string) $board_data['description']); ?></p>
|
||||
<?php endif; ?>
|
||||
<div class="aksrt-forum-board__meta">
|
||||
<span><i class="fas fa-list-alt"></i> <?php printf(esc_html__('%1$d 个%2$s', 'aksrt'), (int) ($board_data['post_count'] ?? $board_data['topic_count'] ?? 0), esc_html($name_topic)); ?></span>
|
||||
<span><i class="fas fa-comments"></i> <?php printf(esc_html__('%d 条%s', 'aksrt'), (int) ($board_data['reply_count'] ?? 0), esc_html($name_reply)); ?></span>
|
||||
<span><i class="fas fa-eye"></i> <?php printf(esc_html__('%d 浏览', 'aksrt'), (int) ($board_data['views'] ?? 0)); ?></span>
|
||||
<span><i class="fas fa-heart"></i> <?php printf(esc_html__('%d 关注', 'aksrt'), (int) ($board_data['follow_count'] ?? 0)); ?></span>
|
||||
<span><i class="fas fa-shield-alt"></i> <?php printf(esc_html__('%d 位版主', 'aksrt'), count($moderators)); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-board__actions">
|
||||
<?php
|
||||
$follow_pay_on = $forum && method_exists($forum, 'is_plate_follow_pay_enabled')
|
||||
? $forum->is_plate_follow_pay_enabled($plate_id)
|
||||
: ((int) get_post_meta($plate_id, '_aksrt_follow_pay', true) === 1);
|
||||
$follow_pay_modo = sanitize_key((string) (get_post_meta($plate_id, '_aksrt_follow_pay_modo', true) ?: 'money'));
|
||||
$allow_guest_plate = $current_user_id <= 0
|
||||
&& $follow_pay_on
|
||||
&& $follow_pay_modo === 'money'
|
||||
&& function_exists('aksrt_allow_guest_forum_pay')
|
||||
&& aksrt_allow_guest_forum_pay(get_post($plate_id));
|
||||
$guest_followed = $current_user_id <= 0
|
||||
&& function_exists('aksrt_guest_has_plate_follow_access')
|
||||
&& aksrt_guest_has_plate_follow_access($plate_id);
|
||||
?>
|
||||
<?php if ($current_user_id > 0) : ?>
|
||||
<button type="button"
|
||||
class="aksrt-forum-board__follow-btn js-aksrt-follow-plate"
|
||||
data-plate-id="<?php echo esc_attr((string) $plate_id); ?>"
|
||||
data-followed="<?php echo $is_followed ? '1' : '0'; ?>">
|
||||
<i class="fas fa-heart"></i>
|
||||
<?php echo $is_followed ? esc_html__('已关注', 'aksrt') : esc_html__('关注', 'aksrt'); ?>
|
||||
</button>
|
||||
<?php elseif ($guest_followed) : ?>
|
||||
<button type="button" class="aksrt-forum-board__follow-btn is-followed" disabled>
|
||||
<i class="fas fa-heart"></i>
|
||||
<?php esc_html_e('已关注', 'aksrt'); ?>
|
||||
</button>
|
||||
<?php elseif ($allow_guest_plate) : ?>
|
||||
<button type="button"
|
||||
class="aksrt-forum-board__follow-btn"
|
||||
data-aksrt-pay-plate-follow="<?php echo esc_attr((string) $plate_id); ?>">
|
||||
<i class="fas fa-heart"></i>
|
||||
<?php esc_html_e('付费关注', 'aksrt'); ?>
|
||||
</button>
|
||||
<p class="description" style="margin-top:6px;font-size:12px;">
|
||||
<?php esc_html_e('未登录关注通过 Cookie 生效;建议登录后关注以便保存订单。', 'aksrt'); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($permissions['can_compose'])) : ?>
|
||||
<a href="<?php echo esc_url($compose_url); ?>" class="aksrt-forum-board__compose-btn">
|
||||
<i class="fas fa-pen"></i>
|
||||
<?php esc_html_e('发布新主题', 'aksrt'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$is_forum_admin = $forum && $forum->is_forum_admin($current_user_id);
|
||||
$is_plate_author = $board_data && (int) ($board_data['author_id'] ?? 0) === $current_user_id;
|
||||
?>
|
||||
<?php if ($is_forum_admin || $is_plate_author) : ?>
|
||||
<button type="button" class="aksrt-forum-board__manage-btn js-aksrt-edit-plate"
|
||||
data-plate-id="<?php echo esc_attr((string) $plate_id); ?>"
|
||||
data-name="<?php echo esc_attr((string) ($board_data['name'] ?? '')); ?>"
|
||||
data-description="<?php echo esc_attr((string) ($board_data['description'] ?? '')); ?>"
|
||||
data-icon="<?php echo esc_attr((string) ($board_data['icon'] ?? '')); ?>"
|
||||
data-cover="<?php echo esc_attr((string) ($board_data['cover_url'] ?? '')); ?>">
|
||||
<i class="fas fa-cog"></i> <?php esc_html_e('编辑版块', 'aksrt'); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ($is_forum_admin) : ?>
|
||||
<button type="button" class="aksrt-forum-board__manage-btn aksrt-forum-board__manage-btn--danger js-aksrt-delete-plate"
|
||||
data-plate-id="<?php echo esc_attr((string) $plate_id); ?>"
|
||||
data-topic-count="<?php echo esc_attr((string) ($board_data['post_count'] ?? $board_data['topic_count'] ?? 0)); ?>">
|
||||
<i class="fas fa-trash-alt"></i> <?php esc_html_e('删除版块', 'aksrt'); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($board_data['content'])) : ?>
|
||||
<div class="aksrt-forum-board__content entry-content">
|
||||
<?php echo wp_kses_post((string) $board_data['content']); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($sticky_topics)) : ?>
|
||||
<div class="aksrt-forum-board__sticky">
|
||||
<h3><i class="fas fa-thumbtack"></i> <?php esc_html_e('置顶主题', 'aksrt'); ?></h3>
|
||||
<?php foreach ($sticky_topics as $topic) : ?>
|
||||
<a href="<?php echo esc_url((string) ($topic['permalink'] ?? '#')); ?>" class="aksrt-forum-board__sticky-item">
|
||||
<?php $sticky_label = (string) ($topic['sticky_label'] ?? __('置顶', 'aksrt')); ?>
|
||||
<span class="aksrt-forum-board__sticky-badge"><?php echo esc_html($sticky_label); ?></span>
|
||||
<span class="aksrt-forum-board__sticky-title"><?php echo esc_html((string) ($topic['title'] ?? '')); ?></span>
|
||||
<span class="aksrt-forum-board__sticky-meta">
|
||||
<?php echo esc_html((string) ($topic['author']['display_name'] ?? '')); ?>
|
||||
· <?php echo esc_html((string) ($topic['date'] ?? '')); ?>
|
||||
</span>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($tabs)) : ?>
|
||||
<nav class="aksrt-forum-board__tabs" aria-label="<?php esc_attr_e('版块栏目', 'aksrt'); ?>">
|
||||
<?php foreach ($tabs as $tab) :
|
||||
$sort = sanitize_key((string) ($tab['sort'] ?? 'date'));
|
||||
$label = (string) ($tab['label'] ?? $sort);
|
||||
$tab_url = add_query_arg('forum_sort', $sort, $plate_url);
|
||||
$is_active = $sort === $active_sort;
|
||||
?>
|
||||
<a class="aksrt-forum-board__tab js-aksrt-board-sort-tab<?php echo $is_active ? ' is-active' : ''; ?>"
|
||||
href="<?php echo esc_url($tab_url); ?>"
|
||||
data-sort="<?php echo esc_attr($sort); ?>"
|
||||
<?php echo $is_active ? 'aria-current="page"' : ''; ?>>
|
||||
<?php echo esc_html($label); ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="aksrt-forum-board__topics">
|
||||
<div class="aksrt-forum-topics__list js-aksrt-board-topic-list">
|
||||
<?php if (!empty($topics) && $forum) : ?>
|
||||
<?php foreach ($topics as $topic) { $forum->render_topic_row($topic); } ?>
|
||||
<?php else : ?>
|
||||
<div class="aksrt-forum-board__empty aksrt-forum__empty">
|
||||
<i class="fas fa-comments"></i>
|
||||
<p><?php esc_html_e('内容空空如也', 'aksrt'); ?></p>
|
||||
<?php if (!empty($permissions['can_compose'])) : ?>
|
||||
<a href="<?php echo esc_url($compose_url); ?>"><?php esc_html_e('发布第一个主题', 'aksrt'); ?></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($max_pages > 1) : ?>
|
||||
<div class="aksrt-forum-board__pagination">
|
||||
<?php
|
||||
echo paginate_links([
|
||||
'total' => $max_pages,
|
||||
'current' => $paged,
|
||||
'prev_text' => '<i class="fas fa-chevron-left"></i>',
|
||||
'next_text' => '<i class="fas fa-chevron-right"></i>',
|
||||
'add_args' => $active_sort !== '' ? ['forum_sort' => $active_sort] : [],
|
||||
]);
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<section class="aksrt-forum-board__governance aksrt-forum-board__governance--footer">
|
||||
<div class="aksrt-forum-board__governance-card">
|
||||
<h2 class="aksrt-forum-board__section-title"><?php esc_html_e('版主团队', 'aksrt'); ?></h2>
|
||||
<?php if (!empty($moderators)) : ?>
|
||||
<div class="aksrt-forum-board__moderators">
|
||||
<?php foreach ($moderators as $moderator) : ?>
|
||||
<div class="aksrt-forum-board__moderator">
|
||||
<?php if (!empty($moderator['avatar'])) : ?>
|
||||
<img src="<?php echo esc_url((string) $moderator['avatar']); ?>" alt="" width="36" height="36">
|
||||
<?php endif; ?>
|
||||
<span><?php echo esc_html((string) ($moderator['name'] ?? $moderator['display_name'] ?? '')); ?></span>
|
||||
<?php if (!empty($moderator['role'])) : ?>
|
||||
<small class="aksrt-forum-board__moderator-role"><?php echo esc_html((string) $moderator['role']); ?></small>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<p><?php esc_html_e('当前还没有设置版主。', 'aksrt'); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-forum-board__governance-card">
|
||||
<h2 class="aksrt-forum-board__section-title"><?php esc_html_e('版主申请', 'aksrt'); ?></h2>
|
||||
<?php if (!is_user_logged_in()) : ?>
|
||||
<p class="aksrt-forum-board__application-note"><?php esc_html_e('登录后可申请协助管理本版块。', 'aksrt'); ?></p>
|
||||
<a href="<?php echo esc_url(wp_login_url(get_permalink())); ?>" class="aksrt-forum-board__apply-btn"><?php esc_html_e('登录后申请', 'aksrt'); ?></a>
|
||||
<?php elseif (!empty($application)) : ?>
|
||||
<p class="aksrt-forum-board__application-note">
|
||||
<?php printf(
|
||||
esc_html__('你最近一次申请状态:%s', 'aksrt'),
|
||||
esc_html((string) ($application['status_label'] ?? __('待处理', 'aksrt')))
|
||||
); ?>
|
||||
</p>
|
||||
<?php if (!empty($application['reason'])) : ?>
|
||||
<blockquote class="aksrt-forum-board__application-reason"><?php echo esc_html((string) $application['reason']); ?></blockquote>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($application['review_note'])) : ?>
|
||||
<p class="aksrt-forum-board__application-note"><?php printf(esc_html__('审核备注:%s', 'aksrt'), esc_html((string) $application['review_note'])); ?></p>
|
||||
<?php endif; ?>
|
||||
<?php if (($application['status'] ?? '') !== 'pending' && !empty($permissions['can_apply_moderator'])) : ?>
|
||||
<form class="aksrt-forum-board__application-form js-aksrt-moderator-apply-form" data-board-id="<?php echo esc_attr((string) $plate_id); ?>">
|
||||
<label for="aksrt-plate-apply-reason"><?php esc_html_e('重新申请理由', 'aksrt'); ?></label>
|
||||
<textarea id="aksrt-plate-apply-reason" name="reason" rows="4" placeholder="<?php esc_attr_e('请简要说明你的社区经验、擅长领域或管理计划。', 'aksrt'); ?>"></textarea>
|
||||
<div class="aksrt-forum-board__application-actions">
|
||||
<button type="submit" class="aksrt-forum-board__apply-btn"><?php esc_html_e('重新提交申请', 'aksrt'); ?></button>
|
||||
<span class="aksrt-forum-board__application-feedback js-aksrt-action-feedback" aria-live="polite"></span>
|
||||
</div>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<?php elseif (!empty($permissions['can_apply_moderator'])) : ?>
|
||||
<p class="aksrt-forum-board__application-note"><?php esc_html_e('如果你熟悉本版块内容并愿意协助维护秩序,可以提交版主申请。', 'aksrt'); ?></p>
|
||||
<form class="aksrt-forum-board__application-form js-aksrt-moderator-apply-form" data-board-id="<?php echo esc_attr((string) $plate_id); ?>">
|
||||
<label for="aksrt-plate-apply-reason"><?php esc_html_e('申请理由', 'aksrt'); ?></label>
|
||||
<textarea id="aksrt-plate-apply-reason" name="reason" rows="4" placeholder="<?php esc_attr_e('请简要说明你的社区经验、擅长领域或管理计划。', 'aksrt'); ?>"></textarea>
|
||||
<div class="aksrt-forum-board__application-actions">
|
||||
<button type="submit" class="aksrt-forum-board__apply-btn"><?php esc_html_e('提交版主申请', 'aksrt'); ?></button>
|
||||
<span class="aksrt-forum-board__application-feedback js-aksrt-action-feedback" aria-live="polite"></span>
|
||||
</div>
|
||||
</form>
|
||||
<?php else : ?>
|
||||
<p class="aksrt-forum-board__application-note"><?php esc_html_e('你当前已是本版块管理成员,或暂不满足申请条件。', 'aksrt'); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
<?php if (is_active_sidebar('bbs_plate_sidebar')) : ?>
|
||||
<aside class="content-layout__sidebar aksrt-forum-widget-zone">
|
||||
<?php dynamic_sidebar('bbs_plate_sidebar'); ?>
|
||||
</aside>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php get_footer(); ?>
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* 论坛标签归档模板
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
get_header();
|
||||
|
||||
$term = get_queried_object();
|
||||
$paged = max(1, (int) get_query_var('paged'));
|
||||
$forum = class_exists('\AKSRT\Forum\Forum') ? \AKSRT\Forum\Forum::get_instance() : null;
|
||||
$view = $forum ? $forum->get_tag_archive_view([
|
||||
'term_id' => $term->term_id,
|
||||
'paged' => $paged,
|
||||
]) : ['topics' => [], 'term' => null, 'total' => 0, 'max_pages' => 0];
|
||||
|
||||
$topics = $view['topics'];
|
||||
$total = $view['total'];
|
||||
$max_pages = $view['max_pages'];
|
||||
$term_name = $term->name ?? '';
|
||||
$term_desc = $term->description ?? '';
|
||||
?>
|
||||
|
||||
<main id="main-content" class="site-main content-shell content-shell--stream content-shell--forum" tabindex="-1">
|
||||
<div class="content-wrap container">
|
||||
<div class="content-layout content-layout--no-sidebar">
|
||||
<div class="content-layout__primary">
|
||||
|
||||
|
||||
<div class="aksrt-forum-tag">
|
||||
<header class="aksrt-forum-tag__header">
|
||||
<h1 class="aksrt-forum-tag__title">
|
||||
<i class="fas fa-tag"></i>
|
||||
<?php echo esc_html($term_name); ?>
|
||||
</h1>
|
||||
<?php if ($term_desc) : ?>
|
||||
<p class="aksrt-forum-tag__desc"><?php echo esc_html($term_desc); ?></p>
|
||||
<?php endif; ?>
|
||||
<p class="aksrt-forum-tag__count"><?php printf(esc_html__('共 %d 个话题', 'aksrt'), $total); ?></p>
|
||||
</header>
|
||||
|
||||
<?php if (!empty($topics) && $forum) : ?>
|
||||
<div class="aksrt-forum-topics__list aksrt-forum-tag__list">
|
||||
<?php foreach ($topics as $topic) { $forum->render_topic_row($topic); } ?>
|
||||
</div>
|
||||
|
||||
<?php if ($max_pages > 1) : ?>
|
||||
<nav class="aksrt-forum-tag__pagination" aria-label="<?php esc_attr_e('话题分页', 'aksrt'); ?>">
|
||||
<?php
|
||||
echo paginate_links([
|
||||
'total' => $max_pages,
|
||||
'current' => $paged,
|
||||
'prev_text' => '<i class="fas fa-chevron-left"></i>',
|
||||
'next_text' => '<i class="fas fa-chevron-right"></i>',
|
||||
]);
|
||||
?>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
<?php else : ?>
|
||||
<div class="aksrt-forum-tag__empty aksrt-forum__empty">
|
||||
<i class="fas fa-comments"></i>
|
||||
<p><?php esc_html_e('内容空空如也', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php get_footer(); ?>
|
||||
@@ -1,850 +0,0 @@
|
||||
<?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\Forum') ? \AKSRT\Forum\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\Settings') ? \AKSRT\Settings\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);
|
||||
$pay_hide_part = !empty($topic['pay_hide_part']) || ((int) get_post_meta($topic_id, '_aksrt_pay_hide_part', true) === 1);
|
||||
$partial_ok = $pay_hide_part && in_array($deny_vis, ['pay', 'credits'], true);
|
||||
|
||||
// Partial hide: show title + body with payshow/hidecontent locked blocks + pay CTA.
|
||||
if ($partial_ok) :
|
||||
?>
|
||||
<main id="main-content" class="site-main content-shell content-shell--stream content-shell--forum" tabindex="-1">
|
||||
<div class="content-wrap container">
|
||||
<div class="content-layout content-layout--no-sidebar">
|
||||
<div class="content-layout__primary">
|
||||
<div class="aksrt-forum-topic">
|
||||
<header class="aksrt-forum-topic__header">
|
||||
<h1 class="aksrt-forum-topic__title"><?php echo esc_html((string) ($topic['title'] ?? get_the_title($topic_id))); ?></h1>
|
||||
</header>
|
||||
<div class="aksrt-forum-topic__denied aksrt-forum-topic__denied--partial">
|
||||
<i class="fas fa-lock"></i>
|
||||
<p><?php esc_html_e('部分内容需解锁后查看。', 'aksrt'); ?></p>
|
||||
<?php if ($deny_vis === 'credits' && $credits_cost > 0 && 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 elseif ($deny_vis === 'pay' && is_user_logged_in()) : ?>
|
||||
<?php
|
||||
$viewer_id = get_current_user_id();
|
||||
$price_info = class_exists('\AKSRT\Forum\Forum')
|
||||
? \AKSRT\Forum\Forum::get_instance()->resolve_topic_pay_price($topic_id, $viewer_id)
|
||||
: ['amount' => (float) $pay_price, 'is_free' => false, 'label' => '', 'base' => (float) $pay_price];
|
||||
$charge_amount = (float) ($price_info['amount'] ?? 0);
|
||||
$is_free_vip = !empty($price_info['is_free']);
|
||||
?>
|
||||
<button type="button" class="aksrt-forum-topic__primary-btn"
|
||||
data-aksrt-pay-topic="<?php echo esc_attr((string) $topic_id); ?>"
|
||||
data-price="<?php echo esc_attr(number_format($charge_amount, 2, '.', '')); ?>"
|
||||
data-free="<?php echo $is_free_vip ? '1' : '0'; ?>">
|
||||
<i class="fas fa-shopping-cart"></i>
|
||||
<?php
|
||||
if ($is_free_vip) {
|
||||
esc_html_e('VIP 免费解锁', 'aksrt');
|
||||
} else {
|
||||
printf(esc_html__('购买解锁 ¥%s', 'aksrt'), esc_html(number_format($charge_amount, 2, '.', '')));
|
||||
}
|
||||
?>
|
||||
</button>
|
||||
<span class="aksrt-forum-topic__unlock-feedback js-aksrt-action-feedback" aria-live="polite"></span>
|
||||
<?php elseif (!is_user_logged_in()) : ?>
|
||||
<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; ?>
|
||||
</div>
|
||||
<article class="aksrt-forum-topic__content aksrt-forum-topic__content--partial">
|
||||
<?php
|
||||
// Render WP content so payshow/hidecontent shortcodes run for locked parts.
|
||||
if (have_posts()) {
|
||||
while (have_posts()) {
|
||||
the_post();
|
||||
the_content();
|
||||
}
|
||||
} else {
|
||||
echo apply_filters('the_content', (string) ($topic['content'] ?? '')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
?>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<?php
|
||||
get_footer();
|
||||
return;
|
||||
endif;
|
||||
?>
|
||||
<main id="main-content" class="site-main content-shell content-shell--stream content-shell--forum" tabindex="-1">
|
||||
<div class="content-wrap container">
|
||||
<div class="content-layout content-layout--no-sidebar">
|
||||
<div class="content-layout__primary">
|
||||
|
||||
<div class="aksrt-forum-topic">
|
||||
<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') : ?>
|
||||
<?php
|
||||
$viewer_id = get_current_user_id();
|
||||
$price_info = class_exists('\AKSRT\Forum\Forum')
|
||||
? \AKSRT\Forum\Forum::get_instance()->resolve_topic_pay_price($topic_id, $viewer_id)
|
||||
: ['amount' => (float) $pay_price, 'is_free' => false, 'is_vip_price' => false, 'base' => (float) $pay_price, 'label' => ''];
|
||||
$charge_amount = (float) ($price_info['amount'] ?? 0);
|
||||
$base_amount = (float) ($price_info['base'] ?? $charge_amount);
|
||||
$is_free_vip = !empty($price_info['is_free']);
|
||||
$is_vip_price = !empty($price_info['is_vip_price']);
|
||||
?>
|
||||
<p><?php esc_html_e('该主题为付费内容,请购买后查看。', 'aksrt'); ?></p>
|
||||
<?php if ($is_vip_price) : ?>
|
||||
<span class="aksrt-forum-topic__pay-price">
|
||||
<?php
|
||||
if ($is_free_vip) {
|
||||
esc_html_e('VIP 免费', 'aksrt');
|
||||
} else {
|
||||
printf(
|
||||
esc_html__('VIP 价:¥%s', 'aksrt'),
|
||||
esc_html(number_format($charge_amount, 2, '.', ''))
|
||||
);
|
||||
if ($base_amount > $charge_amount) {
|
||||
echo ' <del>' . esc_html(sprintf(__('原价 ¥%s', 'aksrt'), number_format($base_amount, 2, '.', ''))) . '</del>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
<?php elseif ($charge_amount > 0 || $base_amount > 0) : ?>
|
||||
<span class="aksrt-forum-topic__pay-price"><?php printf(esc_html__('价格:¥%s', 'aksrt'), esc_html(number_format(max($charge_amount, $base_amount), 2, '.', ''))); ?></span>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
$allow_guest_topic = !is_user_logged_in()
|
||||
&& function_exists('aksrt_allow_guest_forum_pay')
|
||||
&& aksrt_allow_guest_forum_pay(get_post($topic_id));
|
||||
?>
|
||||
<?php if (!is_user_logged_in() && !$allow_guest_topic) : ?>
|
||||
<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 else : ?>
|
||||
<button type="button" class="aksrt-forum-topic__primary-btn"
|
||||
data-aksrt-pay-topic="<?php echo esc_attr((string) $topic_id); ?>"
|
||||
data-price="<?php echo esc_attr(number_format($charge_amount, 2, '.', '')); ?>"
|
||||
data-free="<?php echo $is_free_vip ? '1' : '0'; ?>">
|
||||
<i class="fas fa-shopping-cart"></i>
|
||||
<?php
|
||||
if ($is_free_vip && is_user_logged_in()) {
|
||||
esc_html_e('VIP 免费解锁', 'aksrt');
|
||||
} else {
|
||||
printf(esc_html__('购买解锁 ¥%s', 'aksrt'), esc_html(number_format(max($charge_amount, $base_amount), 2, '.', '')));
|
||||
}
|
||||
?>
|
||||
</button>
|
||||
<?php if ($allow_guest_topic) : ?>
|
||||
<p class="description" style="margin-top:8px;">
|
||||
<?php esc_html_e('未登录购买将通过浏览器 Cookie 解锁;建议登录后购买以便保存订单。', 'aksrt'); ?>
|
||||
<a href="<?php echo esc_url(wp_login_url(get_permalink($topic_id))); ?>"><?php esc_html_e('去登录', 'aksrt'); ?></a>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<span class="aksrt-forum-topic__unlock-feedback js-aksrt-action-feedback" aria-live="polite"></span>
|
||||
<?php endif; ?>
|
||||
<?php else : ?>
|
||||
<p><?php esc_html_e('该主题当前处于受限可见或审核状态。', 'aksrt'); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</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 content-shell--stream content-shell--forum" tabindex="-1">
|
||||
<div class="content-wrap container">
|
||||
<div class="content-layout content-layout--no-sidebar">
|
||||
<div class="content-layout__primary">
|
||||
|
||||
|
||||
<?php if (function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs(); } ?>
|
||||
|
||||
<div class="aksrt-forum-topic">
|
||||
<?php
|
||||
// Cover + paid extensions for forum topics.
|
||||
$cover_type = (string) get_post_meta(get_the_ID(), '_aksrt_cover_type', true);
|
||||
$cover_image = (string) get_post_meta(get_the_ID(), '_aksrt_cover_image', true);
|
||||
$cover_video = (string) get_post_meta(get_the_ID(), '_aksrt_featured_video', true);
|
||||
$cover_ratio = (string) get_post_meta(get_the_ID(), '_aksrt_cover_ratio', true);
|
||||
if ($cover_ratio === '') { $cover_ratio = '16:9'; }
|
||||
if ($cover_type === 'image' && $cover_image !== '') : ?>
|
||||
<div class="aksrt-forum-topic__cover aksrt-forum-topic__cover--image" style="--cover-ratio:<?php echo esc_attr(str_replace(':', '/', $cover_ratio)); ?>">
|
||||
<img src="<?php echo esc_url($cover_image); ?>" alt="" loading="lazy">
|
||||
</div>
|
||||
<?php elseif ($cover_type === 'video' && $cover_video !== '') : ?>
|
||||
<div class="aksrt-forum-topic__cover aksrt-forum-topic__cover--video">
|
||||
<?php echo wp_oembed_get($cover_video) ?: esc_html($cover_video); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
<?php elseif ($cover_type === 'slide') :
|
||||
$slides = get_post_meta(get_the_ID(), '_aksrt_featured_slide', true);
|
||||
if (is_array($slides) && $slides) : ?>
|
||||
<div class="aksrt-forum-topic__cover aksrt-forum-topic__cover--slide">
|
||||
<?php foreach ($slides as $slide) :
|
||||
$src = is_array($slide) ? (string) ($slide['url'] ?? $slide['src'] ?? '') : (string) $slide;
|
||||
if ($src === '') { continue; } ?>
|
||||
<img src="<?php echo esc_url($src); ?>" alt="" loading="lazy">
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?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>
|
||||
<?php if (is_active_sidebar('bbs_posts_sidebar')) : ?>
|
||||
<div class="aksrt-forum-widget-zone">
|
||||
<?php dynamic_sidebar('bbs_posts_sidebar'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</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>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php get_footer(); ?>
|
||||
@@ -1,364 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Template Name: AKSRT - Forums
|
||||
* Template Post Type: page
|
||||
*
|
||||
* §7.10 / stream-h §3 — 主站社区首页:公开 tabs + 侧栏发帖/热门,pending 不进公开主内容。
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
get_header();
|
||||
|
||||
$forum = class_exists('\AKSRT\Forum\Forum') ? \AKSRT\Forum\Forum::get_instance() : null;
|
||||
$current_user_id = get_current_user_id();
|
||||
$view = $forum ? $forum->get_home_view($current_user_id) : [
|
||||
'boards' => [],
|
||||
'recent_topics' => [],
|
||||
'hot_topics' => [],
|
||||
'stats' => [],
|
||||
'permissions' => ['can_compose' => false, 'can_manage' => false],
|
||||
'applications' => [],
|
||||
'home_tabs' => [],
|
||||
'active_index' => 1,
|
||||
'quick_posts' => true,
|
||||
];
|
||||
|
||||
$boards = $view['boards'] ?? [];
|
||||
$recent_topics = $view['recent_topics'] ?? [];
|
||||
$synthesis = is_array($view['synthesis'] ?? null) ? $view['synthesis'] : ['items' => $recent_topics, 'max_pages' => 1, 'page' => 1, 'total' => count($recent_topics)];
|
||||
$synthesis_max = max(1, (int) ($synthesis['max_pages'] ?? 1));
|
||||
$hot_topics = $view['hot_topics'] ?? [];
|
||||
$stats = $view['stats'] ?? [];
|
||||
$permissions = $view['permissions'] ?? [];
|
||||
$applications = $view['applications'] ?? [];
|
||||
$compose_url = aksrt_get_forum_compose_url();
|
||||
|
||||
$forum_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_forum_settings() : [];
|
||||
$forum_names = $forum_settings['names'] ?? [];
|
||||
$name_forum = $forum_names['forum'] ?? __('论坛', 'aksrt');
|
||||
$name_plate = $forum_names['plate'] ?? __('版块', 'aksrt');
|
||||
$name_topic = $forum_names['posts'] ?? __('主题', 'aksrt');
|
||||
$name_reply = $forum_names['comment'] ?? __('回复', 'aksrt');
|
||||
$admin_forum_url = admin_url('admin.php?page=aksrt-theme-admin#/forum');
|
||||
|
||||
$home_tabs = $view['home_tabs'] ?? [];
|
||||
$active_index = max(0, min(count($home_tabs) - 1, (int) ($view['active_index'] ?? 1)));
|
||||
$quick_posts = !empty($view['quick_posts']);
|
||||
$nonce = wp_create_nonce('aksrt_public_nonce');
|
||||
|
||||
// Resolve active tab from query param or default
|
||||
$active_tab_type = isset($_GET['forum_tab']) ? sanitize_key(wp_unslash($_GET['forum_tab'])) : '';
|
||||
if ($active_tab_type === '' && isset($home_tabs[$active_index])) {
|
||||
$active_tab_type = $home_tabs[$active_index]['type'] ?? 'synthesis';
|
||||
}
|
||||
if ($active_tab_type === '') {
|
||||
$active_tab_type = 'synthesis';
|
||||
}
|
||||
|
||||
// 前台公开主 tabs 不允许 pending;未登录时 follow 回落到综合
|
||||
$can_manage = !empty($permissions['can_manage']);
|
||||
if ($active_tab_type === 'pending') {
|
||||
$active_tab_type = 'synthesis';
|
||||
}
|
||||
if ($active_tab_type === 'follow' && $current_user_id <= 0) {
|
||||
$active_tab_type = 'synthesis';
|
||||
}
|
||||
|
||||
// 配置里的 pending 类型从公开 tab 列表剔除(治理入口单独渲染)
|
||||
$public_home_tabs = [];
|
||||
foreach ((array) $home_tabs as $tab_row) {
|
||||
$tt = sanitize_key((string) ($tab_row['type'] ?? ''));
|
||||
if ($tt === '' || $tt === 'pending') {
|
||||
continue;
|
||||
}
|
||||
$public_home_tabs[] = $tab_row;
|
||||
}
|
||||
if (empty($public_home_tabs)) {
|
||||
$public_home_tabs = [
|
||||
['type' => 'synthesis', 'label' => __('综合', 'aksrt')],
|
||||
['type' => 'follow', 'label' => __('关注', 'aksrt')],
|
||||
['type' => 'plate', 'label' => $name_plate],
|
||||
];
|
||||
}
|
||||
?>
|
||||
|
||||
<main id="main-content" class="site-main content-shell" tabindex="-1">
|
||||
|
||||
<?php if (function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs(); } ?>
|
||||
|
||||
<header class="aksrt-forum-header container">
|
||||
<div class="aksrt-forum-header__content">
|
||||
<div class="aksrt-forum-header__eyebrow">
|
||||
<span class="aksrt-forum-header__eyebrow-pill"><i class="fas fa-comments"></i> <?php echo esc_html($name_forum); ?></span>
|
||||
<span class="aksrt-forum-header__eyebrow-meta"><?php printf(esc_html__('%1$d 个%2$s · %3$d 条%4$s', 'aksrt'), (int) ($stats['board_count'] ?? 0), esc_html($name_plate), (int) ($stats['topic_count'] ?? 0), esc_html($name_topic)); ?></span>
|
||||
</div>
|
||||
<h1 class="aksrt-forum-header__title"><?php echo esc_html(get_the_title() ?: __('社区论坛', 'aksrt')); ?></h1>
|
||||
<?php if (get_the_excerpt()) : ?>
|
||||
<p class="aksrt-forum-header__desc"><?php echo esc_html(get_the_excerpt()); ?></p>
|
||||
<?php else : ?>
|
||||
<p class="aksrt-forum-header__desc"><?php esc_html_e('围绕站点内容延展讨论、问答与经验分享,保留社区能力但回归主站内容流语义。', 'aksrt'); ?></p>
|
||||
<?php endif; ?>
|
||||
<div class="aksrt-forum-header__actions">
|
||||
<?php if (!empty($permissions['can_compose'])) : ?>
|
||||
<a class="aksrt-forum-header__action" href="<?php echo esc_url($compose_url); ?>">
|
||||
<i class="fas fa-pen"></i> <?php esc_html_e('发布主题', 'aksrt'); ?>
|
||||
</a>
|
||||
<?php elseif ($current_user_id <= 0) : ?>
|
||||
<a class="aksrt-forum-header__action" href="<?php echo esc_url(function_exists('aksrt_get_login_url') ? aksrt_get_login_url(get_permalink()) : wp_login_url(get_permalink())); ?>">
|
||||
<i class="fas fa-sign-in-alt"></i> <?php esc_html_e('登录后参与', 'aksrt'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<?php if (isset($_GET['compose_status']) && $_GET['compose_status'] === 'pending') : ?>
|
||||
<div class="aksrt-alert aksrt-alert--info" data-aksrt-flash-query="compose_status">
|
||||
<?php esc_html_e('你的主题已提交审核,审核通过后会在版块中展示。', 'aksrt'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="aksrt-forum container">
|
||||
<div class="content-wrap">
|
||||
<div class="content-layout content-layout--no-sidebar">
|
||||
<div class="content-layout__primary">
|
||||
<div class="aksrt-forum__layout">
|
||||
<div class="aksrt-forum__main">
|
||||
|
||||
<?php if (!empty($public_home_tabs)) : ?>
|
||||
<nav class="aksrt-forum-home-tabs" id="aksrt-forum-home-tabs"
|
||||
data-nonce="<?php echo esc_attr($nonce); ?>"
|
||||
data-ajax-url="<?php echo esc_attr(admin_url('admin-ajax.php')); ?>"
|
||||
aria-label="<?php esc_attr_e('论坛内容切换', 'aksrt'); ?>">
|
||||
<?php
|
||||
$rendered_types = [];
|
||||
foreach ($public_home_tabs as $tab) :
|
||||
$tab_type = sanitize_key($tab['type'] ?? 'synthesis');
|
||||
if ($tab_type === '' || isset($rendered_types[$tab_type])) {
|
||||
continue;
|
||||
}
|
||||
// plate 由下方统一按钮渲染,避免配置重复
|
||||
if ($tab_type === 'plate') {
|
||||
continue;
|
||||
}
|
||||
$rendered_types[$tab_type] = true;
|
||||
$tab_label = esc_html($tab['label'] ?? $tab_type);
|
||||
$is_active = $tab_type === $active_tab_type;
|
||||
?>
|
||||
<button type="button"
|
||||
class="aksrt-forum-home-tabs__btn<?php echo $is_active ? ' is-active' : ''; ?>"
|
||||
data-tab-type="<?php echo esc_attr($tab_type); ?>">
|
||||
<?php echo $tab_label; ?>
|
||||
</button>
|
||||
<?php endforeach; ?>
|
||||
<?php if (!empty($boards)) : ?>
|
||||
<button type="button"
|
||||
class="aksrt-forum-home-tabs__btn<?php echo $active_tab_type === 'plate' ? ' is-active' : ''; ?>"
|
||||
data-tab-type="plate">
|
||||
<?php echo esc_html($name_plate); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ($can_manage && (int) ($stats['pending_topic_count'] ?? 0) > 0) : ?>
|
||||
<a class="aksrt-forum-home-tabs__btn aksrt-forum-home-tabs__btn--secondary" href="<?php echo esc_url($admin_forum_url); ?>">
|
||||
<?php esc_html_e('审核', 'aksrt'); ?>
|
||||
<span class="aksrt-forum-home-tabs__badge"><?php echo esc_html((string) ($stats['pending_topic_count'] ?? 0)); ?></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="aksrt-forum-home-content" id="aksrt-forum-home-content">
|
||||
<?php if ($active_tab_type === 'plate') : ?>
|
||||
<?php if (!empty($boards)) : ?>
|
||||
<div class="aksrt-forum-boards__grid">
|
||||
<?php foreach ($boards as $board) :
|
||||
$board_id = (int) ($board['id'] ?? 0);
|
||||
?>
|
||||
<article class="aksrt-forum-board-card">
|
||||
<a class="aksrt-forum-board-card__link" href="<?php echo esc_url((string) ($board['url'] ?? '#')); ?>">
|
||||
<div class="aksrt-forum-board-card__icon">
|
||||
<?php if (!empty($board['thumbnail_url'])) : ?>
|
||||
<img src="<?php echo esc_url((string) $board['thumbnail_url']); ?>" alt="" width="48" height="48">
|
||||
<?php else : ?>
|
||||
<i class="<?php echo esc_attr((string) ($board['icon'] ?: 'fas fa-comments')); ?>"></i>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="aksrt-forum-board-card__body">
|
||||
<div class="aksrt-forum-board-card__head">
|
||||
<h3 class="aksrt-forum-board-card__title"><?php echo esc_html((string) ($board['name'] ?? '')); ?></h3>
|
||||
</div>
|
||||
<?php if (!empty($board['description'])) : ?>
|
||||
<p class="aksrt-forum-board-card__desc"><?php echo esc_html((string) $board['description']); ?></p>
|
||||
<?php endif; ?>
|
||||
<div class="aksrt-forum-board-card__meta">
|
||||
<span><i class="fas fa-file-alt"></i> <?php echo esc_html(number_format_i18n((int) ($board['topic_count'] ?? $board['post_count'] ?? 0))); ?></span>
|
||||
<span><i class="fas fa-comment"></i> <?php echo esc_html(number_format_i18n((int) ($board['reply_count'] ?? 0))); ?></span>
|
||||
<span><i class="fas fa-heart"></i> <?php echo esc_html(number_format_i18n((int) ($board['follow_count'] ?? 0))); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="aksrt-forum__empty">
|
||||
<i class="fas fa-comments"></i>
|
||||
<p><?php esc_html_e('当前还没有论坛版块。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php elseif ($active_tab_type === 'follow') : ?>
|
||||
<?php
|
||||
$follow_data = $forum ? $forum->get_follow_stream($current_user_id) : ['items' => []];
|
||||
if (!empty($follow_data['items'])) : ?>
|
||||
<div class="aksrt-forum-topics__list js-aksrt-home-topic-list">
|
||||
<?php foreach ($follow_data['items'] as $topic) { $forum->render_topic_row($topic); } ?>
|
||||
</div>
|
||||
<?php if ($follow_data['max_pages'] > 1) : ?>
|
||||
<div class="aksrt-forum-home__load-more">
|
||||
<button type="button" class="aksrt-forum-replies__more-btn js-aksrt-home-load-more"
|
||||
data-page="1" data-max="<?php echo esc_attr((string) $follow_data['max_pages']); ?>"
|
||||
data-tab="follow">
|
||||
<i class="fas fa-chevron-down"></i> <?php esc_html_e('加载更多', 'aksrt'); ?>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php elseif ($current_user_id > 0) : ?>
|
||||
<div class="aksrt-forum__empty">
|
||||
<i class="far fa-heart"></i>
|
||||
<p><?php esc_html_e('你还没有关注任何版块,去看看有哪些版块吧!', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="aksrt-forum__empty">
|
||||
<i class="fas fa-sign-in-alt"></i>
|
||||
<p><?php esc_html_e('登录后即可看到你关注的版块内容。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php else : /* synthesis (default) — pending 不在公开主内容区渲染 */ ?>
|
||||
<?php if (!empty($recent_topics)) : ?>
|
||||
<div class="aksrt-forum-topics__list js-aksrt-home-topic-list">
|
||||
<?php foreach ($recent_topics as $topic) {
|
||||
if ($forum) { $forum->render_topic_row($topic); }
|
||||
} ?>
|
||||
</div>
|
||||
<?php if ($synthesis_max > 1) : ?>
|
||||
<div class="aksrt-forum-home__load-more">
|
||||
<button type="button" class="aksrt-forum-replies__more-btn js-aksrt-home-load-more"
|
||||
data-page="1" data-max="<?php echo esc_attr((string) $synthesis_max); ?>" data-tab="synthesis">
|
||||
<i class="fas fa-chevron-down"></i> <?php esc_html_e('加载更多', 'aksrt'); ?>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php else : ?>
|
||||
<div class="aksrt-forum__empty">
|
||||
<i class="fas fa-feather-alt"></i>
|
||||
<p><?php esc_html_e('内容空空如也', 'aksrt'); ?></p>
|
||||
<?php if (!empty($permissions['can_compose'])) : ?>
|
||||
<a href="<?php echo esc_url($compose_url); ?>"><?php esc_html_e('发布第一个主题', 'aksrt'); ?></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<aside class="aksrt-forum__sidebar">
|
||||
<?php if ($quick_posts && !empty($permissions['can_compose'])) : ?>
|
||||
<div class="aksrt-forum-sidebar-card aksrt-forum-sidebar-card--compose">
|
||||
<a class="aksrt-forum-quick-post__input" href="<?php echo esc_url($compose_url); ?>">
|
||||
<?php echo get_avatar($current_user_id, 32); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<span><?php esc_html_e('分享你的想法…', 'aksrt'); ?></span>
|
||||
</a>
|
||||
</div>
|
||||
<?php elseif ($current_user_id <= 0) : ?>
|
||||
<div class="aksrt-forum-sidebar-card aksrt-forum-sidebar-card--compose">
|
||||
<a class="aksrt-forum-header__action" href="<?php echo esc_url(function_exists('aksrt_get_login_url') ? aksrt_get_login_url(get_permalink()) : wp_login_url(get_permalink())); ?>">
|
||||
<i class="fas fa-sign-in-alt"></i> <?php esc_html_e('登录后发帖', 'aksrt'); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="aksrt-forum-sidebar-card">
|
||||
<h3 class="aksrt-forum-sidebar-card__title">
|
||||
<i class="fas fa-fire"></i>
|
||||
<?php printf(esc_html__('热门%s', 'aksrt'), esc_html($name_topic)); ?>
|
||||
</h3>
|
||||
<?php if (!empty($hot_topics)) : ?>
|
||||
<ul class="aksrt-forum-sidebar-card__list">
|
||||
<?php foreach ($hot_topics as $index => $topic) : ?>
|
||||
<li class="aksrt-forum-sidebar-card__item">
|
||||
<span class="aksrt-forum-sidebar-card__rank"><?php echo esc_html((string) ($index + 1)); ?></span>
|
||||
<a href="<?php echo esc_url((string) ($topic['permalink'] ?? '#')); ?>" class="aksrt-forum-sidebar-card__link">
|
||||
<?php echo esc_html((string) ($topic['title'] ?? '')); ?>
|
||||
</a>
|
||||
<span class="aksrt-forum-sidebar-card__views"><?php echo esc_html(number_format_i18n((int) ($topic['views'] ?? 0))); ?></span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php else : ?>
|
||||
<p class="aksrt-forum-sidebar-card__empty"><?php esc_html_e('暂无热门主题', 'aksrt'); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($boards)) : ?>
|
||||
<div class="aksrt-forum-sidebar-card">
|
||||
<h3 class="aksrt-forum-sidebar-card__title">
|
||||
<i class="fas fa-th-list"></i>
|
||||
<?php echo esc_html($name_plate); ?>
|
||||
</h3>
|
||||
<ul class="aksrt-forum-sidebar-card__list">
|
||||
<?php foreach (array_slice($boards, 0, 8) as $board) : ?>
|
||||
<li class="aksrt-forum-sidebar-card__item">
|
||||
<a href="<?php echo esc_url((string) ($board['url'] ?? '#')); ?>" class="aksrt-forum-sidebar-card__link">
|
||||
<?php echo esc_html((string) ($board['name'] ?? '')); ?>
|
||||
</a>
|
||||
<span class="aksrt-forum-sidebar-card__views"><?php echo esc_html(number_format_i18n((int) ($board['topic_count'] ?? $board['post_count'] ?? 0))); ?></span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($can_manage && !empty($applications)) : ?>
|
||||
<div class="aksrt-forum-sidebar-card">
|
||||
<h3 class="aksrt-forum-sidebar-card__title">
|
||||
<i class="fas fa-shield-alt"></i>
|
||||
<?php esc_html_e('版主申请状态', 'aksrt'); ?>
|
||||
</h3>
|
||||
<ul class="aksrt-forum-sidebar-card__list aksrt-forum-sidebar-card__list--applications">
|
||||
<?php foreach ($applications as $board_id => $application) :
|
||||
if (!$application) continue;
|
||||
$board_name = '';
|
||||
foreach ($boards as $board) {
|
||||
if ((int) ($board['id'] ?? 0) === (int) $board_id) {
|
||||
$board_name = (string) ($board['name'] ?? '');
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<li class="aksrt-forum-sidebar-card__item aksrt-forum-sidebar-card__item--stack">
|
||||
<strong><?php echo esc_html($board_name); ?></strong>
|
||||
<span><?php echo esc_html((string) ($application['status_label'] ?? '')); ?></span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (is_active_sidebar('bbs_home_sidebar')) : ?>
|
||||
<div class="aksrt-forum-widget-zone">
|
||||
<?php dynamic_sidebar('bbs_home_sidebar'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php get_footer(); ?>
|
||||
@@ -65,7 +65,6 @@ require_once AKSRT_DIR . '/templates/parts/user-shared-helpers.php';
|
||||
|
||||
<?php
|
||||
get_template_part('templates/parts/user-home/panels', 'core', $ctx);
|
||||
get_template_part('templates/parts/user-home/panel', 'forum', $ctx);
|
||||
get_template_part('templates/parts/user-home/panel', 'follow', $ctx);
|
||||
?>
|
||||
</div>
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Public user home — forum tab panel.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$args = is_array($args ?? null) ? $args : [];
|
||||
extract($args, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
|
||||
|
||||
?>
|
||||
<?php if (in_array('forum', $enabled_tabs, true)) : ?>
|
||||
<div id="panel-forum" class="dashboard-panel<?php echo $active_tab === 'forum' ? ' is-active' : ''; ?>" role="tabpanel"<?php echo $active_tab !== 'forum' ? ' hidden' : ''; ?>>
|
||||
<div class="uh-forum__section-head">
|
||||
<div>
|
||||
<h2 class="uh-forum__section-title-main"><?php esc_html_e('论坛内容', 'aksrt'); ?></h2>
|
||||
<p class="uh-forum__section-desc"><?php esc_html_e('在用户主页中保留论坛维度,但仍以内容流和身份展示为主。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<a class="uh-forum__section-link" href="<?php echo esc_url(aksrt_get_forum_home_url()); ?>"><?php esc_html_e('进入社区', 'aksrt'); ?></a>
|
||||
</div>
|
||||
<?php
|
||||
$forum_page = max(1, isset($_GET['forum_page']) ? (int) $_GET['forum_page'] : 1);
|
||||
$forum_sub = isset($_GET['forum_sub']) ? sanitize_key(wp_unslash($_GET['forum_sub'])) : 'topics';
|
||||
$forum_sub = in_array($forum_sub, ['topics', 'favorites', 'plates'], true) ? $forum_sub : 'topics';
|
||||
?>
|
||||
<div class="uh-forum__subtabs">
|
||||
<a class="uh-forum__subtab<?php echo $forum_sub === 'topics' ? ' is-active' : ''; ?>"
|
||||
href="<?php echo esc_url(add_query_arg(['tab' => 'forum', 'forum_sub' => 'topics', 'forum_page' => 1], $home_url)); ?>">
|
||||
<i class="fas fa-file-alt"></i> <?php esc_html_e('帖子', 'aksrt'); ?>
|
||||
<span class="uh-forum__subtab-count"><?php echo esc_html((string) $forum_topic_count); ?></span>
|
||||
</a>
|
||||
<a class="uh-forum__subtab<?php echo $forum_sub === 'favorites' ? ' is-active' : ''; ?>"
|
||||
href="<?php echo esc_url(add_query_arg(['tab' => 'forum', 'forum_sub' => 'favorites', 'forum_page' => 1], $home_url)); ?>">
|
||||
<i class="fas fa-star"></i> <?php esc_html_e('收藏帖子', 'aksrt'); ?>
|
||||
<span class="uh-forum__subtab-count"><?php echo esc_html((string) ($forum_stats['favorite_count'] ?? 0)); ?></span>
|
||||
</a>
|
||||
<a class="uh-forum__subtab<?php echo $forum_sub === 'plates' ? ' is-active' : ''; ?>"
|
||||
href="<?php echo esc_url(add_query_arg(['tab' => 'forum', 'forum_sub' => 'plates', 'forum_page' => 1], $home_url)); ?>">
|
||||
<i class="fas fa-th-large"></i> <?php esc_html_e('版块', 'aksrt'); ?>
|
||||
<span class="uh-forum__subtab-count"><?php echo esc_html((string) ($forum_stats['managed_plate_count'] ?? 0)); ?></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?php if ($forum_sub === 'topics' && $forum_instance) :
|
||||
$forum_topics = $forum_instance->get_user_forum_topics($user_id, ['page' => $forum_page, 'limit' => $per_page]);
|
||||
if (!empty($forum_topics['items'])) : ?>
|
||||
<div class="uh-forum__list">
|
||||
<?php foreach ($forum_topics['items'] as $ft) : ?>
|
||||
<div class="uh-forum__item">
|
||||
<div class="uh-forum__item-body">
|
||||
<a class="uh-forum__item-title" href="<?php echo esc_url(get_permalink((int) ($ft['id'] ?? 0))); ?>">
|
||||
<?php echo esc_html((string) ($ft['title'] ?? '')); ?>
|
||||
</a>
|
||||
<div class="uh-forum__item-meta">
|
||||
<span><i class="far fa-eye"></i> <?php echo esc_html((string) ($ft['views'] ?? 0)); ?></span>
|
||||
<span><i class="far fa-comment"></i> <?php echo esc_html((string) ($ft['comment_count'] ?? 0)); ?></span>
|
||||
<time><?php echo esc_html((string) ($ft['date'] ?? '')); ?></time>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php if ($forum_topics['max_pages'] > 1) : ?>
|
||||
<div class="uh-forum__pagination">
|
||||
<?php
|
||||
echo paginate_links([
|
||||
'base' => add_query_arg('forum_page', '%#%', $home_url),
|
||||
'format' => '',
|
||||
'current' => $forum_page,
|
||||
'total' => $forum_topics['max_pages'],
|
||||
'add_args' => ['tab' => 'forum', 'forum_sub' => 'topics'],
|
||||
]);
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php else : ?>
|
||||
<?php aksrt_render_profile_empty($svg_empty_post, __('暂无论坛帖子', 'aksrt')); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php elseif ($forum_sub === 'favorites' && $forum_instance) :
|
||||
$fav_topics = $forum_instance->get_user_favorite_topics($user_id, $forum_page, $per_page);
|
||||
if (!empty($fav_topics['items'])) : ?>
|
||||
<div class="uh-forum__list">
|
||||
<?php foreach ($fav_topics['items'] as $ft) : ?>
|
||||
<div class="uh-forum__item">
|
||||
<div class="uh-forum__item-body">
|
||||
<a class="uh-forum__item-title" href="<?php echo esc_url(get_permalink((int) ($ft['id'] ?? 0))); ?>">
|
||||
<?php echo esc_html((string) ($ft['title'] ?? '')); ?>
|
||||
</a>
|
||||
<div class="uh-forum__item-meta">
|
||||
<span><i class="far fa-eye"></i> <?php echo esc_html((string) ($ft['views'] ?? 0)); ?></span>
|
||||
<span><i class="far fa-comment"></i> <?php echo esc_html((string) ($ft['comment_count'] ?? 0)); ?></span>
|
||||
<time><?php echo esc_html((string) ($ft['date'] ?? '')); ?></time>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php if ($fav_topics['max_pages'] > 1) : ?>
|
||||
<div class="uh-forum__pagination">
|
||||
<?php
|
||||
echo paginate_links([
|
||||
'base' => add_query_arg('forum_page', '%#%', $home_url),
|
||||
'format' => '',
|
||||
'current' => $forum_page,
|
||||
'total' => $fav_topics['max_pages'],
|
||||
'add_args' => ['tab' => 'forum', 'forum_sub' => 'favorites'],
|
||||
]);
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php else : ?>
|
||||
<?php aksrt_render_profile_empty($svg_empty_favorite, __('暂无收藏帖子', 'aksrt')); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php elseif ($forum_sub === 'plates' && $forum_instance) :
|
||||
$managed_plates = $forum_instance->get_user_managed_plates($user_id);
|
||||
$followed_plates = $forum_instance->get_user_followed_plates($user_id);
|
||||
$has_plates = !empty($managed_plates['owned']) || !empty($managed_plates['moderating']) || !empty($followed_plates);
|
||||
if ($has_plates) : ?>
|
||||
<?php if (!empty($managed_plates['owned'])) : ?>
|
||||
<h3 class="uh-forum__section-title"><i class="fas fa-crown"></i> <?php esc_html_e('创建的版块', 'aksrt'); ?></h3>
|
||||
<div class="uh-forum__plate-grid">
|
||||
<?php foreach ($managed_plates['owned'] as $plate) : ?>
|
||||
<a class="uh-forum__plate-card" href="<?php echo esc_url(get_permalink((int) ($plate['id'] ?? 0))); ?>">
|
||||
<div class="uh-forum__plate-name"><?php echo esc_html((string) ($plate['name'] ?? '')); ?></div>
|
||||
<div class="uh-forum__plate-stats">
|
||||
<span><?php printf(esc_html__('%d 帖子', 'aksrt'), (int) ($plate['topic_count'] ?? 0)); ?></span>
|
||||
<span><?php printf(esc_html__('%d 关注', 'aksrt'), (int) ($plate['follow_count'] ?? 0)); ?></span>
|
||||
</div>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($managed_plates['moderating'])) : ?>
|
||||
<h3 class="uh-forum__section-title"><i class="fas fa-shield-alt"></i> <?php esc_html_e('管理的版块', 'aksrt'); ?></h3>
|
||||
<div class="uh-forum__plate-grid">
|
||||
<?php foreach ($managed_plates['moderating'] as $plate) : ?>
|
||||
<a class="uh-forum__plate-card" href="<?php echo esc_url(get_permalink((int) ($plate['id'] ?? 0))); ?>">
|
||||
<div class="uh-forum__plate-name"><?php echo esc_html((string) ($plate['name'] ?? '')); ?></div>
|
||||
<div class="uh-forum__plate-stats">
|
||||
<span><?php printf(esc_html__('%d 帖子', 'aksrt'), (int) ($plate['topic_count'] ?? 0)); ?></span>
|
||||
</div>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($followed_plates)) : ?>
|
||||
<h3 class="uh-forum__section-title"><i class="fas fa-heart"></i> <?php esc_html_e('关注的版块', 'aksrt'); ?></h3>
|
||||
<div class="uh-forum__plate-grid">
|
||||
<?php foreach ($followed_plates as $plate) : ?>
|
||||
<a class="uh-forum__plate-card" href="<?php echo esc_url(get_permalink((int) ($plate['id'] ?? 0))); ?>">
|
||||
<div class="uh-forum__plate-name"><?php echo esc_html((string) ($plate['name'] ?? '')); ?></div>
|
||||
<div class="uh-forum__plate-stats">
|
||||
<span><?php printf(esc_html__('%d 帖子', 'aksrt'), (int) ($plate['topic_count'] ?? 0)); ?></span>
|
||||
<span><?php printf(esc_html__('%d 关注', 'aksrt'), (int) ($plate['follow_count'] ?? 0)); ?></span>
|
||||
</div>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php else : ?>
|
||||
<?php aksrt_render_profile_empty($svg_empty_post, __('暂无版块数据', 'aksrt')); ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
@@ -130,92 +130,3 @@ extract($args, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_ext
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (in_array('product', $enabled_tabs, true)) : ?>
|
||||
<div id="panel-product" class="dashboard-panel<?php echo $active_tab === 'product' ? ' is-active' : ''; ?>" role="tabpanel"<?php echo $active_tab !== 'product' ? ' hidden' : ''; ?>>
|
||||
<?php
|
||||
$product_page = max(1, isset($_GET['product_page']) ? (int) $_GET['product_page'] : 1);
|
||||
$product_view = ['items' => [], 'total' => 0, 'max_pages' => 0];
|
||||
if (class_exists('\AKSRT\Shop\Shop')) {
|
||||
$product_view = \AKSRT\Shop\Shop::get_instance()->get_store_products((int) $user_id, $product_page, (int) $per_page);
|
||||
}
|
||||
$product_items = is_array($product_view['items'] ?? null) ? $product_view['items'] : [];
|
||||
$product_max_pages = (int) ($product_view['max_pages'] ?? 0);
|
||||
if (!empty($product_items)) :
|
||||
?>
|
||||
<div class="aksrt-product-archive__grid aksrt-product-archive__grid--default uh-product-grid">
|
||||
<?php foreach ($product_items as $product) :
|
||||
get_template_part('templates/parts/shop/product', 'card', [
|
||||
'product' => $product,
|
||||
'show_sales' => ((int) ($product['sales'] ?? 0) > 0),
|
||||
]);
|
||||
endforeach; ?>
|
||||
</div>
|
||||
<?php if ($product_max_pages > 1 && function_exists('aksrt_render_profile_pagination')) : ?>
|
||||
<?php aksrt_render_profile_pagination($product_max_pages, $product_page, 'product_page'); ?>
|
||||
<?php elseif ($product_max_pages > 1) : ?>
|
||||
<?php
|
||||
echo paginate_links([
|
||||
'base' => add_query_arg(['tab' => 'product', 'product_page' => '%#%'], $home_url),
|
||||
'format' => '',
|
||||
'current' => $product_page,
|
||||
'total' => $product_max_pages,
|
||||
'add_args' => ['tab' => 'product'],
|
||||
]);
|
||||
?>
|
||||
<?php endif; ?>
|
||||
<?php else : ?>
|
||||
<?php aksrt_render_profile_empty($svg_empty_post, __('暂无商品内容', 'aksrt')); ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (in_array('plate', $enabled_tabs, true)) : ?>
|
||||
<div id="panel-plate" class="dashboard-panel<?php echo $active_tab === 'plate' ? ' is-active' : ''; ?>" role="tabpanel"<?php echo $active_tab !== 'plate' ? ' hidden' : ''; ?>>
|
||||
<?php
|
||||
$plate_items = [];
|
||||
if ($forum_instance) {
|
||||
if (method_exists($forum_instance, 'get_user_followed_plates')) {
|
||||
$plate_items = array_merge($plate_items, (array) $forum_instance->get_user_followed_plates((int) $user_id));
|
||||
}
|
||||
if (method_exists($forum_instance, 'get_user_managed_plates')) {
|
||||
$managed = (array) $forum_instance->get_user_managed_plates((int) $user_id);
|
||||
foreach (['owned', 'moderating'] as $bucket) {
|
||||
foreach ((array) ($managed[$bucket] ?? []) as $plate) {
|
||||
$plate_items[] = $plate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// de-dupe by id
|
||||
$seen = [];
|
||||
$unique_plates = [];
|
||||
foreach ($plate_items as $plate) {
|
||||
$pid = (int) ($plate['id'] ?? 0);
|
||||
if ($pid <= 0 || isset($seen[$pid])) {
|
||||
continue;
|
||||
}
|
||||
$seen[$pid] = true;
|
||||
$unique_plates[] = $plate;
|
||||
}
|
||||
if (!empty($unique_plates)) :
|
||||
?>
|
||||
<div class="uh-forum__plate-grid">
|
||||
<?php foreach ($unique_plates as $plate) :
|
||||
$purl = !empty($plate['url']) ? (string) $plate['url'] : get_permalink((int) ($plate['id'] ?? 0));
|
||||
?>
|
||||
<a class="uh-forum__plate-card" href="<?php echo esc_url((string) $purl); ?>">
|
||||
<div class="uh-forum__plate-name"><?php echo esc_html((string) ($plate['name'] ?? '')); ?></div>
|
||||
<div class="uh-forum__plate-stats">
|
||||
<span><?php printf(esc_html__('%d 帖子', 'aksrt'), (int) ($plate['topic_count'] ?? $plate['post_count'] ?? 0)); ?></span>
|
||||
<span><?php printf(esc_html__('%d 关注', 'aksrt'), (int) ($plate['follow_count'] ?? 0)); ?></span>
|
||||
</div>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php else :
|
||||
aksrt_render_profile_empty($svg_empty_post, __('暂无圈子内容', 'aksrt'));
|
||||
endif;
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
Reference in new issue
Block a user