优化了一些问题
This commit is contained in:
@@ -26,6 +26,10 @@ if ($pay_type !== 'download' || empty($downloads)) {
|
||||
|
||||
$is_resource_context = function_exists('aksrt_is_resource_post') && aksrt_is_resource_post($post_id);
|
||||
$context_variant = $is_resource_context ? 'resource' : 'content';
|
||||
|
||||
// 下载总开关关闭 = 直连模式:下载按钮直接输出原始地址,不走本站中转链接。
|
||||
$direct_download = class_exists('\AKSRT\Content\Download')
|
||||
&& !\AKSRT\Content\Download::get_instance()->is_enabled();
|
||||
$subject_label = trim((string) ($meta['subject_label'] ?? ''));
|
||||
if ($subject_label === '') {
|
||||
$subject_label = $is_resource_context ? __('资源', 'aksrt') : __('内容', 'aksrt');
|
||||
@@ -56,7 +60,10 @@ $pay_modo = is_array($priced)
|
||||
$user_amount = is_array($priced) ? (float) ($priced['amount'] ?? 0) : (float) ($meta['price'] ?? 0);
|
||||
$cost = function_exists('aksrt_resource_download_cost') ? (int) aksrt_resource_download_cost($post_id) : 0;
|
||||
|
||||
$captcha_active = function_exists('aksrt_is_captcha_enabled_for') && aksrt_is_captcha_enabled_for('download');
|
||||
// 直连模式下没有“获取链接”请求,验证码容器不会被打开,属死 UI 不渲染。
|
||||
$captcha_active = !$direct_download
|
||||
&& function_exists('aksrt_is_captcha_enabled_for')
|
||||
&& aksrt_is_captcha_enabled_for('download');
|
||||
$balance = (int) ($gate_data['balance'] ?? (is_user_logged_in() ? \AKSRT\Ledger\LedgerService::get_instance()->balance(get_current_user_id(), \AKSRT\Ledger\AssetType::POINTS) : 0));
|
||||
$login_url = (string) ($gate_data['login_url'] ?? wp_login_url(get_permalink($post_id)));
|
||||
$vip_url = function_exists('aksrt_get_user_center_tab_url')
|
||||
@@ -343,6 +350,10 @@ if ($is_need_purchase && $user_amount > 0) {
|
||||
}
|
||||
$type = isset($row['type']) ? (string) $row['type'] : 'direct';
|
||||
$url = isset($row['url']) ? (string) $row['url'] : '';
|
||||
if ($direct_download && $url === '') {
|
||||
// 直连模式没有可用的原始地址,空源不渲染。
|
||||
continue;
|
||||
}
|
||||
$extract_code = isset($row['extract_code']) ? trim((string) $row['extract_code']) : '';
|
||||
$has_extract = $extract_code !== '';
|
||||
|
||||
@@ -353,23 +364,38 @@ if ($is_need_purchase && $user_amount > 0) {
|
||||
|
||||
if ($is_need_login) {
|
||||
$btn_tag = 'a';
|
||||
$btn_href = $login_url;
|
||||
$btn_text = __('登录后下载', 'aksrt');
|
||||
$btn_icon = 'fa-sign-in-alt';
|
||||
$btn_modifier = ' resource-download-box__btn--login';
|
||||
$btn_action = '';
|
||||
$btn_target = '';
|
||||
$btn_rel = '';
|
||||
} elseif ($direct_download) {
|
||||
$btn_tag = 'a';
|
||||
$btn_href = $url;
|
||||
$btn_text = __('立即下载', 'aksrt');
|
||||
$btn_icon = 'fa-download';
|
||||
$btn_modifier = $has_paid_access ? ' resource-download-box__btn--owned' : '';
|
||||
$btn_action = '';
|
||||
$btn_target = ' target="_blank"';
|
||||
$btn_rel = ' rel="nofollow noopener"';
|
||||
} else {
|
||||
$btn_tag = 'button';
|
||||
$btn_href = '';
|
||||
$btn_text = __('立即下载', 'aksrt');
|
||||
$btn_icon = 'fa-download';
|
||||
$btn_modifier = $has_paid_access ? ' resource-download-box__btn--owned' : '';
|
||||
$btn_action = 'aksrt-download';
|
||||
$btn_target = '';
|
||||
$btn_rel = '';
|
||||
}
|
||||
?>
|
||||
<li class="resource-download-box__item">
|
||||
<?php if ($btn_tag === 'a') : ?>
|
||||
<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); ?>"
|
||||
href="<?php echo esc_url($login_url); ?>"
|
||||
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']); ?>"
|
||||
@@ -380,6 +406,12 @@ if ($is_need_purchase && $user_amount > 0) {
|
||||
<?php echo esc_html($service['name']); ?>
|
||||
</span>
|
||||
</a>
|
||||
<?php if ($direct_download && $has_extract) : ?>
|
||||
<button type="button" class="resource-download-box__btn resource-download-box__btn--extract"
|
||||
data-clipboard-tag="<?php esc_attr_e('提取码', 'aksrt'); ?>"
|
||||
data-clipboard-text="<?php echo esc_attr($extract_code); ?>"
|
||||
><?php echo esc_html($extract_code); ?></button>
|
||||
<?php endif; ?>
|
||||
<?php else : ?>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in New Issue
Block a user