feat(users): merge promotion into revenue center

This commit is contained in:
kate522 committed 2026-08-03 15:38:17 +08:00
1 parent 156060d2ec
commit 49c12b761f
20 files changed
+369 -413

No files matched your search

+17 -13
View File
@@ -103,8 +103,8 @@ 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) {
$tab = 'promotion';
if ('invite' === $tab || 'promotion' === $tab) {
$tab = 'revenue';
}
$url = remove_query_arg([
'tab', 'posts_page', 'comments_page', 'favorites_page', 'credits_page',
@@ -154,7 +154,7 @@ if (!function_exists('aksrt_capture_user_center_view')) {
'vip' => 'vip',
'orders' => 'orders',
'auth' => 'auth',
'promotion' => 'promotion',
'revenue' => 'revenue',
'settings' => 'settings',
'header' => 'header',
'sidebar' => 'sidebar',
@@ -179,7 +179,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', 'promotion', 'settings'];
$built_in_tabs = ['profile', 'level', 'posts', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'revenue', 'settings'];
if (in_array($tab_key, $built_in_tabs, true)) {
return aksrt_capture_user_center_view($tab_key, $context);
}
@@ -284,8 +284,8 @@ if (!function_exists('aksrt_user_center_resolve_tabs')) {
$active = isset($_GET['tab']) ? sanitize_key(wp_unslash($_GET['tab'])) : $default;
if ('signin' === $active || 'assets' === $active) {
$active = 'credits';
} elseif ('invite' === $active) {
$active = 'promotion';
} elseif ('invite' === $active || 'promotion' === $active) {
$active = 'revenue';
} elseif ('vip' === $active) {
// Prefer dedicated vip tab when registered; else credits (VIP shop).
$active = in_array('vip', $keys, true) ? 'vip' : 'credits';
@@ -344,7 +344,8 @@ if (!function_exists('aksrt_user_center_runtime_config')) {
'activeTab' => $active_tab,
'tabAliases' => [
'signin' => 'credits',
'invite' => 'promotion',
'invite' => 'revenue',
'promotion' => 'revenue',
'assets' => 'credits',
// vip → vip when panel exists; SPA may still map missing keys via server resolve.
'vip' => 'vip',
@@ -491,9 +492,14 @@ 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 = (!empty($revenue_settings['enabled']) || !empty($affiliate_settings['enabled'])) && function_exists('aksrt_get_revenue_page_url')
? aksrt_get_revenue_page_url()
$revenue_url = isset($tabs['tabs']['revenue'])
? aksrt_get_user_center_tab_url('revenue')
: '';
$render_context = [
@@ -534,16 +540,14 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
'show_vip' => !empty($vip_settings['enabled']),
'show_credit_tabs' => $show_credit_tabs,
'affiliate_enabled' => $show_credit_tabs && !empty($affiliate_settings['enabled']),
'show_revenue_section' => $show_revenue_section,
'currency_name' => $currency_name,
'credit_balance' => (float) ($dashboard['credit_balance'] ?? 0.0),
'credits_enabled' => $show_credit_tabs,
'balance_enabled' => $balance_enabled,
'wallet_balance' => $wallet_balance,
'vip_settings' => $vip_settings,
'show_invite_section' => $show_credit_tabs
&& class_exists('\AKSRT\Settings\Settings')
&& \AKSRT\Settings\Settings::invite_enabled()
&& \AKSRT\Settings\Settings::invite_registration_enabled(),
'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),