fix: improve promotion tabs and referral layout
This commit is contained in:
@@ -851,20 +851,6 @@ $hmb_js = get_template_directory() . '/assets/js/header-newadd.js';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($is_profile_page) {
|
||||
$revenue_invite_js_path = get_template_directory() . '/assets/js/revenue-invite.js';
|
||||
if (file_exists($revenue_invite_js_path)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-revenue-invite',
|
||||
$base_uri . '/assets/js/revenue-invite.js',
|
||||
['aksrt-script'],
|
||||
(string) filemtime($revenue_invite_js_path),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
// Badges UI: user center + public profile (zibll medal modal/list).
|
||||
if (class_exists('\AKSRT\User\Badges') && \AKSRT\User\Badges::enabled()) {
|
||||
$is_badge_surface = $is_profile_page
|
||||
|
||||
@@ -182,7 +182,7 @@ final class ReferralAttribution {
|
||||
}
|
||||
|
||||
public function register_routes(): void {
|
||||
register_rest_route('aksrt/v1', '/promotion/me', [
|
||||
register_rest_route('aksrt/v1', '/revenue/me', [
|
||||
'methods' => \WP_REST_Server::READABLE,
|
||||
'callback' => [$this, 'rest_me'],
|
||||
'permission_callback' => static fn() => is_user_logged_in(),
|
||||
|
||||
@@ -84,14 +84,14 @@ class UserRuntime {
|
||||
*/
|
||||
public static function get_user_center_settings(): array {
|
||||
$settings = Settings::get_all();
|
||||
$raw_tabs = $settings['user_center_tabs'] ?? 'profile,level,comments,credits,promotion,revenue,favorites,auth';
|
||||
$raw_tabs = $settings['user_center_tabs'] ?? 'profile,level,comments,credits,revenue,favorites,auth';
|
||||
$tabs = is_array($raw_tabs)
|
||||
? $raw_tabs
|
||||
: preg_split('/[\s,]+/', (string) $raw_tabs, -1, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
// 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', 'comments', 'favorites', 'credits', 'promotion', 'revenue', 'vip', 'orders', 'auth', 'settings'];
|
||||
$allowed_tabs = ['profile', 'level', 'comments', 'favorites', 'credits', 'revenue', 'vip', 'orders', 'auth', 'settings'];
|
||||
$normalized_tabs = ['profile'];
|
||||
|
||||
foreach ((array) $tabs as $tab) {
|
||||
|
||||
+6
-9
@@ -55,9 +55,6 @@ class Center {
|
||||
*/
|
||||
public function rest_panel(\WP_REST_Request $request) {
|
||||
$tab = sanitize_key((string) $request->get_param('tab'));
|
||||
if ($tab === 'revenue') {
|
||||
$tab = 'promotion';
|
||||
}
|
||||
$tabs = $this->get_dashboard_tabs();
|
||||
if (!isset($tabs[$tab])) {
|
||||
return new \WP_Error('aksrt_user_center_panel', __('用户中心面板不存在', 'aksrt'), ['status' => 404]);
|
||||
@@ -79,7 +76,7 @@ class Center {
|
||||
$context['creator_income_request'] = $income_request;
|
||||
}
|
||||
$revenue_request = [];
|
||||
if ($tab === 'promotion') {
|
||||
if ($tab === 'revenue') {
|
||||
$reward_tab = sanitize_key((string) $request->get_param('reward_tab'));
|
||||
if (!in_array($reward_tab, ['detail', 'orders', 'users'], true)) {
|
||||
$reward_tab = 'detail';
|
||||
@@ -185,7 +182,7 @@ class Center {
|
||||
'priority' => 50,
|
||||
'type' => 'panel',
|
||||
],
|
||||
'promotion' => [
|
||||
'revenue' => [
|
||||
'label' => __('推广收益', 'aksrt'),
|
||||
'icon' => 'chart-line',
|
||||
'priority' => 55,
|
||||
@@ -221,7 +218,7 @@ class Center {
|
||||
&& !empty(\AKSRT\User\Level::settings()['enabled']);
|
||||
$credits_on = class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::credits_enabled();
|
||||
$balance_on = class_exists('\AKSRT\Credits\Balance') && \AKSRT\Credits\Balance::enabled();
|
||||
$promotion_tab_on = class_exists('\AKSRT\Settings\Settings')
|
||||
$revenue_tab_on = class_exists('\AKSRT\Settings\Settings')
|
||||
&& !empty(\AKSRT\Settings\Settings::get_affiliate_settings()['enabled']);
|
||||
$creator_tab_on = class_exists('\AKSRT\Settings\Settings')
|
||||
&& !empty(\AKSRT\Settings\Settings::get_payment_revenue_settings()['enabled']);
|
||||
@@ -290,7 +287,7 @@ class Center {
|
||||
$order[] = 'credits';
|
||||
}
|
||||
|
||||
if ($promotion_tab_on && !in_array('promotion', $order, true)) {
|
||||
if ($revenue_tab_on && !in_array('revenue', $order, true)) {
|
||||
$insert_at = count($order);
|
||||
foreach (['credits', 'favorites'] as $anchor) {
|
||||
$idx = array_search($anchor, $order, true);
|
||||
@@ -299,7 +296,7 @@ class Center {
|
||||
break;
|
||||
}
|
||||
}
|
||||
array_splice($order, $insert_at, 0, ['promotion']);
|
||||
array_splice($order, $insert_at, 0, ['revenue']);
|
||||
}
|
||||
$auth_on = class_exists('\AKSRT\User\AuthApply')
|
||||
&& !empty(\AKSRT\User\AuthApply::settings()['enabled']);
|
||||
@@ -320,7 +317,7 @@ class Center {
|
||||
if ($key === 'credits' && !$credits_on && !$balance_on) {
|
||||
continue;
|
||||
}
|
||||
if ($key === 'promotion' && !$promotion_tab_on) {
|
||||
if ($key === 'revenue' && !$revenue_tab_on) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user