Merge pull request 'feat(frontend): single pay-box positions + Zibll cover episodes/slides' (#64) from worktree-frontend-single-pay-cover into main
Reviewed-on: CYL/wordpress-theme-aksrt#64
This commit is contained in:
@@ -57,7 +57,7 @@ export const orderSchema = {
|
||||
icon: 'fas fa-eye',
|
||||
fields: [
|
||||
{ key: 'pay_mark', label: '付费标记', type: 'input', default: '付费' },
|
||||
{ key: 'pay_box_position', label: '付费框位置', type: 'radio', default: 'top', options: [{ label: '内容顶部(正文前)', value: 'top' }, { label: '内容底部(正文后)', value: 'bottom' }] },
|
||||
{ key: 'pay_box_position', label: '付费框位置', type: 'radio', default: 'top', options: [{ label: '文章框顶部(封面后)', value: 'box_top' }, { label: '正文顶部', value: 'top' }, { label: '正文底部', value: 'bottom' }, { label: '文章框底部(相关前)', value: 'box_bottom' }] },
|
||||
{ key: 'pay_free_logged_show', label: '登录用户显示免费', type: 'switch', default: false },
|
||||
{ key: 'payment_show_ip', label: '显示用户IP', type: 'switch', default: false },
|
||||
{ key: 'payment_show_device', label: '显示设备信息', type: 'switch', default: false },
|
||||
|
||||
@@ -51,7 +51,7 @@ export const paidSchema = {
|
||||
{ key: 'payment_currency_symbol', label: '货币符号', type: 'input', default: '¥', help: '商品价格前缀,如 ¥、$、¥' },
|
||||
{ key: 'pay_show_user', label: '显示购买用户', type: 'switch', default: true },
|
||||
{ key: 'pay_show_paycount', label: '显示购买次数', type: 'switch', default: true },
|
||||
{ key: 'pay_box_position', label: '付费框位置', type: 'radio', default: 'top', options: [{ label: '内容顶部(正文前)', value: 'top' }, { label: '内容底部(正文后)', value: 'bottom' }] },
|
||||
{ key: 'pay_box_position', label: '付费框位置', type: 'radio', default: 'top', options: [{ label: '文章框顶部(封面后)', value: 'box_top' }, { label: '正文顶部', value: 'top' }, { label: '正文底部', value: 'bottom' }, { label: '文章框底部(相关前)', value: 'box_bottom' }] },
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -193,3 +193,23 @@
|
||||
color: var(--color-ink);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ===== Video footer (Zibll single-video-footer) ===== */
|
||||
.single-head-cover .single-video-footer { padding: 12px 4px 4px; }
|
||||
.single-head-cover .single-video-footer .article-title {
|
||||
font-size: clamp(1.1rem, 2.4vw, 1.45rem); font-weight: 700; margin: 8px 0 0; line-height: 1.35;
|
||||
}
|
||||
.single-head-cover .featured-video-episode { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
|
||||
.single-head-cover .featured-video-episode .switch-video {
|
||||
display: inline-flex; align-items: center; max-width: 100%; padding: 6px 10px; border-radius: 8px;
|
||||
background: var(--surface-2, rgba(0,0,0,.04)); color: var(--color-ink); font-size: 13px;
|
||||
}
|
||||
.single-head-cover .featured-video-episode .switch-video.active {
|
||||
background: var(--color-primary-soft, rgba(240, 68, 148, 0.12)); color: var(--color-primary);
|
||||
}
|
||||
.single-head-cover .cover-meta.single-metabox {
|
||||
display: flex; flex-wrap: wrap; gap: 8px 12px; font-size: 12px; color: var(--color-ink-4);
|
||||
}
|
||||
.aksrt-single-pay-box { margin: 16px 0 20px; }
|
||||
.aksrt-single-pay-box .pay-box, .aksrt-single-pay-box .aksrt-paywall { margin: 0; }
|
||||
|
||||
@@ -35,8 +35,10 @@ class AKSRT_Admin_Schema_Payment {
|
||||
['key' => 'pay_show_user', 'label' => '显示购买用户', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'pay_show_paycount', 'label' => '显示购买次数', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'pay_box_position', 'label' => '付费框位置', 'type' => 'radio', 'default' => 'top', 'options' => [
|
||||
['label' => '内容顶部(正文前)', 'value' => 'top'],
|
||||
['label' => '内容底部(正文后)', 'value' => 'bottom'],
|
||||
['label' => '文章框顶部', 'value' => 'box_top'],
|
||||
['label' => '正文顶部', 'value' => 'top'],
|
||||
['label' => '正文底部', 'value' => 'bottom'],
|
||||
['label' => '文章框底部', 'value' => 'box_bottom'],
|
||||
]],
|
||||
]],
|
||||
['key' => 'download', 'title' => '下载能力', 'fields' => [
|
||||
@@ -282,8 +284,10 @@ class AKSRT_Admin_Schema_Payment {
|
||||
['key' => 'display', 'title' => '展示设置', 'fields' => [
|
||||
['key' => 'pay_mark', 'label' => '付费标记', 'type' => 'input', 'default' => '付费'],
|
||||
['key' => 'pay_box_position', 'label' => '付费框位置', 'type' => 'radio', 'default' => 'top', 'options' => [
|
||||
['label' => '内容顶部(正文前)', 'value' => 'top'],
|
||||
['label' => '内容底部(正文后)', 'value' => 'bottom'],
|
||||
['label' => '文章框顶部', 'value' => 'box_top'],
|
||||
['label' => '正文顶部', 'value' => 'top'],
|
||||
['label' => '正文底部', 'value' => 'bottom'],
|
||||
['label' => '文章框底部', 'value' => 'box_bottom'],
|
||||
]],
|
||||
['key' => 'pay_free_logged_show', 'label' => '登录用户显示免费', 'type' => 'switch', 'default' => false],
|
||||
['key' => 'payment_show_ip', 'label' => '显示用户IP', 'type' => 'switch', 'default' => false],
|
||||
|
||||
@@ -37,7 +37,8 @@ class AKSRT_Settings_Payment_Runtime {
|
||||
$manual_note = trim((string) ($settings['payment_manual_delivery_note'] ?? ''));
|
||||
|
||||
$box_position = sanitize_key((string) ($settings['pay_box_position'] ?? 'top'));
|
||||
if (!in_array($box_position, ['top', 'bottom'], true)) {
|
||||
// Zibll: box_top | top | bottom | box_bottom
|
||||
if (!in_array($box_position, ['box_top', 'top', 'bottom', 'box_bottom'], true)) {
|
||||
$box_position = 'top';
|
||||
}
|
||||
|
||||
@@ -312,7 +313,7 @@ class AKSRT_Settings_Payment_Runtime {
|
||||
$max_minutes = max(5, min(1440, (int) ($s['payment_order_max_minutes'] ?? 30)));
|
||||
|
||||
$box_position = sanitize_key((string) ($s['pay_box_position'] ?? 'top'));
|
||||
if (!in_array($box_position, ['top', 'bottom'], true)) {
|
||||
if (!in_array($box_position, ['box_top', 'top', 'bottom', 'box_bottom'], true)) {
|
||||
$box_position = 'top';
|
||||
}
|
||||
|
||||
|
||||
@@ -254,19 +254,49 @@ if (!function_exists('aksrt_resolve_single_post_display_settings')) :
|
||||
$video_url = (string) ($meta['featured_video'] ?? '');
|
||||
}
|
||||
|
||||
// 2. Slide cover — check for gallery/cover_images.
|
||||
// 2. Slide cover — featured_slide URLs and/or cover_images (attachment IDs).
|
||||
$slide_images = [];
|
||||
if ($slide_cover_on && !empty($meta['cover_images'])) {
|
||||
$slide_images = array_filter(array_map('trim', explode(',', (string) $meta['cover_images'])));
|
||||
if ($slide_cover_on) {
|
||||
$raw_slides = [];
|
||||
if (!empty($meta['featured_slide'])) {
|
||||
$raw_slides = array_merge($raw_slides, preg_split('/[,\s]+/', (string) $meta['featured_slide']) ?: []);
|
||||
}
|
||||
if (!empty($meta['cover_images'])) {
|
||||
$raw_slides = array_merge($raw_slides, preg_split('/[,\s]+/', (string) $meta['cover_images']) ?: []);
|
||||
}
|
||||
foreach ($raw_slides as $token) {
|
||||
$token = trim((string) $token);
|
||||
if ($token === '') {
|
||||
continue;
|
||||
}
|
||||
if (ctype_digit($token)) {
|
||||
$src = wp_get_attachment_image_url((int) $token, 'full');
|
||||
if (is_string($src) && $src !== '') {
|
||||
$slide_images[] = $src;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (filter_var($token, FILTER_VALIDATE_URL)) {
|
||||
$slide_images[] = esc_url_raw($token);
|
||||
}
|
||||
}
|
||||
$slide_images = array_values(array_unique(array_filter($slide_images)));
|
||||
}
|
||||
|
||||
// 3. Image cover — existing logic.
|
||||
if ($video_url !== '') {
|
||||
$cover_type = 'video';
|
||||
$cover_url = $video_url;
|
||||
} elseif (!empty($slide_images) && count($slide_images) > 1) {
|
||||
$cover_type = 'slide';
|
||||
$cover_url = $slide_images[0];
|
||||
} elseif (!empty($slide_images) && count($slide_images) >= 1) {
|
||||
// One explicit slide image still becomes image cover; 2+ become slide.
|
||||
if (count($slide_images) > 1) {
|
||||
$cover_type = 'slide';
|
||||
$cover_url = $slide_images[0];
|
||||
} else {
|
||||
$cover_type = 'image';
|
||||
$cover_url = $slide_images[0];
|
||||
$slide_images = [];
|
||||
}
|
||||
} elseif ($image_cover_on) {
|
||||
if ($cover_mode === 'auto') {
|
||||
$cover_url = function_exists('aksrt_get_first_content_image_url')
|
||||
@@ -287,6 +317,9 @@ if (!function_exists('aksrt_resolve_single_post_display_settings')) :
|
||||
$settings['cover_type'] = $cover_type;
|
||||
$settings['show_cover'] = $cover_type !== 'none';
|
||||
$settings['slide_images'] = $slide_images ?? [];
|
||||
$settings['featured_video'] = (string) ($meta['featured_video'] ?? '');
|
||||
$settings['episode_count'] = max(0, (int) ($meta['featured_video_episode'] ?? 0));
|
||||
$settings['video_poster'] = (string) ($meta['cover_image'] ?? '');
|
||||
$meta_copyright = trim((string) ($meta['copyright_text'] ?? ''));
|
||||
if ($meta_copyright !== '') {
|
||||
$settings['copyright_text'] = $meta_copyright;
|
||||
|
||||
+149
-61
@@ -74,19 +74,20 @@ if (!function_exists('aksrt_single_build_context')) :
|
||||
|
||||
$paid_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_paid_content_settings() : [];
|
||||
$paid_display = is_array($paid_settings['display'] ?? null) ? $paid_settings['display'] : [];
|
||||
$paid_box_position = (string) ($paid_display['box_position'] ?? 'top');
|
||||
if ($paid_box_position === 'box_top') {
|
||||
$paid_box_position = 'top';
|
||||
} elseif ($paid_box_position === 'box_bottom') {
|
||||
$paid_box_position = 'bottom';
|
||||
}
|
||||
if (!in_array($paid_box_position, ['top', 'bottom'], true)) {
|
||||
$paid_box_position = sanitize_key((string) ($paid_display['box_position'] ?? 'top'));
|
||||
// Zibll positions: box_top | top | bottom | box_bottom (do not collapse).
|
||||
if (!in_array($paid_box_position, ['box_top', 'top', 'bottom', 'box_bottom'], true)) {
|
||||
$paid_box_position = 'top';
|
||||
}
|
||||
|
||||
$show_cover = !empty($settings['show_cover']) && (string) ($settings['cover_url'] ?? '') !== '';
|
||||
$show_toc = !empty($settings['toc_enabled']);
|
||||
$has_download = function_exists('aksrt_is_downloadable_content') && aksrt_is_downloadable_content($post_id);
|
||||
$pay_meta = function_exists('aksrt_get_pay_meta') ? aksrt_get_pay_meta($post_id) : ['pay_type' => 'no'];
|
||||
$pay_type = (string) ($pay_meta['pay_type'] ?? 'no');
|
||||
$is_paid_post = function_exists('aksrt_is_paid_post') && aksrt_is_paid_post($post_id);
|
||||
// Pay module: download box OR non-download paid types (reading/gallery/video/vip).
|
||||
$show_pay_box = $has_download || ($is_paid_post && $pay_type !== 'no' && $pay_type !== 'download');
|
||||
|
||||
$breadcrumbs_html = '';
|
||||
if (!empty($settings['breadcrumbs']) && function_exists('aksrt_breadcrumbs')) {
|
||||
@@ -124,7 +125,8 @@ if (!function_exists('aksrt_single_build_context')) :
|
||||
'img_scale' => (int) ($settings['article_image_cover_scale'] ?? 35),
|
||||
'video_scale' => (int) ($settings['article_video_cover_scale'] ?? 56),
|
||||
'slide_images' => array_values(array_filter((array) ($settings['slide_images'] ?? []))),
|
||||
'episode_count' => max(0, (int) get_post_meta($post_id, '_aksrt_featured_video_episode', true)),
|
||||
'episode_count' => max(0, (int) ($settings['episode_count'] ?? 0)),
|
||||
'video_poster' => (string) ($settings['video_poster'] ?? ''),
|
||||
'meta_items' => $meta_items,
|
||||
'views' => $views,
|
||||
'comment_count' => $comment_count,
|
||||
@@ -137,10 +139,13 @@ if (!function_exists('aksrt_single_build_context')) :
|
||||
'after_content' => (string) ($settings['after_content'] ?? ''),
|
||||
'content_maxheight' => !empty($settings['maxheight_enabled']) ? max(0, (int) ($settings['maxheight'] ?? 0)) : 0,
|
||||
'has_download' => $has_download,
|
||||
'show_pay_box' => $show_pay_box,
|
||||
'pay_type' => $pay_type,
|
||||
'is_paid_post' => $is_paid_post,
|
||||
'paid_box_position' => $paid_box_position,
|
||||
'breadcrumbs_html' => $breadcrumbs_html,
|
||||
'status_badge' => $status_badge,
|
||||
'show_aside' => $aside_widgets || $show_toc || $has_download,
|
||||
'show_aside' => $aside_widgets || $show_toc || $has_download || $show_pay_box,
|
||||
'toc_title' => __('文章目录', 'aksrt'),
|
||||
];
|
||||
}
|
||||
@@ -177,7 +182,7 @@ endif;
|
||||
|
||||
if (!function_exists('aksrt_single_render_cover')) :
|
||||
/**
|
||||
* Cover / slide / video header.
|
||||
* Cover / slide / video header (Zibll single-head-cover).
|
||||
*
|
||||
* @param array<string,mixed> $ctx Single context.
|
||||
*/
|
||||
@@ -190,29 +195,44 @@ if (!function_exists('aksrt_single_render_cover')) :
|
||||
$badge = (string) $ctx['status_badge'];
|
||||
$crumbs = (string) $ctx['breadcrumbs_html'];
|
||||
$meta_items = is_array($ctx['meta_items'] ?? null) ? $ctx['meta_items'] : [];
|
||||
$img_scale = (int) $ctx['img_scale'];
|
||||
$video_scale = (int) $ctx['video_scale'];
|
||||
$img_scale = max(10, min(100, (int) $ctx['img_scale']));
|
||||
$video_scale = max(20, min(100, (int) $ctx['video_scale']));
|
||||
$episode = (int) $ctx['episode_count'];
|
||||
$slides = is_array($ctx['slide_images'] ?? null) ? $ctx['slide_images'] : [];
|
||||
$poster = (string) ($ctx['video_poster'] ?? '');
|
||||
$title = get_the_title();
|
||||
|
||||
if ($type === 'video') :
|
||||
?>
|
||||
<div class="single-head-cover single-cover single-cover--video graphic imgbox-container" style="padding-bottom:<?php echo esc_attr((string) $video_scale); ?>%;">
|
||||
<video src="<?php echo esc_url($ctx['cover_url']); ?>" autoplay muted loop playsinline class="single-cover__video"></video>
|
||||
<div class="single-cover__overlay"></div>
|
||||
<div class="single-cover__content">
|
||||
<?php if ($crumbs !== '') : ?>
|
||||
<div class="post-breadcrumbs"><?php echo $crumbs; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
||||
<?php endif; ?>
|
||||
<h1 class="article-title title-h-left"><?php the_title(); ?></h1>
|
||||
<?php echo $badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<div class="cover-meta abs-right">
|
||||
<?php foreach ($meta_items as $item) : ?>
|
||||
<item class="meta-view"><?php echo esc_html((string) ($item['text'] ?? '')); ?></item>
|
||||
<?php endforeach; ?>
|
||||
<div class="single-head-cover">
|
||||
<div class="single-video single-cover single-cover--video graphic imgbox-container" style="padding-bottom:<?php echo esc_attr((string) $video_scale); ?>%;">
|
||||
<video src="<?php echo esc_url($ctx['cover_url']); ?>"<?php echo $poster !== '' ? ' poster="' . esc_url($poster) . '"' : ''; ?> autoplay muted loop playsinline controls class="single-cover__video fit-cover"></video>
|
||||
<div class="single-cover__overlay"></div>
|
||||
</div>
|
||||
<div class="single-video-footer dplayer-featured">
|
||||
<div class="flex jsb at">
|
||||
<?php if ($crumbs !== '') : ?>
|
||||
<div class="post-breadcrumbs"><?php echo $crumbs; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
||||
<?php endif; ?>
|
||||
<div class="cover-meta single-metabox">
|
||||
<?php foreach ($meta_items as $item) : ?>
|
||||
<item class="meta-view"><?php echo esc_html((string) ($item['text'] ?? '')); ?></item>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<h1 class="article-title">
|
||||
<?php if ($episode > 1) : ?>
|
||||
<span class="badg badg-sm b-theme mr6"><i class="fa fa-play-circle mr3" aria-hidden="true"></i><?php printf(esc_html__('共%d集', 'aksrt'), $episode); ?></span>
|
||||
<?php else : ?>
|
||||
<i class="fa fa-play-circle-o mr6 opacity8" aria-hidden="true"></i>
|
||||
<?php endif; ?>
|
||||
<?php echo esc_html($title); ?>
|
||||
</h1>
|
||||
<?php echo $badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php if ($episode > 0) : ?>
|
||||
<div class="featured-video-episode single-video"><?php printf(esc_html__('第 %d 集', 'aksrt'), $episode); ?></div>
|
||||
<div class="featured-video-episode mt10">
|
||||
<span class="switch-video text-ellipsis active"><span class="mr6 badg badg-sm">1</span><i class="episode-active-icon"></i><?php printf(esc_html__('第%d集', 'aksrt'), 1); ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -222,27 +242,29 @@ if (!function_exists('aksrt_single_render_cover')) :
|
||||
|
||||
if ($type === 'slide' && !empty($slides)) :
|
||||
?>
|
||||
<div class="single-head-cover single-cover single-cover--slide graphic imgbox-container" style="padding-bottom:<?php echo esc_attr((string) $img_scale); ?>%;">
|
||||
<div class="single-cover__slides">
|
||||
<?php foreach ($slides as $idx => $slide_url) : ?>
|
||||
<div class="single-cover__slide<?php echo $idx === 0 ? ' is-active' : ''; ?>">
|
||||
<img src="<?php echo esc_url($slide_url); ?>" alt="<?php echo esc_attr(get_the_title()); ?>" class="fit-cover" loading="<?php echo $idx === 0 ? 'eager' : 'lazy'; ?>">
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="single-cover__overlay"></div>
|
||||
<div class="single-cover__content">
|
||||
<?php if ($crumbs !== '') : ?>
|
||||
<div class="post-breadcrumbs"><?php echo $crumbs; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
||||
<?php endif; ?>
|
||||
<h1 class="article-title title-h-left"><?php the_title(); ?></h1>
|
||||
<?php echo $badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<div class="single-head-cover">
|
||||
<div class="single-cover single-cover--slide graphic imgbox-container mb20 single-cover-slide" style="padding-bottom:<?php echo esc_attr((string) $img_scale); ?>%;">
|
||||
<div class="single-cover__slides">
|
||||
<?php foreach ($slides as $idx => $slide_url) : ?>
|
||||
<div class="single-cover__slide<?php echo $idx === 0 ? ' is-active' : ''; ?>">
|
||||
<img src="<?php echo esc_url($slide_url); ?>" alt="<?php echo esc_attr($title); ?>" class="fit-cover" loading="<?php echo $idx === 0 ? 'eager' : 'lazy'; ?>">
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="single-cover__overlay"></div>
|
||||
<div class="abs-center left-bottom single-cover-con single-cover__content">
|
||||
<?php if ($crumbs !== '') : ?>
|
||||
<div class="post-breadcrumbs"><?php echo $crumbs; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
||||
<?php endif; ?>
|
||||
<h1 class="article-title title-h-left"><?php echo esc_html($title); ?></h1>
|
||||
<?php echo $badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
<div class="cover-meta abs-right">
|
||||
<?php foreach ($meta_items as $item) : ?>
|
||||
<item class="meta-view"><?php echo esc_html((string) ($item['text'] ?? '')); ?></item>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="single-cover__dots single-cover-slide" aria-hidden="true">
|
||||
<div class="single-cover__dots" aria-hidden="true">
|
||||
<?php foreach ($slides as $idx => $_slide) : ?>
|
||||
<span class="single-cover__dot<?php echo $idx === 0 ? ' is-active' : ''; ?>"></span>
|
||||
<?php endforeach; ?>
|
||||
@@ -253,15 +275,17 @@ if (!function_exists('aksrt_single_render_cover')) :
|
||||
return;
|
||||
endif;
|
||||
?>
|
||||
<div class="single-head-cover single-cover graphic imgbox-container" style="padding-bottom:<?php echo esc_attr((string) $img_scale); ?>%;">
|
||||
<img src="<?php echo esc_url($ctx['cover_url']); ?>" alt="<?php echo esc_attr(get_the_title()); ?>" class="fit-cover" loading="eager">
|
||||
<div class="single-cover__overlay"></div>
|
||||
<div class="single-cover__content">
|
||||
<?php if ($crumbs !== '') : ?>
|
||||
<div class="post-breadcrumbs"><?php echo $crumbs; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
||||
<?php endif; ?>
|
||||
<h1 class="article-title title-h-left"><?php the_title(); ?></h1>
|
||||
<?php echo $badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<div class="single-head-cover">
|
||||
<div class="graphic mb20 single-cover imgbox-container" style="padding-bottom:<?php echo esc_attr((string) $img_scale); ?>%;">
|
||||
<img src="<?php echo esc_url($ctx['cover_url']); ?>" alt="<?php echo esc_attr($title); ?>" class="fit-cover" loading="eager">
|
||||
<div class="single-cover__overlay"></div>
|
||||
<div class="abs-center left-bottom single-cover-con single-cover__content">
|
||||
<?php if ($crumbs !== '') : ?>
|
||||
<div class="post-breadcrumbs"><?php echo $crumbs; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
||||
<?php endif; ?>
|
||||
<h1 class="article-title title-h-left"><?php echo esc_html($title); ?></h1>
|
||||
<?php echo $badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
<div class="cover-meta abs-right">
|
||||
<?php foreach ($meta_items as $item) : ?>
|
||||
<item class="meta-view"><?php echo esc_html((string) ($item['text'] ?? '')); ?></item>
|
||||
@@ -689,6 +713,68 @@ if (!function_exists('aksrt_single_render_related')) :
|
||||
}
|
||||
endif;
|
||||
|
||||
|
||||
if (!function_exists('aksrt_single_render_pay_box')) :
|
||||
/**
|
||||
* Unified single pay module (Zibll zibpay_posts_pay_content equivalent).
|
||||
*
|
||||
* @param array<string,mixed> $ctx Single context.
|
||||
*/
|
||||
function aksrt_single_render_pay_box(array $ctx = []): void {
|
||||
if ($ctx === []) {
|
||||
$ctx = function_exists('aksrt_single_build_context') ? aksrt_single_build_context() : [];
|
||||
}
|
||||
if (empty($ctx['show_pay_box'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$post_id = (int) ($ctx['post_id'] ?? get_the_ID());
|
||||
$post = get_post($post_id);
|
||||
if (!($post instanceof WP_Post)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$pay_type = (string) ($ctx['pay_type'] ?? 'no');
|
||||
if (!empty($ctx['has_download']) || $pay_type === 'download') {
|
||||
echo '<div class="aksrt-single-pay-box aksrt-single-pay-box--download" id="posts-pay">';
|
||||
get_template_part('templates/parts/resource-download-box');
|
||||
echo '</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_get_pay_meta')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$has_access = function_exists('aksrt_has_paid_access') ? aksrt_has_paid_access($post) : false;
|
||||
echo '<div class="aksrt-single-pay-box aksrt-single-pay-box--' . esc_attr($pay_type) . '" id="posts-pay">';
|
||||
if ($has_access) {
|
||||
if ($pay_type === 'gallery' && function_exists('aksrt_render_paid_gallery')) {
|
||||
echo aksrt_render_paid_gallery($post); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
} elseif ($pay_type === 'video' && function_exists('aksrt_render_paid_video')) {
|
||||
echo aksrt_render_paid_video($post); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
} else {
|
||||
echo '<div class="zib-widget pay-box paid-box"><div class="box-body"><span class="badg c-green hollow badg-sm mr6">' . esc_html__('已解锁', 'aksrt') . '</span><b>' . esc_html(get_the_title($post)) . '</b></div></div>';
|
||||
}
|
||||
} elseif (function_exists('aksrt_get_paywall_html')) {
|
||||
echo aksrt_get_paywall_html($post); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_single_pay_box_matches')) :
|
||||
/**
|
||||
* @param array<string,mixed> $ctx
|
||||
*/
|
||||
function aksrt_single_pay_box_matches(array $ctx, string $slot): bool {
|
||||
if (empty($ctx['show_pay_box'])) {
|
||||
return false;
|
||||
}
|
||||
return (string) ($ctx['paid_box_position'] ?? 'top') === $slot;
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_single_render_article')) :
|
||||
/**
|
||||
* Main article box.
|
||||
@@ -708,11 +794,9 @@ if (!function_exists('aksrt_single_render_article')) :
|
||||
|
||||
<?php do_action('aksrt_single_content_before', get_post()); ?>
|
||||
|
||||
<?php if (!empty($ctx['has_download']) && $ctx['paid_box_position'] === 'top') : ?>
|
||||
<div class="aksrt-single-download-box aksrt-single-download-box--before">
|
||||
<?php get_template_part('templates/parts/resource-download-box'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (function_exists('aksrt_single_pay_box_matches') && aksrt_single_pay_box_matches($ctx, 'top')) : ?>
|
||||
<?php aksrt_single_render_pay_box($ctx); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($ctx['front_content'] !== '') : ?>
|
||||
<div class="post_front_content theme-box box-body"><?php echo wp_kses_post((string) $ctx['front_content']); ?></div>
|
||||
@@ -738,11 +822,9 @@ if (!function_exists('aksrt_single_render_article')) :
|
||||
<div class="post_after_content theme-box box-body"><?php echo wp_kses_post((string) $ctx['after_content']); ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($ctx['has_download']) && $ctx['paid_box_position'] === 'bottom') : ?>
|
||||
<div class="aksrt-single-download-box aksrt-single-download-box--after">
|
||||
<?php get_template_part('templates/parts/resource-download-box'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (function_exists('aksrt_single_pay_box_matches') && aksrt_single_pay_box_matches($ctx, 'bottom')) : ?>
|
||||
<?php aksrt_single_render_pay_box($ctx); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php aksrt_single_render_actions($ctx); ?>
|
||||
<?php aksrt_single_render_content_footer($ctx); ?>
|
||||
@@ -839,9 +921,15 @@ if (!function_exists('aksrt_single')) :
|
||||
}
|
||||
|
||||
do_action('aksrt_single_before', get_post());
|
||||
if (function_exists('aksrt_single_pay_box_matches') && aksrt_single_pay_box_matches($ctx, 'box_top')) {
|
||||
aksrt_single_render_pay_box($ctx);
|
||||
}
|
||||
aksrt_single_render_article($ctx);
|
||||
do_action('aksrt_single_article_after', get_post());
|
||||
aksrt_single_render_after_box($ctx);
|
||||
if (function_exists('aksrt_single_pay_box_matches') && aksrt_single_pay_box_matches($ctx, 'box_bottom')) {
|
||||
aksrt_single_render_pay_box($ctx);
|
||||
}
|
||||
do_action('aksrt_single_after', get_post());
|
||||
}
|
||||
endif;
|
||||
|
||||
Reference in New Issue
Block a user