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;/); });