更多资料新增元信息

This commit is contained in:
2026-08-23 13:09:55 +08:00
parent 57b12dea80
commit 32cda220f7
3 changed files with 59 additions and 15 deletions
+3
View File
@@ -25,6 +25,7 @@ defined('ABSPATH') || exit;
* @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 array $profile_notice Ban/restriction notice, if any.
* @type string $background_url Cover image URL.
* @type float $credit_balance Credit balance (own profile only).
@@ -86,6 +87,7 @@ function aksrt_get_user_dashboard_view(int $user_id, array $args = []): array {
$profile_signals = $user_home_manager ? $user_home_manager->get_profile_signals($user_id) : [];
$profile_notice = $user_home_manager ? $user_home_manager->get_profile_notice($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,
@@ -96,6 +98,7 @@ function aksrt_get_user_dashboard_view(int $user_id, array $args = []): array {
'profile_details' => $profile_details,
'profile_signals' => $profile_signals,
'profile_notice' => $profile_notice,
'verify_state' => $verify_state,
'show_report' => $show_report,
'background_url' => $background_url,
'credit_balance' => $credit_balance,
+49 -15
View File
@@ -124,23 +124,11 @@ class Home {
$signals = [];
if (!empty($settings['verify']['enabled']) && !empty($settings['verify']['public_display']) && $this->is_user_verified($user_id, $settings['verify'])) {
$info = class_exists('AKSRT\\User\\AuthApply') ? AuthApply::get_auth_info($user_id) : [];
$application = class_exists('AKSRT\\User\\AuthApply') ? AuthApply::get_apply_payload($user_id) : [];
$type = sanitize_key((string) ($info['type'] ?? $application['type'] ?? ''));
$type_settings = is_array($settings['verify']['types'][$type] ?? null) ? $settings['verify']['types'][$type] : [];
$label = trim((string) ($type_settings['badge_text'] ?? $type_settings['label'] ?? ''));
if ($label === '') {
foreach ((array) ($settings['verify']['types'] ?? []) as $configured_type) {
if (is_array($configured_type) && !empty($configured_type['badge_text'])) {
$label = trim((string) $configured_type['badge_text']);
break;
}
}
}
$resolved = $this->resolve_verified_type($user_id, $settings['verify']);
$signals[] = [
'type' => 'verify',
'label' => $label,
'title' => $label,
'label' => $resolved['label'],
'title' => $resolved['label'],
'icon' => 'check-circle',
'icon_url' => get_theme_file_uri('/assets/img/user/user-certification.svg'),
'tone' => 'success',
@@ -217,6 +205,52 @@ class Home {
return $signals;
}
/**
* 解析"更多资料"弹窗用的认证三态标识。
*
* @return array{state:string,label:string} state 为空串表示认证公开展示已关闭;
* 否则为 none|personal|enterprise,label 为对应展示文案(与名字旁认证 chip 同源)。
*/
public function get_verify_state(int $user_id): array {
if ($user_id <= 0 || !class_exists('\AKSRT\Settings\Settings')) {
return ['state' => '', 'label' => ''];
}
$verify = \AKSRT\Settings\Settings::get_user_identity_settings()['verify'] ?? [];
$verify = is_array($verify) ? $verify : [];
if (empty($verify['enabled']) || empty($verify['public_display'])) {
return ['state' => '', 'label' => ''];
}
if (!$this->is_user_verified($user_id, $verify)) {
return ['state' => 'none', 'label' => __('未认证', 'aksrt')];
}
$resolved = $this->resolve_verified_type($user_id, $verify);
// 邮箱核验通过等无申请类型的场景与名字旁 chip 一致,回落到首个已配置类型。
$state = in_array($resolved['state'], ['personal', 'enterprise'], true) ? $resolved['state'] : 'personal';
return ['state' => $state, 'label' => $resolved['label']];
}
/**
* @return array{state:string,label:string} state 为申请类型 personal|enterprise(可为空串),label 为展示文案。
*/
private function resolve_verified_type(int $user_id, array $verify): array {
$info = class_exists('AKSRT\\User\\AuthApply') ? AuthApply::get_auth_info($user_id) : [];
$application = class_exists('AKSRT\\User\\AuthApply') ? AuthApply::get_apply_payload($user_id) : [];
$type = sanitize_key((string) ($info['type'] ?? $application['type'] ?? ''));
$type_settings = is_array($verify['types'][$type] ?? null) ? $verify['types'][$type] : [];
$label = trim((string) ($type_settings['badge_text'] ?? $type_settings['label'] ?? ''));
if ($label === '') {
foreach ((array) ($verify['types'] ?? []) as $configured_type) {
if (is_array($configured_type) && !empty($configured_type['badge_text'])) {
$label = trim((string) $configured_type['badge_text']);
break;
}
}
}
return ['state' => $type, 'label' => $label];
}
/**
* 获取公开治理提示。
*
+7
View File
@@ -195,6 +195,13 @@ $pm_url = ($pm_enabled && $messages_url !== '')
<button type="button" class="aksrt-profile-details-modal__close" data-aksrt-modal-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>">&times;</button>
<h2 id="aksrt-profile-details-title"><?php esc_html_e('更多资料', 'aksrt'); ?></h2>
<dl>
<?php
$verify_state = is_array($dashboard['verify_state'] ?? null) ? $dashboard['verify_state'] : [];
$verify_state_value = (string) ($verify_state['state'] ?? '');
$verify_tones = ['none' => 'neutral', 'personal' => 'success', 'enterprise' => 'warning'];
$verify_icons = ['none' => '', 'personal' => 'fa-user-check', 'enterprise' => 'fa-building'];
?>
<?php if ($verify_state_value !== '' && ($verify_state['label'] ?? '') !== '') : ?><div><dt><?php esc_html_e('认证', 'aksrt'); ?></dt><dd><span class="badg badg-sm aksrt-identity-chip aksrt-identity-chip--<?php echo esc_attr($verify_tones[$verify_state_value]); ?>"><?php if ($verify_icons[$verify_state_value] !== '') : ?><i class="fa fas <?php echo esc_attr($verify_icons[$verify_state_value]); ?>" aria-hidden="true"></i> <?php endif; ?><?php echo esc_html((string) $verify_state['label']); ?></span></dd></div><?php endif; ?>
<?php if (!empty($profile_details['gender'])) : ?><div><dt><?php esc_html_e('性别', 'aksrt'); ?></dt><dd><?php echo esc_html($profile_details['gender'] === 'male' ? __('男', 'aksrt') : __('女', 'aksrt')); ?></dd></div><?php endif; ?>
<?php if (!empty($profile_details['website'])) : ?><div><dt><?php esc_html_e('个人网站', 'aksrt'); ?></dt><dd><a href="<?php echo esc_url($profile_details['website']); ?>" target="_blank" rel="noopener noreferrer"><?php echo esc_html($profile_details['website']); ?></a></dd></div><?php endif; ?>
<?php if (!empty($profile_details['github'])) : ?><div><dt>GitHub</dt><dd><a href="<?php echo esc_url($profile_details['github']); ?>" target="_blank" rel="noopener noreferrer"><?php echo esc_html($profile_details['github']); ?></a></dd></div><?php endif; ?>