Merge pull request 'feat(forum): 论坛首页壳层收束 降 stats/pending/治理感' (#72) from worktree-forum-shell-1to1 into main
Reviewed-on: CYL/wordpress-theme-aksrt#72
This commit is contained in:
@@ -2,3 +2,31 @@
|
||||
@import url("forum/topic.css");
|
||||
@import url("forum/compose.css");
|
||||
@import url("forum/extras.css");
|
||||
|
||||
|
||||
/* Forum home shell: sidebar compose CTA */
|
||||
.aksrt-forum-sidebar-card--compose {
|
||||
padding: 12px;
|
||||
}
|
||||
.aksrt-forum-sidebar-card--compose .aksrt-forum-quick-post__input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
padding: 10px 12px;
|
||||
border-radius: 10px;
|
||||
background: var(--body-bg-color, #f5f6f7);
|
||||
color: var(--muted-color, #777);
|
||||
text-decoration: none;
|
||||
}
|
||||
.aksrt-forum-sidebar-card--compose .aksrt-forum-quick-post__input:hover {
|
||||
color: var(--focus-color, #f04494);
|
||||
}
|
||||
.aksrt-forum-sidebar-card--compose .aksrt-forum-header__action {
|
||||
display: inline-flex;
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
}
|
||||
.aksrt-forum-header__stats {
|
||||
display: none; /* stats demoted on home shell; counts remain in eyebrow meta */
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Template Name: AKSRT - Forums
|
||||
* Template Post Type: page
|
||||
*
|
||||
* §7.10 — Tab engine + quick post + plate grid + follow/synthesis/pending streams.
|
||||
* §7.10 / stream-h §3 — 主站社区首页:公开 tabs + 侧栏发帖/热门,pending 不进公开主内容。
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
@@ -57,6 +57,32 @@ if ($active_tab_type === '' && isset($home_tabs[$active_index])) {
|
||||
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">
|
||||
@@ -77,42 +103,16 @@ if ($active_tab_type === '') {
|
||||
<?php endif; ?>
|
||||
<div class="aksrt-forum-header__actions">
|
||||
<?php if (!empty($permissions['can_compose'])) : ?>
|
||||
<a class="aksrt-forum-header__action aksrt-forum-header__action--primary" href="<?php echo esc_url($compose_url); ?>">
|
||||
<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 else : ?>
|
||||
<a class="aksrt-forum-header__action aksrt-forum-header__action--primary" href="<?php echo esc_url(wp_login_url(get_permalink())); ?>">
|
||||
<i class="fas fa-sign-in-alt"></i> <?php esc_html_e('登录后发帖', 'aksrt'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($permissions['can_manage'])) : ?>
|
||||
<a class="aksrt-forum-header__action" href="<?php echo esc_url($admin_forum_url); ?>">
|
||||
<i class="fas fa-tools"></i> <?php esc_html_e('进入治理后台', 'aksrt'); ?>
|
||||
<?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>
|
||||
|
||||
<div class="aksrt-forum-header__stats">
|
||||
<div class="aksrt-forum-header__stat is-active">
|
||||
<span class="aksrt-forum-header__stat-num"><?php echo esc_html(number_format_i18n((int) ($stats['topic_count'] ?? 0))); ?></span>
|
||||
<span class="aksrt-forum-header__stat-label"><?php echo esc_html($name_topic); ?></span>
|
||||
</div>
|
||||
<div class="aksrt-forum-header__stat">
|
||||
<span class="aksrt-forum-header__stat-num"><?php echo esc_html(number_format_i18n((int) ($stats['post_count'] ?? 0))); ?></span>
|
||||
<span class="aksrt-forum-header__stat-label"><?php echo esc_html($name_reply); ?></span>
|
||||
</div>
|
||||
<div class="aksrt-forum-header__stat">
|
||||
<span class="aksrt-forum-header__stat-num"><?php echo esc_html(number_format_i18n((int) ($stats['board_count'] ?? 0))); ?></span>
|
||||
<span class="aksrt-forum-header__stat-label"><?php echo esc_html($name_plate); ?></span>
|
||||
</div>
|
||||
<?php if ((int) ($stats['pending_topic_count'] ?? 0) > 0 && !empty($permissions['can_manage'])) : ?>
|
||||
<div class="aksrt-forum-header__stat aksrt-forum-header__stat--muted">
|
||||
<span class="aksrt-forum-header__stat-num"><?php echo esc_html(number_format_i18n((int) ($stats['pending_topic_count'] ?? 0))); ?></span>
|
||||
<span class="aksrt-forum-header__stat-label"><?php esc_html_e('待审核', 'aksrt'); ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<?php if (isset($_GET['compose_status']) && $_GET['compose_status'] === 'pending') : ?>
|
||||
@@ -128,26 +128,25 @@ if ($active_tab_type === '') {
|
||||
<div class="aksrt-forum__layout">
|
||||
<div class="aksrt-forum__main">
|
||||
|
||||
<?php if ($quick_posts && !empty($permissions['can_compose'])) : ?>
|
||||
<div class="aksrt-forum-quick-post">
|
||||
<a class="aksrt-forum-quick-post__input" href="<?php echo esc_url($compose_url); ?>">
|
||||
<?php echo get_avatar($current_user_id, 32); ?>
|
||||
<span><?php esc_html_e('分享你的想法…', 'aksrt'); ?></span>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($home_tabs)) : ?>
|
||||
<?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')); ?>">
|
||||
<?php foreach ($home_tabs as $i => $tab) :
|
||||
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');
|
||||
$tab_label = esc_html($tab['label'] ?? $tab_type);
|
||||
$is_active = $tab_type === $active_tab_type;
|
||||
if ($tab_type === 'pending' || ($tab_type === 'plate' && !empty($boards))) {
|
||||
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' : ''; ?>"
|
||||
@@ -162,9 +161,9 @@ if ($active_tab_type === '') {
|
||||
<?php echo esc_html($name_plate); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($permissions['can_manage']) && (int) ($stats['pending_topic_count'] ?? 0) > 0) : ?>
|
||||
<?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'); ?>
|
||||
<?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; ?>
|
||||
@@ -239,21 +238,7 @@ if ($active_tab_type === '') {
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php elseif ($active_tab_type === 'pending') : ?>
|
||||
<?php
|
||||
$pending_data = $forum ? $forum->get_pending_stream($current_user_id) : ['items' => []];
|
||||
if (!empty($pending_data['items'])) : ?>
|
||||
<div class="aksrt-forum-topics__list js-aksrt-home-topic-list">
|
||||
<?php foreach ($pending_data['items'] as $topic) { $forum->render_topic_row($topic); } ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="aksrt-forum__empty">
|
||||
<i class="fas fa-check-circle"></i>
|
||||
<p><?php esc_html_e('没有待审核的主题。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php else : /* synthesis (default) */ ?>
|
||||
<?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) {
|
||||
@@ -282,6 +267,21 @@ if ($active_tab_type === '') {
|
||||
</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>
|
||||
@@ -323,7 +323,7 @@ if ($active_tab_type === '') {
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($applications)) : ?>
|
||||
<?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>
|
||||
|
||||
Reference in New Issue
Block a user