diff --git a/inc/classes/class-aksrt-content-visibility.php b/inc/classes/class-aksrt-content-visibility.php index 7a7e4809..40c40755 100644 --- a/inc/classes/class-aksrt-content-visibility.php +++ b/inc/classes/class-aksrt-content-visibility.php @@ -97,7 +97,11 @@ class AKSRT_Content_Visibility { : (int) ceil($price); $state['download_cost'] = max(0, $download_cost); - $state['need_login'] = !empty($paid_settings['download_login']) || !empty($pay_meta['require_login']); + // Zibll pay_free_logged_show: free download still requires login. + $free_logged_show = !empty($paid_settings['free_logged_show']); + $state['need_login'] = !empty($paid_settings['download_login']) + || !empty($pay_meta['require_login']) + || ($free_logged_show && $state['download_cost'] <= 0); $state['require_captcha'] = !empty($paid_settings['download_captcha']) || !empty($pay_meta['require_captcha']); $state['need_purchase'] = !$has_vip_access && $state['download_cost'] > 0; $state['has_paid_access'] = $has_vip_access || $has_paid_order || !$state['need_purchase']; @@ -154,10 +158,18 @@ class AKSRT_Content_Visibility { ]); } + // Free download + pay_free_logged_show (belt-and-suspenders with state.need_login). $cost = (int) ($state['download_cost'] ?? 0); $paid_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_paid_content_settings() - : ['download_credit' => true]; + : ['download_credit' => true, 'free_logged_show' => false]; + + if ($cost <= 0 && !empty($paid_settings['free_logged_show']) && $uid <= 0) { + return new WP_Error('aksrt_need_login', __('免费资源,请登录后下载。', 'aksrt'), [ + 'status' => 401, + 'login_url' => wp_login_url(get_permalink($resource_post)), + ]); + } if (!empty($paid_settings['download_credit']) && $cost > 0) { $balance = class_exists('AKSRT_Credits') ? AKSRT_Credits::balance($uid) : 0; diff --git a/inc/helpers/aksrt-pay.php b/inc/helpers/aksrt-pay.php index 83da69da..78f0e9f0 100644 --- a/inc/helpers/aksrt-pay.php +++ b/inc/helpers/aksrt-pay.php @@ -420,6 +420,85 @@ if (!function_exists('aksrt_get_pay_type_badge')) { } } +/** + * Zibll zibpay_get_service() — service bullets under pay/download box. + * + * @return string HTML list of service items. + */ +if (!function_exists('aksrt_get_pay_service_html')) { + function aksrt_get_pay_service_html(string $class = 'resource-download-box__guarantee'): string { + $service = []; + if (class_exists('AKSRT_Settings')) { + $order = AKSRT_Settings::get_order_settings(); + $service = is_array($order['service'] ?? null) ? $order['service'] : []; + } + + $items = []; + $text = trim((string) ($service['text'] ?? '')); + $value = trim((string) ($service['value'] ?? '')); + $icon = trim((string) ($service['icon'] ?? 'fas fa-check-circle')); + if ($icon === '') { + $icon = 'fas fa-check-circle'; + } + + // Support multi-line pay_service textarea (one bullet per line). + $lines = []; + if ($text !== '') { + $lines = preg_split('/\r\n|\r|\n/', $text) ?: []; + } + if ($value !== '') { + $lines[] = $value; + } + $lines = array_values(array_filter(array_map('trim', $lines))); + + if ($lines === []) { + // Defaults aligned with previous hardcoded guarantees. + $lines = [ + __('安全检测', 'aksrt'), + __('支持 VIP 权益', 'aksrt'), + __('支持积分结算', 'aksrt'), + ]; + } + + $html = ''; + foreach ($lines as $line) { + $html .= ''; + $html .= ' '; + $html .= esc_html($line); + $html .= ''; + } + + return $html; + } +} + +/** + * Demo link button (Zibll zibpay_get_demo_link). + */ +if (!function_exists('aksrt_get_demo_link_html')) { + function aksrt_get_demo_link_html($post = null, string $class = 'resource-download-box__btn btn-outline resource-download-box__btn--demo'): string { + $p = get_post($post); + if (!($p instanceof WP_Post)) { + return ''; + } + $meta = aksrt_get_pay_meta($p); + if (($meta['pay_type'] ?? '') !== AKSRT_PAY_TYPE_DOWNLOAD) { + return ''; + } + $url = trim((string) ($meta['demo_url'] ?? '')); + if ($url === '') { + return ''; + } + $text = __('查看演示', 'aksrt'); + return sprintf( + '%s', + esc_url($url), + esc_attr($class), + esc_html($text) + ); + } +} + // ============================================================ // 付费墙 HTML // ============================================================ diff --git a/templates/parts/resource-download-box.php b/templates/parts/resource-download-box.php index 2786a4dd..4bf6d730 100644 --- a/templates/parts/resource-download-box.php +++ b/templates/parts/resource-download-box.php @@ -185,12 +185,18 @@ $currency = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name() - + - + - +