Files
wordpress-theme-aksrt/inc/helpers/user-center-renderers/profile-header.php
T
Claude 4325ce0c1c fix(ui): render user level icon inline beside the name
The level (等级) badge was wrapping to its own line below the username and
rendering at the intrinsic PNG size in most surfaces. Centralize the badge
sizing after zibll's `.img-icon` (height: 1.1em, inline-block) in base.css so
every route gets the same compact inline badge, and keep the name row from
flex-wrapping.

- Add shared `.aksrt-user-level-icon / .aksrt-identity-medal` rule + nowrap name
  rows in base.css (loaded on all routes).
- Header dropdown: append the level icon next to the display name (was a
  separate badges row); constrain the name to ellipsis so the badge never wraps.
- User center profile header & author hero: render the level icon inside the
  <h1> name row; drop the duplicate level chip from the signals row.
- Single article author bar / after-box author card: nowrap the name row and
  size the level icon to 1.2em (was unstyled → intrinsic PNG size).
- Comments: inner <name> nowrap with a name clamp; medal sized to 1em.
- Consolidate the per-route `.aksrt-user-level-icon` duplicates in
  user-center/level.css and profile/layout.css onto the shared rule.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-30 18:13:41 +08:00

129 lines
6.1 KiB
PHP

<?php
/**
* User center profile header part.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
?>
<div class="uc-header">
<div class="uc-header__cover">
<img id="aksrt-cover-img" class="uc-header__cover-img" src="<?php echo esc_url($user_background_url ? $user_background_url : get_theme_file_uri('assets/img/person_background.png')); ?>" alt="">
<div class="uc-header__cover-mask"></div>
<?php if ($allow_bg_upload) : ?>
<button type="button" class="uc-header__cover-upload" id="aksrt-upload-bg-btn" title="<?php esc_attr_e('编辑背景图', 'aksrt'); ?>">
<i class="fas fa-pen" aria-hidden="true"></i>
<span><?php esc_html_e('编辑', 'aksrt'); ?></span>
</button>
<input type="file" id="aksrt-bg-file-input" accept="image/jpeg,image/png,image/webp,image/gif" style="display:none">
<?php endif; ?>
</div>
<div class="uc-header__content">
<div class="uc-header__avatar">
<?php echo aksrt_get_avatar_html($user_id, 120, ['id' => 'aksrt-user-avatar-image', 'alt' => $target_user->display_name, 'loading' => 'eager']); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php if ($show_avatar_edit) : ?>
<button type="button" id="aksrt-upload-avatar-btn" class="uc-header__avatar-upload" title="<?php esc_attr_e('更换头像', 'aksrt'); ?>" aria-label="<?php esc_attr_e('更换头像', 'aksrt'); ?>">
<i class="fas fa-camera" aria-hidden="true"></i>
<span><?php esc_html_e('更换头像', 'aksrt'); ?></span>
</button>
<input type="file" id="aksrt-avatar-file-input" accept="image/jpeg,image/png,image/webp,image/gif" hidden>
<?php endif; ?>
</div>
<div class="uc-header__info">
<h1 class="uc-header__name">
<?php echo esc_html($target_user->display_name); ?>
<?php
$vip_badge = function_exists('aksrt_render_vip_badge') ? aksrt_render_vip_badge($user_id) : '';
if ($vip_badge) {
echo $vip_badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
// Level icon inline to the right of the name (zibll parity).
if (class_exists('\AKSRT\User\Level') && method_exists('\AKSRT\User\Level', 'get_badge_html')) {
echo \AKSRT\User\Level::get_badge_html((int) $user_id); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
</h1>
<?php if ($target_user->description) : ?>
<p class="uc-header__desc"><?php echo esc_html($target_user->description); ?></p>
<?php endif; ?>
<?php if (!empty($profile_signals)) : ?>
<div class="aksrt-identity-chips">
<?php foreach ($profile_signals as $signal) : ?>
<?php
// Level is rendered inline next to the name above; skip it here.
if ((string) ($signal['type'] ?? '') === 'level') {
continue;
}
?>
<span class="aksrt-identity-chip aksrt-identity-chip--<?php echo esc_attr($signal['tone']); ?>">
<i class="fas fa-<?php echo esc_attr($signal['icon']); ?>" aria-hidden="true"></i>
<span><?php echo esc_html($signal['label']); ?></span>
</span>
<?php endforeach; ?>
</div>
<?php endif; ?>
<div class="uc-header__meta desc user-identity flex ac hh">
<span class="uc-header__meta-item" title="<?php esc_attr_e('用户名', 'aksrt'); ?>">
<i class="fas fa-user" aria-hidden="true"></i> <?php echo esc_html($target_user->user_login); ?>
</span>
<?php if ($target_user->user_email) : ?>
<span class="uc-header__meta-item" title="<?php esc_attr_e('邮箱', 'aksrt'); ?>">
<i class="fas fa-envelope" aria-hidden="true"></i> <?php echo esc_html($target_user->user_email); ?>
</span>
<?php endif; ?>
<?php
// IP 归属地 (zibll user_page_header_desc + user_city_s).
$uc_city = function_exists('aksrt_get_user_city_badge_html')
? aksrt_get_user_city_badge_html((int) $user_id, 'user_center', 'badg')
: '';
if ($uc_city !== '') {
echo $uc_city; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
</div>
</div>
<div class="uc-header__actions">
<?php if (class_exists('\AKSRT\User\Badges') && \AKSRT\User\Badges::enabled()) : ?>
<button type="button" class="btn-ghost btn-sm" data-aksrt-badges-open>
<i class="fas fa-award" aria-hidden="true"></i> <?php esc_html_e('我的徽章', 'aksrt'); ?>
</button>
<?php
$remote_badge = \AKSRT\User\Badges::get_info_link((int) $user_id, 'btn-ghost btn-sm', __('徽章弹层', 'aksrt'));
if ($remote_badge !== '') {
echo $remote_badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
<?php endif; ?>
<?php if (!empty($messages_url)) : ?>
<a href="<?php echo esc_url($messages_url); ?>" class="btn-ghost btn-sm">
<i class="fas fa-bell" aria-hidden="true"></i> <?php esc_html_e('消息通知', 'aksrt'); ?>
<?php if ($notification_unread_count > 0) : ?>
<span class="uc-header__action-badge"><?php echo esc_html((string) $notification_unread_count); ?></span>
<?php endif; ?>
</a>
<?php endif; ?>
<a href="<?php echo esc_url(aksrt_get_user_home_url()); ?>" class="btn-ghost btn-sm">
<i class="fas fa-map-marker-alt" aria-hidden="true"></i> <?php esc_html_e('我的主页', 'aksrt'); ?>
</a>
</div>
</div>
</div>
<?php if (class_exists('\AKSRT\User\Badges') && \AKSRT\User\Badges::enabled()) : ?>
<div class="uc-modal" id="aksrt-badges-modal" hidden data-aksrt-badges-modal data-user-id="<?php echo (int) $user_id; ?>" data-can-wear="1">
<div class="uc-modal__overlay" data-aksrt-badges-close></div>
<div class="uc-modal__dialog" role="dialog" aria-modal="true" aria-label="<?php esc_attr_e('我的徽章', 'aksrt'); ?>">
<button type="button" class="uc-modal__close" data-aksrt-badges-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fas fa-times" aria-hidden="true"></i></button>
<h3 class="uc-modal__title"><i class="fas fa-award mr6" aria-hidden="true"></i><?php esc_html_e('我的徽章', 'aksrt'); ?></h3>
<div class="uc-badges-list" data-aksrt-badges-body>
<div class="muted-2-color em09"><?php esc_html_e('加载中…', 'aksrt'); ?></div>
</div>
</div>
</div>
<?php endif; ?>