feat(user-center): 用户中心前台 1:1 列表/URL/关注/身份
补齐 orders/cart/revenue/messages 页面 URL helper,修复私有中心商务与消息死链,公共主页商品/关注接入真实数据,开启身份 chips governance,并注册消息中心页面模板。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
458df7e487
commit
a86649946a
10 files changed
+206
-49
No files matched your search
@@ -48,6 +48,7 @@ class AKSRT_Templates {
|
||||
'templates/pages/page-orders.php' => __('AKSRT - 订单中心', 'aksrt'),
|
||||
'templates/pages/page-revenue.php' => __('AKSRT - 收益中心', 'aksrt'),
|
||||
'templates/pages/page-cart.php' => __('AKSRT - 购物车', 'aksrt'),
|
||||
'templates/pages/page-messages.php' => __('AKSRT - 消息中心', 'aksrt'),
|
||||
'templates/pages/page-product.php' => __('AKSRT - 商品详情', 'aksrt'),
|
||||
'templates/pages/page-product-edit.php' => __('AKSRT - 商品编辑', 'aksrt'),
|
||||
'templates/pages/page-forums.php' => __('AKSRT - 论坛', 'aksrt'),
|
||||
|
||||
@@ -672,6 +672,51 @@ function aksrt_get_user_center_url(string $tab = ''): string {
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_get_orders_page_url')) :
|
||||
/**
|
||||
* 订单中心页面 URL(模板 templates/pages/page-orders.php)。
|
||||
* 未指派页面时返回空串,调用方应隐藏入口。
|
||||
*/
|
||||
function aksrt_get_orders_page_url(): string {
|
||||
return function_exists('aksrt_get_page_url_by_template')
|
||||
? aksrt_get_page_url_by_template('templates/pages/page-orders.php')
|
||||
: '';
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_get_cart_page_url')) :
|
||||
/**
|
||||
* 购物车页面 URL(模板 templates/pages/page-cart.php)。
|
||||
*/
|
||||
function aksrt_get_cart_page_url(): string {
|
||||
return function_exists('aksrt_get_page_url_by_template')
|
||||
? aksrt_get_page_url_by_template('templates/pages/page-cart.php')
|
||||
: '';
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_get_revenue_page_url')) :
|
||||
/**
|
||||
* 收益中心页面 URL(模板 templates/pages/page-revenue.php)。
|
||||
*/
|
||||
function aksrt_get_revenue_page_url(): string {
|
||||
return function_exists('aksrt_get_page_url_by_template')
|
||||
? aksrt_get_page_url_by_template('templates/pages/page-revenue.php')
|
||||
: '';
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_get_messages_page_url')) :
|
||||
/**
|
||||
* 消息中心页面 URL(模板 templates/pages/page-messages.php)。
|
||||
*/
|
||||
function aksrt_get_messages_page_url(): string {
|
||||
return function_exists('aksrt_get_page_url_by_template')
|
||||
? aksrt_get_page_url_by_template('templates/pages/page-messages.php')
|
||||
: '';
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_get_user_home_url')) :
|
||||
/**
|
||||
* 获取公开用户主页 URL(/user/{nicename}/)
|
||||
|
||||
@@ -401,7 +401,7 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
|
||||
? aksrt_get_user_dashboard_view($user_id, [
|
||||
'viewer_id' => $user_id,
|
||||
'include_recent_posts' => false,
|
||||
'include_governance' => false,
|
||||
'include_governance' => true,
|
||||
])
|
||||
: [];
|
||||
|
||||
@@ -453,7 +453,7 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
|
||||
'show_avatar_edit' => !empty($user_center_settings['avatar_upload']),
|
||||
'avatar_settings_url' => admin_url('profile.php'),
|
||||
'notification_unread_count' => function_exists('aksrt_get_user_unread_notification_count') ? aksrt_get_user_unread_notification_count($user_id) : 0,
|
||||
'messages_url' => aksrt_get_user_center_url('notif'),
|
||||
'messages_url' => function_exists('aksrt_get_messages_page_url') ? aksrt_get_messages_page_url() : '',
|
||||
'per_page' => 10,
|
||||
'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),
|
||||
|
||||
@@ -82,17 +82,25 @@ if (!function_exists('aksrt_get_user_home_page_context')) {
|
||||
$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);
|
||||
$product_count = 0;
|
||||
if (class_exists('AKSRT_Shop')) {
|
||||
$product_count = (int) AKSRT_Shop::get_instance()->count_author_products($user_id);
|
||||
}
|
||||
|
||||
$follow_count = 0;
|
||||
if (class_exists('AKSRT_Follow')) {
|
||||
$follow_count = (int) AKSRT_Follow::get_instance()->get_following_count($user_id);
|
||||
}
|
||||
|
||||
$tab_counts = [
|
||||
'posts' => $post_count,
|
||||
'comments' => $comment_count,
|
||||
'favorites' => $favorite_count,
|
||||
'credits' => $credits_enabled && $is_own_profile ? (int) round((float) $credit_balance) : 0,
|
||||
'product' => 0,
|
||||
'product' => $product_count,
|
||||
'plate' => 0,
|
||||
'forum' => $forum_topic_count,
|
||||
'follow' => $forum_followed_count,
|
||||
'follow' => $follow_count,
|
||||
];
|
||||
|
||||
$tab_labels = [
|
||||
|
||||
@@ -16,6 +16,9 @@ if (empty($orders_url) && empty($show_vip) && empty($show_credit_tabs)) {
|
||||
<div class="uc-sidebar__section">
|
||||
<div class="uc-sidebar__title"><?php esc_html_e('权益与消费', 'aksrt'); ?></div>
|
||||
<div class="uc-sidebar__buttons">
|
||||
<?php
|
||||
$revenue_url = function_exists('aksrt_get_revenue_page_url') ? aksrt_get_revenue_page_url() : '';
|
||||
?>
|
||||
<?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>
|
||||
@@ -34,8 +37,8 @@ if (empty($orders_url) && empty($show_vip) && empty($show_credit_tabs)) {
|
||||
<span><?php echo esc_html($currency_name); ?></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($affiliate_enabled)) : ?>
|
||||
<a class="uc-sidebar__btn<?php echo $active_tab === 'credits' ? ' is-active' : ''; ?>" href="<?php echo esc_url(aksrt_get_user_center_tab_url('credits')); ?>" data-tab="credits">
|
||||
<?php if (!empty($affiliate_enabled) && $revenue_url) : ?>
|
||||
<a href="<?php echo esc_url($revenue_url); ?>" class="uc-sidebar__btn">
|
||||
<i class="fas fa-share-alt" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('推广返佣', 'aksrt'); ?></span>
|
||||
</a>
|
||||
|
||||
Reference in new issue
Block a user