feat(pay): free-login gate in access policy plus service/demo helpers
This commit is contained in:
1 parent
5acf302e53
commit
7cce3ff275
3 files changed
+115
-19
No files matched your search
@@ -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 .= '<span class="' . esc_attr($class) . '">';
|
||||
$html .= '<i class="' . esc_attr($icon) . '" aria-hidden="true"></i> ';
|
||||
$html .= esc_html($line);
|
||||
$html .= '</span>';
|
||||
}
|
||||
|
||||
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(
|
||||
'<a target="_blank" rel="nofollow noopener" href="%s" class="%s"><i class="fas fa-external-link-alt" aria-hidden="true"></i><span>%s</span></a>',
|
||||
esc_url($url),
|
||||
esc_attr($class),
|
||||
esc_html($text)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 付费墙 HTML
|
||||
// ============================================================
|
||||
|
||||
Reference in new issue
Block a user