修复公开主页禁封提示框为空的问题,并对齐参考主题(Zibll)全部前台禁封提示入口: - fix(profile): 资料卡下方治理提示框渲染为空——模板读取的 tone/message 键与 数据层实际输出的 state/label/text 契约不匹配;现按禁封类型展示 「违规已封号/小黑屋禁封中/禁言中」+ 可配置说明文案 - feat(ban): 用户中心页头展示治理状态徽章 + 查看详情入口,直达禁封申诉页 (参考主题 user_page_header_desc / zib_get_user_ban_info_link) - feat(ban): 评论拒绝态区分禁封/小黑屋/禁言,附状态徽章与申诉链接 (参考主题 zib_get_user_ban_nocan_info,原为笼统的无权限文案) - feat(ban): 禁封申诉页补全状态信息卡(状态/开始时间/结束时间/原因/说明/ 申诉权限),对齐 zib_get_ban_info_modal;此前仅有「禁封原因」一行且无入口 - feat(ban): 昵称旁禁封徽章 + 头像禁封角标(覆盖 VIP 位,参考主题 user_name_badge / user_avatar_badge 钩子语义),main.css 与入队的 main.min.css 同步新增角标样式 - fix(ban): 举报入口对已封禁/小黑屋目标隐藏(评论、文章下拉、封面菜单三处, 对齐 zib_get_report_link 排除语义;禁言为轻量限制不隐藏) - refactor(ban): 治理展示态收敛为单一数据源 Restriction::get_display_state() + state_labels(),资料卡/用户中心/评论拒绝态/昵称徽章共用 - feat(ban): 小黑屋用户开放申诉(对齐参考主题 zib_user_is_ban 双类型语义), 禁封站内信附加申诉页链接 - test: report-ban 契约测试 +3(展示态单一数据源、提示面入口矩阵、举报排除), 45 个测试文件全部通过
143 lines
6.4 KiB
PHP
143 lines
6.4 KiB
PHP
<?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();
|