The user-center sidebar rendered Font Awesome glyphs while the reference theme paints multi-tone inline SVGs, and several glyphs were simply wrong for their slot: fa-chart-line served both 我的等级 and 推广收益, fa-money-bill served both 余额 and 积分, and fa-pen stood in for 创作收益. The theme already ships every sprite key the reference sidebar needs in assets/js/runtime/svg-icon.js, and main.min.js injects the <symbol id="icon-*"> set on every frontend page, so no new icon system was needed. The two grids now use the reference theme's icon-but-box / user-icon-but-box shell (four per row, em16 icon, 12px muted label) in place of AKSRT's tinted 38px pill, and every remaining sidebar glyph and arrow resolves through aksrt_icon_markup(): 我的服务 我的等级 trend-color, 官方认证 user-auth, 我的订单 order-color 功能设置 消息通知 msg-color, 个人资料 user-color, 账户安全 security-color 资产卡 余额 money-color-2, 积分 points-color 中心卡 创作收益 merchant-color, 推广收益 money-color 其它 VIP 入口 vip_1, 抽屉触发器 menu, 箭头统一 right Dead code went with the swap: the whole .uc-service-grid block including the unused --cart and --revenue tones, the count badge (no caller ever set count), and the tone key. The two card selectors that targeted <i> now also cover <svg> so the icon sizes survive the element change, and the VIP arrow keeps uc-sidebar-vip__arrow for its hover animation. level/profile/settings gained their missing tab keys, which completes the icon-but-* class names and lets the existing .is-active sync cover all six entries. Verification: node --test across widget-system, navigation, admin, asset-ledger, dev, front-submit and fixtures (620 tests), plus php -l on the five changed PHP files. Contract-locked in tests/widget-system/user-center-sidebar-icons-contract.test.cjs.
63 lines
2.4 KiB
PHP
63 lines
2.4 KiB
PHP
<?php
|
|
/**
|
|
* User center sidebar: VIP entry.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
$vip_settings = is_array($vip_settings ?? null) ? $vip_settings : [];
|
|
$vip_levels = is_array($vip_settings['levels'] ?? null) ? $vip_settings['levels'] : [];
|
|
$vip_enabled = !empty($vip_settings['enabled'])
|
|
&& (!empty($vip_levels[1]['enabled']) || !empty($vip_levels[2]['enabled']));
|
|
if (!$vip_enabled) {
|
|
return;
|
|
}
|
|
|
|
$user_id = (int) ($user_id ?? get_current_user_id());
|
|
$vip_state = function_exists('aksrt_get_user_vip_state') ? aksrt_get_user_vip_state($user_id) : [];
|
|
$vip_level = (int) ($vip_state['level'] ?? 0);
|
|
$expired_level = min(2, max(0, (int) ($vip_state['expired_level'] ?? 0)));
|
|
$expires = max(0, (int) ($vip_state['expires'] ?? 0));
|
|
$vip_url = aksrt_get_user_center_tab_url('vip');
|
|
|
|
$title = __('开通会员', 'aksrt');
|
|
$status = (string) ($vip_settings['desc'] ?? '');
|
|
if ($status === '') {
|
|
$status = __('尊享会员权益', 'aksrt');
|
|
}
|
|
|
|
if ($vip_level > 0) {
|
|
$title = (string) ($vip_levels[$vip_level]['name'] ?? ('VIP' . $vip_level));
|
|
if ($expires <= 0 && ($vip_state['source'] ?? 'none') !== 'order') {
|
|
$status = __('永久会员', 'aksrt');
|
|
} else {
|
|
$remaining_days = max(1, (int) ceil(($expires - time()) / DAY_IN_SECONDS));
|
|
$status = sprintf(
|
|
/* translators: %d: remaining membership days */
|
|
__('还有 %d 天到期', 'aksrt'),
|
|
$remaining_days
|
|
);
|
|
}
|
|
} elseif ($expired_level > 0) {
|
|
$title = (string) ($vip_levels[$expired_level]['name'] ?? ('VIP' . $expired_level));
|
|
$status = __('已过期', 'aksrt');
|
|
}
|
|
|
|
$sidebar_level = $vip_level > 0 ? $vip_level : $expired_level;
|
|
$sidebar_icon_url = esc_url((string) ($vip_levels[$sidebar_level]['img_icon'] ?? ''));
|
|
$sidebar_icon = $sidebar_icon_url !== ''
|
|
? '<img' . aksrt_get_lazy_attr('lazy_other', $sidebar_icon_url, 'aksrt-vip-level-icon') . ' alt="" decoding="async">'
|
|
: aksrt_icon_markup('zibsvg-vip_1');
|
|
$sidebar_arrow = aksrt_icon_markup('zibsvg-right', 'uc-sidebar-vip__arrow');
|
|
?>
|
|
<a class="uc-sidebar-vip" href="<?php echo esc_url($vip_url); ?>" data-tab="vip">
|
|
<span class="uc-sidebar-vip__icon"><?php echo $sidebar_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span>
|
|
<span class="uc-sidebar-vip__content">
|
|
<strong><?php echo esc_html($title); ?></strong>
|
|
<small><?php echo esc_html($status); ?></small>
|
|
</span>
|
|
<?php echo $sidebar_arrow; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
</a>
|