feat(pay): mirror reference resource row with copy, icon and reorder
The post editor's download row only exposed address / button text / remark, leaving copy_key, copy_val and class as hidden inputs with no UI, so the reference copy area, custom button icon, text and color were unreachable. The submission popup already emitted those keys, which made the two write paths diverge from anything the editor could produce. Expose the full reference field set (地址/备注/复制名称/复制内容/图标/文案/ 颜色) as an accordion card with drag reordering, add the one genuinely new `icon` key through aksrt_sanitize_icon_value(), and teach both frontend download renderers to consume the fields they previously ignored. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -333,10 +333,7 @@ if ($is_need_purchase && $user_amount > 0) {
|
||||
<?php else : ?>
|
||||
<ul class="resource-download-box__list">
|
||||
<?php foreach ($downloads as $idx => $row) :
|
||||
$label = isset($row['label']) ? (string) $row['label'] : '';
|
||||
if ($label === '') {
|
||||
$label = sprintf(__('下载源 %d', 'aksrt'), $idx + 1);
|
||||
}
|
||||
$label = isset($row['label']) ? trim((string) $row['label']) : '';
|
||||
$type = isset($row['type']) ? (string) $row['type'] : 'direct';
|
||||
$url = isset($row['url']) ? (string) $row['url'] : '';
|
||||
if ($url === '') {
|
||||
@@ -345,47 +342,56 @@ if ($is_need_purchase && $user_amount > 0) {
|
||||
}
|
||||
$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 = 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 ($label === '') {
|
||||
$label = strpos($service['name'], '本地') === 0 ? sprintf(__('下载源 %d', 'aksrt'), $idx + 1) : (string) $service['name'];
|
||||
}
|
||||
|
||||
$icon_markup = $icon !== '' && function_exists('aksrt_icon_markup') ? aksrt_icon_markup($icon) : '';
|
||||
|
||||
if ($is_need_login) {
|
||||
$btn_href = $login_url;
|
||||
$btn_text = __('登录后下载', 'aksrt');
|
||||
$btn_icon = 'fa-sign-in-alt';
|
||||
$btn_icon = $icon_markup !== '' ? $icon_markup : '<i class="fa 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 = __('立即下载', 'aksrt');
|
||||
$btn_icon = 'fa-download';
|
||||
$btn_modifier = $has_paid_access ? ' resource-download-box__btn--owned' : '';
|
||||
$btn_text = $label;
|
||||
$btn_icon = $icon_markup !== '' ? $icon_markup : '<i class="fa 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">
|
||||
<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); ?>"
|
||||
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']); ?>"
|
||||
>
|
||||
<i class="fa <?php echo esc_attr($btn_icon); ?>" aria-hidden="true"></i>
|
||||
<?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 if ($has_extract) : ?>
|
||||
<?php if ($has_extract || $has_copy) : ?>
|
||||
<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>
|
||||
data-clipboard-tag="<?php echo esc_attr($has_copy ? ($copy_key !== '' ? $copy_key : __('内容', 'aksrt')) : __('提取码', 'aksrt')); ?>"
|
||||
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 : __('复制内容', 'aksrt'))); ?></button>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
|
||||
Reference in New Issue
Block a user