fix: improve promotion tabs and referral layout
This commit is contained in:
1 parent
5b9f54f5ac
commit
853114a9f9
18 files changed
+127
-602
No files matched your search
@@ -133,11 +133,6 @@ 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';
|
||||
} elseif ('revenue' === $tab) {
|
||||
$tab = 'promotion';
|
||||
}
|
||||
return aksrt_get_user_center_url($tab);
|
||||
}
|
||||
}
|
||||
@@ -182,7 +177,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',
|
||||
@@ -207,7 +202,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', 'creator', 'posts', 'follow', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'promotion', 'settings'];
|
||||
$built_in_tabs = ['profile', 'level', 'creator', 'posts', 'follow', '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);
|
||||
}
|
||||
@@ -316,10 +311,6 @@ if (!function_exists('aksrt_user_center_resolve_tabs')) {
|
||||
}
|
||||
if ('signin' === $active || 'assets' === $active) {
|
||||
$active = 'credits';
|
||||
} elseif ('invite' === $active) {
|
||||
$active = 'promotion';
|
||||
} elseif ('revenue' === $active) {
|
||||
$active = 'promotion';
|
||||
} elseif ('vip' === $active) {
|
||||
// Prefer dedicated vip tab when registered; else credits (VIP shop).
|
||||
$active = in_array('vip', $keys, true) ? 'vip' : 'credits';
|
||||
@@ -358,8 +349,7 @@ if (!function_exists('aksrt_user_center_runtime_config')) {
|
||||
'activeTab' => $active_tab,
|
||||
'tabAliases' => [
|
||||
'signin' => 'credits',
|
||||
'invite' => 'promotion',
|
||||
'revenue' => 'promotion',
|
||||
'revenue' => 'revenue',
|
||||
'assets' => 'credits',
|
||||
// vip → vip when panel exists; SPA may still map missing keys via server resolve.
|
||||
'vip' => 'vip',
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* User center promotion (invite) card.
|
||||
*
|
||||
* Rendered inside the standalone 推广中心 tab (profile-promotion.php).
|
||||
* Section order follows the task priority: 成果概览 → 分享操作 → 奖励说明 → 邀请记录.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
?>
|
||||
<section class="uc-promotion-panel uc-promotion-card" aria-labelledby="uc-promotion-title" data-aksrt-invite>
|
||||
<header class="uc-promotion-panel__header">
|
||||
<span class="uc-promotion-panel__icon"><i class="fas fa-user-plus" aria-hidden="true"></i></span>
|
||||
<div>
|
||||
<p class="uc-promotion-panel__eyebrow"><?php esc_html_e('邀请与奖励', 'aksrt'); ?></p>
|
||||
<h3 id="uc-promotion-title"><?php esc_html_e('推广奖励', 'aksrt'); ?></h3>
|
||||
</div>
|
||||
</header>
|
||||
<p class="uc-promotion-panel__intro"><?php esc_html_e('分享专属链接,邀请好友完成注册与验证后即可获得奖励。', 'aksrt'); ?></p>
|
||||
<p class="uc-promotion-panel__status" data-invite-status role="status" aria-live="polite"><?php esc_html_e('正在加载推广数据…', 'aksrt'); ?></p>
|
||||
<section class="uc-promotion-section uc-promotion-section--stats" aria-labelledby="uc-promotion-stats-title"><div class="uc-promotion-section__header"><h4 id="uc-promotion-stats-title"><?php esc_html_e('推广成果', 'aksrt'); ?></h4><p><?php esc_html_e('实时汇总你的邀请进度', 'aksrt'); ?></p></div><div class="uc-promotion-stats" data-invite-stats aria-live="polite"><div class="uc-promotion-stat"><span><?php esc_html_e('已注册', 'aksrt'); ?></span><strong data-stat="registered">—</strong><small><?php esc_html_e('通过链接完成注册', 'aksrt'); ?></small></div><div class="uc-promotion-stat"><span><?php esc_html_e('已验证', 'aksrt'); ?></span><strong data-stat="verified">—</strong><small><?php esc_html_e('已完成邮箱验证', 'aksrt'); ?></small></div><div class="uc-promotion-stat"><span><?php esc_html_e('已奖励', 'aksrt'); ?></span><strong data-stat="rewarded">—</strong><small><?php esc_html_e('奖励已发放', 'aksrt'); ?></small></div></div></section>
|
||||
<section class="uc-promotion-section uc-promotion-section--share" aria-labelledby="uc-promotion-share-title"><div class="uc-promotion-section__header"><h4 id="uc-promotion-share-title"><?php esc_html_e('分享专属链接', 'aksrt'); ?></h4><p><?php esc_html_e('好友通过此链接注册,邀请关系会自动记录。', 'aksrt'); ?></p></div><div class="uc-promotion-share"><div class="uc-promotion-code"><span><?php esc_html_e('我的邀请码', 'aksrt'); ?></span><strong data-invite-code>—</strong></div><label class="screen-reader-text" for="aksrt-invite-link"><?php esc_html_e('推广链接', 'aksrt'); ?></label><div class="uc-promotion-link-row"><input id="aksrt-invite-link" type="text" class="uc-promotion-link" data-invite-link readonly value=""><button type="button" class="btn-primary btn-sm uc-promotion-copy" data-invite-copy disabled><i class="fas fa-copy" aria-hidden="true"></i><span><?php esc_html_e('复制链接', 'aksrt'); ?></span></button></div><p class="uc-promotion-copy-feedback" data-invite-copy-feedback role="status" aria-live="polite"></p></div></section>
|
||||
<section class="uc-promotion-section uc-promotion-section--reward" aria-labelledby="uc-promotion-reward-title"><div class="uc-promotion-section__header"><h4 id="uc-promotion-reward-title"><?php esc_html_e('奖励说明', 'aksrt'); ?></h4></div><p><?php echo esc_html(sprintf(__('邀请好友完成注册与邮箱验证后,双方将按站点规则获得%s奖励。', 'aksrt'), (string) ($currency_name ?? __('积分', 'aksrt')))); ?></p></section>
|
||||
<section class="uc-promotion-section uc-promotion-section--records" aria-labelledby="uc-promotion-records-title"><div class="uc-promotion-section__header uc-promotion-records__header"><div><h4 id="uc-promotion-records-title"><?php esc_html_e('邀请记录', 'aksrt'); ?></h4><p><?php esc_html_e('查看最近邀请好友的状态', 'aksrt'); ?></p></div><span data-invite-total><?php esc_html_e('加载中…', 'aksrt'); ?></span></div><div class="uc-promotion-record-list is-loading" data-invite-list aria-live="polite"><div class="uc-promotion-record-empty"><?php esc_html_e('正在加载邀请记录…', 'aksrt'); ?></div></div></section>
|
||||
</section>
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Unified user-center promotion earnings panel.
|
||||
*
|
||||
* The promotion tab is the single entry point for referral links, commission
|
||||
* details and withdrawals. The renderer lives in profile-revenue.php so the
|
||||
* existing earnings markup and AJAX refresh path remain in one place.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
require __DIR__ . '/profile-revenue.php';
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* User center commission and promotion rewards panel.
|
||||
* User center commission and referral revenue panel.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
@@ -50,8 +50,8 @@ if (!in_array($active_reward_tab, ['detail', 'orders', 'users'], true)) {
|
||||
$active_reward_tab = 'detail';
|
||||
}
|
||||
$base_url = function_exists('aksrt_get_user_center_tab_url')
|
||||
? aksrt_get_user_center_tab_url('promotion')
|
||||
: home_url('/user/promotion/');
|
||||
? aksrt_get_user_center_tab_url('revenue')
|
||||
: home_url('/user/revenue/');
|
||||
$reward_url = static function (string $tab, array $extra = []) use ($base_url): string {
|
||||
return add_query_arg(array_merge(['reward_tab' => $tab], $extra), $base_url);
|
||||
};
|
||||
@@ -125,18 +125,18 @@ $status_labels = [
|
||||
</nav>
|
||||
|
||||
<?php if ($active_reward_tab === 'detail') : ?>
|
||||
<div class="uc-reward-pane uc-reward-pane--detail" data-aksrt-promotion-page>
|
||||
<div class="uc-promotion-summary-list">
|
||||
<div class="uc-promotion-summary-row uc-promotion-summary-row--link">
|
||||
<div class="uc-reward-pane uc-reward-pane--detail" data-aksrt-revenue-page>
|
||||
<div class="uc-revenue-summary-list">
|
||||
<div class="uc-revenue-summary-row uc-revenue-summary-row--link">
|
||||
<span><?php esc_html_e('推广链接', 'aksrt'); ?></span>
|
||||
<input type="text" readonly data-affiliate-link aria-label="<?php esc_attr_e('推广链接', 'aksrt'); ?>">
|
||||
<button type="button" class="btn-primary btn-sm" data-affiliate-copy><?php esc_html_e('复制', 'aksrt'); ?></button>
|
||||
<small data-affiliate-feedback role="status" aria-live="polite"></small>
|
||||
</div>
|
||||
<div class="uc-promotion-summary-row"><span><?php esc_html_e('佣金比例', 'aksrt'); ?></span><strong data-affiliate-ratio><?php echo esc_html((string) $commission_ratio); ?>%</strong></div>
|
||||
<div class="uc-promotion-summary-row"><span><?php esc_html_e('推广人数', 'aksrt'); ?></span><div class="uc-promotion-count"><strong data-affiliate-promoters>—</strong><em><?php esc_html_e('人', 'aksrt'); ?></em></div></div>
|
||||
<div class="uc-promotion-summary-row uc-promotion-summary-row--total"><span><?php esc_html_e('累计佣金', 'aksrt'); ?></span><div><strong>累计<?php echo esc_html($format_amount($commission_stats['total'] ?? 0)); ?>元</strong><strong>已提现<?php echo esc_html($format_amount($commission_stats['withdrawn'] ?? 0)); ?>元</strong></div></div>
|
||||
<div class="uc-promotion-summary-row uc-promotion-summary-row--explain"><span><?php esc_html_e('返佣详解', 'aksrt'); ?></span><div class="uc-reward-richtext"><?php echo wp_kses_post(wpautop($details_text)); ?></div></div>
|
||||
<div class="uc-revenue-summary-row"><span><?php esc_html_e('佣金比例', 'aksrt'); ?></span><strong data-affiliate-ratio><?php echo esc_html((string) $commission_ratio); ?>%</strong></div>
|
||||
<div class="uc-revenue-summary-row"><span><?php esc_html_e('推广人数', 'aksrt'); ?></span><div class="uc-revenue-count"><strong data-affiliate-promoters>—</strong><em><?php esc_html_e('人', 'aksrt'); ?></em></div></div>
|
||||
<div class="uc-revenue-summary-row uc-revenue-summary-row--total"><span><?php esc_html_e('累计佣金', 'aksrt'); ?></span><div><strong>累计<?php echo esc_html($format_amount($commission_stats['total'] ?? 0)); ?>元</strong><strong>已提现<?php echo esc_html($format_amount($commission_stats['withdrawn'] ?? 0)); ?>元</strong></div></div>
|
||||
<div class="uc-revenue-summary-row uc-revenue-summary-row--explain"><span><?php esc_html_e('返佣详解', 'aksrt'); ?></span><div class="uc-reward-richtext"><?php echo wp_kses_post(wpautop($details_text)); ?></div></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php elseif ($active_reward_tab === 'orders') : ?>
|
||||
@@ -159,9 +159,9 @@ $status_labels = [
|
||||
<div class="uc-reward-pane">
|
||||
<div class="uc-reward-list-heading"><div><h4><?php esc_html_e('推广用户', 'aksrt'); ?></h4><p><?php esc_html_e('通过你的 ref 推广链接完成绑定的用户。', 'aksrt'); ?></p></div><strong><?php printf(esc_html__('%d 人', 'aksrt'), (int) ($user_view['total'] ?? 0)); ?></strong></div>
|
||||
<?php if (!empty($user_view['items'])) : ?>
|
||||
<div class="uc-promotion-user-list">
|
||||
<div class="uc-revenue-user-list">
|
||||
<?php foreach ($user_view['items'] as $item) : ?>
|
||||
<article class="uc-promotion-user-row"><img src="<?php echo esc_url((string) ($item['avatar'] ?? '')); ?>" alt=""><div><strong><?php echo esc_html((string) ($item['name'] ?? __('推广用户', 'aksrt'))); ?></strong><small><?php echo esc_html((string) ($item['bound_at'] ?? '')); ?></small></div><span><?php esc_html_e('已绑定', 'aksrt'); ?></span></article>
|
||||
<article class="uc-revenue-user-row"><img src="<?php echo esc_url((string) ($item['avatar'] ?? '')); ?>" alt=""><div><strong><?php echo esc_html((string) ($item['name'] ?? __('推广用户', 'aksrt'))); ?></strong><small><?php echo esc_html((string) ($item['bound_at'] ?? '')); ?></small></div><span><?php esc_html_e('已绑定', 'aksrt'); ?></span></article>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php if ($user_total_pages > 1) : ?><nav class="uc-reward-pagination" aria-label="<?php esc_attr_e('推广用户分页', 'aksrt'); ?>"><?php for ($i = 1; $i <= $user_total_pages; $i++) : ?><a class="<?php echo $i === $user_page ? 'is-active' : ''; ?>" href="<?php echo esc_url($reward_url('users', ['user_page' => $i])); ?>"><?php echo esc_html((string) $i); ?></a><?php endfor; ?></nav><?php endif; ?>
|
||||
|
||||
@@ -53,12 +53,9 @@ add_action('template_redirect', function () {
|
||||
return;
|
||||
}
|
||||
$tab = $tab === 'balance' ? 'credits' : sanitize_key($tab);
|
||||
if ($tab === 'revenue') {
|
||||
$tab = 'promotion';
|
||||
}
|
||||
$allowed = class_exists('\\AKSRT\\User\\Center')
|
||||
? array_keys(\AKSRT\User\Center::get_instance()->get_dashboard_tabs())
|
||||
: ['profile', 'level', 'creator', 'posts', 'follow', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'promotion', 'settings'];
|
||||
: ['profile', 'level', 'creator', 'posts', 'follow', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'revenue', 'settings'];
|
||||
if (!in_array($tab, $allowed, true)) {
|
||||
global $wp_query;
|
||||
if ($wp_query instanceof WP_Query) { $wp_query->set_404(); }
|
||||
|
||||
@@ -20,7 +20,7 @@ if (!function_exists('aksrt_get_user_center_url')) :
|
||||
*/
|
||||
function aksrt_get_user_center_url(string $tab = ''): string {
|
||||
$tab = sanitize_key($tab ?: 'vip');
|
||||
$aliases = ['assets' => 'credits', 'signin' => 'credits', 'invite' => 'promotion', 'promotion' => 'promotion', 'revenue' => 'promotion'];
|
||||
$aliases = ['assets' => 'credits', 'signin' => 'credits', 'revenue' => 'revenue'];
|
||||
$tab = $aliases[$tab] ?? $tab;
|
||||
$path_tab = $tab === 'credits' ? 'balance' : $tab;
|
||||
return get_option('permalink_structure')
|
||||
|
||||
Reference in new issue
Block a user