fix(user-center): embed official certification panel
This commit is contained in:
1 parent
d3bf75fbea
commit
0a04c3e4cc
22 files changed
+415
-461
No files matched your search
@@ -148,6 +148,7 @@ if (!function_exists('aksrt_capture_user_center_view')) {
|
||||
'credits' => 'credits',
|
||||
'vip' => 'vip',
|
||||
'orders' => 'orders',
|
||||
'auth' => 'auth',
|
||||
'settings' => 'settings',
|
||||
'header' => 'header',
|
||||
'sidebar' => 'sidebar',
|
||||
@@ -172,7 +173,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', 'posts', 'comments', 'favorites', 'credits', 'vip', 'orders', 'settings'];
|
||||
$built_in_tabs = ['profile', 'posts', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'settings'];
|
||||
if (in_array($tab_key, $built_in_tabs, true)) {
|
||||
return aksrt_capture_user_center_view($tab_key, $context);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* User center panel: official certification.
|
||||
*
|
||||
* Zibll parity: compact center card + in-place application modal.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
use AKSRT\User\AuthApply;
|
||||
|
||||
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
||||
$user_id = (int) ($context['user_id'] ?? get_current_user_id());
|
||||
$settings = class_exists(AuthApply::class) ? AuthApply::settings() : ['enabled' => false, 'allow_apply' => false];
|
||||
$status = $user_id > 0 && class_exists(AuthApply::class) ? AuthApply::get_status($user_id) : '';
|
||||
$info = $user_id > 0 && class_exists(AuthApply::class) ? AuthApply::get_auth_info($user_id) : [];
|
||||
$apply = $user_id > 0 && class_exists(AuthApply::class) ? AuthApply::get_apply_payload($user_id) : [];
|
||||
$type_labels = [];
|
||||
foreach ((array) ($settings['types'] ?? []) as $type) {
|
||||
$type_labels[(string) ($type['slug'] ?? '')] = (string) ($type['label'] ?? '');
|
||||
}
|
||||
$apply_type = sanitize_key((string) ($apply['type'] ?? ''));
|
||||
$limit = (int) ($settings['limit_level'] ?? 0);
|
||||
$current_level = class_exists('\AKSRT\User\Level') ? (int) \AKSRT\User\Level::get_level($user_id) : 0;
|
||||
$blocked_level = $limit > 0 && $current_level < $limit;
|
||||
$can_apply = !empty($settings['enabled']) && !empty($settings['allow_apply']) && !$blocked_level && $status !== 'verified';
|
||||
?>
|
||||
<div class="aksrt-user-auth-panel uc-auth-panel">
|
||||
<?php if ($status === 'verified') :
|
||||
$name = (string) ($info['name'] ?? $apply['name'] ?? __('官方认证', 'aksrt'));
|
||||
$desc = (string) ($info['desc'] ?? $apply['desc'] ?? '');
|
||||
$time = (string) ($info['time'] ?? get_user_meta($user_id, 'aksrt_user_verify_reviewed_at', true));
|
||||
?>
|
||||
<div class="uc-auth-card uc-auth-card--verified">
|
||||
<span class="uc-auth-card__art"><i class="fas fa-check-circle" aria-hidden="true"></i></span>
|
||||
<div class="uc-auth-card__content">
|
||||
<small><?php esc_html_e('已通过官方认证', 'aksrt'); ?></small>
|
||||
<h2><?php echo esc_html($name); ?></h2>
|
||||
<?php if ($desc !== '') : ?><p><?php echo esc_html($desc); ?></p><?php endif; ?>
|
||||
<?php if ($time !== '') : ?><time><?php printf(esc_html__('认证时间:%s', 'aksrt'), esc_html($time)); ?></time><?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="uc-auth-card">
|
||||
<span class="uc-auth-card__art"><i class="fas fa-id-badge" aria-hidden="true"></i></span>
|
||||
<div class="uc-auth-card__content">
|
||||
<small><?php esc_html_e('身份权益', 'aksrt'); ?></small>
|
||||
<h2><?php esc_html_e('官方认证', 'aksrt'); ?></h2>
|
||||
<p><?php echo esc_html((string) ($settings['desc'] ?? __('认证后将展示官方身份标识。', 'aksrt'))); ?></p>
|
||||
<?php if (empty($settings['allow_apply'])) : ?>
|
||||
<div class="uc-auth-card__notice"><?php echo wp_kses_post(nl2br(esc_html((string) ($settings['disable_desc'] ?? __('暂时不能申请身份认证', 'aksrt'))))); ?></div>
|
||||
<?php elseif ($blocked_level) : ?>
|
||||
<div class="uc-auth-card__notice"><?php printf(esc_html__('达到 LV.%d 后即可申请', 'aksrt'), $limit); ?></div>
|
||||
<?php elseif ($can_apply) : ?>
|
||||
<button type="button" class="btn-primary uc-auth-apply-open" data-auth-modal-open>
|
||||
<?php echo $status === 'pending' ? esc_html__('查看申请进度', 'aksrt') : esc_html__('申请认证', 'aksrt'); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($can_apply) : ?>
|
||||
<div class="aksrt-modal uc-auth-modal" id="uc-auth-modal" aria-hidden="true">
|
||||
<div class="aksrt-modal__backdrop" data-auth-modal-close></div>
|
||||
<div class="aksrt-modal__dialog" role="dialog" aria-modal="true" aria-labelledby="uc-auth-modal-title">
|
||||
<div class="aksrt-modal__header uc-auth-modal__header">
|
||||
<div><span><i class="fas fa-id-badge" aria-hidden="true"></i></span><strong id="uc-auth-modal-title"><?php esc_html_e('申请身份认证', 'aksrt'); ?></strong></div>
|
||||
<button type="button" class="aksrt-modal__close" data-auth-modal-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fas fa-times" aria-hidden="true"></i></button>
|
||||
</div>
|
||||
<div class="aksrt-modal__body uc-auth-modal__body">
|
||||
<?php if ($status === 'pending') : ?>
|
||||
<div class="uc-auth-pending">
|
||||
<span><i class="fas fa-hourglass-half" aria-hidden="true"></i></span>
|
||||
<h3><?php esc_html_e('您的申请正在审核中', 'aksrt'); ?></h3>
|
||||
<p><?php esc_html_e('请耐心等待,审核结果会通过消息中心通知。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<div class="uc-auth-apply-detail">
|
||||
<dl><dt><?php esc_html_e('认证身份', 'aksrt'); ?></dt><dd><?php echo esc_html((string) ($apply['name'] ?? '')); ?></dd></dl>
|
||||
<?php if ($apply_type !== '') : ?><dl><dt><?php esc_html_e('认证类型', 'aksrt'); ?></dt><dd><?php echo esc_html($type_labels[$apply_type] ?? $apply_type); ?></dd></dl><?php endif; ?>
|
||||
<?php if (!empty($apply['desc'])) : ?><dl><dt><?php esc_html_e('身份简介', 'aksrt'); ?></dt><dd><?php echo esc_html((string) $apply['desc']); ?></dd></dl><?php endif; ?>
|
||||
<?php if (!empty($apply['msg'])) : ?><dl><dt><?php esc_html_e('申请说明', 'aksrt'); ?></dt><dd><?php echo esc_html((string) $apply['msg']); ?></dd></dl><?php endif; ?>
|
||||
<?php if (!empty($apply['time'])) : ?><dl><dt><?php esc_html_e('申请时间', 'aksrt'); ?></dt><dd><?php echo esc_html((string) $apply['time']); ?></dd></dl><?php endif; ?>
|
||||
</div>
|
||||
<?php if (!empty($apply['img'])) : ?>
|
||||
<div class="aksrt-user-auth-panel__imgs uc-auth-proof-list"><?php foreach ((array) $apply['img'] as $img_url) : ?><div class="preview-item"><img src="<?php echo esc_attr(AuthApply::evidence_src((string) $img_url)); ?>" alt="" loading="lazy"></div><?php endforeach; ?></div>
|
||||
<?php endif; ?>
|
||||
<button type="button" class="btn-primary uc-auth-modal__confirm" data-auth-modal-close><?php esc_html_e('确定', 'aksrt'); ?></button>
|
||||
<?php else : ?>
|
||||
<form class="aksrt-user-auth-form uc-auth-form" enctype="multipart/form-data">
|
||||
<label><span><?php esc_html_e('认证类型', 'aksrt'); ?></span><select class="form-control" name="type" required><?php foreach ((array) ($settings['types'] ?? []) as $type) : ?><option value="<?php echo esc_attr((string) $type['slug']); ?>"><?php echo esc_html((string) $type['label']); ?></option><?php endforeach; ?></select></label>
|
||||
<label><span><?php esc_html_e('认证身份', 'aksrt'); ?></span><input type="text" class="form-control" name="name" required minlength="4" maxlength="16" placeholder="<?php esc_attr_e('请输入 4-16 个字符', 'aksrt'); ?>"></label>
|
||||
<label><span><?php esc_html_e('身份简介', 'aksrt'); ?></span><textarea class="form-control" name="desc" rows="3" maxlength="300" placeholder="<?php esc_attr_e('认证通过后公开展示的身份说明', 'aksrt'); ?>"></textarea></label>
|
||||
<label><span><?php esc_html_e('申请说明', 'aksrt'); ?></span><textarea class="form-control" name="msg" rows="3" maxlength="500" placeholder="<?php esc_attr_e('说明申请缘由,便于管理员审核', 'aksrt'); ?>"></textarea></label>
|
||||
<label class="uc-auth-upload"><span><?php esc_html_e('证明材料', 'aksrt'); ?></span><input type="file" name="image[]" accept="image/jpeg,image/png,image/gif,image/webp" multiple data-auth-files><small><?php esc_html_e('最多上传 3 张图片,单张不超过 2MB(可选)。', 'aksrt'); ?></small><div class="uc-auth-upload__previews" data-auth-previews></div></label>
|
||||
<?php wp_nonce_field('aksrt_user_auth_apply', '_wpnonce', false); ?>
|
||||
<input type="hidden" name="action" value="aksrt_user_auth_apply">
|
||||
<button type="submit" class="btn-primary uc-auth-submit"><i class="fas fa-check" aria-hidden="true"></i><?php esc_html_e('确认提交', 'aksrt'); ?></button>
|
||||
<div class="uc-auth-form__message" data-auth-message role="status"></div>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@@ -11,10 +11,7 @@ $cart_url = function_exists('aksrt_get_cart_page_url') ? aksrt_get_cart_page_url
|
||||
$level_url = isset($dashboard_tabs['credits'])
|
||||
? add_query_arg('asset_tab', 'points', aksrt_get_user_center_tab_url('credits'))
|
||||
: '';
|
||||
$auth_settings = class_exists('\AKSRT\User\AuthApply') ? \AKSRT\User\AuthApply::settings() : [];
|
||||
$auth_url = !empty($auth_settings['enabled']) && function_exists('aksrt_get_user_auth_page_url')
|
||||
? aksrt_get_user_auth_page_url()
|
||||
: '';
|
||||
$auth_url = isset($dashboard_tabs['auth']) ? aksrt_get_user_center_tab_url('auth') : '';
|
||||
|
||||
$services = array_values(array_filter([
|
||||
[
|
||||
@@ -34,6 +31,7 @@ $services = array_values(array_filter([
|
||||
'icon' => 'id-badge',
|
||||
'tone' => 'auth',
|
||||
'url' => $auth_url,
|
||||
'tab' => 'auth',
|
||||
],
|
||||
], static fn(array $item): bool => (string) $item['url'] !== ''));
|
||||
|
||||
@@ -63,7 +61,7 @@ $render_grid = static function (array $items): void {
|
||||
?>
|
||||
<div class="uc-service-grid">
|
||||
<?php foreach ($items as $item) : ?>
|
||||
<a class="uc-service-grid__item uc-service-grid__item--<?php echo esc_attr((string) $item['tone']); ?>" href="<?php echo esc_url((string) $item['url']); ?>">
|
||||
<a class="uc-service-grid__item uc-service-grid__item--<?php echo esc_attr((string) $item['tone']); ?><?php echo !empty($item['tab']) && ($active_tab ?? '') === $item['tab'] ? ' is-active' : ''; ?>" href="<?php echo esc_url((string) $item['url']); ?>"<?php if (!empty($item['tab'])) : ?> data-tab="<?php echo esc_attr((string) $item['tab']); ?>"<?php endif; ?>>
|
||||
<span class="uc-service-grid__icon">
|
||||
<i class="fas fa-<?php echo esc_attr((string) $item['icon']); ?>" aria-hidden="true"></i>
|
||||
<?php if (!empty($item['count'])) : ?><small><?php echo esc_html((string) $item['count']); ?></small><?php endif; ?>
|
||||
|
||||
@@ -18,7 +18,6 @@ add_filter('query_vars', function ($vars) {
|
||||
$vars[] = 'aksrt_orders';
|
||||
$vars[] = 'aksrt_cart';
|
||||
$vars[] = 'aksrt_revenue';
|
||||
$vars[] = 'aksrt_user_auth';
|
||||
return $vars;
|
||||
});
|
||||
|
||||
@@ -43,14 +42,12 @@ add_action('init', function () {
|
||||
add_rewrite_tag('%aksrt_orders%', '([0-1])');
|
||||
add_rewrite_tag('%aksrt_cart%', '([0-1])');
|
||||
add_rewrite_tag('%aksrt_revenue%', '([0-1])');
|
||||
add_rewrite_tag('%aksrt_user_auth%', '([0-1])');
|
||||
add_rewrite_rule('^profile/?$', 'index.php?aksrt_user_center=1', 'top');
|
||||
add_rewrite_rule('^user/([^/]+)/?$', 'index.php?user_nicename=$matches[1]', 'top');
|
||||
// Commerce center aliases (work even before WP page is assigned).
|
||||
add_rewrite_rule('^orders/?$', 'index.php?aksrt_orders=1', 'top');
|
||||
add_rewrite_rule('^cart/?$', 'index.php?aksrt_cart=1', 'top');
|
||||
add_rewrite_rule('^revenue/?$', 'index.php?aksrt_revenue=1', 'top');
|
||||
add_rewrite_rule('^user-auth/?$', 'index.php?aksrt_user_auth=1', 'top');
|
||||
});
|
||||
|
||||
// --- 3b. 统一模板拦截器(核心)---
|
||||
@@ -169,7 +166,7 @@ add_action('init', function () {
|
||||
}
|
||||
|
||||
// 统一 flush 检查 — bump when user-home rewrite / author override changes
|
||||
$rewrite_version = AKSRT_VERSION . ':user-home-profile-routing-v4';
|
||||
$rewrite_version = AKSRT_VERSION . ':user-home-profile-routing-v5';
|
||||
$flushed = get_option('aksrt_user_rules_flushed');
|
||||
$rules = get_option('rewrite_rules');
|
||||
$need_flush = ($flushed !== $rewrite_version)
|
||||
@@ -218,9 +215,6 @@ add_filter('request', function ($query_vars) {
|
||||
if (empty($query_vars['aksrt_user_center']) && isset($_GET['aksrt_user_center'])) {
|
||||
$query_vars['aksrt_user_center'] = '1';
|
||||
}
|
||||
if (empty($query_vars['aksrt_user_auth']) && isset($_GET['aksrt_user_auth'])) {
|
||||
$query_vars['aksrt_user_auth'] = '1';
|
||||
}
|
||||
return $query_vars;
|
||||
});
|
||||
|
||||
|
||||
@@ -131,12 +131,6 @@ $_aksrt_special_templates = [
|
||||
'title' => '消息中心',
|
||||
'fallback' => '/messages/',
|
||||
],
|
||||
'user-auth' => [
|
||||
'file' => 'templates/pages/page-user-auth.php',
|
||||
'slug' => 'user-auth',
|
||||
'title' => '官方认证',
|
||||
'fallback' => '/user-auth/',
|
||||
],
|
||||
'submit' => [
|
||||
'file' => 'templates/pages/page-submit.php',
|
||||
'slug' => 'submit',
|
||||
@@ -282,7 +276,6 @@ function aksrt_resolve_page_template_file(string $template_file = '', string $po
|
||||
'categories' => 'templates/pages/page-categories.php',
|
||||
'friends' => 'templates/pages/page-friends.php',
|
||||
'profile' => 'templates/pages/page-profile.php',
|
||||
'user-auth' => 'templates/pages/page-user-auth.php',
|
||||
];
|
||||
|
||||
if (!empty($slug_map[$post_slug]) && aksrt_locate_template_file($slug_map[$post_slug])) {
|
||||
@@ -444,11 +437,6 @@ function aksrt_get_current_special_template_path(): string {
|
||||
return $revenue_template ?: '';
|
||||
}
|
||||
|
||||
if (get_query_var('aksrt_user_auth')) {
|
||||
$auth_template = aksrt_locate_template_file('templates/pages/page-user-auth.php');
|
||||
return $auth_template ?: '';
|
||||
}
|
||||
|
||||
if (get_query_var('aksrt_sign')) {
|
||||
$auth_template = aksrt_get_auth_template_file((string) get_query_var('aksrt_auth_tab'), true);
|
||||
$auth_template_path = aksrt_locate_template_file($auth_template);
|
||||
|
||||
@@ -106,21 +106,6 @@ function aksrt_get_revenue_page_url(): string {
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_get_user_auth_page_url')) :
|
||||
/**
|
||||
* 官方认证页面 URL。
|
||||
*/
|
||||
function aksrt_get_user_auth_page_url(): string {
|
||||
if (function_exists('aksrt_get_template_url')) {
|
||||
return aksrt_get_template_url('user-auth');
|
||||
}
|
||||
if (get_option('permalink_structure')) {
|
||||
return home_url('/user-auth/');
|
||||
}
|
||||
return add_query_arg('aksrt_user_auth', '1', home_url('/'));
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_get_messages_page_url')) :
|
||||
/**
|
||||
* 消息中心页面 URL(模板 templates/pages/page-messages.php)。
|
||||
|
||||
Reference in new issue
Block a user