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)) {