';
+ $html .= '
';
+ $html .= '
 . ')
';
+ $html .= '
' . esc_html(sprintf(__('%s的徽章', 'aksrt'), $display));
+ if ($wear !== '') {
+ $map = self::get_dictionary_map();
+ if (isset($map[$wear])) {
+ $html .= ' ' . esc_html(sprintf(__('佩戴:%s', 'aksrt'), (string) $map[$wear]['label'])) . '';
+ }
+ } else {
+ $html .= ' ' . esc_html__('暂无徽章', 'aksrt') . '';
+ }
+ $html .= '
';
+ $html .= '
';
+ $html .= '
';
+
+ $html .= '
';
+ return $html;
+ }
+
+ /**
+ * Single badge card modal.
+ */
+ public static function render_single_modal_html(string $slug, int $user_id = 0): string {
+ $map = self::get_dictionary_map();
+ $slug = sanitize_key($slug);
+ if ($slug === '' || !isset($map[$slug])) {
+ return '';
+ $html .= '
';
+ $html .= '
';
+ if (!empty($item['icon_url'])) {
+ $html .= '
 $item['icon_url']) . ')
';
+ } else {
+ $html .= '
';
+ }
+ $html .= '
' . esc_html((string) $item['label']) . '
';
+ if ($is_self) {
+ $html .= $has
+ ? '
' . esc_html__('已获得', 'aksrt') . '
'
+ : '
' . esc_html__('暂未获得', 'aksrt') . '
';
+ }
+ $html .= '
';
+ if ($is_self && $has && !$is_wear) {
+ $html .= '
';
+ } elseif ($is_self && $is_wear) {
+ $html .= '
' . esc_html__('当前佩戴此徽章', 'aksrt') . '
';
+ }
+ $html .= '
';
+ return $html;
+ }
+
+ /**
+ * Remote-modal trigger for a user's badge list (zibll zib_get_user_medal_info_link).
+ */
+ public static function get_info_link(int $user_id, string $class = '', ?string $text = null): string {
+ if ($user_id <= 0 || !self::enabled()) {
+ return '';
+ }
+ if ($text === null) {
+ $text = __('徽章明细', 'aksrt');
+ }
+ if (!function_exists('aksrt_get_remote_modal_link')) {
+ return '';
+ }
+ $url = add_query_arg(
+ [
+ 'action' => 'aksrt_user_badge_info_modal',
+ 'id' => $user_id,
+ ],
+ admin_url('admin-ajax.php')
+ );
+ return aksrt_get_remote_modal_link([
+ 'tag' => 'a',
+ 'class' => trim('user-medal-info ' . $class),
+ 'text' => $text,
+ 'url' => $url,
+ 'data_class' => 'full-sm',
+ 'height' => 240,
+ 'mobile_bottom' => true,
+ ]);
}
public function register_routes(): void {
diff --git a/templates/parts/user/author-hero.php b/templates/parts/user/author-hero.php
index 02dee3cf..62248511 100644
--- a/templates/parts/user/author-hero.php
+++ b/templates/parts/user/author-hero.php
@@ -102,6 +102,16 @@ $pm_url = ($pm_enabled && $messages_url !== '')
+ ' . $badge_link . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ }
+ }
+ ?>
+
description) : ?>