fix(pay): render paid reading as fragments

This commit is contained in:
kate522 committed 2026-08-13 18:58:24 +08:00
1 parent 4cc1f2b2ea
commit f040a680d6
9 files changed
+316 -65

No files matched your search

+7
View File
@@ -89,6 +89,10 @@ class ResourceMetaBox {
</span>
</div>
<p class="aksrt-pmb__hint" id="aksrt-pmb-reading-hint" hidden>
<?php esc_html_e('付费阅读价格只作用于正文中的“付费可见”片段;未插入片段时,正文保持公开。', 'aksrt'); ?>
</p>
<div class="aksrt-pmb__fields" id="aksrt-pmb-fields" data-disabled="<?php echo $is_paid ? '0' : '1'; ?>">
<!-- 基础价格 -->
@@ -378,6 +382,9 @@ class ResourceMetaBox {
var isPaid = t !== 'no';
fields.setAttribute('data-disabled', isPaid ? '0' : '1');
var readingHint = document.getElementById('aksrt-pmb-reading-hint');
if (readingHint) readingHint.hidden = t !== 'reading';
// 根据付费类型显示/隐藏相关字段
if (dlFields) dlFields.style.display = (t === 'download') ? '' : 'none';
if (galleryFields) galleryFields.style.display = (t === 'gallery') ? '' : 'none';
+5
View File
@@ -163,10 +163,15 @@ class Setup {
'type' => 'string',
'enum' => array_keys(DomainModel::pay_type_labels()),
],
'pay_modo' => ['type' => 'string', 'enum' => ['0', 'points']],
'price' => ['type' => 'number'],
'points_price' => ['type' => 'integer'],
'original_price' => ['type' => 'number'],
'vip1_price' => ['type' => 'number'],
'vip2_price' => ['type' => 'number'],
'vip1_points' => ['type' => 'integer'],
'vip2_points' => ['type' => 'integer'],
'pay_limit' => ['type' => 'integer', 'enum' => [0, 1, 2]],
'version' => ['type' => 'string'],
'size' => ['type' => 'string'],
'license' => ['type' => 'string'],
+26 -11
View File
@@ -101,6 +101,17 @@ class Shortcodes {
$atts = shortcode_atts(['message' => ''], $atts, 'payshow');
$pid = get_the_ID();
$post = $pid > 0 ? get_post($pid) : null;
// Payshow is a paid-reading fragment, not a generic hide mechanism.
// Until the post has an active reading price, keep its content public
// so authors can compose and publish before completing price setup.
if (!($post instanceof \WP_Post)
|| !function_exists('aksrt_is_payshow_purchase_enabled')
|| !aksrt_is_payshow_purchase_enabled($post)) {
return '<div class="aksrt-hidden-content aksrt-hidden-content--unlocked aksrt-hidden-content--payshow">'
. do_shortcode($content) . '</div>';
}
$can_view = $this->viewer_can_see_paid_block($pid);
if ($can_view) {
@@ -109,18 +120,22 @@ class Shortcodes {
}
$message = $atts['message'] ?: __('此内容需付费后查看', 'aksrt');
$uid = get_current_user_id();
$html = '<div class="aksrt-hidden-content aksrt-hidden-content--locked aksrt-hidden-content--payshow">';
$html .= '<div class="aksrt-hidden-content__message">';
$html .= '<i class="fas fa-lock" aria-hidden="true"></i> ';
$html .= '<span>' . esc_html($message) . '</span>';
$html .= '</div>';
if ($uid <= 0) {
$html .= '<a href="' . esc_url(wp_login_url(get_permalink())) . '" class="aksrt-hidden-content__login-btn btn-primary btn-sm">';
$html .= esc_html__('登录后购买查看', 'aksrt') . '</a>';
if (function_exists('aksrt_get_paywall_html')) {
$paywall = aksrt_get_paywall_html($post, true);
if ($message !== '') {
$paywall = str_replace(
'<p class="aksrt-paywall__desc">',
'<p class="aksrt-paywall__desc">' . esc_html($message) . ' ',
$paywall
);
}
return $paywall;
}
$html .= '</div>';
return $html;
return '<div class="aksrt-hidden-content aksrt-hidden-content--locked aksrt-hidden-content--payshow">'
. '<div class="aksrt-hidden-content__message"><i class="fas fa-lock" aria-hidden="true"></i><span>'
. esc_html($message)
. '</span></div></div>';
}
/**