feat(pay): alone download page, free-login gate, list pay badges

This commit is contained in:
2026-07-14 00:38:43 +08:00
parent 0ad41715e2
commit 5acf302e53
8 changed files with 448 additions and 186 deletions
+154
View File
@@ -0,0 +1,154 @@
<?php
/**
* Template Name: AKSRT - 单篇资源下载
* Template Post Type: page
*
* Zibll pages/download.php equivalent.
* URL: {page}?post={post_id}
* Only for pay_type=download posts. Shows download buttons when allowed,
* or a no-permission state with a back link to the article.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$post_id = isset($_GET['post']) ? absint($_GET['post']) : 0;
$post = $post_id > 0 ? get_post($post_id) : null;
if (!$post instanceof WP_Post || $post->post_status !== 'publish') {
get_header();
echo '<main class="container"><div class="content-wrap"><div class="content-layout">';
echo '<div class="alert jb-red em12" style="margin:2em;"><b>' . esc_html__('无效的下载请求', 'aksrt') . '</b></div>';
echo '</div></div></main>';
get_footer();
exit;
}
$pay_meta = function_exists('aksrt_get_pay_meta') ? aksrt_get_pay_meta($post) : ['pay_type' => 'no', 'downloads' => []];
$pay_type = (string) ($pay_meta['pay_type'] ?? 'no');
$is_download = $pay_type === 'download' || (function_exists('aksrt_is_downloadable_content') && aksrt_is_downloadable_content($post));
if (!$is_download) {
get_header();
echo '<main class="container"><div class="content-wrap"><div class="content-layout">';
echo '<div class="alert jb-red em12" style="margin:2em;"><b>' . esc_html__('该内容不是可下载资源', 'aksrt') . '</b></div>';
echo '<p><a class="but jb-yellow padding-lg" href="' . esc_url(get_permalink($post)) . '#posts-pay"><i class="fa fa-long-arrow-left" aria-hidden="true"></i><span class="ml10">' . esc_html__('返回文章', 'aksrt') . '</span></a></p>';
echo '</div></div></main>';
get_footer();
exit;
}
$article_url = get_permalink($post) . '#posts-pay';
$pay_title = get_the_title($post);
$subtitle = '';
if (function_exists('get_the_subtitle')) {
// noop — AKSRT may not have zibll subtitle helper
}
$has_access = function_exists('aksrt_has_paid_access') ? aksrt_has_paid_access($post) : false;
$gate = function_exists('aksrt_can_download') ? aksrt_can_download($post) : true;
$can_dl = $gate === true;
$need_login = is_wp_error($gate) && $gate->get_error_code() === 'aksrt_need_login';
// Free download + login required (Zibll pay_free_logged_show).
$price = (float) ($pay_meta['price'] ?? 0);
$order_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_order_settings() : [];
$free_logged_show = !empty($order_settings['free_logged_show']);
if ($price <= 0 && $free_logged_show && !is_user_logged_in()) {
$can_dl = false;
$need_login = true;
$has_access = true; // free "access" but must login to download
}
$paid_name = '';
if ($has_access || $can_dl) {
if ($price <= 0) {
$paid_name = __('免费资源', 'aksrt');
} else {
$paid_name = __('已获得下载权限', 'aksrt');
}
}
get_header();
?>
<style>
.aksrt-single-download .but-download > .but,
.aksrt-single-download .but-download > a,
.aksrt-single-download .but-download > button,
.aksrt-single-download .resource-download-box__btn {
min-width: 200px;
padding: .5em;
margin-top: 10px;
}
.aksrt-single-download .pay-extra-hide {
background: var(--muted-border-color, #f0f0f0);
display: block;
margin: 10px 0;
padding: 20px;
color: var(--muted-color, #888);
border-radius: 4px;
}
</style>
<main class="container aksrt-single-download">
<div class="content-wrap">
<div class="content-layout">
<article class="article page-article main-bg theme-box box-body radius8 main-shadow">
<div class="pay-box">
<div class="article-header theme-box">
<div class="article-title">
<a href="<?php echo esc_url($article_url); ?>"><?php echo esc_html($pay_title); ?></a>
</div>
<?php if ($paid_name !== '') : ?>
<b class="badg jb-red mr6" style="font-size:12px;padding:2px 10px;line-height:1.4;">
<i class="fa fa-check mr6" aria-hidden="true"></i><?php echo esc_html($paid_name); ?>
</b>
<?php endif; ?>
</div>
<?php if ($can_dl) : ?>
<div style="margin-bottom:2em;" class="pay-box">
<?php
// Reuse single download box UI for the allowed state.
global $post;
$GLOBALS['post'] = $post;
setup_postdata($post);
$GLOBALS['aksrt_on_download_file_page'] = true;
get_template_part('templates/parts/resource-download-box');
unset($GLOBALS['aksrt_on_download_file_page']);
wp_reset_postdata();
?>
</div>
<?php elseif ($need_login) : ?>
<div class="alert jb-yellow em12" style="margin:2em;">
<b><?php esc_html_e('免费资源,请登录后下载', 'aksrt'); ?></b>
</div>
<div class="pay-extra-hide">
<?php
$login_url = wp_login_url(add_query_arg('post', $post_id, get_permalink()));
printf(
/* translators: %s: login url */
wp_kses_post(__('Hi!请先 <a href="%s">登录</a> 后再下载。', 'aksrt')),
esc_url($login_url)
);
?>
</div>
<a style="margin-bottom:2em;" href="<?php echo esc_url($article_url); ?>" class="but jb-yellow padding-lg">
<i class="fa fa-long-arrow-left" aria-hidden="true"></i>
<span class="ml10"><?php esc_html_e('返回文章', 'aksrt'); ?></span>
</a>
<?php else : ?>
<div class="alert jb-red em12" style="margin:2em;">
<b><?php esc_html_e('暂无下载权限', 'aksrt'); ?></b>
</div>
<a style="margin-bottom:2em;" href="<?php echo esc_url($article_url); ?>" class="but jb-yellow padding-lg">
<i class="fa fa-long-arrow-left" aria-hidden="true"></i>
<span class="ml10"><?php esc_html_e('返回文章', 'aksrt'); ?></span>
</a>
<?php endif; ?>
</div>
</article>
</div>
</div>
</main>
<?php
get_footer();
+174 -174
View File
@@ -1,174 +1,174 @@
<?php
/**
* Post Card / List Item Template — Unified Wrapper (v4.0)
*
* This template delegates to the unified shared renderer (aksrt_render_post).
* It preserves backward compatibility for callers using get_template_part().
*
* @package AKSRT
* @since 4.0.0
*/
defined('ABSPATH') || exit;
// If the shared renderer is available, delegate entirely
if (function_exists('aksrt_render_post')) {
$args = isset($args) && is_array($args) ? $args : [];
// Resolve layout mode from query var or args
$forced_layout = (string) get_query_var('aksrt_post_card_layout', '');
$mode = 'card';
if (is_string($forced_layout) && in_array($forced_layout, ['card', 'list', 'grid-cms'], true)) {
$mode = $forced_layout;
} elseif (!empty($args['mode']) && in_array($args['mode'], ['card', 'list', 'grid-cms', 'mini'], true)) {
$mode = $args['mode'];
} elseif (function_exists('aksrt_get_post_flow') && aksrt_get_post_flow(get_the_ID()) === 'cms') {
$mode = 'grid-cms';
} elseif (class_exists('AKSRT_Settings')) {
$archive_layout = AKSRT_Settings::get_archive_layout();
$mode = in_array($archive_layout, ['card', 'list', 'grid-cms'], true) ? $archive_layout : 'card';
}
// Resolve scene context
$scene = (string) get_query_var('aksrt_post_card_scene', '');
$context = ($scene === 'home' || is_front_page() || (is_home() && !is_paged())) ? 'home' : 'archive';
$config = array_merge($args, [
'mode' => $mode,
'context' => $context,
]);
echo aksrt_render_post($config); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
return;
}
// ============================================================
// Fallback: self-contained rendering when shared renderer unavailable
// ============================================================
$args = isset($args) && is_array($args) ? $args : [];
$lazy_cfg = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_lazyload_config() : ['enabled' => false, 'placeholder_url' => ''];
$lazy_on = !empty($lazy_cfg['enabled']);
$placeholder_url = !empty($lazy_cfg['placeholder_url']) ? (string) $lazy_cfg['placeholder_url'] : (get_template_directory_uri() . '/assets/img/placeholder.svg');
$forced_layout = (string) get_query_var('aksrt_post_card_layout', '');
$layout = 'card';
if (is_string($forced_layout) && in_array($forced_layout, ['card', 'list', 'masonry', 'grid-cms'], true)) {
$layout = $forced_layout;
} elseif (function_exists('aksrt_get_post_flow') && aksrt_get_post_flow(get_the_ID()) === 'cms') {
$layout = 'grid-cms';
} elseif (class_exists('AKSRT_Settings')) {
$layout = AKSRT_Settings::get_archive_layout();
}
$post_id = get_the_ID();
$author_id = get_the_author_meta('ID');
$author = get_the_author();
$avatar_url = get_avatar_url($author_id, ['size' => 40]);
$time_ago = human_time_diff(get_the_time('U'), current_time('timestamp')) . __('前', 'aksrt');
$excerpt = wp_trim_words(get_the_excerpt(), 'list' === $layout ? 30 : 20, '...');
$tags = get_the_tags() ?: [];
$categories = get_the_category() ?: [];
$comment_count = (int) get_comments_number();
$views = function_exists('aksrt_get_post_views') ? aksrt_get_post_views($post_id) : 0;
$is_sticky = is_sticky($post_id);
$title_html = isset($args['title_html']) ? (string) $args['title_html'] : get_the_title();
$resource_badge = function_exists('aksrt_resource_card_badge_text') ? aksrt_resource_card_badge_text($post_id) : '';
$img_url = '';
if (has_post_thumbnail()) {
$img_url = get_the_post_thumbnail_url($post_id, 'medium_large');
} elseif (function_exists('aksrt_get_first_content_image_url')) {
$img_url = (string) aksrt_get_first_content_image_url($post_id);
}
$has_img = !empty($img_url);
$scene = (string) get_query_var('aksrt_post_card_scene', '');
$is_home_scene = $scene === 'home' || is_front_page() || (is_home() && !is_paged());
$category_limit = $is_home_scene ? 1 : 3;
$tag_limit = $is_home_scene ? 2 : 3;
// Badges HTML
ob_start();
?>
<div class="item-tags scroll-x no-scrollbar">
<?php if ($resource_badge !== '') : ?>
<badge class="meta-pay but jb-yellow"><?php echo esc_html($resource_badge); ?></badge>
<?php endif; ?>
<?php foreach (array_slice($categories, 0, $category_limit) as $category) : ?>
<a href="<?php echo esc_url(get_category_link($category->term_id)); ?>" class="but"><i class="far fa-folder-open" aria-hidden="true"></i> <?php echo esc_html($category->name); ?></a>
<?php endforeach; ?>
<?php foreach (array_slice($tags, 0, $tag_limit) as $tag) : ?>
<a href="<?php echo esc_url(get_tag_link($tag->term_id)); ?>" class="but"># <?php echo esc_html($tag->name); ?></a>
<?php endforeach; ?>
</div>
<?php
$badges_html = trim((string) ob_get_clean());
// Meta HTML
ob_start();
?>
<div class="item-meta muted-2-color flex jsb ac">
<item class="meta-author flex ac">
<img src="<?php echo esc_url($avatar_url); ?>" alt="" class="avatar-mini" width="20" height="20" loading="lazy">
<name class="meta-name"><?php echo esc_html($author); ?></name>
<item class="meta-time"><?php echo esc_html($time_ago); ?></item>
</item>
<div class="meta-right">
<item class="meta-view"><i class="fas fa-eye" aria-hidden="true"></i> <?php echo esc_html(function_exists('aksrt_format_number') ? aksrt_format_number($views) : (string) $views); ?></item>
<item class="meta-view"><i class="fas fa-comment" aria-hidden="true"></i> <?php echo esc_html((string) $comment_count); ?></item>
</div>
</div>
<?php
$meta_html = trim((string) ob_get_clean());
if ('list' === $layout) : ?>
<article <?php post_class('posts-item list ajax-item'); ?>>
<div class="item-thumbnail">
<a href="<?php the_permalink(); ?>">
<?php if ($has_img && $lazy_on) : ?>
<span class="aksrt-skeleton"></span>
<img class="fit-cover aksrt-lazy" data-src="<?php echo esc_url($img_url); ?>" src="<?php echo esc_url($placeholder_url); ?>" alt="<?php echo esc_attr(get_the_title()); ?>">
<?php elseif ($has_img) : ?>
<img class="fit-cover" src="<?php echo esc_url($img_url); ?>" alt="<?php echo esc_attr(get_the_title()); ?>">
<?php else : ?>
<img class="fit-cover" src="<?php echo esc_url($placeholder_url); ?>" alt="">
<?php endif; ?>
</a>
<?php if ($is_sticky) : ?>
<span class="img-badge left badge-sticky"><?php esc_html_e('置顶', 'aksrt'); ?></span>
<?php endif; ?>
</div>
<div class="item-body">
<h2 class="item-heading"><a href="<?php the_permalink(); ?>"><?php echo wp_kses_post($title_html); ?></a></h2>
<p class="item-excerpt"><?php echo wp_kses_post(esc_html($excerpt)); ?></p>
<?php echo $badges_html; ?>
<?php echo $meta_html; ?>
</div>
</article>
<?php else : ?>
<article <?php post_class('posts-item card ajax-item' . ($is_home_scene ? ' posts-item--home' : '')); ?>>
<div class="item-thumbnail">
<a href="<?php the_permalink(); ?>">
<?php if ($has_img && $lazy_on) : ?>
<span class="aksrt-skeleton"></span>
<img class="fit-cover aksrt-lazy" data-src="<?php echo esc_url($img_url); ?>" src="<?php echo esc_url($placeholder_url); ?>" alt="<?php echo esc_attr(get_the_title()); ?>">
<?php elseif ($has_img) : ?>
<img class="fit-cover" src="<?php echo esc_url($img_url); ?>" alt="<?php echo esc_attr(get_the_title()); ?>">
<?php else : ?>
<img class="fit-cover" src="<?php echo esc_url($placeholder_url); ?>" alt="">
<?php endif; ?>
</a>
<?php if ($is_sticky) : ?>
<span class="img-badge left badge-sticky"><?php esc_html_e('置顶', 'aksrt'); ?></span>
<?php endif; ?>
</div>
<div class="item-body">
<h2 class="item-heading"><a href="<?php the_permalink(); ?>"><?php echo wp_kses_post($title_html); ?></a></h2>
<?php echo $badges_html; ?>
<?php echo $meta_html; ?>
</div>
</article>
<?php endif; ?>
<?php␍
/**␍
* Post Card / List Item Template — Unified Wrapper (v4.0)␍
*␍
* This template delegates to the unified shared renderer (aksrt_render_post).␍
* It preserves backward compatibility for callers using get_template_part().␍
*␍
* @package AKSRT␍
* @since 4.0.0␍
*/␍
␍
defined('ABSPATH') || exit;␍
␍
// If the shared renderer is available, delegate entirely␍
if (function_exists('aksrt_render_post')) {␍
$args = isset($args) && is_array($args) ? $args : [];␍
␍
// Resolve layout mode from query var or args␍
$forced_layout = (string) get_query_var('aksrt_post_card_layout', '');␍
$mode = 'card';␍
␍
if (is_string($forced_layout) && in_array($forced_layout, ['card', 'list', 'grid-cms'], true)) {␍
$mode = $forced_layout;␍
} elseif (!empty($args['mode']) && in_array($args['mode'], ['card', 'list', 'grid-cms', 'mini'], true)) {␍
$mode = $args['mode'];␍
} elseif (function_exists('aksrt_get_post_flow') && aksrt_get_post_flow(get_the_ID()) === 'cms') {␍
$mode = 'grid-cms';␍
} elseif (class_exists('AKSRT_Settings')) {␍
$archive_layout = AKSRT_Settings::get_archive_layout();␍
$mode = in_array($archive_layout, ['card', 'list', 'grid-cms'], true) ? $archive_layout : 'card';␍
}␍
␍
// Resolve scene context␍
$scene = (string) get_query_var('aksrt_post_card_scene', '');␍
$context = ($scene === 'home' || is_front_page() || (is_home() && !is_paged())) ? 'home' : 'archive';␍
␍
$config = array_merge($args, [␍
'mode' => $mode,␍
'context' => $context,␍
]);␍
␍
echo aksrt_render_post($config); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped␍
return;␍
}␍
␍
// ============================================================␍
// Fallback: self-contained rendering when shared renderer unavailable␍
// ============================================================␍
␍
$args = isset($args) && is_array($args) ? $args : [];␍
␍
$lazy_cfg = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_lazyload_config() : ['enabled' => false, 'placeholder_url' => ''];␍
$lazy_on = !empty($lazy_cfg['enabled']);␍
$placeholder_url = !empty($lazy_cfg['placeholder_url']) ? (string) $lazy_cfg['placeholder_url'] : (get_template_directory_uri() . '/assets/img/placeholder.svg');␍
␍
$forced_layout = (string) get_query_var('aksrt_post_card_layout', '');␍
$layout = 'card';␍
if (is_string($forced_layout) && in_array($forced_layout, ['card', 'list', 'masonry', 'grid-cms'], true)) {␍
$layout = $forced_layout;␍
} elseif (function_exists('aksrt_get_post_flow') && aksrt_get_post_flow(get_the_ID()) === 'cms') {␍
$layout = 'grid-cms';␍
} elseif (class_exists('AKSRT_Settings')) {␍
$layout = AKSRT_Settings::get_archive_layout();␍
}␍
␍
$post_id = get_the_ID();␍
$author_id = get_the_author_meta('ID');␍
$author = get_the_author();␍
$avatar_url = get_avatar_url($author_id, ['size' => 40]);␍
$time_ago = human_time_diff(get_the_time('U'), current_time('timestamp')) . __('前', 'aksrt');␍
$excerpt = wp_trim_words(get_the_excerpt(), 'list' === $layout ? 30 : 20, '...');␍
$tags = get_the_tags() ?: [];␍
$categories = get_the_category() ?: [];␍
$comment_count = (int) get_comments_number();␍
$views = function_exists('aksrt_get_post_views') ? aksrt_get_post_views($post_id) : 0;␍
$is_sticky = is_sticky($post_id);␍
$title_html = isset($args['title_html']) ? (string) $args['title_html'] : get_the_title();␍
$resource_badge = function_exists('aksrt_resource_card_badge_text') ? aksrt_resource_card_badge_text($post_id) : '';␍
␍
$img_url = '';␍
if (has_post_thumbnail()) {␍
$img_url = get_the_post_thumbnail_url($post_id, 'medium_large');␍
} elseif (function_exists('aksrt_get_first_content_image_url')) {␍
$img_url = (string) aksrt_get_first_content_image_url($post_id);␍
}␍
$has_img = !empty($img_url);␍
␍
$scene = (string) get_query_var('aksrt_post_card_scene', '');␍
$is_home_scene = $scene === 'home' || is_front_page() || (is_home() && !is_paged());␍
$category_limit = $is_home_scene ? 1 : 3;␍
$tag_limit = $is_home_scene ? 2 : 3;␍
␍
// Badges HTML␍
ob_start();␍
?>␍
<div class="item-tags scroll-x no-scrollbar">␍
<?php if ($resource_badge !== '') : ?>␍
<a rel="nofollow" href="<?php echo esc_url(get_permalink($post_id) . '#posts-pay'); ?>" class="meta-pay but jb-yellow"><?php echo esc_html($resource_badge); ?></a>␍
<?php endif; ?>␍
<?php foreach (array_slice($categories, 0, $category_limit) as $category) : ?>␍
<a href="<?php echo esc_url(get_category_link($category->term_id)); ?>" class="but"><i class="far fa-folder-open" aria-hidden="true"></i> <?php echo esc_html($category->name); ?></a>␍
<?php endforeach; ?>␍
<?php foreach (array_slice($tags, 0, $tag_limit) as $tag) : ?>␍
<a href="<?php echo esc_url(get_tag_link($tag->term_id)); ?>" class="but"># <?php echo esc_html($tag->name); ?></a>␍
<?php endforeach; ?>␍
</div>␍
<?php␍
$badges_html = trim((string) ob_get_clean());␍
␍
// Meta HTML␍
ob_start();␍
?>␍
<div class="item-meta muted-2-color flex jsb ac">␍
<item class="meta-author flex ac">␍
<img src="<?php echo esc_url($avatar_url); ?>" alt="" class="avatar-mini" width="20" height="20" loading="lazy">␍
<name class="meta-name"><?php echo esc_html($author); ?></name>␍
<item class="meta-time"><?php echo esc_html($time_ago); ?></item>␍
</item>␍
<div class="meta-right">␍
<item class="meta-view"><i class="fas fa-eye" aria-hidden="true"></i> <?php echo esc_html(function_exists('aksrt_format_number') ? aksrt_format_number($views) : (string) $views); ?></item>␍
<item class="meta-view"><i class="fas fa-comment" aria-hidden="true"></i> <?php echo esc_html((string) $comment_count); ?></item>␍
</div>␍
</div>␍
<?php␍
$meta_html = trim((string) ob_get_clean());␍
␍
if ('list' === $layout) : ?>␍
<article <?php post_class('posts-item list ajax-item'); ?>>␍
<div class="item-thumbnail">␍
<a href="<?php the_permalink(); ?>">␍
<?php if ($has_img && $lazy_on) : ?>␍
<span class="aksrt-skeleton"></span>␍
<img class="fit-cover aksrt-lazy" data-src="<?php echo esc_url($img_url); ?>" src="<?php echo esc_url($placeholder_url); ?>" alt="<?php echo esc_attr(get_the_title()); ?>">␍
<?php elseif ($has_img) : ?>␍
<img class="fit-cover" src="<?php echo esc_url($img_url); ?>" alt="<?php echo esc_attr(get_the_title()); ?>">␍
<?php else : ?>␍
<img class="fit-cover" src="<?php echo esc_url($placeholder_url); ?>" alt="">␍
<?php endif; ?>␍
</a>␍
<?php if ($is_sticky) : ?>␍
<span class="img-badge left badge-sticky"><?php esc_html_e('置顶', 'aksrt'); ?></span>␍
<?php endif; ?>␍
</div>␍
<div class="item-body">␍
<h2 class="item-heading"><a href="<?php the_permalink(); ?>"><?php echo wp_kses_post($title_html); ?></a></h2>␍
<p class="item-excerpt"><?php echo wp_kses_post(esc_html($excerpt)); ?></p>␍
<?php echo $badges_html; ?>␍
<?php echo $meta_html; ?>␍
</div>␍
</article>␍
<?php else : ?>␍
<article <?php post_class('posts-item card ajax-item' . ($is_home_scene ? ' posts-item--home' : '')); ?>>␍
<div class="item-thumbnail">␍
<a href="<?php the_permalink(); ?>">␍
<?php if ($has_img && $lazy_on) : ?>␍
<span class="aksrt-skeleton"></span>␍
<img class="fit-cover aksrt-lazy" data-src="<?php echo esc_url($img_url); ?>" src="<?php echo esc_url($placeholder_url); ?>" alt="<?php echo esc_attr(get_the_title()); ?>">␍
<?php elseif ($has_img) : ?>␍
<img class="fit-cover" src="<?php echo esc_url($img_url); ?>" alt="<?php echo esc_attr(get_the_title()); ?>">␍
<?php else : ?>␍
<img class="fit-cover" src="<?php echo esc_url($placeholder_url); ?>" alt="">␍
<?php endif; ?>␍
</a>␍
<?php if ($is_sticky) : ?>␍
<span class="img-badge left badge-sticky"><?php esc_html_e('置顶', 'aksrt'); ?></span>␍
<?php endif; ?>␍
</div>␍
<div class="item-body">␍
<h2 class="item-heading"><a href="<?php the_permalink(); ?>"><?php echo wp_kses_post($title_html); ?></a></h2>␍
<?php echo $badges_html; ?>␍
<?php echo $meta_html; ?>␍
</div>␍
</article>␍
<?php endif; ?>␍
+37 -3
View File
@@ -55,7 +55,26 @@ $balance = (int) ($gate_data['balance'] ?? 0);
$login_url = (string) ($gate_data['login_url'] ?? wp_login_url(get_permalink($post_id)));
$is_need_login = $gate_blocked && $gate_code === 'aksrt_need_login';
$is_low_credit = $gate_blocked && $gate_code === 'aksrt_credits_insufficient';
$is_low_credit = $gate_blocked && $gate_code === 'aksrt_credits_insufficient';
// Zibll pay_free_logged_show: free downloads still require login.
$free_logged_show = !empty($paid_settings['free_logged_show']);
$price_amount = (float) ($meta['price'] ?? 0);
if ($price_amount <= 0 && $free_logged_show && !is_user_logged_in()) {
$is_need_login = true;
$gate_blocked = true;
}
// Zibll 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_low_credit;
if (!empty($GLOBALS['aksrt_on_download_file_page'])) {
$use_alone_entry = false;
}
// 缩略图
$thumbnail = get_the_post_thumbnail_url($post_id, 'medium') ?: '';
@@ -160,7 +179,21 @@ $currency = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name()
<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 if (!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="fas fa-download" aria-hidden="true"></i>
<span><?php esc_html_e('资源下载', 'aksrt'); ?></span>
</a>
<?php if (!empty($meta['demo_url'])) : ?>
<a target="_blank" rel="nofollow" href="<?php echo esc_url((string) $meta['demo_url']); ?>" class="resource-download-box__btn btn-outline resource-download-box__btn--demo">
<i class="fas fa-external-link-alt" aria-hidden="true"></i>
<span><?php esc_html_e('在线演示', 'aksrt'); ?></span>
</a>
<?php endif; ?>
</div>
<?php else : ?>
<ul class="resource-download-box__list">
<?php foreach ($downloads as $idx => $row) :
$label = isset($row['label']) ? (string) $row['label'] : '';
if ($label === '') {
@@ -241,6 +274,7 @@ $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">
@@ -262,7 +296,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 echo (isset($price_amount) && $price_amount <= 0) ? esc_html__('免费资源,请登录后下载。', 'aksrt') : esc_html__('登录后可解锁并下载该内容。', 'aksrt'); ?>
</p>
<?php elseif ($is_low_credit) : ?>
<p class="resource-download-box__hint resource-download-box__hint--credit">