Files
wordpress-theme-aksrt/templates/parts/resource-download-box.php
T
kate522andClaude Opus 5 fac4a714e0 feat(creator-studio): 前台 Gutenberg 创作工作台与受保护付费附件
前台投稿页改为沉浸式创作工作台:Gutenberg 负责区块解析与序列化,
React + TypeScript 负责工作台外壳与发布抽屉,Jio 服务端继续作为权限、
审核与付费的唯一权威。

- 新增 assets/creator-studio 独立构建(wp-scripts,锁定 WP 6.4 时代包),
  仅在投稿模板加载,构建缺失或游客访问时回退原有 TinyMCE 表单
- 自动保存(4s 防抖 + rev 冲突 409)、本地快照恢复、发布配置抽屉、
  移动端全屏单列与安全区适配
- 图片插入走现有 front-submit 上传管线,保留能力校验与待认领生命周期
- 已发布文章的改稿写入私有版本,审核通过前线上内容/链接/付费条款不变;
  原生后台「改稿审核」一次性应用或退回,并校验源文章并发指纹
- 私有附件新表 jio_private_asset + jio_dl_token.asset_id,schema 升到 3.4.0;
  文件存放 ABSPATH 之外,未配置私有存储时 fail closed
- 下载令牌绑定文章/附件/用户/IP/UA/次数,每次交付复核 Visibility 的
  订单、VIP 与配额判定;中断传输归还次数
- 付费字段改为写入前校验,非法价格不再留下半保存文章
- 新增 creator-studio 契约测试;更新受影响的 schema/下载/投稿契约

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-06 14:53:23 +08:00

501 lines
24 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Unified paid-content download box.
*
* Downloadable content now follows the unified single.php mainline; resource-
* specific visuals are treated as content variants rather than a separate page
* system.
*
* @package Jio
*/
defined('ABSPATH') || exit;
$post_id = get_the_ID();
$meta = get_query_var('jio_resource_meta', null);
if (!is_array($meta)) {
$meta = function_exists('jio_get_download_box_meta') ? jio_get_download_box_meta($post_id) : null;
}
if (!is_array($meta)) return;
$downloads = is_array($meta['downloads']) ? $meta['downloads'] : [];
$pay_type = $meta['pay_type'] ?? 'download';
if ($pay_type !== 'download' || empty($downloads)) {
return;
}
$is_resource_context = function_exists('jio_is_resource_post') && jio_is_resource_post($post_id);
$context_variant = $is_resource_context ? 'resource' : 'content';
$subject_label = trim((string) ($meta['subject_label'] ?? ''));
if ($subject_label === '') {
$subject_label = $is_resource_context ? __('资源', 'jio') : __('内容', 'jio');
}
$price_label = function_exists('jio_get_pay_price_label')
? jio_get_pay_price_label($post_id)
: ['text' => '', 'free' => true];
// 下载策略检查
$gate = function_exists('jio_can_download') ? jio_can_download($post_id) : true;
$gate_blocked = is_wp_error($gate);
$gate_code = $gate_blocked ? $gate->get_error_code() : '';
$gate_data = $gate_blocked ? (array) $gate->get_error_data() : [];
$paid_settings = class_exists('\Jio\Settings\Settings')
? \Jio\Settings\Settings::get_paid_content_settings()
: ['download_credit' => true];
$access = class_exists('\Jio\Content\Visibility')
? \Jio\Content\Visibility::get_post_access_state($post_id)
: [];
$has_paid_access = !empty($access['has_paid_access']);
$priced = function_exists('jio_get_user_pay_price') ? jio_get_user_pay_price($post_id) : null;
$pay_modo = is_array($priced)
? ((($priced['modo'] ?? '0') === 'points') ? 'points' : '0')
: ((($meta['pay_modo'] ?? '0') === 'points') ? 'points' : '0');
$user_amount = is_array($priced) ? (float) ($priced['amount'] ?? 0) : (float) ($meta['price'] ?? 0);
$login_url = (string) ($gate_data['login_url'] ?? wp_login_url(get_permalink($post_id)));
$vip_url = function_exists('jio_get_user_center_tab_url')
? jio_get_user_center_tab_url('credits')
: (function_exists('jio_get_user_center_url') ? jio_get_user_center_url() : home_url('/'));
$is_need_login = $gate_blocked && $gate_code === 'jio_need_login';
$is_need_vip = $gate_blocked && $gate_code === 'jio_need_vip';
$is_need_purchase = $gate_blocked && $gate_code === 'jio_need_purchase';
// Points unpaid may also surface as need_purchase; treat low balance only after cashier.
$is_low_credit = false;
$allow_guest_buy = !is_user_logged_in()
&& function_exists('jio_allow_guest_content_pay')
&& jio_allow_guest_content_pay($post_id)
&& $pay_modo !== 'points'
&& $user_amount > 0
&& empty($access['need_vip']);
// If gate only says login but guest buy allowed for cash posts, convert to purchase CTA.
if ($is_need_login && $allow_guest_buy) {
$is_need_login = false;
$is_need_purchase = true;
$gate_blocked = true;
}
$price_amount = (float) ($price_label['amount'] ?? $user_amount);
// legacy down_alone_page: single entry to independent download page.
$alone_page = !empty($paid_settings['down_alone_page']) || !empty($paid_settings['download']['alone_page']);
$alone_url = '';
if ($alone_page && function_exists('jio_get_single_download_page_url')) {
$alone_url = jio_get_single_download_page_url($post_id);
}
$use_alone_entry = $alone_page && $alone_url !== '' && !$is_need_login && !$is_need_vip && !$is_need_purchase && !$gate_blocked;
if (!empty($GLOBALS['jio_on_download_file_page'])) {
$use_alone_entry = false;
}
// 缩略图
$thumbnail = get_the_post_thumbnail_url($post_id, 'medium') ?: '';
$has_thumbnail = $thumbnail !== '';
// 原价 & VIP 价(按 pay_modo 切换现金/积分档)
$original_price = (float) ($meta['original_price'] ?? 0);
if ($pay_modo === 'points') {
$vip1_price = (float) ($meta['vip1_points'] ?? 0);
$vip2_price = (float) ($meta['vip2_points'] ?? 0);
$base_price = (float) ($meta['points_price'] ?? $meta['price'] ?? 0);
} else {
$vip1_price = (float) ($meta['vip1_price'] ?? 0);
$vip2_price = (float) ($meta['vip2_price'] ?? 0);
$base_price = (float) ($meta['price'] ?? 0);
}
$has_original = $original_price > 0 && $original_price > $base_price;
$has_vip = ($vip1_price > 0 && $vip1_price < $base_price) || ($vip2_price > 0 && $vip2_price < $base_price);
$pay_limit = (int) ($meta['pay_limit'] ?? 0);
$user_vip_level = is_array($priced) ? (int) ($priced['vip_level'] ?? 0) : 0;
$member_blocked = $pay_limit > 0 && $user_vip_level < $pay_limit;
// 销量
$download_count = (int) ($meta['download_count'] ?? 0);
$sales_count = (int) ($meta['sales_count'] ?? 0);
$display_count = max($download_count, $sales_count);
$show_sales = !isset($meta['show_sales']) || !empty($meta['show_sales']);
// 付费类型徽章
$pay_type_badge = function_exists('jio_get_pay_type_badge') ? jio_get_pay_type_badge($pay_type) : '';
// 货币名称
$currency = class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::get_currency_name() : __('积分', 'jio');
$cash_symbol = '¥';
if (class_exists('\Jio\Settings\Settings')) {
$paid_display = \Jio\Settings\Settings::get_paid_content_settings();
$cash_symbol = (string) ($paid_display['display']['currency_symbol'] ?? '¥');
}
$format_vip = static function (float $amount) use ($pay_modo, $currency, $cash_symbol): string {
if ($amount <= 0) {
return (string) __('免费', 'jio');
}
$n = function_exists('jio_format_price') ? jio_format_price($amount) : (string) $amount;
return $pay_modo === 'points' ? ($n . ' ' . $currency) : ($cash_symbol . $n);
};
$purchase_label = '';
if ($is_need_purchase && $user_amount > 0) {
$purchase_label = $pay_modo === 'points'
? sprintf(__('立即购买(%s %s)', 'jio'), jio_format_price($user_amount), $currency)
: sprintf(__('立即购买(%s%s)', 'jio'), $cash_symbol, jio_format_price($user_amount));
} elseif ($is_need_purchase) {
$purchase_label = __('购买后下载', 'jio');
}
?>
<section class="widget resource-download-box resource-download-box--v2<?php echo $gate_blocked ? ' is-blocked' : ''; ?><?php echo $has_paid_access ? ' is-purchased' : ''; ?> resource-download-box--<?php echo esc_attr($context_variant); ?>"
data-jio-download-box
data-post-id="<?php echo esc_attr((string) $post_id); ?>"
data-price="<?php echo esc_attr((string) $base_price); ?>"
data-amount="<?php echo esc_attr((string) $user_amount); ?>"
data-pay-modo="<?php echo esc_attr($pay_modo); ?>"
data-pay-limit="<?php echo esc_attr((string) $pay_limit); ?>"
data-has-paid="<?php echo $has_paid_access ? '1' : '0'; ?>"
data-credit="0"
aria-label="<?php esc_attr_e('下载区', 'jio'); ?>">
<?php if ($has_paid_access && $user_amount > 0) : ?>
<span class="resource-download-box__sales-badge resource-download-box__paid-badge">
<i class="fa fas fa-check-circle" aria-hidden="true"></i>
<?php esc_html_e('已购买', 'jio'); ?>
</span>
<?php elseif ($show_sales && $display_count > 0) : ?>
<span class="resource-download-box__sales-badge">
<i class="fa fas fa-fire" aria-hidden="true"></i>
<?php
/* translators: %s: 下载/销量数 */
$sales_label = function_exists('jio_format_number') ? jio_format_number($display_count) : number_format_i18n($display_count);
printf(esc_html__('已售 %s', 'jio'), $sales_label);
?>
</span>
<?php endif; ?>
<?php
$paid_order = null;
if ($has_paid_access && is_user_logged_in() && function_exists('jio_get_user_content_paid_order')) {
$paid_order = jio_get_user_content_paid_order((int) $post_id);
}
?>
<div class="resource-download-box__body">
<?php if ($has_thumbnail) : ?>
<div class="resource-download-box__thumb-col">
<img<?php echo jio_get_lazy_attr('lazy_other', (string) $thumbnail, 'resource-download-box__thumb'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> alt="<?php echo esc_attr(get_the_title()); ?>">
<?php if ($pay_type_badge) : ?>
<div class="resource-download-box__pay-tag"><?php echo $pay_type_badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
<?php endif; ?>
</div>
<?php endif; ?>
<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付费 / 下载能力', 'jio'), $subject_label)); ?></p>
<h2 class="resource-download-box__title">
<i class="fa fas fa-cloud-download-alt" aria-hidden="true"></i>
<?php echo $has_paid_access ? esc_html__('资源下载', 'jio') : esc_html__('解锁下载', 'jio'); ?>
</h2>
</div>
<span class="resource-download-box__count">
<?php echo esc_html(sprintf(_n('%s 个下载源', '%s 个下载源', count($downloads), 'jio'), number_format_i18n(count($downloads)))); ?>
</span>
</header>
<?php if ($has_paid_access && $user_amount > 0) : ?>
<div class="resource-download-box__pricing">
<span class="resource-download-box__price is-free"><?php esc_html_e('已解锁', 'jio'); ?></span>
<?php echo $pay_type_badge && !$has_thumbnail ? $pay_type_badge : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
<?php if (is_array($paid_order) && !empty($paid_order['order_number'])) : ?>
<div class="resource-download-box__paid-meta">
<span><?php printf(esc_html__('订单号:%s', 'jio'), esc_html((string) $paid_order['order_number'])); ?></span>
<?php if (!empty($paid_order['paid_at'])) : ?>
<span><?php printf(esc_html__('支付时间:%s', 'jio'), esc_html((string) $paid_order['paid_at'])); ?></span>
<?php endif; ?>
<span>
<?php
$paid_amt = (float) ($paid_order['amount'] ?? 0);
$paid_cur = (string) ($paid_order['currency'] ?? '');
if ($paid_cur === 'points') {
printf(esc_html__('实付:%s %s', 'jio'), esc_html(function_exists('jio_format_price') ? jio_format_price($paid_amt) : (string) $paid_amt), esc_html($currency));
} else {
printf(esc_html__('实付:%s%s', 'jio'), esc_html($cash_symbol), esc_html(function_exists('jio_format_price') ? jio_format_price($paid_amt) : (string) $paid_amt));
}
?>
</span>
</div>
<?php endif; ?>
<?php else : ?>
<div class="resource-download-box__pricing">
<span class="resource-download-box__price<?php echo !empty($price_label['free']) || $has_paid_access ? ' is-free' : ''; ?>">
<?php
if ($has_paid_access && $user_amount > 0) {
esc_html_e('已解锁', 'jio');
} else {
echo esc_html((string) ($price_label['text'] ?? ''));
}
?>
</span>
<?php if ($has_original && !$member_blocked && !$has_paid_access) : ?>
<span class="resource-download-box__original-price">
<?php
echo esc_html(
$pay_modo === 'points'
? (jio_format_price($original_price) . ' ' . $currency)
: ($cash_symbol . jio_format_price($original_price))
);
?>
</span>
<?php endif; ?>
<?php echo $pay_type_badge && !$has_thumbnail ? $pay_type_badge : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
<?php endif; ?>
<?php if ($has_vip && !$member_blocked && !$has_paid_access) : ?>
<div class="resource-download-box__vip-pricing">
<?php if ($vip1_price > 0 && $vip1_price < $base_price) : ?>
<span class="resource-download-box__vip-badge resource-download-box__vip-badge--1">
<i class="fa fas fa-certificate" aria-hidden="true"></i>
<?php
/* translators: %s: VIP1 价格 */
printf(esc_html__('VIP1 %s', 'jio'), $format_vip($vip1_price));
?>
</span>
<?php endif; ?>
<?php if ($vip2_price > 0 && $vip2_price < $base_price) : ?>
<span class="resource-download-box__vip-badge resource-download-box__vip-badge--2">
<i class="fa fas fa-gem" aria-hidden="true"></i>
<?php
/* translators: %s: VIP2 价格 */
printf(esc_html__('VIP2 %s', 'jio'), $format_vip($vip2_price));
?>
</span>
<?php endif; ?>
</div>
<?php endif; ?>
<?php
if (function_exists('jio_get_pay_attributes_html')) {
echo jio_get_pay_attributes_html($post_id); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
<?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; ?>
<?php if ($is_need_vip || $member_blocked) : ?>
<div class="mt10 resource-download-box__vip-gate">
<a href="<?php echo esc_url($vip_url); ?>" class="resource-download-box__btn btn-primary resource-download-box__btn--vip">
<i class="fa fas fa-certificate" aria-hidden="true"></i>
<span><?php echo esc_html($gate instanceof WP_Error ? $gate->get_error_message() : __('开通会员后下载', 'jio')); ?></span>
</a>
<?php
if (function_exists('jio_get_demo_link_html')) {
echo jio_get_demo_link_html($post_id); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
</div>
<?php elseif ($is_need_purchase) : ?>
<div class="mt10 resource-download-box__purchase-gate">
<button
type="button"
class="resource-download-box__btn btn-primary resource-download-box__btn--purchase cashier-link <?php echo $pay_modo === 'points' ? 'is-points' : 'is-cash'; ?>"
data-action="jio-need-purchase"
data-jio-pay-content="<?php echo esc_attr((string) $post_id); ?>"
data-post-id="<?php echo esc_attr((string) $post_id); ?>"
data-pay-modo="<?php echo esc_attr($pay_modo); ?>"
data-amount="<?php echo esc_attr((string) $user_amount); ?>"
>
<i class="fa fas fa-shopping-cart" aria-hidden="true"></i>
<span><?php echo esc_html($purchase_label); ?></span>
</button>
<?php
if (function_exists('jio_get_demo_link_html')) {
echo jio_get_demo_link_html($post_id); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
</div>
<?php elseif (!empty($use_alone_entry)) : ?>
<div class="mt10 resource-download-box__alone">
<a target="_blank" rel="nofollow" href="<?php echo esc_url($alone_url); ?>" class="resource-download-box__btn btn-primary resource-download-box__btn--alone">
<i class="fa fas fa-download" aria-hidden="true"></i>
<span><?php esc_html_e('资源下载', 'jio'); ?></span>
</a>
<?php
if (function_exists('jio_get_demo_link_html')) {
echo jio_get_demo_link_html($post_id); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
</div>
<?php else : ?>
<ul class="resource-download-box__list">
<?php foreach ($downloads as $idx => $row) :
$label = isset($row['label']) ? trim((string) $row['label']) : '';
$type = isset($row['type']) ? (string) $row['type'] : 'direct';
$asset_key = class_exists('\Jio\Content\PrivateAssets')
? \Jio\Content\PrivateAssets::sanitize_asset_key((string) ($row['asset_key'] ?? ''))
: '';
$is_protected = $asset_key !== '';
$url = isset($row['url']) ? (string) $row['url'] : '';
if (!$is_protected) {
if ($url === '') {
// 直连模式没有可用的原始地址,空源不渲染。
continue;
}
} else {
// 受保护附件按设计没有公开 URL,只带 asset_key。
$url = '';
}
if ($is_protected && $label === '') {
$label = trim((string) ($row['file_name'] ?? ''));
}
$extract_code = isset($row['extract_code']) ? trim((string) $row['extract_code']) : '';
$has_extract = $extract_code !== '';
$copy_key = isset($row['copy_key']) ? trim((string) $row['copy_key']) : '';
$copy_val = isset($row['copy_val']) ? trim((string) $row['copy_val']) : '';
$icon = isset($row['icon']) ? trim((string) $row['icon']) : '';
$button_class = isset($row['class']) ? trim((string) $row['class']) : '';
$has_copy = $copy_val !== '';
$service = $is_protected
? ['key' => 'protected', 'name' => __('受保护下载', 'jio'), 'color' => '#267665']
: (function_exists('jio_detect_cloud_service') ? jio_detect_cloud_service($url) : ['key' => 'other', 'name' => $label, 'color' => '#6b7280']);
if ($label === '') {
$label = strpos($service['name'], '本地') === 0 ? sprintf(__('下载源 %d', 'jio'), $idx + 1) : (string) $service['name'];
}
$icon_markup = $icon !== '' && function_exists('jio_icon_markup') ? jio_icon_markup($icon) : '';
if ($is_need_login) {
$btn_href = $login_url;
$btn_text = __('登录后下载', 'jio');
$btn_icon = $icon_markup !== '' ? $icon_markup : '<i class="fa fas fa-sign-in-alt" aria-hidden="true"></i>';
$btn_extra_class = '';
$btn_modifier = ' resource-download-box__btn--login';
$btn_target = '';
$btn_rel = '';
} else {
$btn_href = $url;
$btn_text = $label;
$btn_icon = $icon_markup !== '' ? $icon_markup : '<i class="fa fas fa-download" aria-hidden="true"></i>';
$btn_extra_class = $button_class !== '' ? ' ' . $button_class : '';
$btn_modifier = ($has_paid_access ? ' resource-download-box__btn--owned' : '') . ($button_class !== '' ? ' resource-download-box__btn--custom' : '');
$btn_target = ' target="_blank"';
$btn_rel = ' rel="nofollow noopener"';
}
?>
<li class="resource-download-box__item">
<div class="resource-download-box__row">
<?php if ($is_protected && !$is_need_login) : ?>
<button
type="button"
class="resource-download-box__btn btn-primary resource-download-box__btn--service-protected<?php echo esc_attr($btn_modifier); ?><?php echo esc_attr($btn_extra_class); ?>"
data-jio-protected-asset="<?php echo esc_attr($asset_key); ?>"
data-jio-protected-post="<?php echo esc_attr((string) $post_id); ?>"
style="--service-color: <?php echo esc_attr($service['color']); ?>"
>
<?php echo $btn_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<span><?php echo esc_html($btn_text); ?></span>
<span class="resource-download-box__service-badge" style="background: <?php echo esc_attr($service['color']); ?>">
<?php echo esc_html($service['name']); ?>
</span>
</button>
<?php else : ?>
<a
class="resource-download-box__btn btn-primary resource-download-box__btn--service-<?php echo esc_attr($service['key']); ?><?php echo esc_attr($btn_modifier); ?><?php echo esc_attr($btn_extra_class); ?>"
href="<?php echo esc_url($btn_href); ?>"<?php echo $btn_target; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><?php echo $btn_rel; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
data-source-index="<?php echo esc_attr((string) $idx); ?>"
data-source-type="<?php echo esc_attr($type); ?>"
style="--service-color: <?php echo esc_attr($service['color']); ?>"
>
<?php echo $btn_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<span><?php echo esc_html($btn_text); ?></span>
<span class="resource-download-box__service-badge" style="background: <?php echo esc_attr($service['color']); ?>">
<?php echo esc_html($service['name']); ?>
</span>
</a>
<?php endif; ?>
<?php if ($has_extract || $has_copy) : ?>
<button type="button" class="resource-download-box__btn resource-download-box__btn--extract"
<?php if ($has_copy && $copy_key !== '') : ?>data-toggle="tooltip" title="<?php echo esc_attr(sprintf(__('点击复制%s', 'jio'), $copy_key)); ?>"<?php endif; ?>
data-clipboard-tag="<?php echo esc_attr($has_copy ? ($copy_key !== '' ? $copy_key : __('内容', 'jio')) : __('提取码', 'jio')); ?>"
data-clipboard-text="<?php echo esc_attr($has_copy ? $copy_val : $extract_code); ?>"
><?php echo esc_html($has_extract ? $extract_code : ($copy_key !== '' ? $copy_key : __('复制内容', 'jio'))); ?></button>
<?php endif; ?>
</div>
</li>
<?php endforeach; ?>
</ul>
<?php
if (function_exists('jio_get_demo_link_html')) {
$demo = jio_get_demo_link_html($post_id);
if ($demo !== '') {
echo '<div class="mt10 resource-download-box__demo-row">' . $demo . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
?>
<?php endif; ?>
<?php
if (is_user_logged_in() && $user_amount <= 0 && function_exists('jio_get_user_free_download_limit')) {
$dl_limit = jio_get_user_free_download_limit();
if ($dl_limit > 0) {
$dl_used = function_exists('jio_get_user_free_downloaded_number') ? jio_get_user_free_downloaded_number() : 0;
$dl_surplus = max(0, $dl_limit - $dl_used);
$vip_lv = function_exists('jio_get_user_vip_level') ? jio_get_user_vip_level() : 0;
$over_price = max(0.0, (float) ($meta['download_limit_over_price'] ?? 0));
if ($dl_surplus <= 0) {
echo '<div class="resource-download-box__quota-notice"><span class="badg c-red btn-block">' . esc_html__('您今日下载免费资源个数已超限,请明日再下载。', 'jio') . '</span></div>';
if ($over_price > 0 && !$has_paid_access) {
$over_label = $pay_modo === 'points'
? sprintf(__('立即购买(%s %s)', 'jio'), function_exists('jio_format_price') ? jio_format_price($over_price) : (string) $over_price, $currency)
: sprintf(__('立即购买(%s%s)', 'jio'), $cash_symbol, function_exists('jio_format_price') ? jio_format_price($over_price) : (string) $over_price);
echo '<div class="mt10 resource-download-box__purchase-gate">';
echo '<button type="button" class="resource-download-box__btn btn-primary resource-download-box__btn--purchase cashier-link" data-action="jio-need-purchase" data-jio-pay-content="' . esc_attr((string) $post_id) . '" data-post-id="' . esc_attr((string) $post_id) . '" data-price-type="download_limit_over" data-pay-modo="' . esc_attr($pay_modo) . '" data-amount="' . esc_attr((string) $over_price) . '">';
echo '<i class="fa fas fa-shopping-cart" aria-hidden="true"></i><span>' . esc_html($over_label) . '</span></button></div>';
}
} else {
$who = $vip_lv > 0 ? esc_html__('您是尊贵的会员,', 'jio') : esc_html__('您', 'jio');
echo '<div class="resource-download-box__quota-notice"><span class="badg c-red btn-block">' . $who . esc_html(sprintf(__('今日还可下载 %s 个免费资源', 'jio'), number_format_i18n($dl_surplus))) . '</span></div>';
}
}
}
?>
<?php $service_html = jio_get_pay_service_html(); ?>
<?php if ($service_html !== '') : ?>
<div class="resource-download-box__guarantees">
<?php echo $service_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
<?php endif; ?>
</div>
</div>
<?php if ($is_need_login) : ?>
<p class="resource-download-box__hint resource-download-box__hint--login">
<i class="fa fas fa-info-circle" aria-hidden="true"></i>
<?php echo ($price_amount <= 0) ? esc_html__('免费资源,请登录后下载。', 'jio') : esc_html__('登录后可解锁并下载该内容。', 'jio'); ?>
</p>
<?php elseif ($is_need_vip || $member_blocked) : ?>
<p class="resource-download-box__hint resource-download-box__hint--vip">
<i class="fa fas fa-info-circle" aria-hidden="true"></i>
<?php echo esc_html($gate instanceof WP_Error ? $gate->get_error_message() : __('该资源仅限会员购买/下载。', 'jio')); ?>
</p>
<?php elseif ($is_need_purchase) : ?>
<p class="resource-download-box__hint resource-download-box__hint--purchase">
<i class="fa fas fa-info-circle" aria-hidden="true"></i>
<?php esc_html_e('请先完成购买后再下载该资源。', 'jio'); ?>
</p>
<?php endif; ?>
<footer class="resource-download-box__footer">
<p class="resource-download-box__notice-text">
<i class="fa fas fa-info-circle" aria-hidden="true"></i>
<?php esc_html_e('下载能力是统一付费内容的一部分,请确认内容适用性后再使用。', 'jio'); ?>
</p>
</footer>
</section>