fix(pay): render paid reading as fragments
This commit is contained in:
1 parent
4cc1f2b2ea
commit
f040a680d6
9 files changed
+316
-65
No files matched your search
+26
-11
@@ -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>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user