对照参考主题(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 项通过
122 lines
5.4 KiB
PHP
122 lines
5.4 KiB
PHP
<?php
|
|
/**
|
|
* User Dashboard Data Helper
|
|
*
|
|
* Aggregates user data for author pages and public user homepages.
|
|
* Shared between author.php and page-user-home.php to avoid duplicate queries.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
/**
|
|
* Get aggregated dashboard view data for a user.
|
|
*
|
|
* @param int $user_id Target user ID.
|
|
* @param array $args Optional. Supported keys:
|
|
* - viewer_id: Current viewer ID.
|
|
* - include_recent_posts: Whether to query recent posts.
|
|
* - include_governance: Whether to resolve notice/report data.
|
|
* @return array {
|
|
* @type int $post_count Published post count.
|
|
* @type int $comment_count Approved comment count.
|
|
* @type int $favorite_count Favorited post count.
|
|
* @type array $favorite_post_ids Array of favorited post IDs.
|
|
* @type array $profile_details Server-filtered fixed public profile fields.
|
|
* @type array $profile_signals Identity chips (verified, level, badges).
|
|
* @type array $verify_state Verification tri-state {state,label} for the details dialog.
|
|
* @type string $background_url Cover image URL.
|
|
* @type float $credit_balance Credit balance (own profile only).
|
|
* @type string $currency_name Currency/credits display name.
|
|
* @type bool $credits_enabled Whether credits system is active.
|
|
* @type bool $is_own_profile Whether viewer is the user themselves.
|
|
* }
|
|
*/
|
|
function aksrt_get_user_dashboard_view(int $user_id, array $args = []): array {
|
|
$viewer_id = (int) ($args['viewer_id'] ?? get_current_user_id());
|
|
$include_recent_posts = !array_key_exists('include_recent_posts', $args) || (bool) $args['include_recent_posts'];
|
|
$include_governance = !array_key_exists('include_governance', $args) || (bool) $args['include_governance'];
|
|
$is_own_profile = is_user_logged_in() && $viewer_id === $user_id;
|
|
|
|
$post_count = (int) count_user_posts($user_id, 'post', true);
|
|
$comment_count = (int) get_comments([
|
|
'user_id' => $user_id,
|
|
'count' => true,
|
|
'status' => 'approve',
|
|
]);
|
|
|
|
$favorite_post_ids = function_exists('aksrt_get_user_interaction_posts')
|
|
? aksrt_get_user_interaction_posts('_aksrt_favorite_posts', $user_id)
|
|
: [];
|
|
$favorite_count = count($favorite_post_ids);
|
|
$recent_posts = $include_recent_posts
|
|
? get_posts([
|
|
'author' => $user_id,
|
|
'post_type' => 'post',
|
|
'post_status' => 'publish',
|
|
'posts_per_page' => 5,
|
|
'orderby' => 'date',
|
|
'order' => 'DESC',
|
|
'no_found_rows' => true,
|
|
])
|
|
: [];
|
|
|
|
$profile_details = function_exists('aksrt_get_visible_user_profile_details')
|
|
? aksrt_get_visible_user_profile_details($user_id, $viewer_id)
|
|
: ['gender' => '', 'website' => '', 'qq' => '', 'wechat' => '', 'github' => ''];
|
|
|
|
$background_url = function_exists('aksrt_get_user_cover_url') ? aksrt_get_user_cover_url($user_id) : '';
|
|
|
|
$credits_enabled = class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::credits_enabled();
|
|
$credit_balance = $credits_enabled && $is_own_profile
|
|
? (float) aksrt_user_points($user_id)
|
|
: 0.0;
|
|
$currency_name = $credits_enabled && class_exists('\AKSRT\Settings\Settings')
|
|
? \AKSRT\Settings\Settings::get_currency_name()
|
|
: __('积分', 'aksrt');
|
|
|
|
$recharge = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_payment_recharge_settings() : [];
|
|
$balance_enabled = $is_own_profile && !empty($recharge['enabled']);
|
|
$wallet_balance = $balance_enabled ? aksrt_user_balance_decimal($user_id) : '0.00';
|
|
|
|
$user_home_manager = $include_governance && class_exists('\AKSRT\User\Home')
|
|
? \AKSRT\User\Home::get_instance()
|
|
: null;
|
|
$profile_signals = $user_home_manager ? $user_home_manager->get_profile_signals($user_id) : [];
|
|
$show_report = $user_home_manager ? $user_home_manager->show_report_entry() : false;
|
|
$verify_state = $user_home_manager ? $user_home_manager->get_verify_state($user_id) : ['state' => '', 'label' => ''];
|
|
|
|
return [
|
|
'post_count' => $post_count,
|
|
'comment_count' => $comment_count,
|
|
'favorite_count' => $favorite_count,
|
|
'favorite_post_ids'=> $favorite_post_ids,
|
|
'recent_posts' => $recent_posts,
|
|
'profile_details' => $profile_details,
|
|
'profile_signals' => $profile_signals,
|
|
'verify_state' => $verify_state,
|
|
'show_report' => $show_report,
|
|
'background_url' => $background_url,
|
|
'credit_balance' => $credit_balance,
|
|
'currency_name' => $currency_name,
|
|
'credits_enabled' => $credits_enabled,
|
|
'balance_enabled' => $balance_enabled,
|
|
'wallet_balance' => $wallet_balance,
|
|
'is_own_profile' => $is_own_profile,
|
|
];
|
|
}
|
|
|
|
add_action('wp_login', static function ($user_login, $user = null): void {
|
|
$user_id = 0;
|
|
if ($user instanceof WP_User) {
|
|
$user_id = (int) $user->ID;
|
|
} elseif (is_string($user_login) && $user_login !== '') {
|
|
$found = get_user_by('login', $user_login);
|
|
$user_id = $found instanceof WP_User ? (int) $found->ID : 0;
|
|
}
|
|
if ($user_id > 0) {
|
|
update_user_meta($user_id, 'aksrt_last_login', time());
|
|
}
|
|
}, 20, 2);
|