fix(vip): Batch 0 wiring for VIP settings, URLs, and order meta

Wire get_vip_settings alias, tab aliases for vip/assets, expired-level meta,
VIP2 order-level fallback, JSON-safe order notes, and header/float pay-vip CTAs.
This commit is contained in:
kate522 committed 2026-07-21 16:16:43 +08:00
1 parent 01719b7fa1
commit 69836154fd
9 files changed
+122 -71

No files matched your search

+8 -34
View File
@@ -57,10 +57,10 @@ if (!function_exists('aksrt_get_float_pay_vip_html')) :
* Floating VIP open button.
*/
function aksrt_get_float_pay_vip_html(array $item = []): string {
$show_vip = true;
if (class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'get_vip_settings')) {
$vs = \AKSRT\Settings\Settings::get_vip_settings();
$show_vip = !empty($vs['enabled']) || !empty($vs['vip1_enabled']) || !empty($vs['vip2_enabled']);
$show_vip = false;
if (class_exists('\AKSRT\Settings\Settings')) {
$vs = \AKSRT\Settings\Settings::get_payment_vip_settings();
$show_vip = !empty($vs['enabled']);
}
if (!$show_vip) {
return '';
@@ -74,13 +74,11 @@ if (!function_exists('aksrt_get_float_pay_vip_html')) :
if ($level >= 2) {
return '';
}
$vip_url = function_exists('aksrt_get_vip_purchase_url')
? aksrt_get_vip_purchase_url()
: (function_exists('aksrt_get_user_center_url') ? aksrt_get_user_center_url('vip') : '#');
$title = $level === 1 ? __('升级会员', 'aksrt') : __('开通会员', 'aksrt');
$icon = !empty($item['icon']) ? (string) $item['icon'] : 'fa fa-diamond';
$cls = $user_id > 0 ? 'float-btn pay-vip' : 'float-btn signin-loader';
$href = $user_id > 0 ? $vip_url : 'javascript:;';
// Modal path: .pay-vip opens VIP modal (Batch 2+); guests use signin-loader.
$href = 'javascript:;';
$style = [];
if (!empty($item['color'])) {
$style[] = '--this-color:' . esc_attr((string) $item['color']);
@@ -89,7 +87,8 @@ if (!function_exists('aksrt_get_float_pay_vip_html')) :
$style[] = '--this-bg:' . esc_attr((string) $item['bg']);
}
$style_attr = $style ? ' style="' . implode(';', $style) . '"' : '';
return '<a class="' . esc_attr($cls) . '" href="' . esc_url($href) . '" title="' . esc_attr($title) . '"' . $style_attr . '>'
$vip_level_attr = $user_id > 0 ? ' vip-level="' . esc_attr((string) max(1, min(2, $level + 1))) . '"' : '';
return '<a class="' . esc_attr($cls) . '" href="' . esc_attr($href) . '" title="' . esc_attr($title) . '"' . $style_attr . $vip_level_attr . '>'
. '<i class="' . esc_attr($icon) . '" aria-hidden="true"></i>'
. '</a>';
}
@@ -152,28 +151,3 @@ if (!function_exists('aksrt_get_win_runtime_config')) :
];
}
endif;
if (!function_exists('aksrt_print_win_var')) :
/**
* Echo window._win + alias window.aksrtData bridge.
*/
function aksrt_print_win_var(): void {
static $done = false;
if ($done) {
return;
}
$done = true;
$cfg = aksrt_get_win_runtime_config();
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<script type="text/javascript">window._win=' . wp_json_encode($cfg, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . ';'
. 'window.aksrtData=window.aksrtData||{};'
. 'window.aksrtData.ajaxUrl=window.aksrtData.ajaxUrl||window._win.ajax_url;'
. 'window.aksrtData.siteUrl=window.aksrtData.siteUrl||window._win.www;'
. 'window.aksrtData.themeUri=window.aksrtData.themeUri||window._win.uri;'
. 'window.aksrtData.restUrl=window.aksrtData.restUrl||window._win.rest_url;'
. 'window.aksrtData.restNonce=window.aksrtData.restNonce||window._win.rest_nonce;'
. 'window.aksrtData.nonce=window.aksrtData.nonce||window._win.nonce;'
. 'window.aksrtData.imgbox=window._win;'
. '</script>' . "\n";
}
endif;