feat(vip): add default icons and remove download speed
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
77d54b3b9d
commit
18da39788f
15 files changed
+105
-74
No files matched your search
+10
-26
@@ -230,31 +230,6 @@ if (!function_exists('aksrt_get_user_free_download_limit')) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Download speed cap in KB/s for a user (0 = unlimited).
|
||||
*/
|
||||
if (!function_exists('aksrt_get_user_download_speed')) {
|
||||
function aksrt_get_user_download_speed(int $user_id = 0): int {
|
||||
if ($user_id <= 0) {
|
||||
$user_id = get_current_user_id();
|
||||
}
|
||||
if ($user_id <= 0 || !class_exists('\AKSRT\Settings\Settings')) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$vip = \AKSRT\Settings\Settings::get_payment_vip_settings();
|
||||
$level = function_exists('aksrt_get_user_vip_level') ? aksrt_get_user_vip_level($user_id) : 0;
|
||||
$levels = is_array($vip['levels'] ?? null) ? $vip['levels'] : [];
|
||||
$benefit = is_array($vip['benefit'] ?? null) ? $vip['benefit'] : [];
|
||||
|
||||
if ($level >= 1 && !empty($levels[$level]['enabled'])) {
|
||||
return max(0, (int) ($levels[$level]['download_speed'] ?? 0));
|
||||
}
|
||||
|
||||
return max(0, (int) ($benefit['download_speed'] ?? 0));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Count free downloads used today for a user (zibll pay_down_number).
|
||||
*/
|
||||
@@ -383,7 +358,16 @@ function aksrt_render_vip_badge(int $user_id = 0, string $size = 'sm'): string {
|
||||
$size_class = 'aksrt-vip-badge--' . $size;
|
||||
$level_class = $level >= 2 ? 'aksrt-vip-badge--vip2' : 'aksrt-vip-badge--vip1';
|
||||
|
||||
return '<span class="aksrt-vip-badge aksrt-vip-badge--gold ' . esc_attr($size_class . ' ' . $level_class) . '"><i class="fas fa-crown"></i> ' . esc_html($badge_text) . '</span>';
|
||||
$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'] ?? ''));
|
||||
}
|
||||
$icon = $icon_url !== ''
|
||||
? '<img class="aksrt-vip-badge__icon" src="' . $icon_url . '" alt="" loading="lazy" decoding="async" />'
|
||||
: '<i class="fas fa-crown" aria-hidden="true"></i>';
|
||||
|
||||
return '<span class="aksrt-vip-badge aksrt-vip-badge--gold ' . esc_attr($size_class . ' ' . $level_class) . '">' . $icon . ' ' . esc_html($badge_text) . '</span>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user