Merge pull request 'Worktree prd user promotion center inline uiux' (#366) from worktree-prd-user-promotion-center-inline-uiux into main
Reviewed-on: CYL/wordpress-theme-aksrt#366
This commit is contained in:
commit
edb62fd22f
12 files changed
+213
-106
No files matched your search
@@ -4,7 +4,7 @@ export const featuresSchema = {
|
|||||||
icon: 'fas fa-user-cog',
|
icon: 'fas fa-user-cog',
|
||||||
description: '配置用户中心和个人主页的功能模块。',
|
description: '配置用户中心和个人主页的功能模块。',
|
||||||
defaults: {
|
defaults: {
|
||||||
user_center_tabs: 'profile,level,posts,comments,favorites,vip,credits,auth',
|
user_center_tabs: 'profile,level,posts,comments,favorites,vip,credits,promotion,auth',
|
||||||
user_cover_upload: true,
|
user_cover_upload: true,
|
||||||
user_social_links: true,
|
user_social_links: true,
|
||||||
user_desc_std: '这家伙很懒…',
|
user_desc_std: '这家伙很懒…',
|
||||||
@@ -24,7 +24,7 @@ export const featuresSchema = {
|
|||||||
title: '用户中心',
|
title: '用户中心',
|
||||||
icon: 'fas fa-user-shield',
|
icon: 'fas fa-user-shield',
|
||||||
fields: [
|
fields: [
|
||||||
{ key: 'user_center_tabs', label: '用户中心 Tab', type: 'input', default: 'profile,level,posts,comments,favorites,vip,credits,auth', help: '逗号分隔。level=我的等级;auth=官方认证;等级、VIP、订单和认证会按功能开关自动注入' },
|
{ key: 'user_center_tabs', label: '用户中心 Tab', type: 'input', default: 'profile,level,posts,comments,favorites,vip,credits,promotion,auth', help: '逗号分隔。level=我的等级;promotion=推广中心;auth=官方认证;等级、VIP、订单、推广中心和认证会按功能开关自动注入' },
|
||||||
{ key: 'user_cover_upload', label: '封面上传', type: 'switch', default: true },
|
{ key: 'user_cover_upload', label: '封面上传', type: 'switch', default: true },
|
||||||
{ key: 'user_social_links', label: '社交链接', type: 'switch', default: true },
|
{ key: 'user_social_links', label: '社交链接', type: 'switch', default: true },
|
||||||
{ key: 'user_desc_std', label: '默认签名', type: 'input', default: '这家伙很懒…', help: '用户未设置个人简介时显示的默认文案' },
|
{ key: 'user_desc_std', label: '默认签名', type: 'input', default: '这家伙很懒…', help: '用户未设置个人简介时显示的默认文案' },
|
||||||
|
|||||||
+67
-18
@@ -225,6 +225,20 @@
|
|||||||
var codeEl = root.querySelector('[data-invite-code]');
|
var codeEl = root.querySelector('[data-invite-code]');
|
||||||
var listEl = root.querySelector('[data-invite-list]');
|
var listEl = root.querySelector('[data-invite-list]');
|
||||||
var totalEl = root.querySelector('[data-invite-total]');
|
var totalEl = root.querySelector('[data-invite-total]');
|
||||||
|
var statusEl = root.querySelector('[data-invite-status]');
|
||||||
|
var copyFeedback = root.querySelector('[data-invite-copy-feedback]');
|
||||||
|
|
||||||
|
function setStatus(text, isError) {
|
||||||
|
if (!statusEl) return;
|
||||||
|
statusEl.textContent = text;
|
||||||
|
statusEl.classList.toggle('is-error', !!isError);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCopyFeedback(text, isError) {
|
||||||
|
if (!copyFeedback) return;
|
||||||
|
copyFeedback.textContent = text;
|
||||||
|
copyFeedback.classList.toggle('is-error', !!isError);
|
||||||
|
}
|
||||||
|
|
||||||
function escapeHtml(value) {
|
function escapeHtml(value) {
|
||||||
return String(value == null ? '' : value)
|
return String(value == null ? '' : value)
|
||||||
@@ -268,7 +282,7 @@
|
|||||||
else totalEl.textContent = total ? '共 ' + total + ' 条' : '暂无记录';
|
else totalEl.textContent = total ? '共 ' + total + ' 条' : '暂无记录';
|
||||||
}
|
}
|
||||||
if (!items.length) {
|
if (!items.length) {
|
||||||
listEl.innerHTML = '<div class="aksrt-invite-record-empty">分享链接后,好友注册记录会显示在这里。</div>';
|
listEl.innerHTML = '<div class="uc-promotion-record-empty">分享链接后,好友注册记录会显示在这里。</div>';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,14 +298,14 @@
|
|||||||
? '<img src="' + escapeHtml(item.invitee_avatar) + '" alt="">'
|
? '<img src="' + escapeHtml(item.invitee_avatar) + '" alt="">'
|
||||||
: '<span>' + escapeHtml(first) + '</span>';
|
: '<span>' + escapeHtml(first) + '</span>';
|
||||||
|
|
||||||
return '<div class="aksrt-invite-record ' + meta.className + '">' +
|
return '<div class="uc-promotion-record ' + meta.className + '">' +
|
||||||
'<div class="aksrt-invite-record__avatar">' + avatar + '</div>' +
|
'<div class="uc-promotion-record__avatar">' + avatar + '</div>' +
|
||||||
'<div class="aksrt-invite-record__main">' +
|
'<div class="uc-promotion-record__main">' +
|
||||||
'<strong>' + escapeHtml(name) + '</strong>' +
|
'<strong>' + escapeHtml(name) + '</strong>' +
|
||||||
'<span>' + (createdAt ? '注册于 ' + escapeHtml(createdAt) : '注册时间未知') + '</span>' +
|
'<span>' + (createdAt ? '注册于 ' + escapeHtml(createdAt) : '注册时间未知') + '</span>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<div class="aksrt-invite-record__status">' +
|
'<div class="uc-promotion-record__status">' +
|
||||||
'<span class="aksrt-invite-badge ' + meta.className + '">' + meta.label + '</span>' +
|
'<span class="uc-promotion-badge ' + meta.className + '">' + meta.label + '</span>' +
|
||||||
'<small>' + escapeHtml(statusText) + '</small>' +
|
'<small>' + escapeHtml(statusText) + '</small>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
@@ -308,10 +322,12 @@
|
|||||||
el.textContent = '—';
|
el.textContent = '—';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
setStatus((r.json && r.json.message) || '推广数据加载失败,请稍后刷新。', true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var j = r.json;
|
var j = r.json || {};
|
||||||
if (linkInput) linkInput.value = j.invite_url || '';
|
if (linkInput) linkInput.value = j.invite_url || '';
|
||||||
|
if (copyBtn) copyBtn.disabled = !j.invite_url;
|
||||||
if (codeEl) codeEl.textContent = j.code || '--';
|
if (codeEl) codeEl.textContent = j.code || '--';
|
||||||
if (stats && j.stats) {
|
if (stats && j.stats) {
|
||||||
stats.querySelectorAll('[data-stat]').forEach(function (el) {
|
stats.querySelectorAll('[data-stat]').forEach(function (el) {
|
||||||
@@ -319,16 +335,23 @@
|
|||||||
el.textContent = (j.stats[k] || 0).toString();
|
el.textContent = (j.stats[k] || 0).toString();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
setStatus('推广数据已更新。');
|
||||||
}).catch(function () {
|
}).catch(function () {
|
||||||
if (copyBtn) copyBtn.disabled = true;
|
if (copyBtn) copyBtn.disabled = true;
|
||||||
if (codeEl) codeEl.textContent = '--';
|
if (codeEl) codeEl.textContent = '--';
|
||||||
|
if (stats) {
|
||||||
|
stats.querySelectorAll('[data-stat]').forEach(function (el) {
|
||||||
|
el.textContent = '—';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
setStatus('推广数据加载失败,请检查网络后重试。', true);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (listEl) {
|
if (listEl) {
|
||||||
api('/invite/list?per_page=8').then(function (r) {
|
api('/invite/list?per_page=8').then(function (r) {
|
||||||
if (!r.ok) {
|
if (!r.ok) {
|
||||||
listEl.classList.remove('is-loading');
|
listEl.classList.remove('is-loading');
|
||||||
listEl.innerHTML = '<div class="aksrt-invite-record-empty">邀请记录加载失败,请稍后刷新。</div>';
|
listEl.innerHTML = '<div class="uc-promotion-record-empty">邀请记录加载失败,请稍后刷新。</div>';
|
||||||
if (totalEl) totalEl.textContent = '加载失败';
|
if (totalEl) totalEl.textContent = '加载失败';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -336,7 +359,7 @@
|
|||||||
renderInviteList(j.items || [], Number(j.total || 0));
|
renderInviteList(j.items || [], Number(j.total || 0));
|
||||||
}).catch(function () {
|
}).catch(function () {
|
||||||
listEl.classList.remove('is-loading');
|
listEl.classList.remove('is-loading');
|
||||||
listEl.innerHTML = '<div class="aksrt-invite-record-empty">邀请记录加载失败,请稍后刷新。</div>';
|
listEl.innerHTML = '<div class="uc-promotion-record-empty">邀请记录加载失败,请稍后刷新。</div>';
|
||||||
if (totalEl) totalEl.textContent = '加载失败';
|
if (totalEl) totalEl.textContent = '加载失败';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -346,17 +369,43 @@
|
|||||||
copyBtn.addEventListener('click', function () {
|
copyBtn.addEventListener('click', function () {
|
||||||
if (copying || !linkInput || !linkInput.value) return;
|
if (copying || !linkInput || !linkInput.value) return;
|
||||||
copying = true;
|
copying = true;
|
||||||
if (navigator.clipboard) {
|
copyBtn.disabled = true;
|
||||||
navigator.clipboard.writeText(linkInput.value).then(function () {
|
setCopyFeedback('正在复制…');
|
||||||
setCopyText('已复制');
|
|
||||||
setTimeout(function () { setCopyText('复制链接'); copying = false; }, 2000);
|
function copied() {
|
||||||
}).catch(function () { copying = false; });
|
|
||||||
} else {
|
|
||||||
linkInput.select();
|
|
||||||
document.execCommand('copy');
|
|
||||||
setCopyText('已复制');
|
setCopyText('已复制');
|
||||||
setTimeout(function () { setCopyText('复制链接'); copying = false; }, 2000);
|
setCopyFeedback('推广链接已复制到剪贴板。');
|
||||||
|
setTimeout(function () {
|
||||||
|
setCopyText('复制链接');
|
||||||
|
setCopyFeedback('');
|
||||||
|
copyBtn.disabled = false;
|
||||||
|
copying = false;
|
||||||
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function copyFailed() {
|
||||||
|
setCopyText('复制链接');
|
||||||
|
setCopyFeedback('复制失败,请手动选择并复制链接。', true);
|
||||||
|
copyBtn.disabled = false;
|
||||||
|
copying = false;
|
||||||
|
linkInput.focus();
|
||||||
|
linkInput.select();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
|
||||||
|
navigator.clipboard.writeText(linkInput.value).then(copied).catch(copyFailed);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
linkInput.focus();
|
||||||
|
linkInput.select();
|
||||||
|
try {
|
||||||
|
if (document.execCommand('copy')) {
|
||||||
|
copied();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
copyFailed();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,13 +102,17 @@ if (!function_exists('aksrt_get_user_center_tab_url')) {
|
|||||||
* Build a canonical full-page user-center tab URL.
|
* Build a canonical full-page user-center tab URL.
|
||||||
*/
|
*/
|
||||||
function aksrt_get_user_center_tab_url(string $tab): string {
|
function aksrt_get_user_center_tab_url(string $tab): string {
|
||||||
|
$tab = sanitize_key($tab);
|
||||||
|
if ('invite' === $tab) {
|
||||||
|
$tab = 'promotion';
|
||||||
|
}
|
||||||
$url = remove_query_arg([
|
$url = remove_query_arg([
|
||||||
'tab', 'posts_page', 'comments_page', 'favorites_page', 'credits_page',
|
'tab', 'posts_page', 'comments_page', 'favorites_page', 'credits_page',
|
||||||
'post_status', 'saved', 'profile_error',
|
'post_status', 'saved', 'profile_error',
|
||||||
'order_tab', 'otab', 'order_status', 'order_page', 'order_type', 'section',
|
'order_tab', 'otab', 'order_status', 'order_page', 'order_type', 'section',
|
||||||
], aksrt_get_user_center_url());
|
], 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',
|
'vip' => 'vip',
|
||||||
'orders' => 'orders',
|
'orders' => 'orders',
|
||||||
'auth' => 'auth',
|
'auth' => 'auth',
|
||||||
|
'promotion' => 'promotion',
|
||||||
'settings' => 'settings',
|
'settings' => 'settings',
|
||||||
'header' => 'header',
|
'header' => 'header',
|
||||||
'sidebar' => 'sidebar',
|
'sidebar' => 'sidebar',
|
||||||
@@ -174,7 +179,7 @@ if (!function_exists('aksrt_capture_user_center_panel')) {
|
|||||||
* Capture a built-in or registered user-center panel body.
|
* Capture a built-in or registered user-center panel body.
|
||||||
*/
|
*/
|
||||||
function aksrt_capture_user_center_panel(string $tab_key, array $tab, array $context): string {
|
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)) {
|
if (in_array($tab_key, $built_in_tabs, true)) {
|
||||||
return aksrt_capture_user_center_view($tab_key, $context);
|
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) {
|
if ('signin' === $active || 'assets' === $active) {
|
||||||
$active = 'credits';
|
$active = 'credits';
|
||||||
} elseif ('invite' === $active) {
|
} elseif ('invite' === $active) {
|
||||||
$active = 'settings';
|
$active = 'promotion';
|
||||||
} elseif ('vip' === $active) {
|
} elseif ('vip' === $active) {
|
||||||
// Prefer dedicated vip tab when registered; else credits (VIP shop).
|
// Prefer dedicated vip tab when registered; else credits (VIP shop).
|
||||||
$active = in_array('vip', $keys, true) ? 'vip' : 'credits';
|
$active = in_array('vip', $keys, true) ? 'vip' : 'credits';
|
||||||
@@ -339,7 +344,7 @@ if (!function_exists('aksrt_user_center_runtime_config')) {
|
|||||||
'activeTab' => $active_tab,
|
'activeTab' => $active_tab,
|
||||||
'tabAliases' => [
|
'tabAliases' => [
|
||||||
'signin' => 'credits',
|
'signin' => 'credits',
|
||||||
'invite' => 'settings',
|
'invite' => 'promotion',
|
||||||
'assets' => 'credits',
|
'assets' => 'credits',
|
||||||
// vip → vip when panel exists; SPA may still map missing keys via server resolve.
|
// vip → vip when panel exists; SPA may still map missing keys via server resolve.
|
||||||
'vip' => 'vip',
|
'vip' => 'vip',
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* User center promotion panel.
|
||||||
|
*
|
||||||
|
* @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" 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>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<div class="uc-promotion-panel__status" data-invite-status role="status" aria-live="polite">
|
||||||
|
<?php esc_html_e('正在加载推广数据…', 'aksrt'); ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<section class="uc-promotion-section uc-promotion-section--stats" aria-labelledby="uc-promotion-stats-title">
|
||||||
|
<div class="uc-promotion-section__header">
|
||||||
|
<h3 id="uc-promotion-stats-title"><?php esc_html_e('推广成果', 'aksrt'); ?></h3>
|
||||||
|
<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">
|
||||||
|
<h3 id="uc-promotion-share-title"><?php esc_html_e('分享专属链接', 'aksrt'); ?></h3>
|
||||||
|
<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">
|
||||||
|
<h3 id="uc-promotion-reward-title"><?php esc_html_e('奖励说明', 'aksrt'); ?></h3>
|
||||||
|
</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>
|
||||||
|
<h3 id="uc-promotion-records-title"><?php esc_html_e('邀请记录', 'aksrt'); ?></h3>
|
||||||
|
<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>
|
||||||
@@ -13,5 +13,4 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
|
|||||||
$dir = __DIR__;
|
$dir = __DIR__;
|
||||||
require $dir . '/settings-bindings.php';
|
require $dir . '/settings-bindings.php';
|
||||||
require $dir . '/settings-security.php';
|
require $dir . '/settings-security.php';
|
||||||
require $dir . '/settings-invite.php';
|
|
||||||
require $dir . '/settings-runtime-fields.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
|
<?php
|
||||||
/**
|
/**
|
||||||
* User center sidebar: creation and promotion center pair.
|
* User center sidebar: creation and revenue center pair.
|
||||||
*
|
*
|
||||||
* @package AKSRT
|
* @package AKSRT
|
||||||
*/
|
*/
|
||||||
@@ -11,9 +11,9 @@ $creation_url = (string) ($new_post_url ?? '');
|
|||||||
if ($creation_url === '') {
|
if ($creation_url === '') {
|
||||||
$creation_url = isset($dashboard_tabs['posts']) ? aksrt_get_user_center_tab_url('posts') : '';
|
$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;
|
return;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -25,10 +25,10 @@ if ($creation_url === '' && $promotion_url === '') {
|
|||||||
<i class="fas fa-angle-right" aria-hidden="true"></i>
|
<i class="fas fa-angle-right" aria-hidden="true"></i>
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($promotion_url !== '') : ?>
|
<?php if ($revenue_url !== '') : ?>
|
||||||
<a class="uc-center-card uc-center-card--promotion" href="<?php echo esc_url($promotion_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-bullhorn" aria-hidden="true"></i></span>
|
<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>
|
<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>
|
<i class="fas fa-angle-right" aria-hidden="true"></i>
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ $level_url = isset($dashboard_tabs['level'])
|
|||||||
? aksrt_get_user_center_tab_url('level')
|
? aksrt_get_user_center_tab_url('level')
|
||||||
: '';
|
: '';
|
||||||
$auth_url = isset($dashboard_tabs['auth']) ? aksrt_get_user_center_tab_url('auth') : '';
|
$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_available = isset($dashboard_tabs['orders']);
|
||||||
$orders_url = $orders_available ? (string) ($orders_url ?? '') : '';
|
$orders_url = $orders_available ? (string) ($orders_url ?? '') : '';
|
||||||
|
|
||||||
@@ -28,6 +29,13 @@ $services = array_values(array_filter([
|
|||||||
'url' => $auth_url,
|
'url' => $auth_url,
|
||||||
'tab' => 'auth',
|
'tab' => 'auth',
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'label' => __('推广中心', 'aksrt'),
|
||||||
|
'icon' => 'user-plus',
|
||||||
|
'tone' => 'promotion',
|
||||||
|
'url' => $promotion_url,
|
||||||
|
'tab' => 'promotion',
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'label' => __('我的订单', 'aksrt'),
|
'label' => __('我的订单', 'aksrt'),
|
||||||
'icon' => 'receipt',
|
'icon' => 'receipt',
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ function aksrt_get_user_center_url(string $tab = ''): string {
|
|||||||
'assets' => 'credits',
|
'assets' => 'credits',
|
||||||
'vip' => 'vip', // dedicated vip tab when registered; resolver falls back if missing
|
'vip' => 'vip', // dedicated vip tab when registered; resolver falls back if missing
|
||||||
'signin' => 'credits',
|
'signin' => 'credits',
|
||||||
'invite' => 'settings',
|
'invite' => 'promotion',
|
||||||
];
|
];
|
||||||
if (isset($aliases[$tab])) {
|
if (isset($aliases[$tab])) {
|
||||||
$tab = $aliases[$tab];
|
$tab = $aliases[$tab];
|
||||||
|
|||||||
@@ -526,7 +526,7 @@ class SchemaUsers {
|
|||||||
'option_key' => 'aksrt_settings',
|
'option_key' => 'aksrt_settings',
|
||||||
'groups' => [
|
'groups' => [
|
||||||
['key' => 'center', 'title' => '用户中心', 'fields' => [
|
['key' => 'center', 'title' => '用户中心', 'fields' => [
|
||||||
['key' => 'user_center_tabs', 'label' => '用户中心 Tab', 'type' => 'input', 'default' => 'profile,level,posts,comments,favorites,vip,credits,auth', 'help' => '逗号分隔。level=我的等级;auth=官方认证;等级、VIP、订单和认证会按功能开关自动注入'],
|
['key' => 'user_center_tabs', 'label' => '用户中心 Tab', 'type' => 'input', 'default' => 'profile,level,posts,comments,favorites,vip,credits,promotion,auth', 'help' => '逗号分隔。level=我的等级;promotion=推广中心;auth=官方认证;等级、VIP、订单、推广中心和认证会按功能开关自动注入'],
|
||||||
['key' => 'user_cover_upload', 'label' => '封面上传', 'type' => 'switch', 'default' => true],
|
['key' => 'user_cover_upload', 'label' => '封面上传', 'type' => 'switch', 'default' => true],
|
||||||
['key' => 'user_social_links', 'label' => '社交链接', 'type' => 'switch', 'default' => true],
|
['key' => 'user_social_links', 'label' => '社交链接', 'type' => 'switch', 'default' => true],
|
||||||
['key' => 'user_desc_std', 'label' => '默认签名', 'type' => 'input', 'default' => '这家伙很懒…', 'desc' => '用户未设置个人简介时显示的默认文案'],
|
['key' => 'user_desc_std', 'label' => '默认签名', 'type' => 'input', 'default' => '这家伙很懒…', 'desc' => '用户未设置个人简介时显示的默认文案'],
|
||||||
|
|||||||
@@ -83,14 +83,14 @@ class UserRuntime {
|
|||||||
*/
|
*/
|
||||||
public static function get_user_center_settings(): array {
|
public static function get_user_center_settings(): array {
|
||||||
$settings = Settings::get_all();
|
$settings = Settings::get_all();
|
||||||
$raw_tabs = $settings['user_center_tabs'] ?? 'profile,level,posts,comments,credits,favorites,auth';
|
$raw_tabs = $settings['user_center_tabs'] ?? 'profile,level,posts,comments,credits,promotion,favorites,auth';
|
||||||
$tabs = is_array($raw_tabs)
|
$tabs = is_array($raw_tabs)
|
||||||
? $raw_tabs
|
? $raw_tabs
|
||||||
: preg_split('/[\s,]+/', (string) $raw_tabs, -1, PREG_SPLIT_NO_EMPTY);
|
: preg_split('/[\s,]+/', (string) $raw_tabs, -1, PREG_SPLIT_NO_EMPTY);
|
||||||
|
|
||||||
// Built-in switchable panels. VIP is always auto-injected when enabled
|
// Built-in switchable panels. VIP is always auto-injected when enabled
|
||||||
// by AKSRT\User\Center — keep it allowed for explicit config too.
|
// by AKSRT\User\Center — keep it allowed for explicit config too.
|
||||||
$allowed_tabs = ['profile', 'level', 'posts', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'settings'];
|
$allowed_tabs = ['profile', 'level', 'posts', 'comments', 'favorites', 'credits', 'promotion', 'vip', 'orders', 'auth', 'settings'];
|
||||||
$normalized_tabs = ['profile'];
|
$normalized_tabs = ['profile'];
|
||||||
|
|
||||||
foreach ((array) $tabs as $tab) {
|
foreach ((array) $tabs as $tab) {
|
||||||
|
|||||||
@@ -91,6 +91,12 @@ class Center {
|
|||||||
'priority' => 50,
|
'priority' => 50,
|
||||||
'type' => 'panel',
|
'type' => 'panel',
|
||||||
],
|
],
|
||||||
|
'promotion' => [
|
||||||
|
'label' => __('推广中心', 'aksrt'),
|
||||||
|
'icon' => 'user-plus',
|
||||||
|
'priority' => 55,
|
||||||
|
'type' => 'panel',
|
||||||
|
],
|
||||||
'notif' => [
|
'notif' => [
|
||||||
'label' => __('消息通知', 'aksrt'),
|
'label' => __('消息通知', 'aksrt'),
|
||||||
'icon' => 'bell',
|
'icon' => 'bell',
|
||||||
@@ -121,6 +127,10 @@ class Center {
|
|||||||
&& !empty(\AKSRT\User\Level::settings()['enabled']);
|
&& !empty(\AKSRT\User\Level::settings()['enabled']);
|
||||||
$credits_on = class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::credits_enabled();
|
$credits_on = class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::credits_enabled();
|
||||||
$balance_on = class_exists('\AKSRT\Credits\Balance') && \AKSRT\Credits\Balance::enabled();
|
$balance_on = class_exists('\AKSRT\Credits\Balance') && \AKSRT\Credits\Balance::enabled();
|
||||||
|
$promotion_on = $credits_on
|
||||||
|
&& class_exists('\AKSRT\Settings\Settings')
|
||||||
|
&& \AKSRT\Settings\Settings::invite_enabled()
|
||||||
|
&& \AKSRT\Settings\Settings::invite_registration_enabled();
|
||||||
$vip_on = class_exists('\AKSRT\Settings\Settings')
|
$vip_on = class_exists('\AKSRT\Settings\Settings')
|
||||||
&& !empty(\AKSRT\Settings\Settings::get_payment_vip_settings()['enabled']);
|
&& !empty(\AKSRT\Settings\Settings::get_payment_vip_settings()['enabled']);
|
||||||
|
|
||||||
@@ -167,6 +177,17 @@ class Center {
|
|||||||
if (($credits_on || $balance_on) && !in_array('credits', $order, true)) {
|
if (($credits_on || $balance_on) && !in_array('credits', $order, true)) {
|
||||||
$order[] = 'credits';
|
$order[] = 'credits';
|
||||||
}
|
}
|
||||||
|
if ($promotion_on && !in_array('promotion', $order, true)) {
|
||||||
|
$insert_at = count($order);
|
||||||
|
foreach (['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, ['promotion']);
|
||||||
|
}
|
||||||
$auth_on = class_exists('\AKSRT\User\AuthApply')
|
$auth_on = class_exists('\AKSRT\User\AuthApply')
|
||||||
&& !empty(\AKSRT\User\AuthApply::settings()['enabled']);
|
&& !empty(\AKSRT\User\AuthApply::settings()['enabled']);
|
||||||
if ($auth_on && !in_array('auth', $order, true)) {
|
if ($auth_on && !in_array('auth', $order, true)) {
|
||||||
@@ -186,6 +207,9 @@ class Center {
|
|||||||
if ($key === 'credits' && !$credits_on && !$balance_on) {
|
if ($key === 'credits' && !$credits_on && !$balance_on) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if ($key === 'promotion' && !$promotion_on) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ($key === 'vip' && !$vip_on) {
|
if ($key === 'vip' && !$vip_on) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user