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,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