feat(ban): align ban prompts with the reference theme modals and block page

对照参考主题(Zibll)修正四项偏差,申诉链路从页面整体迁移至弹窗:

- feat(ban): 新增三个 1:1 复刻弹窗(REST /user-ban/{info,appeal,log}-modal):
  查看禁封状态(多彩头 c-gray + 信息行 + 申诉按钮)、禁封申诉(edit-header
  gavel/c-blue + 信息框 + 资料项 data[key] 输入 + 审核中态 + 禁止申诉态)、
  禁封记录(多彩头 c-yellow + 计数 + 逐条卡片);user-ban.js 增加
  data-aksrt-ban-info/appeal/log 委托与 admin-ajax 申诉提交
- feat(ban): 禁封/解封弹窗的「当前用户已有N次禁封记录」静态文案改为可点击
  黄链(N>1),打开禁封记录弹窗;解封视图信息行改复用统一数据源
- refactor(ban): 治理展示态收敛至 Restriction::state_badges()(封号=c-red
  违规已封号 / 小黑屋=c-yellow 小黑屋禁封中 / 禁言=c-gray 禁言中,颜色与
  字段统一管理)+ get_ban_info()(状态/起止时间/原因/说明/申诉权限,
  三弹窗与禁封页共用)
- feat(ban): 登录行为对齐参考主题——移除登录期拦截(enforce_login_ban)
  与 complete_login 禁封闸门,封号用户可正常登录;新增 template_redirect
  前台禁封页(1:1 zib_user_ban_restrict_login/zib_die_page:红盒提示 +
  信息行 + 申诉权限 + 退出登录/申诉按钮,模板 templates/parts/user/ban-block.php)
- feat(profile): 公开主页禁封状态从资料卡下方提示框改为占据身份行元信息位
  的 badg 徽章(参考主题 author_header_identity 语义);用户中心元信息改为
  but 按钮(徽章+箭头)打开查看禁封状态弹窗;评论拒绝态链接同源
- refactor: 移除申诉页面模板(page-ban-appeal.php)及其资产/注册/入队、
  get_profile_notice/profile_notice 链、state_labels/state_notices/
  login_ban_message、UserRuntime 的 public_notice/ban_notice_text 死配置、
  report_settings 死键、无消费方的 aksrt_ban_appeal_status 端点
- feat(ban): BanAppeal::ajax_submit 兼容弹窗 data[key] 表单结构
  (逐项清洗入库,申诉说明取 data['申诉说明'],旧平铺字段保持兼容)
- chore: 重新构建 public.css/public.min.css(三个新弹窗几何与头部样式)
- test: 契约测试重写(徽章元信息位、三弹窗与记录链接、禁封页、允许登录 +
  前台拦截、死代码移除断言),全量 362 项通过
This commit is contained in:
kate522 committed 2026-09-22 19:14:02 +08:00
1 parent 11eda33e58
commit a4af024f32
31 files changed
+1037 -679

No files matched your search

-142
View File
@@ -1,142 +0,0 @@
<?php
/**
* Template Name: AKSRT - 禁封申诉
* Template Post Type: page
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
use AKSRT\User\BanAppeal;
use AKSRT\User\Restriction;
get_header();
if (!is_user_logged_in()) {
$login = function_exists('aksrt_get_login_url') ? aksrt_get_login_url(get_permalink()) : wp_login_url(get_permalink());
wp_safe_redirect($login);
exit;
}
$user_id = get_current_user_id();
$settings = class_exists(BanAppeal::class) ? BanAppeal::settings() : ['enabled' => true, 'desc' => '', 'keys' => []];
$ban = class_exists(Restriction::class) ? Restriction::get_instance()->get_active_ban($user_id) : null;
if (!$ban && class_exists(Restriction::class)) {
$ban = Restriction::get_instance()->get_active_suspend($user_id);
}
$status = class_exists(BanAppeal::class) ? BanAppeal::get_status($user_id) : '';
$payload = class_exists(BanAppeal::class) ? BanAppeal::get_payload($user_id) : [];
// 禁封状态信息(对齐参考主题 zib_get_ban_info_modal:状态/起止时间/原因/说明/申诉权限)。
$ban_status_text = '';
$ban_reason = '';
$ban_desc = '';
$ban_end_text = '';
$no_appeal = get_user_meta($user_id, '_aksrt_no_appeal', true);
$no_appeal_desc = is_array($no_appeal) ? (string) ($no_appeal['desc'] ?? '') : '';
if (is_array($ban)) {
$ban_status_text = (string) ($ban['type'] ?? '') === Restriction::TYPE_BAN
? __('禁封中(禁止登录)', 'aksrt')
: __('小黑屋禁封中', 'aksrt');
$ban_end_text = !empty($ban['expires_at']) ? (string) $ban['expires_at'] : __('永久', 'aksrt');
$raw_reason = (string) ($ban['reason'] ?? '');
$ban_reason = $raw_reason;
$desc_marker = "\n" . __('禁封说明:', 'aksrt');
$marker_pos = strpos($raw_reason, $desc_marker);
if (false !== $marker_pos) {
$ban_reason = substr($raw_reason, 0, $marker_pos);
$ban_desc = substr($raw_reason, $marker_pos + strlen($desc_marker));
}
}
$ban_set_row = static function (string $label, string $value): string {
if ($value === '') {
return '';
}
return '<div class="flex"><div class="author-set-left" style="min-width: 80px;">' . esc_html($label) . '</div><div class="author-set-right mt6">' . esc_html($value) . '</div></div>';
};
?>
<main class="container page-template-ban-appeal">
<div class="content-wrap">
<div class="content-layout content-layout--no-sidebar">
<div class="theme-box radius8 main-bg main-shadow box-body mb20">
<h1 class="article-title"><?php echo esc_html(get_the_title() ?: __('禁封申诉', 'aksrt')); ?></h1>
</div>
<?php if (is_array($ban)) : ?>
<div class="theme-box radius8 main-bg main-shadow box-body aksrt-ban-status mb20">
<h2 class="mb15"><?php esc_html_e('禁封状态', 'aksrt'); ?></h2>
<div class="muted-box padding-10 em09">
<?php
echo $ban_set_row(__('状态', 'aksrt'), $ban_status_text); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- row builder escapes.
echo $ban_set_row(__('开始时间', 'aksrt'), (string) ($ban['created_at'] ?? ''));
echo $ban_set_row(__('结束时间', 'aksrt'), $ban_end_text);
echo $ban_set_row(__('原因', 'aksrt'), $ban_reason);
echo $ban_set_row(__('说明', 'aksrt'), $ban_desc);
?>
<div class="flex">
<div class="author-set-left" style="min-width: 80px;"><?php esc_html_e('申诉权限', 'aksrt'); ?></div>
<div class="author-set-right mt6">
<?php if ($no_appeal_desc !== '') : ?>
<span class="c-red"><?php esc_html_e('本次禁封您将不能发起申诉', 'aksrt'); ?></span>
<div class="mt6"><?php echo esc_html($no_appeal_desc); ?></div>
<?php else : ?>
<?php esc_html_e('可提交申诉', 'aksrt'); ?>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php endif; ?>
<div class="theme-box radius8 main-bg main-shadow box-body aksrt-ban-appeal">
<?php if (!$ban) : ?>
<div class="muted-2-color text-center" style="padding:40px 0;">
<i class="fa fas fa-check-circle em2x" aria-hidden="true"></i>
<p class="mt10"><?php esc_html_e('当前账号未处于禁封状态。', 'aksrt'); ?></p>
</div>
<?php elseif (empty($settings['enabled'])) : ?>
<div class="c-red"><i class="fa fas fa-info-circle mr6" aria-hidden="true"></i><?php esc_html_e('申诉功能暂未开启', 'aksrt'); ?></div>
<?php elseif ($status === 'pending') : ?>
<div class="c-red mb10"><?php esc_html_e('您的申诉正在审核中,请耐心等待。', 'aksrt'); ?></div>
<?php if (!empty($payload['reason'])) : ?>
<div class="muted-2-color"><?php echo esc_html(sprintf(__('申诉内容:%s', 'aksrt'), (string) $payload['reason'])); ?></div>
<?php endif; ?>
<?php if (!empty($payload['time'])) : ?>
<div class="muted-2-color mt6"><?php echo esc_html(sprintf(__('提交时间:%s', 'aksrt'), (string) $payload['time'])); ?></div>
<?php endif; ?>
<?php else : ?>
<?php if (!empty($settings['desc'])) : ?>
<div class="muted-color mb20"><?php echo wp_kses_post(nl2br(esc_html((string) $settings['desc']))); ?></div>
<?php endif; ?>
<?php if ($status === 'rejected') : ?>
<div class="c-red mb15"><?php esc_html_e('上次申诉未通过,可修改后重新提交。', 'aksrt'); ?></div>
<?php endif; ?>
<form class="aksrt-ban-appeal-form">
<?php if (!empty($settings['keys'])) : ?>
<div class="mb15">
<label class="em09 muted-2-color"><?php esc_html_e('申诉类型', 'aksrt'); ?></label>
<select name="reason_key" class="form-control">
<?php foreach ($settings['keys'] as $key) : ?>
<option value="<?php echo esc_attr($key); ?>"><?php echo esc_html($key); ?></option>
<?php endforeach; ?>
</select>
</div>
<?php endif; ?>
<div class="mb15">
<label class="em09 muted-2-color"><?php esc_html_e('申诉说明', 'aksrt'); ?> *</label>
<textarea name="reason" class="form-control" rows="5" required placeholder="<?php esc_attr_e('请说明误封原因或补充材料说明', 'aksrt'); ?>"><?php echo esc_textarea((string) ($payload['reason'] ?? '')); ?></textarea>
</div>
<?php wp_nonce_field('aksrt_ban_appeal', '_wpnonce', false); ?>
<input type="hidden" name="action" value="aksrt_ban_appeal_submit">
<button type="submit" class="but c-blue padding-lg">
<i class="fa fas fa-paper-plane" aria-hidden="true"></i> <?php esc_html_e('提交申诉', 'aksrt'); ?>
</button>
</form>
<?php endif; ?>
</div>
</div>
</div>
</main>
<?php
get_footer();
+7 -23
View File
@@ -44,7 +44,6 @@ $last_login_ts = (int) get_user_meta($user_id, 'aksrt_last_login', true);
$last_login_time = $last_login_ts > 0 ? wp_date('Y-m-d H:i:s', $last_login_ts) : '';
$has_more_details = $registered_time !== '' || $last_login_time !== '' || !empty($profile_details['website']) || !empty($profile_details['qq']) || !empty($profile_details['wechat']) || !empty($profile_details['github']);
$signals = $dashboard['profile_signals'] ?? [];
$notice = $dashboard['profile_notice'] ?? null;
$show_report = !empty($dashboard['show_report']);
$bg_url = function_exists('aksrt_get_user_cover_url') ? aksrt_get_user_cover_url($user_id) : '';
$is_own = !empty($dashboard['is_own_profile']);
@@ -136,6 +135,11 @@ $show_cover_menu = $has_more_details || $show_cover_report || $cover_ban_html !=
<?php endif; ?>
<?php
// 治理状态徽章占据身份行元信息位(参考主题 author_header_identity 钩子:
// 红=违规已封号 / 黄=小黑屋禁封中 / 灰=禁言中,字段与颜色统一管理)。
$ban_badge = function_exists('aksrt_get_user_ban_identity_badge')
? aksrt_get_user_ban_identity_badge($user_id)
: '';
// legacy parity: the badge overview leads the identity row.
$city_badge = function_exists('aksrt_get_user_city_badge_html')
? aksrt_get_user_city_badge_html($user_id, 'user_home', 'badg')
@@ -144,8 +148,9 @@ $show_cover_menu = $has_more_details || $show_cover_report || $cover_ban_html !=
? aksrt_render_user_medal_entry($user_id, 'user-home', $is_own)
: '';
?>
<?php if ($medal_entry !== '' || $city_badge !== '') : ?>
<?php if ($ban_badge !== '' || $medal_entry !== '' || $city_badge !== '') : ?>
<div class="aksrt-author-hero__identity user-identity flex ac hh">
<?php echo $ban_badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- helper escapes internally. ?>
<?php echo $medal_entry; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php echo $city_badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
@@ -155,27 +160,6 @@ $show_cover_menu = $has_more_details || $show_cover_report || $cover_ban_html !=
<p class="aksrt-author-hero__desc"><?php echo esc_html($user_description); ?></p>
<?php endif; ?>
<?php if (!empty($notice) && is_array($notice)) : ?>
<?php
// 数据契约:\AKSRT\User\Home::get_profile_notice() 输出 state|label|text;
// 提示框色调修饰符与 state 同名(user-home.css:--banned/--restricted/--muted)。
$notice_state = (string) ($notice['state'] ?? '');
$notice_tone = in_array($notice_state, ['banned', 'restricted', 'muted'], true) ? $notice_state : 'muted';
$notice_label = trim((string) ($notice['label'] ?? ''));
$notice_text = trim((string) ($notice['text'] ?? ''));
$notice_message = $notice_label !== '' && $notice_text !== ''
? $notice_label . ',' . $notice_text
: ($notice_label !== '' ? $notice_label : $notice_text);
$notice_icon = 'muted' === $notice_state ? 'comment-slash' : 'ban';
?>
<?php if ($notice_message !== '') : ?>
<div class="aksrt-author-hero__notice aksrt-author-hero__notice--<?php echo esc_attr($notice_tone); ?>">
<i class="fa fas fa-<?php echo esc_attr($notice_icon); ?>" aria-hidden="true"></i>
<span><?php echo esc_html($notice_message); ?></span>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
<div class="aksrt-author-hero__actions">
+65
View File
@@ -0,0 +1,65 @@
<?php
/**
* 登录后禁封状态页 — 1:1 复刻参考主题 zib_user_ban_restrict_login(zib_die_page):
* 红盒提示 + 禁封信息行 + 申诉权限 + 退出登录/申诉按钮。
* 由 Restriction::restrict_frontend_access()(template_redirect)渲染。
*
* Contract: get_template_part(..., null, $args)
* user WP_User 被封禁用户
* info array Restriction::get_ban_info() 的禁封信息行
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$args = is_array($args ?? null) ? $args : [];
$user = $args['user'] ?? null;
$info = is_array($args['info'] ?? null) ? $args['info'] : [];
if (!($user instanceof WP_User)) {
return;
}
$user_id = (int) $user->ID;
$null_img = function_exists('aksrt_null_image_url') ? aksrt_null_image_url('null.svg') : '';
$logout_url = wp_logout_url(home_url());
$appeal_link = function_exists('aksrt_get_user_ban_appeal_link')
? aksrt_get_user_ban_appeal_link($user_id, 'but c-blue padding-lg hollow')
: '';
$ban_set_row = static function (string $label, string $value): string {
if ($value === '') {
return '';
}
return '<div class="mb10 flex"><div class="author-set-left" style="min-width: 80px;">' . esc_html($label) . '</div><div class="author-set-right mt6">' . esc_html($value) . '</div></div>';
};
?>
<main class="container flex ac">
<div class="f404 flex1">
<?php if ($null_img !== '') : ?>
<img src="<?php echo esc_url($null_img); ?>" alt="">
<?php endif; ?>
<div class="f404-msg mt20">
<div class="c-red box-body separator mb30"><?php esc_html_e('抱歉,您的账号当前处于禁封状态,暂时无法登录', 'aksrt'); ?></div>
<div class="mb20 muted-box text-left" style="max-width: 600px; margin: auto;">
<?php
echo $ban_set_row(__('用户名', 'aksrt'), $user->display_name); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- row builder escapes.
echo $ban_set_row(__('状态', 'aksrt'), (string) ($info['status'] ?? ''));
echo $ban_set_row(__('开始时间', 'aksrt'), (string) ($info['start'] ?? ''));
echo $ban_set_row(__('结束时间', 'aksrt'), (string) ($info['end'] ?? ''));
echo $ban_set_row(__('原因', 'aksrt'), (string) ($info['reason'] ?? ''));
echo $ban_set_row(__('说明', 'aksrt'), (string) ($info['desc'] ?? ''));
if (!empty($info['no_appeal'])) {
echo $ban_set_row(__('申诉权限', 'aksrt'), __('本次禁封您将不能发起申诉', 'aksrt'));
echo $ban_set_row(__('禁止申诉说明', 'aksrt'), (string) ($info['no_appeal_desc'] ?? ''));
}
?>
</div>
<div class="mt20 text-center">
<a href="<?php echo esc_url($logout_url); ?>" class="but c-yellow padding-lg hollow mr20"><?php esc_html_e('退出登录', 'aksrt'); ?></a>
<?php echo $appeal_link; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- helper escapes internally. ?>
</div>
</div>
</div>
</main>