进行了一些小优化
This commit is contained in:
@@ -46,23 +46,20 @@ $classes = trim('article-avatar ' . $extra_class);
|
||||
$login_url = function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(get_permalink());
|
||||
$is_self = is_user_logged_in() && get_current_user_id() === $author_id;
|
||||
|
||||
// Identity: prefer aksrt_get_user_name (legacy order); fall back to chips.
|
||||
$identity_chips = '';
|
||||
$name_html = '';
|
||||
if (function_exists('aksrt_get_user_name')) {
|
||||
$name_html = aksrt_get_user_name([
|
||||
'id' => $author_id,
|
||||
'class' => 'name flex ac flex1',
|
||||
'name_class' => '',
|
||||
'vip' => true,
|
||||
'medal' => true,
|
||||
'auth' => true,
|
||||
'level' => true,
|
||||
'follow' => false,
|
||||
]);
|
||||
} elseif (function_exists('aksrt_render_user_identity_chips')) {
|
||||
$identity_chips = aksrt_render_user_identity_chips($author_id, 'author');
|
||||
}
|
||||
// Identity: aksrt_get_user_name is the canonical renderer (legacy order).
|
||||
$name_html = '';
|
||||
if (function_exists('aksrt_get_user_name')) {
|
||||
$name_html = aksrt_get_user_name([
|
||||
'id' => $author_id,
|
||||
'class' => 'name flex ac flex1',
|
||||
'name_class' => '',
|
||||
'vip' => true,
|
||||
'medal' => true,
|
||||
'auth' => true,
|
||||
'level' => true,
|
||||
'follow' => false,
|
||||
]);
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="<?php echo esc_attr($classes); ?>">
|
||||
@@ -83,9 +80,6 @@ $is_self = is_user_logged_in() && get_current_user_id() === $author_id;
|
||||
<?php else : ?>
|
||||
<span class="name flex ac flex1">
|
||||
<a class="display-name text-ellipsis" href="<?php echo esc_url($author_url); ?>"><?php echo esc_html($author_name); ?></a>
|
||||
<?php if ($identity_chips !== '') : ?>
|
||||
<?php echo $identity_chips; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<div class="px12-sm muted-2-color text-ellipsis">
|
||||
@@ -113,20 +107,26 @@ $is_self = is_user_logged_in() && get_current_user_id() === $author_id;
|
||||
<div class="flex0 user-action">
|
||||
<?php if (!$is_self) : ?>
|
||||
<?php if (is_user_logged_in()) : ?>
|
||||
<button type="button" class="px12-sm ml10 follow but c-red" data-aksrt-follow="<?php echo (int) $author_id; ?>">
|
||||
<i class="fa fas fa-heart em09" aria-hidden="true"></i> <span><?php esc_html_e('关注', 'aksrt'); ?></span>
|
||||
</button>
|
||||
<?php
|
||||
$reward_button = function_exists('aksrt_get_rewards_button')
|
||||
? aksrt_get_rewards_button($author_id, 'ml6 but c-yellow px12-sm', get_the_ID())
|
||||
: '';
|
||||
if ($reward_button !== '') {
|
||||
echo $reward_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
aksrt_render_rewards_modal_for_user($author_id, get_the_ID());
|
||||
}
|
||||
<?php
|
||||
// 服务端直接输出真实关注状态(legacy parity: zib_get_user_follow 恒渲染当前态)。
|
||||
$is_following = class_exists('\AKSRT\User\Follow') && \AKSRT\User\Follow::get_instance()->is_following(get_current_user_id(), $author_id);
|
||||
$follow_label = $is_following ? __('已关注', 'aksrt') : __('关注', 'aksrt');
|
||||
$follow_title = $is_following ? __('点击取消关注', 'aksrt') : __('关注该用户', 'aksrt');
|
||||
?>
|
||||
<button type="button" class="px12-sm ml10 follow c-red<?php echo $is_following ? ' is-following' : ''; ?>" data-aksrt-follow="<?php echo (int) $author_id; ?>" title="<?php echo esc_attr($follow_title); ?>">
|
||||
<i class="fa fas fa-heart em09" aria-hidden="true"></i> <span><?php echo esc_html($follow_label); ?></span>
|
||||
</button>
|
||||
<?php
|
||||
$reward_button = function_exists('aksrt_get_rewards_button')
|
||||
? aksrt_get_rewards_button($author_id, 'ml6 but c-yellow px12-sm', get_the_ID())
|
||||
: '';
|
||||
if ($reward_button !== '') {
|
||||
echo $reward_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
aksrt_render_rewards_modal_for_user($author_id, get_the_ID());
|
||||
}
|
||||
?>
|
||||
<?php else : ?>
|
||||
<a href="<?php echo esc_url($login_url); ?>" class="px12-sm ml10 follow but c-red">
|
||||
<a href="<?php echo esc_url($login_url); ?>" class="px12-sm ml10 follow c-red">
|
||||
<i class="fa fas fa-heart em09" aria-hidden="true"></i> <?php esc_html_e('关注', 'aksrt'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
Reference in New Issue
Block a user