feat(users): add inline promotion center
This commit is contained in:
1 parent
aa958c7d01
commit
d138c05f77
11 files changed
+76
-88
No files matched your search
@@ -102,13 +102,17 @@ if (!function_exists('aksrt_get_user_center_tab_url')) {
|
||||
* Build a canonical full-page user-center tab URL.
|
||||
*/
|
||||
function aksrt_get_user_center_tab_url(string $tab): string {
|
||||
$tab = sanitize_key($tab);
|
||||
if ('invite' === $tab) {
|
||||
$tab = 'promotion';
|
||||
}
|
||||
$url = remove_query_arg([
|
||||
'tab', 'posts_page', 'comments_page', 'favorites_page', 'credits_page',
|
||||
'post_status', 'saved', 'profile_error',
|
||||
'order_tab', 'otab', 'order_status', 'order_page', 'order_type', 'section',
|
||||
], aksrt_get_user_center_url());
|
||||
|
||||
return add_query_arg('tab', sanitize_key($tab), $url);
|
||||
return add_query_arg('tab', $tab, $url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,6 +154,7 @@ if (!function_exists('aksrt_capture_user_center_view')) {
|
||||
'vip' => 'vip',
|
||||
'orders' => 'orders',
|
||||
'auth' => 'auth',
|
||||
'promotion' => 'promotion',
|
||||
'settings' => 'settings',
|
||||
'header' => 'header',
|
||||
'sidebar' => 'sidebar',
|
||||
@@ -174,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', 'settings'];
|
||||
$built_in_tabs = ['profile', 'level', 'posts', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'promotion', 'settings'];
|
||||
if (in_array($tab_key, $built_in_tabs, true)) {
|
||||
return aksrt_capture_user_center_view($tab_key, $context);
|
||||
}
|
||||
@@ -280,7 +285,7 @@ if (!function_exists('aksrt_user_center_resolve_tabs')) {
|
||||
if ('signin' === $active || 'assets' === $active) {
|
||||
$active = 'credits';
|
||||
} elseif ('invite' === $active) {
|
||||
$active = 'settings';
|
||||
$active = 'promotion';
|
||||
} elseif ('vip' === $active) {
|
||||
// Prefer dedicated vip tab when registered; else credits (VIP shop).
|
||||
$active = in_array('vip', $keys, true) ? 'vip' : 'credits';
|
||||
@@ -339,7 +344,7 @@ if (!function_exists('aksrt_user_center_runtime_config')) {
|
||||
'activeTab' => $active_tab,
|
||||
'tabAliases' => [
|
||||
'signin' => 'credits',
|
||||
'invite' => 'settings',
|
||||
'invite' => 'promotion',
|
||||
'assets' => 'credits',
|
||||
// vip → vip when panel exists; SPA may still map missing keys via server resolve.
|
||||
'vip' => 'vip',
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* User center promotion panel shell.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
||||
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
|
||||
?>
|
||||
<section class="uc-promotion-panel" aria-labelledby="uc-promotion-title">
|
||||
<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>
|
||||
<h2 id="uc-promotion-title"><?php esc_html_e('推广中心', 'aksrt'); ?></h2>
|
||||
</div>
|
||||
</header>
|
||||
<p class="uc-promotion-panel__intro"><?php esc_html_e('在这里分享专属邀请链接并查看推广成果。', 'aksrt'); ?></p>
|
||||
</section>
|
||||
@@ -13,5 +13,4 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
|
||||
$dir = __DIR__;
|
||||
require $dir . '/settings-bindings.php';
|
||||
require $dir . '/settings-security.php';
|
||||
require $dir . '/settings-invite.php';
|
||||
require $dir . '/settings-runtime-fields.php';
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* User center settings: invite friends panel.
|
||||
*
|
||||
* Expects extracted $context vars.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if (empty($show_invite_section)) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div class="settings-section">
|
||||
<div class="settings-section__header">
|
||||
<span class="settings-icon"><i class="fas fa-user-plus" aria-hidden="true"></i></span>
|
||||
<h3 class="widget-title settings-section__title"><?php esc_html_e('邀请好友', 'aksrt'); ?></h3>
|
||||
</div>
|
||||
<div class="aksrt-invite-panel" data-aksrt-invite>
|
||||
<div class="aksrt-invite-hero">
|
||||
<div class="aksrt-invite-hero__main">
|
||||
<span class="aksrt-invite-kicker"><?php esc_html_e('邀请奖励', 'aksrt'); ?></span>
|
||||
<p class="aksrt-invite-desc">
|
||||
<?php echo esc_html(sprintf(__('将专属链接分享给好友,好友完成注册与验证后即可获得双向%s奖励。', 'aksrt'), $currency_name)); ?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="aksrt-invite-code-card">
|
||||
<span><?php esc_html_e('邀请码', 'aksrt'); ?></span>
|
||||
<strong data-invite-code>--</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="aksrt-invite-link-row">
|
||||
<input type="text" class="aksrt-invite-link" data-invite-link readonly value="" aria-label="<?php esc_attr_e('邀请链接', 'aksrt'); ?>">
|
||||
<button type="button" class="btn-primary btn-sm aksrt-invite-copy" data-invite-copy>
|
||||
<i class="fas fa-copy" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('复制链接', 'aksrt'); ?></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="aksrt-invite-stats" data-invite-stats>
|
||||
<div class="aksrt-invite-stat">
|
||||
<span><?php esc_html_e('已注册', 'aksrt'); ?></span>
|
||||
<strong data-stat="registered">0</strong>
|
||||
<small><?php esc_html_e('通过链接完成注册', 'aksrt'); ?></small>
|
||||
</div>
|
||||
<div class="aksrt-invite-stat">
|
||||
<span><?php esc_html_e('已验证', 'aksrt'); ?></span>
|
||||
<strong data-stat="verified">0</strong>
|
||||
<small><?php esc_html_e('完成邮箱验证', 'aksrt'); ?></small>
|
||||
</div>
|
||||
<div class="aksrt-invite-stat">
|
||||
<span><?php esc_html_e('已奖励', 'aksrt'); ?></span>
|
||||
<strong data-stat="rewarded">0</strong>
|
||||
<small><?php esc_html_e('奖励已发放', 'aksrt'); ?></small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="aksrt-invite-records">
|
||||
<div class="aksrt-invite-records__header">
|
||||
<h4><?php esc_html_e('邀请记录', 'aksrt'); ?></h4>
|
||||
<span data-invite-total><?php esc_html_e('加载中', 'aksrt'); ?></span>
|
||||
</div>
|
||||
<div class="aksrt-invite-record-list is-loading" data-invite-list>
|
||||
<div class="aksrt-invite-record-empty">
|
||||
<?php esc_html_e('正在加载邀请记录...', 'aksrt'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* User center sidebar: creation and promotion center pair.
|
||||
* User center sidebar: creation and revenue center pair.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
@@ -11,9 +11,9 @@ $creation_url = (string) ($new_post_url ?? '');
|
||||
if ($creation_url === '') {
|
||||
$creation_url = isset($dashboard_tabs['posts']) ? aksrt_get_user_center_tab_url('posts') : '';
|
||||
}
|
||||
$promotion_url = (string) ($revenue_url ?? '');
|
||||
$revenue_url = (string) ($revenue_url ?? '');
|
||||
|
||||
if ($creation_url === '' && $promotion_url === '') {
|
||||
if ($creation_url === '' && $revenue_url === '') {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
@@ -25,10 +25,10 @@ if ($creation_url === '' && $promotion_url === '') {
|
||||
<i class="fas fa-angle-right" aria-hidden="true"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($promotion_url !== '') : ?>
|
||||
<a class="uc-center-card uc-center-card--promotion" href="<?php echo esc_url($promotion_url); ?>">
|
||||
<span class="uc-center-card__icon"><i class="fas fa-bullhorn" aria-hidden="true"></i></span>
|
||||
<span><strong><?php esc_html_e('推广中心', 'aksrt'); ?></strong><small><?php esc_html_e('返佣与收益', 'aksrt'); ?></small></span>
|
||||
<?php if ($revenue_url !== '') : ?>
|
||||
<a class="uc-center-card uc-center-card--promotion" href="<?php echo esc_url($revenue_url); ?>">
|
||||
<span class="uc-center-card__icon"><i class="fas fa-chart-line" aria-hidden="true"></i></span>
|
||||
<span><strong><?php esc_html_e('收益中心', 'aksrt'); ?></strong><small><?php esc_html_e('返佣与收益', 'aksrt'); ?></small></span>
|
||||
<i class="fas fa-angle-right" aria-hidden="true"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -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 ?? '') : '';
|
||||
|
||||
@@ -28,6 +29,13 @@ $services = array_values(array_filter([
|
||||
'url' => $auth_url,
|
||||
'tab' => 'auth',
|
||||
],
|
||||
[
|
||||
'label' => __('推广中心', 'aksrt'),
|
||||
'icon' => 'user-plus',
|
||||
'tone' => 'promotion',
|
||||
'url' => $promotion_url,
|
||||
'tab' => 'promotion',
|
||||
],
|
||||
[
|
||||
'label' => __('我的订单', 'aksrt'),
|
||||
'icon' => 'receipt',
|
||||
|
||||
@@ -32,7 +32,7 @@ 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' => 'settings',
|
||||
'invite' => 'promotion',
|
||||
];
|
||||
if (isset($aliases[$tab])) {
|
||||
$tab = $aliases[$tab];
|
||||
|
||||
Reference in new issue
Block a user