Merge pull request 'Restore unified paid download model' (#6) from worktree-aksrt-zibll-impl-task into main

Reviewed-on: CYL/wordpress-theme-aksrt#6
This commit is contained in:
2026-07-04 23:11:59 +08:00
9 changed files with 246 additions and 154 deletions
@@ -16,13 +16,13 @@ class AKSRT_Admin_Schema_Payment {
'sections' => [
'paid' => [
'key' => 'paid',
'title' => '下载/付费内容中心',
'title' => '内容付费 / 下载',
'version' => '1.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'strategy', 'title' => '付费内容策略', 'fields' => [
['key' => 'strategy', 'title' => '内容付费策略', 'fields' => [
['key' => 'payment_paid_post_types', 'label' => '受管内容类型', 'type' => 'input', 'default' => 'post'],
['key' => 'payment_vip_free_download', 'label' => '角色白名单免扣下载', 'type' => 'switch', 'default' => false],
['key' => 'payment_vip_free_download', 'label' => 'VIP / 角色白名单免扣下载', 'type' => 'switch', 'default' => false],
['key' => 'payment_vip_exempt_roles', 'label' => '免扣角色列表', 'type' => 'input', 'default' => ''],
]],
['key' => 'delivery', 'title' => '交付说明', 'fields' => [
@@ -41,12 +41,12 @@ class AKSRT_Admin_Schema_Payment {
['label' => '模块下', 'value' => 'box_bottom'],
]],
]],
['key' => 'download', 'title' => '下载设置', 'fields' => [
['key' => 'payment_download_enable', 'label' => '启用下载功能', 'type' => 'switch', 'default' => false],
['key' => 'download', 'title' => '下载能力', 'fields' => [
['key' => 'payment_download_enable', 'label' => '启用下载能力', 'type' => 'switch', 'default' => false],
['key' => 'payment_download_remote_s', 'label' => '远程文件下载', 'type' => 'switch', 'default' => true],
['key' => 'payment_download_verify_nonce', 'label' => '下载鉴权', 'type' => 'switch', 'default' => true],
['key' => 'payment_download_user_log', 'label' => '用户下载记录条数', 'type' => 'number', 'default' => 50, 'min' => 0, 'max' => 9999],
['key' => 'payment_download_post_log', 'label' => '文章下载记录条数', 'type' => 'number', 'default' => 50, 'min' => 0, 'max' => 9999],
['key' => 'payment_download_post_log', 'label' => '内容下载记录条数', 'type' => 'number', 'default' => 50, 'min' => 0, 'max' => 9999],
['key' => 'payment_download_remote_size', 'label' => '远程文件大小限制(KB)', 'type' => 'number', 'default' => 2048, 'min' => 1, 'max' => 999999],
['key' => 'payment_download_remote_ext', 'label' => '远程文件格式限制', 'type' => 'input', 'default' => 'zip,rar,7z'],
]],
@@ -136,15 +136,15 @@ class AKSRT_Content_Visibility {
*/
public static function can_download_resource($post = null, int $user_id = 0) {
$resource_post = get_post($post);
if (!($resource_post instanceof WP_Post) || !function_exists('aksrt_is_resource_post') || !aksrt_is_resource_post($resource_post)) {
return new WP_Error('aksrt_not_resource', __('该内容不是可下载资源。', 'aksrt'));
if (!($resource_post instanceof WP_Post) || !function_exists('aksrt_is_downloadable_content') || !aksrt_is_downloadable_content($resource_post)) {
return new WP_Error('aksrt_not_downloadable', __('该内容未启用下载能力。', 'aksrt'));
}
$state = self::get_post_access_state($resource_post, $user_id);
$uid = $user_id > 0 ? $user_id : get_current_user_id();
if (($state['pay_type'] ?? '') !== AKSRT_Domain_Model::PAY_TYPE_DOWNLOAD) {
return new WP_Error('aksrt_not_downloadable', __('该内容不是可下载资源。', 'aksrt'));
return new WP_Error('aksrt_not_downloadable', __('该内容未启用下载能力。', 'aksrt'));
}
if (!empty($state['need_login']) && $uid <= 0) {
+8 -8
View File
@@ -106,11 +106,11 @@ class AKSRT_Download {
public function rest_policy(WP_REST_Request $request) {
$post_id = (int) $request['id'];
$post = get_post($post_id);
if (!$post || !aksrt_is_resource_post($post)) {
return new WP_Error('aksrt_invalid', __('资源不存在', 'aksrt'), ['status' => 404]);
if (!$post || !function_exists('aksrt_is_downloadable_content') || !aksrt_is_downloadable_content($post)) {
return new WP_Error('aksrt_invalid', __('内容不存在或未启用下载能力', 'aksrt'), ['status' => 404]);
}
$meta = aksrt_get_resource_meta($post);
$meta = function_exists('aksrt_get_download_box_meta') ? aksrt_get_download_box_meta($post) : [];
$paid_settings = AKSRT_Settings::get_paid_content_settings();
$cost = aksrt_resource_download_cost($post);
$uid = get_current_user_id();
@@ -148,11 +148,11 @@ class AKSRT_Download {
$source_index = isset($params['source_index']) ? (int) $params['source_index'] : 0;
$post = get_post($post_id);
if (!$post || !aksrt_is_resource_post($post)) {
return new WP_Error('aksrt_invalid', __('资源不存在', 'aksrt'), ['status' => 404]);
if (!$post || !function_exists('aksrt_is_downloadable_content') || !aksrt_is_downloadable_content($post)) {
return new WP_Error('aksrt_invalid', __('内容不存在或未启用下载能力', 'aksrt'), ['status' => 404]);
}
$meta = aksrt_get_resource_meta($post);
$meta = function_exists('aksrt_get_download_box_meta') ? aksrt_get_download_box_meta($post) : [];
if (empty($meta['downloads'][$source_index])) {
return new WP_Error('aksrt_no_source', __('下载源不存在', 'aksrt'), ['status' => 404]);
}
@@ -245,8 +245,8 @@ class AKSRT_Download {
if (!empty($row['ua_hash']) && $row['ua_hash'] !== $ua_hash) $this->fail_410();
$post = get_post((int) $row['post_id']);
if (!$post || !aksrt_is_resource_post($post)) $this->fail_410();
$meta = aksrt_get_resource_meta($post);
if (!$post || !function_exists('aksrt_is_downloadable_content') || !aksrt_is_downloadable_content($post)) $this->fail_410();
$meta = function_exists('aksrt_get_download_box_meta') ? aksrt_get_download_box_meta($post) : [];
$idx = (int) $row['source_index'];
if (empty($meta['downloads'][$idx]['url'])) $this->fail_410();
+3
View File
@@ -476,6 +476,9 @@ add_filter('single_template', function ($template) {
if (!($post instanceof WP_Post)) return $template;
if (!function_exists('aksrt_is_resource_post')) return $template;
if (!aksrt_is_resource_post($post)) return $template;
if (function_exists('aksrt_is_downloadable_content') && !aksrt_is_downloadable_content($post)) {
return $template;
}
$candidate = locate_template(['single-aksrt_resource.php']);
return $candidate ?: $template;
});
+54
View File
@@ -117,6 +117,60 @@ if (!function_exists('aksrt_default_pay_meta')) {
}
}
if (!function_exists('aksrt_is_downloadable_content')) {
function aksrt_is_downloadable_content($post = null): bool {
$p = get_post($post);
if (!($p instanceof WP_Post)) {
return false;
}
$meta = aksrt_get_pay_meta($p);
if (($meta['pay_type'] ?? AKSRT_PAY_TYPE_NO) !== AKSRT_PAY_TYPE_DOWNLOAD) {
return false;
}
return !empty($meta['downloads']) && is_array($meta['downloads']);
}
}
if (!function_exists('aksrt_get_download_box_meta')) {
function aksrt_get_download_box_meta($post = null): array {
$p = get_post($post);
if (!($p instanceof WP_Post)) {
return [];
}
if (function_exists('aksrt_get_resource_meta') && function_exists('aksrt_is_resource_post') && aksrt_is_resource_post($p)) {
$meta = aksrt_get_resource_meta($p);
$meta['subject_label'] = __('资源', 'aksrt');
return $meta;
}
$pay_meta = aksrt_get_pay_meta($p);
$download_count = (int) get_post_meta($p->ID, AKSRT_Domain_Model::RESOURCE_DOWNLOAD_COUNT_KEY, true);
$view_count = (int) get_post_meta($p->ID, AKSRT_Domain_Model::POST_VIEW_COUNT_KEY, true);
return [
'version' => (string) ($pay_meta['version'] ?? ''),
'size' => (string) ($pay_meta['size'] ?? ''),
'price' => (float) ($pay_meta['price'] ?? 0),
'original_price' => (float) ($pay_meta['original_price'] ?? 0),
'vip1_price' => (float) ($pay_meta['vip1_price'] ?? 0),
'vip2_price' => (float) ($pay_meta['vip2_price'] ?? 0),
'pay_type' => (string) ($pay_meta['pay_type'] ?? AKSRT_PAY_TYPE_NO),
'license' => (string) ($pay_meta['license'] ?? ''),
'compat' => (string) ($pay_meta['compat'] ?? ''),
'demo_url' => (string) ($pay_meta['demo_url'] ?? ''),
'downloads' => array_values(is_array($pay_meta['downloads'] ?? null) ? $pay_meta['downloads'] : []),
'download_count' => max(0, $download_count),
'view_count' => max(0, $view_count),
'require_login' => !empty($pay_meta['require_login']),
'require_captcha' => !empty($pay_meta['require_captcha']),
'subject_label' => __('内容', 'aksrt'),
];
}
}
// ============================================================
// 状态判断
// ============================================================
+5
View File
@@ -75,6 +75,7 @@ while (have_posts()) :
}
set_query_var('aksrt_resource_meta', $resource_meta);
$is_legacy_resource_shell = true;
?>
<?php if (!empty($single_settings['reading_progress'])) : ?>
@@ -259,6 +260,10 @@ while (have_posts()) :
</div>
<div class="sidebar aksrt-resource__aside" role="complementary" aria-label="<?php esc_attr_e('侧栏', 'aksrt'); ?>">
<div class="resource-legacy-note resource-legacy-note--aside">
<strong><?php esc_html_e('旧资源兼容入口', 'aksrt'); ?></strong>
<span><?php esc_html_e('当前单页仅保留历史资源内容兼容,下载能力已并入统一内容付费链路。', 'aksrt'); ?></span>
</div>
<?php get_template_part('templates/parts/resource-download-box'); ?>
<?php if ($show_toc) : ?>
+20
View File
@@ -94,6 +94,14 @@ while (have_posts()) :
$post_episode_count = max(0, (int) get_post_meta($post_id, '_aksrt_featured_video_episode', true));
$post_slide_images = array_values(array_filter((array) ($single_settings['slide_images'] ?? [])));
$author_card_html = '';
$is_resource_compat_post = function_exists('aksrt_is_resource_post') && aksrt_is_resource_post($post_id);
$has_download_capability = function_exists('aksrt_is_downloadable_content') && aksrt_is_downloadable_content($post_id);
$paid_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_paid_content_settings() : [];
$paid_display_settings = is_array($paid_settings['display'] ?? null) ? $paid_settings['display'] : [];
$paid_box_position = (string) ($paid_display_settings['box_position'] ?? 'top');
if (!in_array($paid_box_position, ['box_top', 'top', 'bottom', 'box_bottom'], true)) {
$paid_box_position = 'top';
}
if (class_exists('AKSRT_Docs_Presenter')) {
$docs_presenter = AKSRT_Docs_Presenter::get_instance();
if ($docs_presenter->is_docs_page($post_id)) {
@@ -290,6 +298,12 @@ while (have_posts()) :
<?php do_action('aksrt_single_content_before', $post); ?>
<?php if ($has_download_capability && in_array($paid_box_position, ['box_top', 'top'], true)) : ?>
<div class="aksrt-single-download-box aksrt-single-download-box--before<?php echo $is_resource_compat_post ? ' is-legacy-resource' : ''; ?>">
<?php get_template_part('templates/parts/resource-download-box'); ?>
</div>
<?php endif; ?>
<?php if (is_active_sidebar('single_top_content')) : ?>
<div class="aksrt-single-widget-area aksrt-single-widget-area--top">
<?php dynamic_sidebar('single_top_content'); ?>
@@ -317,6 +331,12 @@ while (have_posts()) :
<div class="post_after_content theme-box box-body"><?php echo wp_kses_post($post_after_content); ?></div>
<?php endif; ?>
<?php if ($has_download_capability && in_array($paid_box_position, ['bottom', 'box_bottom'], true)) : ?>
<div class="aksrt-single-download-box aksrt-single-download-box--after<?php echo $is_resource_compat_post ? ' is-legacy-resource' : ''; ?>">
<?php get_template_part('templates/parts/resource-download-box'); ?>
</div>
<?php endif; ?>
<?php if ($author_card_html !== '') : ?>
<?php echo $author_card_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php endif; ?>
+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>
+42 -39
View File
@@ -1,28 +1,35 @@
<?php
/**
* Resource Download Box — v2.0
* Paid Content Download Box
*
* 单篇资源页的下载区,模仿 zibll pay-box 双栏布局:
* - 左侧:资源缩略图 + 付费类型徽章 + 销量徽章
* - 右侧:价格区(原价划线 + 现价 + VIP 价)+ 下载按钮 + 服务保障
* 统一内容付费 / 下载区:普通文章为主线,resource 样式仅保留兼容外壳。
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$post_id = get_the_ID();
$meta = get_query_var('aksrt_resource_meta', null);
if (!is_array($meta)) {
$meta = function_exists('aksrt_get_resource_meta') ? aksrt_get_resource_meta(get_the_ID()) : null;
$meta = function_exists('aksrt_get_download_box_meta') ? aksrt_get_download_box_meta($post_id) : null;
}
if (!is_array($meta)) return;
$post_id = get_the_ID();
$downloads = is_array($meta['downloads']) ? $meta['downloads'] : [];
$pay_type = $meta['pay_type'] ?? 'download';
if ($pay_type !== 'download' || empty($downloads)) {
return;
}
$price_label = function_exists('aksrt_resource_price_label')
? aksrt_resource_price_label((float) $meta['price'])
$is_resource_context = function_exists('aksrt_is_resource_post') && aksrt_is_resource_post($post_id);
$subject_label = trim((string) ($meta['subject_label'] ?? ''));
if ($subject_label === '') {
$subject_label = $is_resource_context ? __('资源', 'aksrt') : __('内容', 'aksrt');
}
$price_label = function_exists('aksrt_get_pay_price_label')
? aksrt_get_pay_price_label($post_id)
: ['text' => '', 'free' => true];
// 下载策略检查
@@ -35,7 +42,7 @@ $paid_settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_paid_content_settings()
: ['download_credit' => true, 'download_captcha' => false];
$cost = function_exists('aksrt_resource_download_cost') ? aksrt_resource_download_cost($post_id) : (int) ceil((float) $meta['price']);
$cost = function_exists('aksrt_get_download_cost') ? aksrt_get_download_cost($post_id) : (int) ceil((float) ($meta['price'] ?? 0));
$credit_active = !empty($paid_settings['download_credit']) && $cost > 0;
$captcha_active = !empty($paid_settings['download_captcha']) || !empty($meta['require_captcha']);
if ($captcha_active && function_exists('aksrt_is_captcha_enabled_for') && !aksrt_is_captcha_enabled_for('download')) {
@@ -55,7 +62,7 @@ $has_thumbnail = $thumbnail !== '';
$original_price = (float) ($meta['original_price'] ?? 0);
$vip1_price = (float) ($meta['vip1_price'] ?? 0);
$vip2_price = (float) ($meta['vip2_price'] ?? 0);
$has_original = $original_price > 0 && $original_price > (float) $meta['price'];
$has_original = $original_price > 0 && $original_price > (float) ($meta['price'] ?? 0);
$has_vip = $vip1_price > 0 || $vip2_price > 0;
// 销量
@@ -64,15 +71,15 @@ $sales_count = (int) ($meta['sales_count'] ?? 0);
$display_count = max($download_count, $sales_count);
// 付费类型徽章
$pay_type_badge = function_exists('aksrt_resource_pay_type_badge') ? aksrt_resource_pay_type_badge($pay_type) : '';
$pay_type_badge = function_exists('aksrt_get_pay_type_badge') ? aksrt_get_pay_type_badge($pay_type) : '';
// 货币名称
$currency = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name() : __('积分', 'aksrt');
?>
<section class="widget resource-download-box resource-download-box--v2<?php echo $gate_blocked ? ' is-blocked' : ''; ?>"
<section class="widget resource-download-box resource-download-box--v2<?php echo $gate_blocked ? ' is-blocked' : ''; ?><?php echo $is_resource_context ? ' resource-download-box--legacy-resource' : ' resource-download-box--content'; ?>"
data-post-id="<?php echo esc_attr((string) $post_id); ?>"
data-price="<?php echo esc_attr((string) $meta['price']); ?>"
data-price="<?php echo esc_attr((string) ($meta['price'] ?? 0)); ?>"
data-credit="<?php echo $credit_active ? '1' : '0'; ?>"
data-captcha="<?php echo $captcha_active ? '1' : '0'; ?>"
aria-label="<?php esc_attr_e('下载区', 'aksrt'); ?>">
@@ -99,25 +106,25 @@ $currency = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name()
<div class="resource-download-box__content-col">
<header class="resource-download-box__header">
<div>
<p class="resource-download-box__eyebrow"><?php echo esc_html(sprintf(__('%s付费 / 下载能力', 'aksrt'), $subject_label)); ?></p>
<h2 class="resource-download-box__title">
<i class="fas fa-cloud-download-alt" aria-hidden="true"></i>
<?php esc_html_e('立即下载', 'aksrt'); ?>
<?php esc_html_e('解锁下载', 'aksrt'); ?>
</h2>
<?php if (!empty($downloads)) : ?>
</div>
<span class="resource-download-box__count">
<?php echo esc_html(sprintf(_n('%s 个下载源', '%s 个下载源', count($downloads), 'aksrt'), number_format_i18n(count($downloads)))); ?>
</span>
<?php endif; ?>
</header>
<!-- 价格区 -->
<div class="resource-download-box__pricing">
<span class="resource-download-box__price<?php echo $price_label['free'] ? ' is-free' : ''; ?>">
<?php echo esc_html($price_label['text']); ?>
<span class="resource-download-box__price<?php echo !empty($price_label['free']) ? ' is-free' : ''; ?>">
<?php echo esc_html((string) ($price_label['text'] ?? '')); ?>
</span>
<?php if ($has_original) : ?>
<span class="resource-download-box__original-price">
<?php echo esc_html(aksrt_resource_price_amount($original_price) . ' ' . $currency); ?>
<?php echo esc_html(aksrt_format_price($original_price) . ' ' . $currency); ?>
</span>
<?php endif; ?>
<?php echo $pay_type_badge && !$has_thumbnail ? $pay_type_badge : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
@@ -130,7 +137,7 @@ $currency = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name()
<i class="fas fa-crown" aria-hidden="true"></i>
<?php
/* translators: %s: VIP1 价格 */
printf(esc_html__('VIP1 %s', 'aksrt'), aksrt_resource_price_amount($vip1_price));
printf(esc_html__('VIP1 %s', 'aksrt'), aksrt_format_price($vip1_price));
?>
</span>
<?php endif; ?>
@@ -139,19 +146,17 @@ $currency = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name()
<i class="fas fa-gem" aria-hidden="true"></i>
<?php
/* translators: %s: VIP2 价格 */
printf(esc_html__('VIP2 %s', 'aksrt'), aksrt_resource_price_amount($vip2_price));
printf(esc_html__('VIP2 %s', 'aksrt'), aksrt_format_price($vip2_price));
?>
</span>
<?php endif; ?>
</div>
<?php endif; ?>
<!-- 下载按钮区 -->
<?php if (empty($downloads)) : ?>
<div class="resource-download-box__notice resource-download-box__notice--empty">
<p><i class="fas fa-info-circle" aria-hidden="true"></i> <?php esc_html_e('该资源暂未提供下载链接。', 'aksrt'); ?></p>
</div>
<?php else : ?>
<?php if (!empty($paid_settings['catalog_note'])) : ?>
<p class="resource-download-box__catalog-note"><?php echo esc_html((string) $paid_settings['catalog_note']); ?></p>
<?php endif; ?>
<ul class="resource-download-box__list">
<?php foreach ($downloads as $idx => $row) :
$label = isset($row['label']) ? (string) $row['label'] : '';
@@ -170,12 +175,12 @@ $currency = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name()
if ($is_need_login) {
$btn_tag = 'a';
$btn_text = __('登录下载', 'aksrt');
$btn_text = __('登录后下载', 'aksrt');
$btn_icon = 'fa-sign-in-alt';
$btn_modifier = ' resource-download-box__btn--login';
} elseif ($is_low_credit) {
$btn_tag = 'button';
$btn_text = sprintf(__('付费下载(%d 积分)', 'aksrt'), $cost);
$btn_text = sprintf(__('解锁下载(%d 积分)', 'aksrt'), $cost);
$btn_icon = 'fa-coins';
$btn_modifier = ' resource-download-box__btn--credit-low';
} elseif ($credit_active && $cost > 0) {
@@ -185,7 +190,7 @@ $currency = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name()
$btn_modifier = ' resource-download-box__btn--paid';
} else {
$btn_tag = 'button';
$btn_text = $label;
$btn_text = __('立即下载', 'aksrt');
$btn_icon = 'fa-download';
$btn_modifier = '';
}
@@ -233,21 +238,19 @@ $currency = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name()
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<!-- 服务保障 -->
<div class="resource-download-box__guarantees">
<span class="resource-download-box__guarantee">
<i class="fas fa-shield-alt" aria-hidden="true"></i>
<?php esc_html_e('安全检测', 'aksrt'); ?>
</span>
<span class="resource-download-box__guarantee">
<i class="fas fa-sync-alt" aria-hidden="true"></i>
<?php esc_html_e('持续更新', 'aksrt'); ?>
<i class="fas fa-crown" aria-hidden="true"></i>
<?php esc_html_e('支持 VIP 权益', 'aksrt'); ?>
</span>
<span class="resource-download-box__guarantee">
<i class="fas fa-headset" aria-hidden="true"></i>
<?php esc_html_e('售后支持', 'aksrt'); ?>
<i class="fas fa-coins" aria-hidden="true"></i>
<?php esc_html_e('支持积分结算', 'aksrt'); ?>
</span>
</div>
</div>
@@ -256,7 +259,7 @@ $currency = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name()
<?php if ($is_need_login) : ?>
<p class="resource-download-box__hint resource-download-box__hint--login">
<i class="fas fa-info-circle" aria-hidden="true"></i>
<?php esc_html_e('登录后可下载此资源。', 'aksrt'); ?>
<?php esc_html_e('登录后可解锁并下载该内容。', 'aksrt'); ?>
</p>
<?php elseif ($is_low_credit) : ?>
<p class="resource-download-box__hint resource-download-box__hint--credit">
@@ -274,7 +277,7 @@ $currency = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name()
<footer class="resource-download-box__footer">
<p class="resource-download-box__notice-text">
<i class="fas fa-info-circle" aria-hidden="true"></i>
<?php esc_html_e('请确认资源安全后再使用,本站仅作信息聚合与分享,不对资源内容负责。', 'aksrt'); ?>
<?php esc_html_e('下载能力是统一付费内容的一部分,请确认内容适用性后再使用。', 'aksrt'); ?>
</p>
</footer>
</section>