进行了一些小修复
This commit is contained in:
@@ -197,6 +197,7 @@ trait ScriptsPart1b {
|
||||
'needs_cover' => 'single-post/cover',
|
||||
'needs_related_toc' => 'single-post/related-toc',
|
||||
'has_hidden_content' => 'single-post/hidden-content',
|
||||
'needs_pay_box' => 'pay-box',
|
||||
];
|
||||
$single_feature_handles = [];
|
||||
foreach ($single_features as $requirement => $part) {
|
||||
|
||||
@@ -28,6 +28,7 @@ trait ScriptsPart1c {
|
||||
'has_toc' => false,
|
||||
'has_video' => false,
|
||||
'has_hidden_content' => false,
|
||||
'needs_pay_box' => false,
|
||||
'needs_cover' => false,
|
||||
'needs_navigation' => false,
|
||||
'needs_related_toc' => false,
|
||||
@@ -112,6 +113,7 @@ trait ScriptsPart1c {
|
||||
$requirements['has_toc'] = $is_article && $heading_count >= 2;
|
||||
$requirements['has_video'] = $has_video;
|
||||
$requirements['has_hidden_content'] = $has_hidden_content || $has_yiyan || $has_inserted_content;
|
||||
$requirements['needs_pay_box'] = $is_paid_content_single || (bool) preg_match('/\[(?:payshow|hidecontent)\b|wp:aksrt\/paid-fragment/i', $content);
|
||||
$requirements['needs_cover'] = $is_article && (
|
||||
$show_cover
|
||||
|| !empty($settings['breadcrumbs'])
|
||||
|
||||
+1
-16
@@ -120,22 +120,7 @@ class Shortcodes {
|
||||
}
|
||||
|
||||
$message = $atts['message'] ?: __('此内容需付费后查看', 'aksrt');
|
||||
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;
|
||||
}
|
||||
|
||||
return '<div class="aksrt-hidden-content aksrt-hidden-content--locked aksrt-hidden-content--payshow">'
|
||||
. '<div class="aksrt-hidden-content__message"><i class="fa fas fa-lock" aria-hidden="true"></i><span>'
|
||||
. esc_html($message)
|
||||
. '</span></div></div>';
|
||||
return aksrt_get_paywall_html($post, ['message' => $message]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,9 @@ final class AssetManager {
|
||||
|
||||
public static function enqueue_for(WidgetDefinition $definition): void {
|
||||
self::register();
|
||||
if ($definition->slug() === 'post_pay') {
|
||||
wp_enqueue_style('aksrt-pay-box');
|
||||
}
|
||||
foreach ($definition->assets() as $asset) {
|
||||
self::enqueue_optional($asset);
|
||||
}
|
||||
@@ -50,8 +53,10 @@ final class AssetManager {
|
||||
$root = get_template_directory();
|
||||
$uri = get_template_directory_uri();
|
||||
$css = $root . '/assets/widgets/frontend.css';
|
||||
$pay_css = $root . '/assets/css/frontend/pay-box.css';
|
||||
$js = $root . '/assets/widgets/frontend.js';
|
||||
wp_register_style(self::STYLE_HANDLE, $uri . '/assets/widgets/frontend.css', ['aksrt-public'], is_file($css) ? (string) filemtime($css) : null);
|
||||
wp_register_style('aksrt-pay-box', $uri . '/assets/css/frontend/pay-box.css', ['aksrt-public'], is_file($pay_css) ? (string) filemtime($pay_css) : null);
|
||||
wp_register_script(self::SCRIPT_HANDLE, $uri . '/assets/widgets/frontend.js', ['aksrt-runtime'], is_file($js) ? (string) filemtime($js) : null, true);
|
||||
$third_party = $uri . '/assets/widgets/third-party/';
|
||||
wp_register_script('aksrt-widget-hls', $third_party . 'hls.min.js', [], 'reference-pinned', true);
|
||||
|
||||
@@ -23,9 +23,9 @@ final class FrontendRenderer {
|
||||
}
|
||||
|
||||
AssetManager::enqueue_for($definition);
|
||||
if (in_array($definition->slug(), ['tab_posts', 'slider', 'slider_media_combo', 'icon_cards', 'icon_cover_cards', 'buttons', 'notice'], true)) {
|
||||
if (in_array($definition->slug(), ['post_pay', 'tab_posts', 'slider', 'slider_media_combo', 'icon_cards', 'icon_cover_cards', 'buttons', 'notice'], true)) {
|
||||
echo (string) ($args['before_widget'] ?? '');
|
||||
echo self::reference_title($instance);
|
||||
if ($definition->slug() !== 'post_pay') echo self::reference_title($instance);
|
||||
echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo (string) ($args['after_widget'] ?? '');
|
||||
return;
|
||||
|
||||
@@ -145,14 +145,11 @@ final class ContentRenderer {
|
||||
}
|
||||
$meta = aksrt_get_pay_meta($post);
|
||||
if (($meta['pay_type'] ?? 'no') === 'no') {
|
||||
return RendererHelpers::empty_state(__('当前文章未配置付费内容', 'aksrt'));
|
||||
return '';
|
||||
}
|
||||
if (function_exists('aksrt_has_paid_access') && aksrt_has_paid_access($post)) {
|
||||
$html = '<div class="aksrt-post-pay is-authorized ' . esc_attr((string) $instance['theme']) . '"><i class="fa fas fa-check-circle" aria-hidden="true"></i><strong>' . esc_html__('内容已解锁', 'aksrt') . '</strong><p>' . esc_html__('你已拥有当前知识内容的访问权限。', 'aksrt') . '</p>';
|
||||
$html .= function_exists('aksrt_get_pay_attributes_html') ? aksrt_get_pay_attributes_html($post, 'aksrt-post-pay__attrs') : '';
|
||||
$html .= function_exists('aksrt_get_demo_link_html') ? aksrt_get_demo_link_html($post, 'aksrt-widget-button') : '';
|
||||
return $html . '</div>';
|
||||
}
|
||||
return function_exists('aksrt_get_paywall_html') ? aksrt_get_paywall_html($post, true) : RendererHelpers::empty_state(__('请登录或购买后查看', 'aksrt'));
|
||||
return aksrt_get_paywall_html($post, [
|
||||
'layout' => 'widget',
|
||||
'theme' => (string) $instance['theme'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user