From a86649946ad3029d59cf3da32d66cc3f422089a2 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 12 Jul 2026 11:03:30 +0800 Subject: [PATCH] =?UTF-8?q?feat(user-center):=20=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E5=89=8D=E5=8F=B0=201:1=20=E5=88=97=E8=A1=A8?= =?UTF-8?q?/URL/=E5=85=B3=E6=B3=A8/=E8=BA=AB=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 补齐 orders/cart/revenue/messages 页面 URL helper,修复私有中心商务与消息死链,公共主页商品/关注接入真实数据,开启身份 chips governance,并注册消息中心页面模板。 Co-Authored-By: Claude Fable 5 --- header.php | 4 +- inc/classes/class-aksrt-templates.php | 1 + inc/classes/class-aksrt-user.php | 45 +++++++++ inc/helpers/aksrt-user-center.php | 4 +- inc/helpers/aksrt-user-home.php | 14 ++- .../sidebar-commerce.php | 7 +- templates/parts/single-author-bar.php | 2 +- templates/parts/user-home/panel-follow.php | 95 ++++++++++++++----- templates/parts/user-home/panels-core.php | 79 ++++++++++++--- templates/parts/user-home/sidebar.php | 4 +- 10 files changed, 206 insertions(+), 49 deletions(-) diff --git a/header.php b/header.php index e0e5054a..f440647f 100644 --- a/header.php +++ b/header.php @@ -140,9 +140,9 @@ if (!empty($aksrt_bg_styles)) { $aksrt_current_user = wp_get_current_user(); $aksrt_user_credit = function_exists('aksrt_user_credits') && is_user_logged_in() ? (int) aksrt_user_credits(get_current_user_id()) : 0; $aksrt_currency_name = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name() : __('积分', 'aksrt'); - $aksrt_orders_url = home_url('/orders/'); + $aksrt_orders_url = function_exists('aksrt_get_orders_page_url') ? aksrt_get_orders_page_url() : ''; $aksrt_publish_url = admin_url('post-new.php'); - $aksrt_messages_url = function_exists('aksrt_get_user_center_url') ? aksrt_get_user_center_url('notif') : home_url('/'); + $aksrt_messages_url = function_exists('aksrt_get_messages_page_url') ? aksrt_get_messages_page_url() : ''; $aksrt_unread_count = (is_user_logged_in() && function_exists('aksrt_get_user_unread_notification_count')) ? (int) aksrt_get_user_unread_notification_count(get_current_user_id()) : 0; diff --git a/inc/classes/class-aksrt-templates.php b/inc/classes/class-aksrt-templates.php index 12c51429..8a00d24e 100644 --- a/inc/classes/class-aksrt-templates.php +++ b/inc/classes/class-aksrt-templates.php @@ -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'), diff --git a/inc/classes/class-aksrt-user.php b/inc/classes/class-aksrt-user.php index 372be14f..ca7fe660 100644 --- a/inc/classes/class-aksrt-user.php +++ b/inc/classes/class-aksrt-user.php @@ -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}/) diff --git a/inc/helpers/aksrt-user-center.php b/inc/helpers/aksrt-user-center.php index 891d9a65..ef0f0aaf 100644 --- a/inc/helpers/aksrt-user-center.php +++ b/inc/helpers/aksrt-user-center.php @@ -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), diff --git a/inc/helpers/aksrt-user-home.php b/inc/helpers/aksrt-user-home.php index 9590a9c8..985fed8d 100644 --- a/inc/helpers/aksrt-user-home.php +++ b/inc/helpers/aksrt-user-home.php @@ -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 = [ diff --git a/inc/helpers/user-center-renderers/sidebar-commerce.php b/inc/helpers/user-center-renderers/sidebar-commerce.php index e8dab67b..48224bd6 100644 --- a/inc/helpers/user-center-renderers/sidebar-commerce.php +++ b/inc/helpers/user-center-renderers/sidebar-commerce.php @@ -16,6 +16,9 @@ if (empty($orders_url) && empty($show_vip) && empty($show_credit_tabs)) {
+ @@ -34,8 +37,8 @@ if (empty($orders_url) && empty($show_vip) && empty($show_credit_tabs)) { - - + + diff --git a/templates/parts/single-author-bar.php b/templates/parts/single-author-bar.php index 15357f26..8a7504e5 100644 --- a/templates/parts/single-author-bar.php +++ b/templates/parts/single-author-bar.php @@ -65,7 +65,7 @@ $classes = trim('article-avatar ' . $extra_class . ($show_actions ? ' article-av - + diff --git a/templates/parts/user-home/panel-follow.php b/templates/parts/user-home/panel-follow.php index cc1abf8a..c6fcf291 100644 --- a/templates/parts/user-home/panel-follow.php +++ b/templates/parts/user-home/panel-follow.php @@ -1,6 +1,6 @@ - -
> - get_user_followed_plates($user_id); - if (!empty($followed)) : ?> - + diff --git a/templates/parts/user-home/panels-core.php b/templates/parts/user-home/panels-core.php index 5db7931f..fce3f43d 100644 --- a/templates/parts/user-home/panels-core.php +++ b/templates/parts/user-home/panels-core.php @@ -131,17 +131,68 @@ extract($args, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_ext
- __('暂无商品内容', 'aksrt'), - 'plate' => __('暂无圈子内容', 'aksrt'), - ]; - foreach ($_uh_extended_tabs as $_uh_ext) : - if (!in_array($_uh_ext, $enabled_tabs, true)) continue; - ?> -
> - -
- + +
> + [], 'total' => 0, 'max_pages' => 0]; + if (class_exists('AKSRT_Shop')) { + $product_view = AKSRT_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)) : + ?> + + 1 && function_exists('aksrt_render_profile_pagination')) : ?> + + 1) : ?> + add_query_arg(['tab' => 'product', 'product_page' => '%#%'], $home_url), + 'format' => '', + 'current' => $product_page, + 'total' => $product_max_pages, + 'add_args' => ['tab' => 'product'], + ]); + ?> + + + + +
+ + + +
> + +
+ diff --git a/templates/parts/user-home/sidebar.php b/templates/parts/user-home/sidebar.php index bbbcc004..3a8dc8da 100644 --- a/templates/parts/user-home/sidebar.php +++ b/templates/parts/user-home/sidebar.php @@ -69,13 +69,13 @@ extract($args, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_ext - + - +