diff --git a/assets/css/routes/user-center/shell.css b/assets/css/routes/user-center/shell.css index 6de9048c..da5d1256 100644 --- a/assets/css/routes/user-center/shell.css +++ b/assets/css/routes/user-center/shell.css @@ -715,6 +715,7 @@ body.aksrt-user-center .uc-content, .uc-service-grid__item--cart .uc-service-grid__icon { color: #dd6941; background: rgba(238, 109, 61, 0.12); } .uc-service-grid__item--level .uc-service-grid__icon { color: #9b6b0a; background: rgba(234, 179, 8, 0.13); } +.uc-service-grid__item--promotion .uc-service-grid__icon { color: #b8377d; background: rgba(219, 39, 119, 0.12); } .uc-service-grid__item--auth .uc-service-grid__icon { color: #287bc4; background: rgba(14, 165, 233, 0.12); } .uc-service-grid__item--orders .uc-service-grid__icon { color: #c05621; background: rgba(234, 88, 12, 0.12); } .uc-service-grid__item--notice .uc-service-grid__icon { color: #d04b65; background: rgba(244, 63, 94, 0.11); } diff --git a/inc/helpers/aksrt-user-center.php b/inc/helpers/aksrt-user-center.php index 48bffc5b..5651f978 100644 --- a/inc/helpers/aksrt-user-center.php +++ b/inc/helpers/aksrt-user-center.php @@ -104,7 +104,7 @@ if (!function_exists('aksrt_get_user_center_tab_url')) { function aksrt_get_user_center_tab_url(string $tab): string { $tab = sanitize_key($tab); if ('invite' === $tab || 'promotion' === $tab) { - $tab = 'revenue'; + $tab = 'promotion'; } $url = remove_query_arg([ 'tab', 'posts_page', 'comments_page', 'favorites_page', 'credits_page', @@ -154,6 +154,7 @@ if (!function_exists('aksrt_capture_user_center_view')) { 'vip' => 'vip', 'orders' => 'orders', 'auth' => 'auth', + 'promotion' => 'promotion', 'revenue' => 'revenue', 'settings' => 'settings', 'header' => 'header', @@ -179,7 +180,7 @@ if (!function_exists('aksrt_capture_user_center_panel')) { * Capture a built-in or registered user-center panel body. */ function aksrt_capture_user_center_panel(string $tab_key, array $tab, array $context): string { - $built_in_tabs = ['profile', 'level', 'posts', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'revenue', 'settings']; + $built_in_tabs = ['profile', 'level', 'posts', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'promotion', 'revenue', 'settings']; if (in_array($tab_key, $built_in_tabs, true)) { return aksrt_capture_user_center_view($tab_key, $context); } @@ -287,7 +288,7 @@ if (!function_exists('aksrt_user_center_resolve_tabs')) { if ('signin' === $active || 'assets' === $active) { $active = 'credits'; } elseif ('invite' === $active || 'promotion' === $active) { - $active = 'revenue'; + $active = 'promotion'; } elseif ('vip' === $active) { // Prefer dedicated vip tab when registered; else credits (VIP shop). $active = in_array('vip', $keys, true) ? 'vip' : 'credits'; @@ -346,8 +347,8 @@ if (!function_exists('aksrt_user_center_runtime_config')) { 'activeTab' => $active_tab, 'tabAliases' => [ 'signin' => 'credits', - 'invite' => 'revenue', - 'promotion' => 'revenue', + 'invite' => 'promotion', + 'promotion' => 'promotion', 'assets' => 'credits', // vip → vip when panel exists; SPA may still map missing keys via server resolve. 'vip' => 'vip', @@ -494,10 +495,6 @@ if (!function_exists('aksrt_get_user_center_render_context')) { $runtime_config = aksrt_user_center_runtime_config($user_id, $tabs['default'], $active_tab, $tabs['urls']); $runtime_config['avatarUpload'] = aksrt_user_center_avatar_upload_config($allow_avatar_upload); $revenue_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_payment_revenue_settings() : []; - $show_invite_section = $show_credit_tabs - && class_exists('\AKSRT\Settings\Settings') - && \AKSRT\Settings\Settings::invite_enabled() - && \AKSRT\Settings\Settings::invite_registration_enabled(); $show_revenue_section = !empty($revenue_settings['enabled']) || !empty($affiliate_settings['enabled']); $new_post_url = function_exists('aksrt_get_new_post_url') ? aksrt_get_new_post_url() : ''; $revenue_url = isset($tabs['tabs']['revenue']) @@ -549,7 +546,6 @@ if (!function_exists('aksrt_get_user_center_render_context')) { 'balance_enabled' => $balance_enabled, 'wallet_balance' => $wallet_balance, 'vip_settings' => $vip_settings, - 'show_invite_section' => $show_invite_section, 'user_email' => (string) $current_user->user_email, 'runtime_config' => $runtime_config, 'cover_upload_config' => aksrt_user_center_cover_upload_config($allow_bg_upload), diff --git a/inc/helpers/user-center-renderers/profile-promotion.php b/inc/helpers/user-center-renderers/profile-promotion.php new file mode 100644 index 00000000..1dcbf053 --- /dev/null +++ b/inc/helpers/user-center-renderers/profile-promotion.php @@ -0,0 +1,25 @@ +' . esc_html__('请先登录', 'aksrt') . ''; + return; +} + +$currency_name = (string) ($context['currency_name'] ?? __('积分', 'aksrt')); +?> +
+ +
diff --git a/inc/helpers/user-center-renderers/profile-revenue.php b/inc/helpers/user-center-renderers/profile-revenue.php index 6861a3ff..2745378c 100644 --- a/inc/helpers/user-center-renderers/profile-revenue.php +++ b/inc/helpers/user-center-renderers/profile-revenue.php @@ -15,7 +15,6 @@ if ($user_id <= 0) { } $show_revenue_section = !empty($context['show_revenue_section']); -$show_invite_section = !empty($context['show_invite_section']); $revenue_view = function_exists('aksrt_get_revenue_page_view') ? aksrt_get_revenue_page_view($user_id) : ['balance' => 0, 'total_earned' => 0, 'total_withdrawn' => 0, 'records' => []]; @@ -59,6 +58,4 @@ $revenue_url = static function (int $target_page): string {

¥
1) : ?>

- - diff --git a/inc/helpers/user-center-renderers/sidebar-creator.php b/inc/helpers/user-center-renderers/sidebar-creator.php index d7fc7e98..b865f3bf 100644 --- a/inc/helpers/user-center-renderers/sidebar-creator.php +++ b/inc/helpers/user-center-renderers/sidebar-creator.php @@ -28,7 +28,7 @@ if ($creation_url === '' && $revenue_url === '') { - + diff --git a/inc/helpers/user-center-renderers/sidebar-nav.php b/inc/helpers/user-center-renderers/sidebar-nav.php index ec9e682e..49d7c863 100644 --- a/inc/helpers/user-center-renderers/sidebar-nav.php +++ b/inc/helpers/user-center-renderers/sidebar-nav.php @@ -11,6 +11,7 @@ $level_url = isset($dashboard_tabs['level']) ? aksrt_get_user_center_tab_url('level') : ''; $auth_url = isset($dashboard_tabs['auth']) ? aksrt_get_user_center_tab_url('auth') : ''; +$promotion_url = isset($dashboard_tabs['promotion']) ? aksrt_get_user_center_tab_url('promotion') : ''; $orders_available = isset($dashboard_tabs['orders']); $orders_url = $orders_available ? (string) ($orders_url ?? '') : ''; @@ -21,6 +22,13 @@ $services = array_values(array_filter([ 'tone' => 'level', 'url' => $level_url, ], + [ + 'label' => __('推广中心', 'aksrt'), + 'icon' => 'bullhorn', + 'tone' => 'promotion', + 'url' => $promotion_url, + 'tab' => 'promotion', + ], [ 'label' => __('官方认证', 'aksrt'), 'icon' => 'id-badge', diff --git a/inc/modules/user-parts/urls.php b/inc/modules/user-parts/urls.php index c6395dca..1d81e717 100644 --- a/inc/modules/user-parts/urls.php +++ b/inc/modules/user-parts/urls.php @@ -32,8 +32,8 @@ function aksrt_get_user_center_url(string $tab = ''): string { 'assets' => 'credits', 'vip' => 'vip', // dedicated vip tab when registered; resolver falls back if missing 'signin' => 'credits', - 'invite' => 'revenue', - 'promotion' => 'revenue', + 'invite' => 'promotion', + 'promotion' => 'promotion', ]; if (isset($aliases[$tab])) { $tab = $aliases[$tab]; diff --git a/src/Core/ScriptsPart1b.php b/src/Core/ScriptsPart1b.php index 641ea97c..7079e49d 100644 --- a/src/Core/ScriptsPart1b.php +++ b/src/Core/ScriptsPart1b.php @@ -700,7 +700,7 @@ $hmb_js = get_template_directory() . '/assets/js/header-newadd.js'; || ( (function_exists('aksrt_is_user_center_page') && aksrt_is_user_center_page()) && isset($_GET['tab']) - && in_array(sanitize_key((string) wp_unslash($_GET['tab'])), ['revenue', 'invite', 'promotion'], true) + && 'revenue' === sanitize_key((string) wp_unslash($_GET['tab'])) ); if ($is_revenue_surface) { $revenue_js = get_template_directory() . '/assets/js/revenue.js'; diff --git a/src/Settings/UserRuntime.php b/src/Settings/UserRuntime.php index aa029a30..bf599c53 100644 --- a/src/Settings/UserRuntime.php +++ b/src/Settings/UserRuntime.php @@ -90,7 +90,7 @@ class UserRuntime { // Built-in switchable panels. VIP is always auto-injected when enabled // by AKSRT\User\Center — keep it allowed for explicit config too. - $allowed_tabs = ['profile', 'level', 'posts', 'comments', 'favorites', 'credits', 'revenue', 'vip', 'orders', 'auth', 'settings']; + $allowed_tabs = ['profile', 'level', 'posts', 'comments', 'favorites', 'credits', 'promotion', 'revenue', 'vip', 'orders', 'auth', 'settings']; $normalized_tabs = ['profile']; foreach ((array) $tabs as $tab) { diff --git a/src/User/Center.php b/src/User/Center.php index df4ca286..77f5f9d9 100644 --- a/src/User/Center.php +++ b/src/User/Center.php @@ -91,6 +91,12 @@ class Center { 'priority' => 50, 'type' => 'panel', ], + 'promotion' => [ + 'label' => __('推广中心', 'aksrt'), + 'icon' => 'bullhorn', + 'priority' => 52, + 'type' => 'panel', + ], 'revenue' => [ 'label' => __('收益中心', 'aksrt'), 'icon' => 'chart-line', @@ -131,12 +137,13 @@ class Center { && class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::invite_enabled() && \AKSRT\Settings\Settings::invite_registration_enabled(); - $revenue_on = class_exists('\AKSRT\Settings\Settings') + // Promotion (invite) center is its own tab; revenue stays pure earnings/withdrawal. + $promotion_on = $invite_on; + $revenue_tab_on = class_exists('\AKSRT\Settings\Settings') && ( !empty(\AKSRT\Settings\Settings::get_payment_revenue_settings()['enabled']) || !empty(\AKSRT\Settings\Settings::get_payment_affiliate_settings()['enabled']) ); - $revenue_tab_on = $revenue_on || $invite_on; $vip_on = class_exists('\AKSRT\Settings\Settings') && !empty(\AKSRT\Settings\Settings::get_payment_vip_settings()['enabled']); @@ -183,7 +190,7 @@ class Center { if (($credits_on || $balance_on) && !in_array('credits', $order, true)) { $order[] = 'credits'; } - if ($revenue_tab_on && !in_array('revenue', $order, true)) { + if ($promotion_on && !in_array('promotion', $order, true)) { $insert_at = count($order); foreach (['credits', 'favorites', 'posts'] as $anchor) { $idx = array_search($anchor, $order, true); @@ -192,6 +199,17 @@ class Center { break; } } + array_splice($order, $insert_at, 0, ['promotion']); + } + if ($revenue_tab_on && !in_array('revenue', $order, true)) { + $insert_at = count($order); + foreach (['promotion', 'credits', 'favorites', 'posts'] as $anchor) { + $idx = array_search($anchor, $order, true); + if ($idx !== false) { + $insert_at = (int) $idx + 1; + break; + } + } array_splice($order, $insert_at, 0, ['revenue']); } $auth_on = class_exists('\AKSRT\User\AuthApply') @@ -216,6 +234,9 @@ class Center { if ($key === 'revenue' && !$revenue_tab_on) { continue; } + if ($key === 'promotion' && !$promotion_on) { + continue; + } if ($key === 'vip' && !$vip_on) { continue; }