fix(comments): match avatar identity layout
This commit is contained in:
1 parent
47bf9c8f0b
commit
26ac8167f3
14 files changed
+51
-176
No files matched your search
@@ -511,18 +511,18 @@ if (!function_exists('aksrt_comments_render_form')) :
|
||||
<div class="comt-title text-center flex0 mr10">
|
||||
<?php if ($is_logged_in && $current_user instanceof WP_User) : ?>
|
||||
<div class="comt-avatar mb10">
|
||||
<?php echo get_avatar($current_user->ID, 60, '', '', ['class' => 'avatar']); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php echo aksrt_get_avatar_html($current_user->ID, 96, ['class' => 'avatar']); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- canonical avatar helper escapes output. ?>
|
||||
</div>
|
||||
<p class="text-ellipsis muted-2-color"><?php echo function_exists('aksrt_render_vip_badge') ? aksrt_render_vip_badge($current_user->ID) : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- vip 徽章内部已转义。 ?><?php echo esc_html($current_user->display_name); ?></p>
|
||||
<p class="text-ellipsis muted-2-color"><?php echo function_exists('aksrt_get_vip_icon') ? aksrt_get_vip_icon($current_user->ID, 'em12 mr3') : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- VIP helper escapes output. ?><?php echo esc_html($current_user->display_name); ?></p>
|
||||
<?php else : ?>
|
||||
<div class="comt-avatar mb10">
|
||||
<?php echo get_avatar(0, 60, '', '', ['class' => 'avatar']); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
<p data-toggle-class="open" data-target="#comment-user-info" data-toggle="tooltip" title="<?php esc_attr_e('填写用户信息', 'aksrt'); ?>">
|
||||
<?php echo $comment_author !== '' ? esc_html($comment_author) : esc_html__('昵称', 'aksrt'); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="comt-avatar mb10">
|
||||
<?php echo aksrt_get_avatar_html(0, 96, ['class' => 'avatar']); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- canonical avatar helper escapes output. ?>
|
||||
</div>
|
||||
<p class="" data-toggle-class="open" data-target="#comment-user-info" data-toggle="tooltip" title="<?php esc_attr_e('填写用户信息', 'aksrt'); ?>">
|
||||
<?php echo $comment_author !== '' ? esc_html($comment_author) : esc_html__('昵称', 'aksrt'); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="comt-box grow1">
|
||||
<div class="action-text mb10 em09 muted-2-color" id="comment-reply-info" style="display:none;"></div>
|
||||
<textarea placeholder="<?php echo esc_attr($placeholder); ?>" autoheight="true" maxheight="188" class="form-control grin" name="comment" id="comment" cols="100%" rows="4" tabindex="1"></textarea>
|
||||
|
||||
@@ -68,8 +68,8 @@ if (!function_exists('aksrt_render_user_identity_chips')) {
|
||||
'skip_level' => false,
|
||||
]);
|
||||
$html = '';
|
||||
if (!empty($args['include_vip']) && function_exists('aksrt_render_vip_badge')) {
|
||||
$vip = aksrt_render_vip_badge($user_id, 'sm');
|
||||
if (!empty($args['include_vip']) && function_exists('aksrt_get_vip_icon')) {
|
||||
$vip = aksrt_get_vip_icon($user_id);
|
||||
if (is_string($vip) && $vip !== '') {
|
||||
$html .= $vip;
|
||||
}
|
||||
@@ -216,8 +216,8 @@ if (!function_exists('aksrt_get_user_name')) {
|
||||
$vip_html = function_exists('aksrt_get_user_ban_name_badge')
|
||||
? aksrt_get_user_ban_name_badge($user_id)
|
||||
: '';
|
||||
if ($vip_html === '' && function_exists('aksrt_render_vip_badge')) {
|
||||
$vip_html = (string) aksrt_render_vip_badge($user_id, 'sm');
|
||||
if ($vip_html === '' && function_exists('aksrt_get_vip_icon')) {
|
||||
$vip_html = (string) aksrt_get_vip_icon($user_id);
|
||||
}
|
||||
}
|
||||
$name_class = trim('display-name text-ellipsis ' . (string) $args['name_class']);
|
||||
|
||||
+17
-20
@@ -342,32 +342,29 @@ if (!function_exists('aksrt_get_free_download_surplus')) {
|
||||
|
||||
|
||||
/**
|
||||
* 渲染 VIP 徽标 HTML
|
||||
* Render the configured VIP icon with the frontend identity-image contract.
|
||||
*
|
||||
* @param int $user_id
|
||||
* @param string $size sm | md | lg
|
||||
* @return string
|
||||
* @param int $user_id User ID.
|
||||
* @param string $class Additional image classes.
|
||||
* @param bool $tooltip Whether to enable the tooltip trigger.
|
||||
*/
|
||||
function aksrt_render_vip_badge(int $user_id = 0, string $size = 'sm'): string {
|
||||
if (!aksrt_is_vip($user_id)) {
|
||||
function aksrt_get_vip_icon(int $user_id = 0, string $class = 'em12 ml3', bool $tooltip = true): string {
|
||||
$level = aksrt_get_user_vip_level($user_id);
|
||||
if ($level <= 0 || !class_exists('\AKSRT\Settings\Settings')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$level = aksrt_get_user_vip_level($user_id);
|
||||
$badge_text = aksrt_get_vip_badge_text($user_id);
|
||||
$size_class = 'aksrt-vip-badge--' . $size;
|
||||
$level_class = $level >= 2 ? 'aksrt-vip-badge--vip2' : 'aksrt-vip-badge--vip1';
|
||||
|
||||
$icon_url = '';
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
$vip_settings = \AKSRT\Settings\Settings::get_payment_vip_settings();
|
||||
$icon_url = esc_url((string) ($vip_settings['levels'][$level]['img_icon'] ?? ''));
|
||||
$vip_settings = \AKSRT\Settings\Settings::get_payment_vip_settings();
|
||||
$icon_url = esc_url((string) ($vip_settings['levels'][$level]['img_icon'] ?? ''));
|
||||
if ($icon_url === '') {
|
||||
return '';
|
||||
}
|
||||
$icon = $icon_url !== ''
|
||||
? '<img' . aksrt_get_lazy_attr('lazy_other', $icon_url, 'aksrt-vip-badge__icon') . ' alt="" decoding="async">'
|
||||
: '<i class="fa fas fa-certificate" aria-hidden="true"></i>';
|
||||
|
||||
return '<span class="aksrt-vip-badge aksrt-vip-badge--gold ' . esc_attr($size_class . ' ' . $level_class) . '" title="' . esc_attr($badge_text) . '">' . $icon . '</span>';
|
||||
$name = sanitize_text_field((string) ($vip_settings['levels'][$level]['name'] ?? aksrt_get_vip_badge_text($user_id)));
|
||||
$tooltip_attr = $tooltip ? ' data-toggle="tooltip"' : '';
|
||||
|
||||
return '<img' . aksrt_get_lazy_attr('lazy_other', $icon_url, trim('img-icon ' . $class), aksrt_get_lazy_thumb())
|
||||
. $tooltip_attr . ' title="' . esc_attr($name) . '" alt="' . esc_attr($name) . '">';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -403,7 +400,7 @@ function aksrt_get_vip_info(int $user_id = 0): array {
|
||||
'is_vip' => $is_vip,
|
||||
'level' => $level,
|
||||
'badge_text' => $badge_text,
|
||||
'badge_html' => $is_vip ? aksrt_render_vip_badge($user_id) : '',
|
||||
'badge_html' => $is_vip ? aksrt_get_vip_icon($user_id) : '',
|
||||
'name' => $name,
|
||||
'expires' => $expires,
|
||||
'expires_label' => $expires_label,
|
||||
|
||||
@@ -142,7 +142,7 @@ if (!function_exists('aksrt_header_user_box_html')) :
|
||||
$display_name = $user->display_name ?: $user->user_login;
|
||||
$avatar = aksrt_get_avatar_html($user_id, 44, ['alt' => $display_name]);
|
||||
$desc = (string) ($ctx['user_desc'] ?? '');
|
||||
$vip_badge = function_exists('aksrt_render_vip_badge') ? aksrt_render_vip_badge($user_id, 'sm') : '';
|
||||
$vip_badge = function_exists('aksrt_get_vip_icon') ? aksrt_get_vip_icon($user_id) : '';
|
||||
// Level and certification icons ride inline to the right of the display name.
|
||||
$level_badge = (class_exists('\AKSRT\User\Level') && method_exists('\AKSRT\User\Level', 'get_badge_html'))
|
||||
? \AKSRT\User\Level::get_badge_html($user_id, 'aksrt-user-level-icon--header')
|
||||
|
||||
Reference in new issue
Block a user