用户主页减层:拆出 panel/sidebar partial 并清理失效 CSS 选择器
把 page-user-home 的内容面板与侧栏抽到 user-home partial,删除公开主页已不再使用的 uc-header/user-home-stats 等 CSS 残段。
This commit is contained in:
@@ -221,27 +221,6 @@
|
||||
background: var(--surface-2);
|
||||
}
|
||||
|
||||
.aksrt-user-home__notice {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 0 0 18px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 10px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.aksrt-user-home__notice--muted,
|
||||
.aksrt-user-home__notice--restricted {
|
||||
color: #92400e;
|
||||
background: rgba(245, 158, 11, 0.12);
|
||||
}
|
||||
|
||||
.aksrt-user-home__notice--banned {
|
||||
color: #b91c1c;
|
||||
background: rgba(239, 68, 68, 0.12);
|
||||
}
|
||||
|
||||
.uc-header__meta {
|
||||
display: flex;
|
||||
|
||||
@@ -420,58 +420,6 @@
|
||||
gap: 18px;
|
||||
}
|
||||
|
||||
.aksrt-user-home .uc-header--no-cover {
|
||||
background: var(--surface-1);
|
||||
border-radius: var(--radius-lg, 12px);
|
||||
border: 1px solid var(--color-line-soft, rgba(0, 0, 0, 0.06));
|
||||
}
|
||||
|
||||
.aksrt-user-home .uc-header--no-cover .uc-header__content {
|
||||
padding-top: 24px;
|
||||
}
|
||||
|
||||
.aksrt-user-home .user-home-stats {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.aksrt-user-home .user-home-stats__item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-height: 34px;
|
||||
padding: 0 12px;
|
||||
border-radius: 999px;
|
||||
background: var(--surface-2);
|
||||
color: var(--color-ink-3);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.aksrt-user-home .user-home-stats__item strong {
|
||||
color: var(--color-ink);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.aksrt-user-home .uc-header__actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.aksrt-user-home .aksrt-user-home__follow-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.aksrt-user-home .aksrt-user-home__follow-btn[aria-disabled="true"] {
|
||||
opacity: 0.72;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.aksrt-user-home .aksrt-user-home__contacts .profile-social-links {
|
||||
display: flex;
|
||||
@@ -611,9 +559,6 @@
|
||||
|
||||
/* ==================== 响应式 ==================== */
|
||||
@media (max-width: 640px) {
|
||||
.aksrt-user-home .user-home-stats {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.aksrt-user-home .dashboard--public {
|
||||
padding: 16px;
|
||||
|
||||
@@ -129,6 +129,7 @@ $svg_empty_favorite = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 2
|
||||
$home_url = function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url($user) : home_url('/');
|
||||
?>
|
||||
|
||||
|
||||
<main id="main-content" class="site-main container content-shell content-shell--stream aksrt-user-home" tabindex="-1">
|
||||
<div class="content-wrap">
|
||||
<div class="content-layout<?php echo !empty($user_home_settings['sidebar']) ? '' : ' content-layout--no-sidebar'; ?> aksrt-user-home__layout">
|
||||
@@ -142,418 +143,59 @@ $home_url = function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url
|
||||
]);
|
||||
?>
|
||||
|
||||
<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
|
||||
get_template_part('templates/parts/content', 'profile-list-item', [
|
||||
'action' => [
|
||||
'type' => 'view',
|
||||
'url' => get_permalink(),
|
||||
'label' => __('阅读', 'aksrt'),
|
||||
],
|
||||
]);
|
||||
?>
|
||||
<?php endwhile; ?>
|
||||
</div>
|
||||
<?php
|
||||
aksrt_render_profile_pagination((int) $author_posts->max_num_pages, $posts_page, 'posts_page');
|
||||
wp_reset_postdata();
|
||||
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
|
||||
get_template_part('templates/parts/content', 'profile-comment-item', ['comment' => $c]);
|
||||
?>
|
||||
<?php endforeach; ?>
|
||||
</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="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';
|
||||
?>
|
||||
<div class="profile-list">
|
||||
<?php while ($favorites_query->have_posts()) : $favorites_query->the_post(); ?>
|
||||
<?php
|
||||
get_template_part('templates/parts/content', 'profile-list-item', [
|
||||
'action' => [
|
||||
'type' => 'view',
|
||||
'url' => get_permalink(),
|
||||
'label' => __('阅读', 'aksrt'),
|
||||
],
|
||||
]);
|
||||
?>
|
||||
<?php endwhile; ?>
|
||||
</div>
|
||||
<?php
|
||||
aksrt_render_profile_pagination((int) $favorites_query->max_num_pages, $favorites_page, 'favorites_page');
|
||||
wp_reset_postdata();
|
||||
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'])) : ?>
|
||||
<aside class="content-layout__aside 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>
|
||||
<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>
|
||||
</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>
|
||||
<?php
|
||||
$uh_panel_args = [
|
||||
'user_id' => $user_id,
|
||||
'user' => $user,
|
||||
'home_url' => $home_url,
|
||||
'active_tab' => $active_tab,
|
||||
'enabled_tabs' => $enabled_tabs,
|
||||
'tab_counts' => $tab_counts,
|
||||
'tab_labels' => $tab_labels,
|
||||
'per_page' => $per_page,
|
||||
'posts_page' => $posts_page,
|
||||
'comments_page' => $comments_page,
|
||||
'favorites_page' => $favorites_page,
|
||||
'comment_count' => $comment_count,
|
||||
'favorite_post_ids' => $favorite_post_ids,
|
||||
'credits_enabled' => $credits_enabled,
|
||||
'is_own_profile' => $is_own_profile,
|
||||
'credit_balance' => $credit_balance,
|
||||
'currency_name' => $currency_name,
|
||||
'svg_empty_post' => $svg_empty_post,
|
||||
'svg_empty_comment' => $svg_empty_comment,
|
||||
'svg_empty_favorite' => $svg_empty_favorite,
|
||||
'forum_instance' => $forum_instance,
|
||||
'forum_topic_count' => $forum_topic_count,
|
||||
'forum_stats' => $forum_stats,
|
||||
'user_home_settings' => $user_home_settings,
|
||||
'user_center_settings' => $user_center_settings,
|
||||
'user_contacts' => $user_contacts,
|
||||
];
|
||||
get_template_part('templates/parts/user-home/panels', 'core', $uh_panel_args);
|
||||
get_template_part('templates/parts/user-home/panel', 'forum', $uh_panel_args);
|
||||
get_template_part('templates/parts/user-home/panel', 'follow', $uh_panel_args);
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<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_side = class_exists('AKSRT_Settings') && AKSRT_Settings::credits_enabled();
|
||||
?>
|
||||
<?php if ($orders_url || $show_vip || $credits_enabled_side) : ?>
|
||||
<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_side) : ?>
|
||||
<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; ?>
|
||||
<?php get_template_part('templates/parts/user-home/sidebar', null, $uh_panel_args); ?>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
当前主路径:
|
||||
- 壳层:templates/pages/page-user-home.php
|
||||
- 头区:templates/parts/user/author-hero.php
|
||||
- 内容面板:panels-core.php / panel-forum.php / panel-follow.php
|
||||
- 侧栏:sidebar.php
|
||||
- 列表项:templates/parts/content-profile-*.php
|
||||
|
||||
旧 uh-* 草稿 partial 已删除,勿再引入。
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Public user home — follow 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('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; ?>
|
||||
@@ -0,0 +1,169 @@
|
||||
<?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(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; ?>
|
||||
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
/**
|
||||
* Public user home — core content panels (posts/comments/favorites/credits/placeholders).
|
||||
*
|
||||
* @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('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
|
||||
get_template_part('templates/parts/content', 'profile-list-item', [
|
||||
'action' => [
|
||||
'type' => 'view',
|
||||
'url' => get_permalink(),
|
||||
'label' => __('阅读', 'aksrt'),
|
||||
],
|
||||
]);
|
||||
?>
|
||||
<?php endwhile; ?>
|
||||
</div>
|
||||
<?php
|
||||
aksrt_render_profile_pagination((int) $author_posts->max_num_pages, $posts_page, 'posts_page');
|
||||
wp_reset_postdata();
|
||||
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
|
||||
get_template_part('templates/parts/content', 'profile-comment-item', ['comment' => $c]);
|
||||
?>
|
||||
<?php endforeach; ?>
|
||||
</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
|
||||
get_template_part('templates/parts/content', 'profile-list-item', [
|
||||
'action' => [
|
||||
'type' => 'view',
|
||||
'url' => get_permalink(),
|
||||
'label' => __('阅读', 'aksrt'),
|
||||
],
|
||||
]);
|
||||
?>
|
||||
<?php endwhile; ?>
|
||||
</div>
|
||||
<?php
|
||||
aksrt_render_profile_pagination((int) $favorites_query->max_num_pages, $favorites_page, 'favorites_page');
|
||||
wp_reset_postdata();
|
||||
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; ?>
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* Public user home — page-owned sidebar.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$args = is_array($args ?? null) ? $args : [];
|
||||
extract($args, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
|
||||
|
||||
?>
|
||||
<?php if (!empty($user_home_settings['sidebar'])) : ?>
|
||||
<aside class="content-layout__aside 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_side = class_exists('AKSRT_Settings') && AKSRT_Settings::credits_enabled();
|
||||
?>
|
||||
<?php if ($orders_url || $show_vip || $credits_enabled_side) : ?>
|
||||
<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_side) : ?>
|
||||
<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; ?>
|
||||
Reference in New Issue
Block a user