Restore unified paid download model

This commit is contained in:
2026-07-04 19:24:04 +08:00
parent ca0a550af8
commit b98faa965a
9 changed files with 246 additions and 154 deletions
+26 -19
View File
@@ -31,8 +31,9 @@ $query_args = [
'ignore_sticky_posts' => true,
'meta_query' => [
[
'key' => AKSRT_Domain_Model::RESOURCE_MARKER_KEY,
'value' => '1',
'key' => AKSRT_Domain_Model::PAY_TYPE_KEY,
'value' => AKSRT_Domain_Model::PAY_TYPE_DOWNLOAD,
'compare' => '=',
],
],
];
@@ -59,8 +60,8 @@ if ($is_logged_in) {
}
$currency_name = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name() : __('积分', 'aksrt');
$dl_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_cms_features() : [];
$dl_requires_login = !empty($dl_settings['download_requires_login']);
$paid_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_paid_content_settings() : [];
$dl_requires_login = !empty($paid_settings['download_login']);
?>
<main id="main-content" class="site-main container" tabindex="-1">
@@ -85,14 +86,14 @@ $dl_requires_login = !empty($dl_settings['download_requires_login']);
</div>
<div class="aksrt-dl-status-bar__item aksrt-dl-status-bar__item--hint">
<i class="fas fa-info-circle" aria-hidden="true"></i>
<span><?php esc_html_e('点击资源卡片查看详情和下载状态', 'aksrt'); ?></span>
<span><?php esc_html_e('下载能力已归入统一内容付费模型,可从文章内容页直接解锁和下载。', 'aksrt'); ?></span>
</div>
<?php else : ?>
<div class="aksrt-dl-status-bar__item aksrt-dl-status-bar__item--hint">
<i class="fas fa-lock" aria-hidden="true"></i>
<span>
<?php if ($dl_requires_login) : ?>
<?php esc_html_e('登录后可查看下载状态和积分余额', 'aksrt'); ?>
<?php esc_html_e('登录后可查看下载状态、积分余额并解锁可下载内容', 'aksrt'); ?>
<?php else : ?>
<?php esc_html_e('登录后可管理下载记录和积分余额', 'aksrt'); ?>
<?php endif; ?>
@@ -109,10 +110,14 @@ $dl_requires_login = !empty($dl_settings['download_requires_login']);
<div class="aksrt-download-center__layout">
<div class="aksrt-download-center__main">
<div class="theme-box box-body aksrt-download-center__intro">
<h2><?php esc_html_e('内容下载中心(兼容入口)', 'aksrt'); ?></h2>
<p><?php esc_html_e('这里汇总所有已启用“付费下载”能力的文章,下载只是统一付费体系中的一种交付方式;普通文章内容页仍是主消费入口。', 'aksrt'); ?></p>
</div>
<?php if ($resource_query->have_posts()) : ?>
<div class="aksrt-download-center__grid">
<?php while ($resource_query->have_posts()) : $resource_query->the_post(); ?>
<article class="aksrt-download-card">
<article class="aksrt-download-card<?php echo function_exists('aksrt_is_resource_post') && aksrt_is_resource_post(get_the_ID()) ? ' is-legacy-resource' : ''; ?>">
<?php if (has_post_thumbnail()) : ?>
<div class="aksrt-download-card__thumb">
<a href="<?php the_permalink(); ?>">
@@ -121,6 +126,9 @@ $dl_requires_login = !empty($dl_settings['download_requires_login']);
</div>
<?php endif; ?>
<div class="aksrt-download-card__body">
<p class="aksrt-download-card__eyebrow">
<?php echo esc_html(function_exists('aksrt_is_resource_post') && aksrt_is_resource_post(get_the_ID()) ? __('旧资源兼容内容', 'aksrt') : __('内容付费入口', 'aksrt')); ?>
</p>
<h3 class="aksrt-download-card__title">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h3>
@@ -141,18 +149,17 @@ $dl_requires_login = !empty($dl_settings['download_requires_login']);
<?php endif; ?>
</div>
<?php
$card_meta = function_exists('aksrt_get_resource_meta') ? aksrt_get_resource_meta(get_the_ID()) : [];
$card_price = (float) ($card_meta['price'] ?? 0);
$price_label = function_exists('aksrt_resource_price_label')
? aksrt_resource_price_label($card_price)
$card_meta = function_exists('aksrt_get_download_box_meta') ? aksrt_get_download_box_meta(get_the_ID()) : [];
$price_label = function_exists('aksrt_get_pay_price_label')
? aksrt_get_pay_price_label(get_the_ID())
: ['text' => __('免费', 'aksrt'), 'free' => true];
?>
<div class="aksrt-download-card__footer">
<span class="aksrt-download-card__price<?php echo $price_label['free'] ? ' is-free' : ' is-paid'; ?>">
<?php echo esc_html($price_label['text']); ?>
<span class="aksrt-download-card__price<?php echo !empty($price_label['free']) ? ' is-free' : ' is-paid'; ?>">
<?php echo esc_html((string) ($price_label['text'] ?? '')); ?>
</span>
<a href="<?php the_permalink(); ?>" class="aksrt-download-card__action">
<?php esc_html_e('查看详情', 'aksrt'); ?>
<?php esc_html_e('进入内容页', 'aksrt'); ?>
<i class="fas fa-arrow-right" aria-hidden="true"></i>
</a>
</div>
@@ -169,7 +176,7 @@ $dl_requires_login = !empty($dl_settings['download_requires_login']);
<?php else : ?>
<div class="aksrt-download-center__empty">
<i class="fas fa-folder-open"></i>
<p><?php esc_html_e('暂无可下载资源。', 'aksrt'); ?></p>
<p><?php esc_html_e('暂无启用下载能力的内容。', 'aksrt'); ?></p>
</div>
<?php endif; ?>
</div>
@@ -180,13 +187,13 @@ $dl_requires_login = !empty($dl_settings['download_requires_login']);
<div class="aksrt-dl-sidebar-card">
<h3 class="aksrt-dl-sidebar-card__title">
<i class="fas fa-folder"></i>
<?php esc_html_e('资源类型', 'aksrt'); ?>
<?php esc_html_e('下载类型', 'aksrt'); ?>
</h3>
<?php if (!empty($resource_type_labels)) : ?>
<ul class="aksrt-dl-sidebar-card__list">
<li class="<?php echo $type_filter === '' ? 'is-active' : ''; ?>">
<a href="<?php echo esc_url(get_permalink()); ?>">
<?php esc_html_e('全部资源', 'aksrt'); ?>
<?php esc_html_e('全部可下载内容', 'aksrt'); ?>
</a>
</li>
<?php foreach ($resource_type_labels as $type_key => $type_label) : ?>
@@ -206,9 +213,9 @@ $dl_requires_login = !empty($dl_settings['download_requires_login']);
<?php esc_html_e('下载须知', 'aksrt'); ?>
</h3>
<div class="aksrt-dl-sidebar-card__tips">
<p><i class="fas fa-shield-alt" aria-hidden="true"></i> <?php esc_html_e('所有资源均经过安全检测', 'aksrt'); ?></p>
<p><i class="fas fa-book-open" aria-hidden="true"></i> <?php esc_html_e('优先从普通文章内容页进入主付费链路', 'aksrt'); ?></p>
<p><i class="fas fa-clock" aria-hidden="true"></i> <?php esc_html_e('下载链接 10 分钟内有效', 'aksrt'); ?></p>
<p><i class="fas fa-sync-alt" aria-hidden="true"></i> <?php esc_html_e('已下载资源可再次下载', 'aksrt'); ?></p>
<p><i class="fas fa-sync-alt" aria-hidden="true"></i> <?php esc_html_e('历史资源页与下载中心仅作为兼容入口保留', 'aksrt'); ?></p>
</div>
</div>
</div>