diff --git a/inc/helpers/aksrt-user-dashboard.php b/inc/helpers/aksrt-user-dashboard.php index 30811c14..b371121e 100644 --- a/inc/helpers/aksrt-user-dashboard.php +++ b/inc/helpers/aksrt-user-dashboard.php @@ -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, diff --git a/src/User/Home.php b/src/User/Home.php index 678ab9cc..d54e59cc 100644 --- a/src/User/Home.php +++ b/src/User/Home.php @@ -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]; + } + /** * 获取公开治理提示。 * diff --git a/templates/parts/user/author-hero.php b/templates/parts/user/author-hero.php index aa61a295..805da28b 100644 --- a/templates/parts/user/author-hero.php +++ b/templates/parts/user/author-hero.php @@ -195,6 +195,13 @@ $pm_url = ($pm_enabled && $messages_url !== '')