Files
wordpress-theme-aksrt/templates/pages/page-user-home.php
T

564 lines
26 KiB
PHP

<?php
/**
* Public user homepage template.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
get_header();
$target_user_nicename = get_query_var('user_nicename');
$user = $target_user_nicename ? get_user_by('slug', $target_user_nicename) : null;
if (!$user) {
wp_safe_redirect(home_url('/'));
exit;
}
$user_id = (int) $user->ID;
// 数据聚合:复用共享 helper
$dashboard = function_exists('aksrt_get_user_dashboard_view')
? aksrt_get_user_dashboard_view($user_id, ['viewer_id' => get_current_user_id()])
: [];
$is_own_profile = !empty($dashboard['is_own_profile']);
$user_home_settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_user_home_settings()
: [
'tabs' => ['posts', 'comments', 'favorites'],
'sidebar' => true,
'cover' => true,
'follow' => true,
'posts_per_page' => 10,
];
$post_count = (int) ($dashboard['post_count'] ?? 0);
$comment_count = (int) ($dashboard['comment_count'] ?? 0);
$favorite_post_ids = $dashboard['favorite_post_ids'] ?? [];
$favorite_count = (int) ($dashboard['favorite_count'] ?? 0);
$user_contacts = $dashboard['user_contacts'] ?? [];
$user_center_settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_user_center_settings()
: ['social_links' => true];
$per_page = (int) $user_home_settings['posts_per_page'];
$credits_enabled = !empty($dashboard['credits_enabled']);
$credit_balance = $dashboard['credit_balance'] ?? 0.0;
$currency_name = $dashboard['currency_name'] ?? __('积分', 'aksrt');
$user_home_manager = class_exists('AKSRT_User_Home') ? AKSRT_User_Home::get_instance() : null;
$visible_tabs = $user_home_manager ? $user_home_manager->get_visible_tabs($is_own_profile) : [];
$profile_signals = $dashboard['profile_signals'] ?? [];
$profile_notice = $dashboard['profile_notice'] ?? null;
$show_report_button = !empty($dashboard['show_report']);
$enabled_tabs = array_keys($visible_tabs);
if (empty($enabled_tabs)) {
$enabled_tabs = ['posts', 'comments', 'favorites'];
}
// Apply admin-configured display order
$_uh_order = $user_home_settings['tabs_order'] ?? [];
$_uh_ordered = [];
foreach ($_uh_order as $_t) {
if (in_array($_t, $enabled_tabs, true)) {
$_uh_ordered[] = $_t;
}
}
foreach ($enabled_tabs as $_t) {
if (!in_array($_t, $_uh_ordered, true)) {
$_uh_ordered[] = $_t;
}
}
$enabled_tabs = $_uh_ordered;
// Device visibility: build PC/mobile tab arrays
$_uh_pc_hide = $user_home_settings['tabs_pc_hide'] ?? [];
$_uh_mobile_hide = $user_home_settings['tabs_mobile_hide'] ?? [];
$enabled_tabs_pc = array_values(array_diff($enabled_tabs, $_uh_pc_hide));
$enabled_tabs_mobile = array_values(array_diff($enabled_tabs, $_uh_mobile_hide));
$_uh_is_mobile = function_exists('wp_is_mobile') && wp_is_mobile();
$display_tabs = $_uh_is_mobile ? $enabled_tabs_mobile : $enabled_tabs_pc;
$_uh_default_tab = !empty($display_tabs) ? $display_tabs[0] : $enabled_tabs[0];
$forum_instance = class_exists('AKSRT_Forum') ? AKSRT_Forum::get_instance() : null;
$forum_stats = $forum_instance ? $forum_instance->get_user_forum_stats($user_id) : [];
$forum_topic_count = (int) ($forum_stats['topic_count'] ?? 0);
$forum_followed_count = (int) ($forum_stats['followed_plate_count'] ?? 0);
$tab_counts = [
'posts' => $post_count,
'comments' => $comment_count,
'favorites' => $favorite_count,
'credits' => $credits_enabled && $is_own_profile ? (int) round($credit_balance) : 0,
'product' => 0,
'plate' => 0,
'forum' => $forum_topic_count,
'follow' => $forum_followed_count,
];
$tab_labels = [
'posts' => __('文章', 'aksrt'),
'comments' => __('评论', 'aksrt'),
'favorites' => __('收藏', 'aksrt'),
'credits' => sprintf(__('我的%s', 'aksrt'), $currency_name),
'product' => __('商品', 'aksrt'),
'plate' => __('圈子', 'aksrt'),
'forum' => __('论坛', 'aksrt'),
'follow' => __('关注', 'aksrt'),
];
foreach ($visible_tabs as $tab_key => $tab_config) {
if (!empty($tab_config['label'])) {
$tab_labels[$tab_key] = (string) $tab_config['label'];
}
}
$active_tab = isset($_GET['tab']) ? sanitize_key(wp_unslash($_GET['tab'])) : $_uh_default_tab;
if (!in_array($active_tab, $enabled_tabs, true)) {
$active_tab = $_uh_default_tab;
}
$posts_page = max(1, isset($_GET['posts_page']) ? (int) $_GET['posts_page'] : 1);
$comments_page = max(1, isset($_GET['comments_page']) ? (int) $_GET['comments_page'] : 1);
$favorites_page = max(1, isset($_GET['favorites_page']) ? (int) $_GET['favorites_page'] : 1);
require_once AKSRT_DIR . '/templates/parts/user-shared-helpers.php';
$svg_empty_post = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6"/><path d="M9 13h6M9 17h6M9 9h1"/></svg>';
$svg_empty_comment = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>';
$svg_empty_favorite = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>';
$home_url = function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url($user) : home_url('/');
?>
<main id="main-content" class="site-main content-shell" tabindex="-1">
<div class="content-layout<?php echo !empty($user_home_settings['sidebar']) ? '' : ' content-layout--no-sidebar'; ?> aksrt-user-home__layout">
<div class="content-layout__primary">
<?php
// 作者 Hero 区:共享 partial
set_query_var('user', $user);
set_query_var('dashboard', $dashboard);
set_query_var('user_home_settings', $user_home_settings);
set_query_var('is_author_page', false);
get_template_part('templates/parts/user/author-hero');
?>
<div class="dashboard dashboard--public" data-default-tab="<?php echo esc_attr($_uh_default_tab); ?>">
<div class="dashboard-tabs" role="tablist">
<?php foreach ($enabled_tabs as $tab_key) :
$_tab_class = $tab_key === $active_tab ? 'is-active' : '';
$_pc_hidden = in_array($tab_key, $_uh_pc_hide, true);
$_mobile_hidden = in_array($tab_key, $_uh_mobile_hide, true);
if ($_pc_hidden) $_tab_class .= ' tab-hide-pc';
if ($_mobile_hidden) $_tab_class .= ' tab-hide-mobile';
?>
<button type="button" class="<?php echo esc_attr(trim($_tab_class)); ?>" data-tab="<?php echo esc_attr($tab_key); ?>" role="tab">
<?php echo esc_html($tab_labels[$tab_key] ?? ucfirst($tab_key)); ?>
<span class="dashboard-tabs__count"><?php echo esc_html((string) ($tab_counts[$tab_key] ?? 0)); ?></span>
</button>
<?php endforeach; ?>
</div>
<?php if (in_array('posts', $enabled_tabs, true)) : ?>
<div id="panel-posts" class="dashboard-panel<?php echo $active_tab === 'posts' ? ' is-active' : ''; ?>" role="tabpanel"<?php echo $active_tab !== 'posts' ? ' hidden' : ''; ?>>
<?php
$author_posts = new WP_Query([
'author' => $user_id,
'posts_per_page' => $per_page,
'post_status' => 'publish',
'paged' => $posts_page,
'no_found_rows' => false,
'update_post_meta_cache' => false,
]);
if ($author_posts->have_posts()) :
?>
<div class="profile-list">
<?php while ($author_posts->have_posts()) : $author_posts->the_post(); ?>
<?php
set_query_var('aksrt_profile_item_action', [
'type' => 'view',
'url' => get_permalink(),
'label' => __('阅读', 'aksrt'),
]);
set_query_var('aksrt_profile_item_status', '');
get_template_part('templates/parts/content', 'profile-list-item');
?>
<?php endwhile; ?>
</div>
<?php
aksrt_render_profile_pagination((int) $author_posts->max_num_pages, $posts_page, 'posts_page');
wp_reset_postdata();
set_query_var('aksrt_profile_item_action', []);
else :
aksrt_render_profile_empty($svg_empty_post, __('TA 还没有发布文章', 'aksrt'));
endif;
?>
</div>
<?php endif; ?>
<?php if (in_array('comments', $enabled_tabs, true)) : ?>
<div id="panel-comments" class="dashboard-panel<?php echo $active_tab === 'comments' ? ' is-active' : ''; ?>" role="tabpanel"<?php echo $active_tab !== 'comments' ? ' hidden' : ''; ?>>
<?php
$user_comments = get_comments([
'user_id' => $user_id,
'status' => 'approve',
'number' => $per_page,
'offset' => ($comments_page - 1) * $per_page,
'type' => 'comment',
'update_comment_meta_cache' => false,
]);
if ($user_comments) :
?>
<div class="profile-comment-list">
<?php foreach ($user_comments as $c) : ?>
<?php
set_query_var('aksrt_profile_comment', $c);
get_template_part('templates/parts/content', 'profile-comment-item');
?>
<?php endforeach; ?>
<?php set_query_var('aksrt_profile_comment', null); ?>
</div>
<?php
$cm_total_pages = (int) ceil($comment_count / $per_page);
aksrt_render_profile_pagination($cm_total_pages, $comments_page, 'comments_page');
else :
aksrt_render_profile_empty($svg_empty_comment, __('TA 还没有发表评论', 'aksrt'));
endif;
?>
</div>
<?php endif; ?>
<?php if (in_array('favorites', $enabled_tabs, true)) : ?>
<div id="panel-favorites" class="dashboard-panel<?php echo $active_tab === 'favorites' ? ' is-active' : ''; ?>" role="tabpanel"<?php echo $active_tab !== 'favorites' ? ' hidden' : ''; ?>>
<?php if (!empty($favorite_post_ids)) : ?>
<?php
$favorites_query = new WP_Query([
'post_type' => 'post',
'post_status' => 'publish',
'post__in' => $favorite_post_ids,
'orderby' => 'post__in',
'posts_per_page' => $per_page,
'paged' => $favorites_page,
'ignore_sticky_posts' => true,
'no_found_rows' => false,
'update_post_meta_cache' => false,
]);
if ($favorites_query->have_posts()) :
?>
<div class="profile-list">
<?php while ($favorites_query->have_posts()) : $favorites_query->the_post(); ?>
<?php
set_query_var('aksrt_profile_item_action', [
'type' => 'view',
'url' => get_permalink(),
'label' => __('阅读', 'aksrt'),
]);
set_query_var('aksrt_profile_item_status', '');
get_template_part('templates/parts/content', 'profile-list-item');
?>
<?php endwhile; ?>
</div>
<?php
aksrt_render_profile_pagination((int) $favorites_query->max_num_pages, $favorites_page, 'favorites_page');
wp_reset_postdata();
set_query_var('aksrt_profile_item_action', []);
else :
aksrt_render_profile_empty($svg_empty_favorite, __('TA 还没有收藏文章', 'aksrt'));
endif;
?>
<?php else : ?>
<?php aksrt_render_profile_empty($svg_empty_favorite, __('TA 还没有收藏文章', 'aksrt')); ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if (in_array('credits', $enabled_tabs, true) && $credits_enabled && $is_own_profile) : ?>
<div id="panel-credits" class="dashboard-panel<?php echo $active_tab === 'credits' ? ' is-active' : ''; ?>" role="tabpanel"<?php echo $active_tab !== 'credits' ? ' hidden' : ''; ?>>
<div class="user-home-balance-card">
<p class="user-home-balance-card__label"><?php echo esc_html(sprintf(__('当前%s余额', 'aksrt'), $currency_name)); ?></p>
<div class="user-home-balance-card__value"><?php echo esc_html(aksrt_format_credits($credit_balance)); ?></div>
<p class="user-home-balance-card__hint"><?php esc_html_e('完整账单和赚取/消费记录请在个人中心查看。', 'aksrt'); ?></p>
<a href="<?php echo esc_url(aksrt_get_user_center_url('credits')); ?>" class="btn-outline btn-sm"><?php esc_html_e('进入个人中心', 'aksrt'); ?></a>
</div>
</div>
<?php endif; ?>
<?php
// Placeholder panels for extended tabs (product, plate)
$_uh_extended_tabs = ['product', 'plate'];
$_uh_placeholder_msgs = [
'product' => __('暂无商品内容', 'aksrt'),
'plate' => __('暂无圈子内容', 'aksrt'),
];
foreach ($_uh_extended_tabs as $_uh_ext) :
if (!in_array($_uh_ext, $enabled_tabs, true)) continue;
?>
<div id="panel-<?php echo esc_attr($_uh_ext); ?>" class="dashboard-panel<?php echo $active_tab === $_uh_ext ? ' is-active' : ''; ?>" role="tabpanel"<?php echo $active_tab !== $_uh_ext ? ' hidden' : ''; ?>>
<?php aksrt_render_profile_empty($svg_empty_post, $_uh_placeholder_msgs[$_uh_ext]); ?>
</div>
<?php endforeach; ?>
<?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(home_url('/forums/')); ?>"><?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; ?>
<?php if (in_array('follow', $enabled_tabs, true)) : ?>
<div id="panel-follow" class="dashboard-panel<?php echo $active_tab === 'follow' ? ' is-active' : ''; ?>" role="tabpanel"<?php echo $active_tab !== 'follow' ? ' hidden' : ''; ?>>
<?php
if ($forum_instance) :
$followed = $forum_instance->get_user_followed_plates($user_id);
if (!empty($followed)) : ?>
<div class="uh-forum__plate-grid">
<?php foreach ($followed 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 else : ?>
<?php aksrt_render_profile_empty($svg_empty_post, __('暂未关注任何版块', 'aksrt')); ?>
<?php endif;
else :
aksrt_render_profile_empty($svg_empty_post, __('暂无关注内容', 'aksrt'));
endif;
?>
</div>
<?php endif; ?>
</div>
</div>
<?php if (!empty($user_home_settings['sidebar'])) : ?>
<div class="sidebar uc-sidebar aksrt-user-home__aside" role="complementary" aria-label="<?php esc_attr_e('用户主页侧栏', 'aksrt'); ?>">
<div class="uc-sidebar__section">
<div class="uc-sidebar__title"><?php esc_html_e('主页概览', 'aksrt'); ?></div>
<div class="uc-stats">
<?php foreach ($enabled_tabs as $tab_key) : ?>
<a class="uc-stats__item" href="<?php echo esc_url(add_query_arg('tab', $tab_key, $home_url)); ?>">
<span class="uc-stats__value"><?php echo esc_html((string) ($tab_counts[$tab_key] ?? 0)); ?></span>
<span class="uc-stats__label"><?php echo esc_html($tab_labels[$tab_key] ?? ucfirst($tab_key)); ?></span>
</a>
<?php endforeach; ?>
</div>
</div>
<?php if (!empty($user_contacts) && !empty($user_center_settings['social_links'])) : ?>
<div class="uc-sidebar__section">
<div class="uc-sidebar__title"><?php esc_html_e('公开联系', 'aksrt'); ?></div>
<div class="aksrt-user-home__contacts">
<?php if (function_exists('aksrt_render_social_links')) : ?>
<?php aksrt_render_social_links($user_contacts); ?>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<div class="uc-sidebar__section">
<div class="uc-sidebar__title"><?php esc_html_e('快捷入口', 'aksrt'); ?></div>
<div class="uc-sidebar__buttons">
<a href="<?php echo esc_url($home_url); ?>" class="uc-sidebar__btn">
<i class="fas fa-user" aria-hidden="true"></i>
<span><?php esc_html_e('主页首页', 'aksrt'); ?></span>
</a>
<?php if ($is_own_profile) : ?>
<a href="<?php echo esc_url(aksrt_get_user_center_url()); ?>" class="uc-sidebar__btn">
<i class="fas fa-cog" aria-hidden="true"></i>
<span><?php esc_html_e('个人中心', 'aksrt'); ?></span>
</a>
<?php endif; ?>
</div>
</div>
<?php if ($is_own_profile) : ?>
<?php
$orders_url = function_exists('aksrt_get_orders_page_url') ? aksrt_get_orders_page_url() : '';
$show_vip = class_exists('AKSRT_Settings') && !empty(AKSRT_Settings::get_all()['payment_vip_enabled']);
$credits_enabled = class_exists('AKSRT_Settings') && AKSRT_Settings::credits_enabled();
?>
<?php if ($orders_url || $show_vip || $credits_enabled) : ?>
<div class="uc-sidebar__section">
<div class="uc-sidebar__title"><?php esc_html_e('交易服务', 'aksrt'); ?></div>
<div class="uc-sidebar__buttons">
<?php if ($orders_url) : ?>
<a href="<?php echo esc_url($orders_url); ?>" class="uc-sidebar__btn">
<i class="fas fa-receipt" aria-hidden="true"></i>
<span><?php esc_html_e('我的订单', 'aksrt'); ?></span>
</a>
<?php endif; ?>
<?php if ($show_vip) : ?>
<a href="<?php echo esc_url(aksrt_get_user_center_url()); ?>" class="uc-sidebar__btn">
<i class="fas fa-crown" aria-hidden="true"></i>
<span><?php esc_html_e('VIP 会员', 'aksrt'); ?></span>
</a>
<?php endif; ?>
<?php if ($credits_enabled) : ?>
<a href="<?php echo esc_url(aksrt_get_user_center_url()); ?>" class="uc-sidebar__btn">
<i class="fas fa-coins" aria-hidden="true"></i>
<span><?php echo esc_html(AKSRT_Settings::get_currency_name()); ?></span>
</a>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
</aside>
<?php endif; ?>
</div>
</main>
<?php get_footer(); ?>