feat(ux): forum pay-hide depth, clogin OAuth, ban appeals admin, posts-navs widget
- Forum compose/save/draft: VIP prices, partial hide, coupons + shortcode tools - Rainbow clogin aggregate login (rewrite + schema + CLoginClient) - Native ban appeals tab: approve/reject + lift ban + notify - WidgetPostsNavs + register missing forum widgets - Submit editor shortcodes: login/reply/vip/payshow
This commit is contained in:
1 parent
25aabb71a3
commit
24330653f0
15 files changed
+834
-35
No files matched your search
@@ -32,6 +32,7 @@ class UsersMenus {
|
||||
add_action('admin_post_aksrt_users_update_report', [$this, 'handle_update_report']);
|
||||
add_action('admin_post_aksrt_users_add_restriction', [$this, 'handle_add_restriction']);
|
||||
add_action('admin_post_aksrt_users_remove_restriction', [$this, 'handle_remove_restriction']);
|
||||
add_action('admin_post_aksrt_users_process_appeal', [$this, 'handle_process_appeal']);
|
||||
add_action('admin_post_aksrt_users_batch_invite_codes', [$this, 'handle_batch_invite_codes']);
|
||||
add_action('admin_post_aksrt_users_disable_invite_code', [$this, 'handle_disable_invite_code']);
|
||||
}
|
||||
@@ -108,6 +109,21 @@ class UsersMenus {
|
||||
echo '<p><a class="button button-primary" href="' . esc_url($url) . '">' . esc_html__('立即处理', 'aksrt') . '</a></p></div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($page !== 'aksrt_user_ban' && class_exists('\AKSRT\User\BanAppeal')) {
|
||||
$pending_appeals = count(get_users([
|
||||
'meta_key' => \AKSRT\User\BanAppeal::META_STATUS,
|
||||
'meta_value' => 'pending',
|
||||
'number' => 50,
|
||||
'fields' => 'ID',
|
||||
]));
|
||||
if ($pending_appeals > 0) {
|
||||
$url = admin_url('users.php?page=aksrt_user_ban&tab=appeals&status=pending');
|
||||
echo '<div class="notice notice-warning is-dismissible"><h3>' . esc_html__('禁封申诉待处理', 'aksrt') . '</h3>';
|
||||
echo '<p>' . esc_html(sprintf(__('您有 %d 条禁封申诉待处理', 'aksrt'), $pending_appeals)) . '</p>';
|
||||
echo '<p><a class="button button-primary" href="' . esc_url($url) . '">' . esc_html__('立即处理', 'aksrt') . '</a></p></div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function ensure_cap(): void {
|
||||
@@ -131,6 +147,9 @@ class UsersMenus {
|
||||
'restriction_added' => __('限制已添加。', 'aksrt'),
|
||||
'restriction_removed' => __('限制已移除。', 'aksrt'),
|
||||
'restriction_failed' => __('限制操作失败。', 'aksrt'),
|
||||
'appeal_approved' => __('申诉已通过,限制已解除。', 'aksrt'),
|
||||
'appeal_rejected' => __('申诉已驳回。', 'aksrt'),
|
||||
'appeal_failed' => __('申诉处理失败。', 'aksrt'),
|
||||
'invite_batch_ok' => __('邀请码批量生成完成。', 'aksrt'),
|
||||
'invite_batch_failed' => __('邀请码批量生成失败。', 'aksrt'),
|
||||
'invite_disabled' => __('邀请码已禁用。', 'aksrt'),
|
||||
@@ -590,10 +609,13 @@ class UsersMenus {
|
||||
echo '<h2 class="nav-tab-wrapper">';
|
||||
printf('<a class="nav-tab%s" href="%s">%s</a>', $tab === 'reports' ? ' nav-tab-active' : '', esc_url(admin_url('users.php?page=aksrt_user_ban&tab=reports')), esc_html__('举报', 'aksrt'));
|
||||
printf('<a class="nav-tab%s" href="%s">%s</a>', $tab === 'restrictions' ? ' nav-tab-active' : '', esc_url(admin_url('users.php?page=aksrt_user_ban&tab=restrictions')), esc_html__('禁封限制', 'aksrt'));
|
||||
printf('<a class="nav-tab%s" href="%s">%s</a>', $tab === 'appeals' ? ' nav-tab-active' : '', esc_url(admin_url('users.php?page=aksrt_user_ban&tab=appeals')), esc_html__('禁封申诉', 'aksrt'));
|
||||
echo '</h2>';
|
||||
|
||||
if ($tab === 'restrictions') {
|
||||
$this->render_restrictions_tab();
|
||||
} elseif ($tab === 'appeals') {
|
||||
$this->render_appeals_tab();
|
||||
} else {
|
||||
$this->render_reports_tab();
|
||||
}
|
||||
@@ -768,6 +790,151 @@ class UsersMenus {
|
||||
$this->redirect('aksrt_user_ban', $ok ? 'restriction_removed' : 'restriction_failed', ['tab' => 'restrictions']);
|
||||
}
|
||||
|
||||
|
||||
private function render_appeals_tab(): void {
|
||||
if (!class_exists('\AKSRT\User\BanAppeal')) {
|
||||
echo '<div class="notice notice-error"><p>' . esc_html__('申诉模块未初始化。', 'aksrt') . '</p></div>';
|
||||
return;
|
||||
}
|
||||
$status = isset($_GET['status']) ? sanitize_key((string) wp_unslash($_GET['status'])) : 'pending';
|
||||
if (!in_array($status, ['pending', 'approved', 'rejected', 'all'], true)) {
|
||||
$status = 'pending';
|
||||
}
|
||||
|
||||
echo '<form method="get" style="margin:12px 0;">';
|
||||
echo '<input type="hidden" name="page" value="aksrt_user_ban" /><input type="hidden" name="tab" value="appeals" />';
|
||||
echo '<select name="status">';
|
||||
foreach (['pending' => __('待处理', 'aksrt'), 'approved' => __('已通过', 'aksrt'), 'rejected' => __('已驳回', 'aksrt'), 'all' => __('全部', 'aksrt')] as $key => $label) {
|
||||
printf('<option value="%s"%s>%s</option>', esc_attr($key), selected($status, $key, false), esc_html($label));
|
||||
}
|
||||
echo '</select> ';
|
||||
submit_button(__('筛选', 'aksrt'), 'secondary', '', false);
|
||||
echo '</form>';
|
||||
|
||||
$users = get_users([
|
||||
'meta_key' => \AKSRT\User\BanAppeal::META_STATUS,
|
||||
'meta_compare' => 'EXISTS',
|
||||
'number' => 100,
|
||||
'fields' => ['ID', 'display_name', 'user_login', 'user_email'],
|
||||
'orderby' => 'ID',
|
||||
'order' => 'DESC',
|
||||
]);
|
||||
|
||||
echo '<table class="wp-list-table widefat fixed striped"><thead><tr>';
|
||||
echo '<th>UID</th><th>' . esc_html__('用户', 'aksrt') . '</th><th>' . esc_html__('状态', 'aksrt') . '</th><th>' . esc_html__('类型', 'aksrt') . '</th><th>' . esc_html__('说明', 'aksrt') . '</th><th>' . esc_html__('提交时间', 'aksrt') . '</th><th>' . esc_html__('操作', 'aksrt') . '</th>';
|
||||
echo '</tr></thead><tbody>';
|
||||
$shown = 0;
|
||||
foreach ($users as $u) {
|
||||
$uid = (int) $u->ID;
|
||||
$st = \AKSRT\User\BanAppeal::get_status($uid);
|
||||
if ($st === '') {
|
||||
continue;
|
||||
}
|
||||
if ($status !== 'all' && $st !== $status) {
|
||||
continue;
|
||||
}
|
||||
$payload = \AKSRT\User\BanAppeal::get_payload($uid);
|
||||
$shown++;
|
||||
echo '<tr>';
|
||||
echo '<td>' . esc_html((string) $uid) . '</td>';
|
||||
echo '<td>' . esc_html($u->display_name . ' (' . $u->user_login . ')') . '<br><span class="description">' . esc_html($u->user_email) . '</span></td>';
|
||||
echo '<td>' . esc_html($st) . '</td>';
|
||||
echo '<td>' . esc_html((string) ($payload['reason_key'] ?? '—')) . '</td>';
|
||||
echo '<td>' . esc_html((string) ($payload['reason'] ?? '')) . '</td>';
|
||||
echo '<td>' . esc_html((string) ($payload['time'] ?? '—')) . '</td>';
|
||||
echo '<td>';
|
||||
if ($st === 'pending') {
|
||||
echo '<form method="post" action="' . esc_url(admin_url('admin-post.php')) . '" style="display:flex;gap:6px;flex-wrap:wrap;align-items:center;">';
|
||||
echo '<input type="hidden" name="action" value="aksrt_users_process_appeal" />';
|
||||
echo '<input type="hidden" name="user_id" value="' . esc_attr((string) $uid) . '" />';
|
||||
wp_nonce_field('aksrt_users_process_appeal_' . $uid);
|
||||
echo '<input type="text" name="note" placeholder="' . esc_attr__('处理备注', 'aksrt') . '" class="regular-text" />';
|
||||
echo '<button type="submit" name="decision" value="approve" class="button button-primary">' . esc_html__('通过并解封', 'aksrt') . '</button>';
|
||||
echo '<button type="submit" name="decision" value="reject" class="button">' . esc_html__('驳回', 'aksrt') . '</button>';
|
||||
echo '</form>';
|
||||
} else {
|
||||
echo '—';
|
||||
}
|
||||
echo '</td></tr>';
|
||||
}
|
||||
if ($shown < 1) {
|
||||
echo '<tr><td colspan="7">' . esc_html__('暂无申诉', 'aksrt') . '</td></tr>';
|
||||
}
|
||||
echo '</tbody></table>';
|
||||
}
|
||||
|
||||
public function handle_process_appeal(): void {
|
||||
if (!current_user_can(self::CAPABILITY)) {
|
||||
wp_die(esc_html__('权限不足', 'aksrt'));
|
||||
}
|
||||
$user_id = isset($_POST['user_id']) ? (int) $_POST['user_id'] : 0;
|
||||
$decision = isset($_POST['decision']) ? sanitize_key((string) wp_unslash($_POST['decision'])) : '';
|
||||
$note = isset($_POST['note']) ? sanitize_textarea_field((string) wp_unslash($_POST['note'])) : '';
|
||||
check_admin_referer('aksrt_users_process_appeal_' . $user_id);
|
||||
|
||||
if ($user_id <= 0 || !in_array($decision, ['approve', 'reject'], true) || !class_exists('\AKSRT\User\BanAppeal')) {
|
||||
$this->redirect('aksrt_user_ban', 'appeal_failed', ['tab' => 'appeals']);
|
||||
}
|
||||
|
||||
$status = $decision === 'approve' ? 'approved' : 'rejected';
|
||||
update_user_meta($user_id, \AKSRT\User\BanAppeal::META_STATUS, $status);
|
||||
|
||||
$payload = \AKSRT\User\BanAppeal::get_payload($user_id);
|
||||
$payload['admin_note'] = $note;
|
||||
$payload['handled_at'] = current_time('Y-m-d H:i');
|
||||
$payload['handled_by'] = get_current_user_id();
|
||||
$payload['decision'] = $status;
|
||||
update_user_meta($user_id, \AKSRT\User\BanAppeal::META_PAYLOAD, $payload);
|
||||
|
||||
$history = get_user_meta($user_id, \AKSRT\User\BanAppeal::META_HISTORY, true);
|
||||
$history = is_array($history) ? $history : [];
|
||||
$history[] = $payload;
|
||||
update_user_meta($user_id, \AKSRT\User\BanAppeal::META_HISTORY, array_slice($history, -30));
|
||||
|
||||
if ($decision === 'approve' && class_exists('\AKSRT\User\Restriction')) {
|
||||
global $wpdb;
|
||||
$table = class_exists('\AKSRT\Core\DBMigrator') ? \AKSRT\Core\DBMigrator::table('user_restriction') : '';
|
||||
if ($table !== '') {
|
||||
$wpdb->query($wpdb->prepare(
|
||||
"UPDATE {$table} SET status = 'lifted', expires_at = %s WHERE user_id = %d AND type IN ('ban','suspend','mute')",
|
||||
current_time('mysql'),
|
||||
$user_id
|
||||
));
|
||||
}
|
||||
$svc = \AKSRT\User\Restriction::get_instance();
|
||||
if (method_exists($svc, 'clear_user_bans')) {
|
||||
$svc->clear_user_bans($user_id);
|
||||
} elseif (method_exists($svc, 'lift_ban')) {
|
||||
$svc->lift_ban($user_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (class_exists('\AKSRT\Messages\Message')) {
|
||||
$msg = $decision === 'approve'
|
||||
? __('你的禁封申诉已通过,限制已解除。', 'aksrt')
|
||||
: __('你的禁封申诉未通过,可修改后重新提交。', 'aksrt');
|
||||
if ($note !== '') {
|
||||
$msg .= ' ' . sprintf(__('备注:%s', 'aksrt'), $note);
|
||||
}
|
||||
\AKSRT\Messages\Message::get_instance()->send(
|
||||
$user_id,
|
||||
'ban_appeal',
|
||||
$msg,
|
||||
[
|
||||
'title' => $decision === 'approve' ? __('申诉通过', 'aksrt') : __('申诉驳回', 'aksrt'),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
do_action('aksrt_ban_appeal_processed', $user_id, $decision, $note);
|
||||
|
||||
$this->redirect(
|
||||
'aksrt_user_ban',
|
||||
$decision === 'approve' ? 'appeal_approved' : 'appeal_rejected',
|
||||
['tab' => 'appeals']
|
||||
);
|
||||
}
|
||||
|
||||
private function pagination(int $pages, int $page_num): void {
|
||||
if ($pages <= 1) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user