'', 'free' => true]; // 下载策略检查 $gate = function_exists('aksrt_can_download') ? aksrt_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('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_paid_content_settings() : ['download_credit' => true]; $access = class_exists('\AKSRT\Content\Visibility') ? \AKSRT\Content\Visibility::get_post_access_state($post_id) : []; $has_paid_access = !empty($access['has_paid_access']); $priced = function_exists('aksrt_get_user_pay_price') ? aksrt_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); $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'); $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') ? aksrt_get_user_center_tab_url('credits') : (function_exists('aksrt_get_user_center_url') ? aksrt_get_user_center_url() : home_url('/')); $is_need_login = $gate_blocked && $gate_code === 'aksrt_need_login'; $is_need_vip = $gate_blocked && $gate_code === 'aksrt_need_vip'; $is_need_purchase = $gate_blocked && $gate_code === 'aksrt_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('aksrt_allow_guest_content_pay') && aksrt_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('aksrt_get_single_download_page_url')) { $alone_url = aksrt_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['aksrt_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('aksrt_get_pay_type_badge') ? aksrt_get_pay_type_badge($pay_type) : ''; // 货币名称 $currency = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_currency_name() : __('积分', 'aksrt'); $cash_symbol = '¥'; if (class_exists('\AKSRT\Settings\Settings')) { $paid_display = \AKSRT\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) __('免费', 'aksrt'); } $n = function_exists('aksrt_format_price') ? aksrt_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)', 'aksrt'), aksrt_format_price($user_amount), $currency) : sprintf(__('立即购买(%s%s)', 'aksrt'), $cash_symbol, aksrt_format_price($user_amount)); } elseif ($is_need_purchase) { $purchase_label = __('购买后下载', 'aksrt'); } ?>
0) : ?> 0) : ?>
alt="">

0) : ?>
0) { esc_html_e('已解锁', 'aksrt'); } else { echo esc_html((string) ($price_label['text'] ?? '')); } ?>
0 && $vip1_price < $base_price) : ?> 0 && $vip2_price < $base_price) : ?>

    $row) : $label = isset($row['label']) ? (string) $row['label'] : ''; if ($label === '') { $label = sprintf(__('下载源 %d', 'aksrt'), $idx + 1); } $type = isset($row['type']) ? (string) $row['type'] : 'direct'; $url = isset($row['url']) ? (string) $row['url'] : ''; $extract_code = isset($row['extract_code']) ? trim((string) $row['extract_code']) : ''; $has_extract = $extract_code !== ''; $service = function_exists('aksrt_detect_cloud_service') ? aksrt_detect_cloud_service($url) : ['key' => 'other', 'name' => $label, 'color' => '#6b7280']; if (strpos($label, '下载源') === 0 && $service['key'] !== 'other') { $label = $service['name']; } if ($is_need_login) { $btn_tag = 'a'; $btn_text = __('登录后下载', 'aksrt'); $btn_icon = 'fa-sign-in-alt'; $btn_modifier = ' resource-download-box__btn--login'; $btn_action = ''; } else { $btn_tag = 'button'; $btn_text = __('立即下载', 'aksrt'); $btn_icon = 'fa-download'; $btn_modifier = $has_paid_access ? ' resource-download-box__btn--owned' : ''; $btn_action = 'aksrt-download'; } ?>
' . $demo . '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } ?> 0) { $dl_used = function_exists('aksrt_get_user_free_downloaded_number') ? aksrt_get_user_free_downloaded_number() : 0; $dl_surplus = max(0, $dl_limit - $dl_used); $vip_lv = function_exists('aksrt_get_user_vip_level') ? aksrt_get_user_vip_level() : 0; $over_price = max(0.0, (float) ($meta['download_limit_over_price'] ?? 0)); if ($dl_surplus <= 0) { echo '
' . esc_html__('您今日下载免费资源个数已超限,请明日再下载。', 'aksrt') . '
'; if ($over_price > 0 && !$has_paid_access) { $over_label = $pay_modo === 'points' ? sprintf(__('立即购买(%s %s)', 'aksrt'), function_exists('aksrt_format_price') ? aksrt_format_price($over_price) : (string) $over_price, $currency) : sprintf(__('立即购买(%s%s)', 'aksrt'), $cash_symbol, function_exists('aksrt_format_price') ? aksrt_format_price($over_price) : (string) $over_price); echo '
'; echo '
'; } } else { $who = $vip_lv > 0 ? esc_html__('您是尊贵的会员,', 'aksrt') : esc_html__('您', 'aksrt'); echo '
' . $who . esc_html(sprintf(__('今日还可下载 %s 个免费资源', 'aksrt'), number_format_i18n($dl_surplus))) . '
'; } } } ?>

get_error_message() : __('该资源仅限会员购买/下载。', 'aksrt')); ?>