From 7f60071460dd9de3b507ff3fb3b221dce188f140 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 24 Sep 2026 21:30:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(pay):=20show=20=E7=82=B9=E5=87=BB=E5=A4=8D?= =?UTF-8?q?=E5=88=B6{copy=20name}=20tooltip=20on=20the=20remark=20button?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hovering the remark gave no affordance hint that it copies anything. The reference theme titles the same button 点击复制{copy name} and omits the tooltip entirely when no copy name is configured. Emit data-toggle="tooltip" with that title on both copy buttons, gated on a non-empty copy name, and mirror it on the paid-card helper so the two surfaces agree. Bootstrap's tooltip init already runs in auto_fun() on load, which is where the clipboard lib is required too. Co-Authored-By: Claude Sonnet 4.6 --- inc/helpers/aksrt-pay.php | 3 ++- templates/parts/resource-download-box.php | 1 + .../widget-system/download-direct-contract.test.cjs | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/inc/helpers/aksrt-pay.php b/inc/helpers/aksrt-pay.php index 2d50dd6b..fa947cb4 100644 --- a/inc/helpers/aksrt-pay.php +++ b/inc/helpers/aksrt-pay.php @@ -1491,7 +1491,8 @@ if (!function_exists('aksrt_get_paid_download_actions_html')) { $buttons .= ''; $buttons .= $icon_html . esc_html($label) . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped if ($copy_value !== '') { - $buttons .= ''; + $tooltip = $copy_key !== '' ? ' data-toggle="tooltip" title="' . esc_attr(sprintf(__('点击复制%s', 'aksrt'), $copy_key)) . '"' : ''; + $buttons .= ''; } elseif ($extract_code !== '') { $buttons .= '' . esc_html($extract_code) . ''; } diff --git a/templates/parts/resource-download-box.php b/templates/parts/resource-download-box.php index a15837d2..b69d213c 100644 --- a/templates/parts/resource-download-box.php +++ b/templates/parts/resource-download-box.php @@ -390,6 +390,7 @@ if ($is_need_purchase && $user_amount > 0) { diff --git a/tests/widget-system/download-direct-contract.test.cjs b/tests/widget-system/download-direct-contract.test.cjs index 1e0d486b..2728071d 100644 --- a/tests/widget-system/download-direct-contract.test.cjs +++ b/tests/widget-system/download-direct-contract.test.cjs @@ -62,6 +62,18 @@ test('the download box renders direct anchors with inline extract codes', () => // Mobile download bar scopes its own copy-button rule. assert.match(css, /\.resource-mobile-download-bar \.resource-download-box__btn--extract \{/); + // Hovering the remark shows 点击复制{copy name}, matching the reference theme, + // and only when a copy name exists. + assert.match(box, /\$has_copy && \$copy_key !== ''\) : \?>/); + assert.match(box, /sprintf\(__\('点击复制%s', 'aksrt'\), \$copy_key\)/); + assert.match(box, /data-toggle="tooltip"/); + const pay = read('inc/helpers/aksrt-pay.php'); + assert.match(pay, /sprintf\(__\('点击复制%s', 'aksrt'\), \$copy_key\)/); + // Bootstrap tooltips must be initialized for the attribute to do anything. + const main = read('assets/js/runtime/main.js'); + assert.match(main, /jQuery\("\[data-toggle='tooltip'\]"\)\.tooltip\(/); + assert.match(main, /^auto_fun\(\);/m); + // The login gate keeps its own anchor. assert.match(box, /\$btn_href = \$login_url;/); });