fix(badges): hide "我的徽章" button until user has visible badges
profile-header.php was rendering two badge buttons ("我的徽章"
opening the local modal and "徽章弹层" opening a remote modal).
Drop the remote one and gate the local one behind the new
aksrt_user_has_visible_badges() helper, which only returns true
when the user actually has at least one badge entry that exists
in the active catalog dictionary — preventing a useless empty
modal when nothing can be shown.
This commit is contained in:
1 parent
e991f1a0c6
commit
3a33f7cd7f
2 files changed
+37
-11
No files matched your search
@@ -86,17 +86,11 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
|
||||
</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 (function_exists('aksrt_user_has_visible_badges') && aksrt_user_has_visible_badges((int) $user_id)) : ?>
|
||||
<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 endif; ?>
|
||||
|
||||
<?php if (!empty($messages_url)) : ?>
|
||||
<a href="<?php echo esc_url($messages_url); ?>" class="btn-ghost btn-sm">
|
||||
|
||||
Reference in new issue
Block a user