进行了一些小修复
This commit is contained in:
@@ -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