进行了一些小修复

This commit is contained in:
2026-08-26 15:36:56 +08:00
parent 562beb15cf
commit 992af2119d
3 changed files with 14 additions and 27 deletions
+5 -14
View File
@@ -1054,7 +1054,6 @@ if (!function_exists('aksrt_get_pay_service_html')) {
$service = is_array($order['service'] ?? null) ? $order['service'] : []; $service = is_array($order['service'] ?? null) ? $order['service'] : [];
} }
$items = [];
$text = trim((string) ($service['text'] ?? '')); $text = trim((string) ($service['text'] ?? ''));
$value = trim((string) ($service['value'] ?? '')); $value = trim((string) ($service['value'] ?? ''));
$icon = trim((string) ($service['icon'] ?? 'fa fas fa-check-circle')); $icon = trim((string) ($service['icon'] ?? 'fa fas fa-check-circle'));
@@ -1062,7 +1061,6 @@ if (!function_exists('aksrt_get_pay_service_html')) {
$icon = 'fa fas fa-check-circle'; $icon = 'fa fas fa-check-circle';
} }
// Support multi-line pay_service textarea (one bullet per line).
$lines = []; $lines = [];
if ($text !== '') { if ($text !== '') {
$lines = preg_split('/\r\n|\r|\n/', $text) ?: []; $lines = preg_split('/\r\n|\r|\n/', $text) ?: [];
@@ -1072,15 +1070,6 @@ if (!function_exists('aksrt_get_pay_service_html')) {
} }
$lines = array_values(array_filter(array_map('trim', $lines))); $lines = array_values(array_filter(array_map('trim', $lines)));
if ($lines === []) {
// Defaults aligned with previous hardcoded guarantees.
$lines = [
__('安全检测', 'aksrt'),
__('支持 VIP 权益', 'aksrt'),
__('支持积分结算', 'aksrt'),
];
}
$html = ''; $html = '';
foreach ($lines as $line) { foreach ($lines as $line) {
$html .= '<span class="' . esc_attr($class) . '">'; $html .= '<span class="' . esc_attr($class) . '">';
@@ -1253,6 +1242,8 @@ if (!function_exists('aksrt_get_paywall_html')) {
$attrs = aksrt_get_pay_attributes_html($post, 'pay-attr'); $attrs = aksrt_get_pay_attributes_html($post, 'pay-attr');
$count = $sales > 0 ? '<badge class="img-badge hot jb-blue px12">' . esc_html(sprintf(__('已售 %s', 'aksrt'), $sales)) . '</badge>' : ''; $count = $sales > 0 ? '<badge class="img-badge hot jb-blue px12">' . esc_html(sprintf(__('已售 %s', 'aksrt'), $sales)) . '</badge>' : '';
$service = aksrt_get_pay_service_html('muted-2-color'); $service = aksrt_get_pay_service_html('muted-2-color');
$widget_service = $service !== '' ? '<div class="px12 muted-2-color">' . $service . '</div>' : '';
$article_service = $service !== '' ? '<div class="px12 muted-2-color mt10 text-right">' . $service . '</div>' : '';
$demo = aksrt_get_demo_link_html($post, 'but jb-yellow padding-lg'); $demo = aksrt_get_demo_link_html($post, 'but jb-yellow padding-lg');
$demo_row = $demo !== '' ? '<div class="mt10">' . $demo . '</div>' : ''; $demo_row = $demo !== '' ? '<div class="mt10">' . $demo . '</div>' : '';
$discount = $modo === '0' ? aksrt_get_post_rebate_discount($post) : '0.00'; $discount = $modo === '0' ? aksrt_get_post_rebate_discount($post) : '0.00';
@@ -1268,11 +1259,11 @@ if (!function_exists('aksrt_get_paywall_html')) {
AKSRT_PAY_TYPE_VIDEO => '<i class="fa fa-play-circle fa-fw" aria-hidden="true"></i>' . esc_html__('查看视频', 'aksrt'), AKSRT_PAY_TYPE_VIDEO => '<i class="fa fa-play-circle fa-fw" aria-hidden="true"></i>' . esc_html__('查看视频', 'aksrt'),
]; ];
$view_label = $view_labels[$pay_type] ?? '<i class="fa fa-dot-circle-o fa-fw" aria-hidden="true"></i>' . esc_html__('查看内容', 'aksrt'); $view_label = $view_labels[$pay_type] ?? '<i class="fa fa-dot-circle-o fa-fw" aria-hidden="true"></i>' . esc_html__('查看内容', 'aksrt');
return '<div class="zib-widget pay-box pay-widget paid-box order-type-' . $order_type . '" style="padding:0">' . $tag . '<div class="relative-h ' . esc_attr($theme) . '" style="background-size:120%"><div class="pay-widget__orb pay-widget__orb--right ' . esc_attr($theme) . '"></div><div class="pay-widget__orb pay-widget__orb--left ' . esc_attr($theme) . '"></div><div class="relative box-body"><div class="text-center mt10 box-body"><p><i class="fa fa-shopping-bag fa-3x" aria-hidden="true"></i></p><b class="em14">' . esc_html__('已购买', 'aksrt') . '</b></div></div></div><div class="box-body"><div class="px12 muted-2-color">' . $service . '</div><div class="mt10"><a href="#posts-pay" class="but padding-lg btn-block ' . esc_attr($theme) . '">' . $view_label . '</a></div>' . $demo_row . $attrs . '</div>' . $count . '</div>'; return '<div class="zib-widget pay-box pay-widget paid-box order-type-' . $order_type . '" style="padding:0">' . $tag . '<div class="relative-h ' . esc_attr($theme) . '" style="background-size:120%"><div class="pay-widget__orb pay-widget__orb--right ' . esc_attr($theme) . '"></div><div class="pay-widget__orb pay-widget__orb--left ' . esc_attr($theme) . '"></div><div class="relative box-body"><div class="text-center mt10 box-body"><p><i class="fa fa-shopping-bag fa-3x" aria-hidden="true"></i></p><b class="em14">' . esc_html__('已购买', 'aksrt') . '</b></div></div></div><div class="box-body">' . $widget_service . '<div class="mt10"><a href="#posts-pay" class="but padding-lg btn-block ' . esc_attr($theme) . '">' . $view_label . '</a></div>' . $demo_row . $attrs . '</div>' . $count . '</div>';
} }
if ($is_widget) { if ($is_widget) {
return '<div class="zib-widget pay-box pay-widget order-type-' . $order_type . '" style="padding:0">' . $tag . '<div class="relative-h ' . esc_attr($theme) . '" style="background-size:120%"><div class="pay-widget__orb pay-widget__orb--right ' . esc_attr($theme) . '"></div><div class="pay-widget__orb pay-widget__orb--left ' . esc_attr($theme) . '"></div><div class="relative box-body"><div class="text-center mt10">' . $price . '</div></div><div class="relative">' . $vip . '</div></div>' . $discount_banner . '<div class="box-body"><div class="px12 muted-2-color">' . $service . '</div><div class="mt10">' . $button . '</div>' . $demo_row . $attrs . '</div>' . $count . '</div>'; return '<div class="zib-widget pay-box pay-widget order-type-' . $order_type . '" style="padding:0">' . $tag . '<div class="relative-h ' . esc_attr($theme) . '" style="background-size:120%"><div class="pay-widget__orb pay-widget__orb--right ' . esc_attr($theme) . '"></div><div class="pay-widget__orb pay-widget__orb--left ' . esc_attr($theme) . '"></div><div class="relative box-body"><div class="text-center mt10">' . $price . '</div></div><div class="relative">' . $vip . '</div></div>' . $discount_banner . '<div class="box-body">' . $widget_service . '<div class="mt10">' . $button . '</div>' . $demo_row . $attrs . '</div>' . $count . '</div>';
} }
$thumb = get_the_post_thumbnail($post, 'medium', ['class' => 'fit-cover', 'alt' => '']); $thumb = get_the_post_thumbnail($post, 'medium', ['class' => 'fit-cover', 'alt' => '']);
@@ -1296,7 +1287,7 @@ if (!function_exists('aksrt_get_paywall_html')) {
$graphic = '<div class="flex0 relative mr20 hide-sm pay-thumb"><div class="graphic">' . $thumb . $graphic_actions . '</div></div>'; $graphic = '<div class="flex0 relative mr20 hide-sm pay-thumb"><div class="graphic">' . $thumb . $graphic_actions . '</div></div>';
} }
$demo_mobile = $demo !== '' ? '<div class="mt10 visible-xs-block">' . $demo . '</div>' : ''; $demo_mobile = $demo !== '' ? '<div class="mt10 visible-xs-block">' . $demo . '</div>' : '';
return '<div class="zib-widget pay-box order-type-' . $order_type . '" id="posts-pay"><div class="flex pay-flexbox">' . $graphic . '<div class="flex-auto-h flex xx jsb"><dt class="text-ellipsis pay-title">' . esc_html($title) . '</dt><div class="mt6 em09 muted-2-color">' . wp_kses_post($doc) . '</div><div>' . $price . '</div>' . $discount_mobile . ($vip !== '' ? '<div>' . $vip . '</div>' : '') . '<div class="text-right mt10">' . $button . '</div></div></div><div class="px12 muted-2-color mt10 text-right">' . $service . '</div>' . $demo_mobile . $attrs . $tag . $count . '</div>'; return '<div class="zib-widget pay-box order-type-' . $order_type . '" id="posts-pay"><div class="flex pay-flexbox">' . $graphic . '<div class="flex-auto-h flex xx jsb"><dt class="text-ellipsis pay-title">' . esc_html($title) . '</dt><div class="mt6 em09 muted-2-color">' . wp_kses_post($doc) . '</div><div>' . $price . '</div>' . $discount_mobile . ($vip !== '' ? '<div>' . $vip . '</div>' : '') . '<div class="text-right mt10">' . $button . '</div></div></div>' . $article_service . $demo_mobile . $attrs . $tag . $count . '</div>';
} }
} }
+6 -13
View File
@@ -437,19 +437,12 @@ if ($is_need_purchase && $user_amount > 0) {
} }
} }
?> ?>
<div class="resource-download-box__guarantees"> <?php $service_html = aksrt_get_pay_service_html(); ?>
<?php <?php if ($service_html !== '') : ?>
if (function_exists('aksrt_get_pay_service_html')) { <div class="resource-download-box__guarantees">
echo aksrt_get_pay_service_html(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped <?php echo $service_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
} else { </div>
?> <?php endif; ?>
<span class="resource-download-box__guarantee"><i class="fa fas fa-shield-alt" aria-hidden="true"></i> <?php esc_html_e('安全检测', 'aksrt'); ?></span>
<span class="resource-download-box__guarantee"><i class="fa fas fa-certificate" aria-hidden="true"></i> <?php esc_html_e('支持 VIP 权益', 'aksrt'); ?></span>
<span class="resource-download-box__guarantee"><i class="fa fas fa-money-bill" aria-hidden="true"></i> <?php esc_html_e('支持积分结算', 'aksrt'); ?></span>
<?php
}
?>
</div>
</div> </div>
</div> </div>
@@ -46,6 +46,7 @@ test('the purchase card owns one direct stylesheet and no retired paywall path',
const widgets = read('assets/widgets/frontend.css'); const widgets = read('assets/widgets/frontend.css');
const css = read('assets/css/frontend/pay-box.css'); const css = read('assets/css/frontend/pay-box.css');
const publicCss = read('assets/css/main.css'); const publicCss = read('assets/css/main.css');
const download = read('templates/parts/resource-download-box.php');
assert.match(assets, /assets\/css\/frontend\/pay-box\.css|\'pay-box\'/); assert.match(assets, /assets\/css\/frontend\/pay-box\.css|\'pay-box\'/);
assert.match(shortcodes, /return aksrt_get_paywall_html\(\$post, \['message' => \$message\]\);/); assert.match(shortcodes, /return aksrt_get_paywall_html\(\$post, \['message' => \$message\]\);/);
@@ -59,4 +60,6 @@ test('the purchase card owns one direct stylesheet and no retired paywall path',
assert.doesNotMatch(retired, /aksrt-post-pay/); assert.doesNotMatch(retired, /aksrt-post-pay/);
assert.doesNotMatch(retired, /str_replace\([\s\S]*aksrt-paywall__desc/); assert.doesNotMatch(retired, /str_replace\([\s\S]*aksrt-paywall__desc/);
assert.doesNotMatch(pay, /aksrt-paid-(?:gallery|video)__(?:locked|preview|overlay|placeholder|price)/); assert.doesNotMatch(pay, /aksrt-paid-(?:gallery|video)__(?:locked|preview|overlay|placeholder|price)/);
assert.doesNotMatch(pay + download, /安全检测|支持 VIP 权益|支持积分结算/);
assert.doesNotMatch(download, /function_exists\('aksrt_get_pay_service_html'\)/);
}); });