fix(frontend): route every user-center points label through the custom currency name

后台「积分配置 → 自定义货币名称」改名后,用户中心仍有大量硬编码
「积分」:做任务赚积分 / 购买积分 / 签到领积分、积分记录 / 积分任务、
每日可免费获取 XX 积分、我的积分、积分+1、创作中心积分收益等。

get_currency_name() 早已存在且可用,问题只是这些文案没有走它。
本PR 全部替换,无双路、无迁移:

服务端渲染(用户中心 renderers)
- credits-balance.php:购买/做任务赚/签到领 + 整个购买弹窗
- profile-credits.php:积分记录 / 积分任务 页签
- credits-points-tasks.php:每日上限三态与空态
- sidebar-creator.php / profile-creator.php:积分收益
- transfer-modal.php:积分转账提示
- Signin.php:签到详情弹窗(我的积分 / 奖励 tooltip / 积分+N)
- VipServiceModal.php:我的积分 / 积分兑换会员
- download-permission-card.php:购买价格

客户端渲染(JS 无法调用 PHP,注入 currencyName 到 aksrtData)
- signin.js:签到状态行「已签到 N 天 +1」
- credits.js:转账标题/金额标签 + 购买提示 toast
- cms-download.js:积分不足视图、我的积分 入口、余额不足文案
- pay-vip.js:积分兑换会员入口(优先 catalog.currency_name)
- order-center.js:订单行单位回退

契约测试同步改为断言模板构造而非死字符串,并新增两例:
改名后跟随、未注入时回退「积分」。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kate522andClaude Opus 5 committed 2026-11-01 15:09:49 +08:00
1 parent 1c95f94bca
commit 5c6b422866
19 files changed
+170 -59

No files matched your search

@@ -24,6 +24,10 @@ $points_exchange = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Se
$recharge = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_payment_recharge_settings() : [];
$points_exchange_on = !empty($points_exchange['enabled']) && !empty($recharge['enabled']);
$currency = (string) ($currency_name ?? __('积分', 'aksrt'));
// 文案里的货币名统一走自定义名称(后台「积分配置 → 自定义货币名称」)。
$points_buy_label = sprintf(__('购买%s', 'aksrt'), $currency);
$points_earn_label = sprintf(__('做任务赚%s', 'aksrt'), $currency);
$points_signin_label = sprintf(__('签到领%s', 'aksrt'), $currency);
?>
<div class="uc-asset-card uc-asset-card--points">
<div class="uc-asset-card__head flex jsb ac">
@@ -36,7 +40,7 @@ $currency = (string) ($currency_name ?? __('积分', 'aksrt'));
<?php echo aksrt_get_user_checkin_details_link('uc-asset-card__signin muted-color px12', '<span>' . esc_html__('已签到', 'aksrt') . '</span><i class="fa fas fa-angle-right em12 ml3" aria-hidden="true"></i>'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php else : ?>
<button type="button" class="uc-asset-card__signin muted-color px12" data-signin-btn data-signin-done-label="<?php esc_attr_e('已签到', 'aksrt'); ?>">
<span data-signin-label><?php esc_html_e('签到领积分', 'aksrt'); ?></span><i class="fa fas fa-angle-right em12 ml3" aria-hidden="true"></i>
<span data-signin-label><?php echo esc_html($points_signin_label); ?></span><i class="fa fas fa-angle-right em12 ml3" aria-hidden="true"></i>
</button>
<?php endif; ?>
<span class="uc-asset-card__signin-status" data-signin-status></span>
@@ -52,11 +56,11 @@ $currency = (string) ($currency_name ?? __('积分', 'aksrt'));
<button type="button" class="but c-green mr6 hollow" data-aksrt-transfer-open="points" data-aksrt-transfer-min="<?php echo esc_attr((string) $points_transfer_min); ?>"><?php esc_html_e('转账', 'aksrt'); ?></button>
<?php endif; ?>
<?php if ($points_exchange_on) : ?>
<button type="button" class="but c-green hollow" data-aksrt-points-pay-open><?php esc_html_e('购买积分', 'aksrt'); ?></button>
<button type="button" class="but c-green hollow" data-aksrt-points-pay-open><?php echo esc_html($points_buy_label); ?></button>
<?php endif; ?>
</div>
</div>
<button type="button" class="uc-asset-card__link muted-2-color em09" data-aksrt-asset-tab="points_free"><?php esc_html_e('做任务赚积分', 'aksrt'); ?><i class="fa fas fa-angle-right em12 ml3" aria-hidden="true"></i></button>
<button type="button" class="uc-asset-card__link muted-2-color em09" data-aksrt-asset-tab="points_free"><?php echo esc_html($points_earn_label); ?><i class="fa fas fa-angle-right em12 ml3" aria-hidden="true"></i></button>
</div>
<?php if ($points_exchange_on) :
@@ -64,6 +68,15 @@ $currency = (string) ($currency_name ?? __('积分', 'aksrt'));
$pb_rate = max(1, (int) ($points_exchange['rate'] ?? 100));
$pb_min_points = max(1, (int) ($points_exchange['min_points'] ?? 100));
$pb_daily_max_points = max(1, (int) ($points_exchange['daily_max_points'] ?? 100000));
// 依赖 $pb_min_points / $pb_daily_max_points,必须排在它们赋值之后。
$points_limit_html = sprintf(
/* translators: 1: currency name, 2: minimum purchase, 3: currency name, 4: maximum purchase */
__('最低购买%2$s%1$s,最高购买%4$s%3$s', 'aksrt'),
$currency,
$pb_min_points,
$currency,
$pb_daily_max_points
);
$points_packages = class_exists('\AKSRT\Credits\BalanceService')
? \AKSRT\Credits\BalanceService::get_instance()->parse_points_packages((string) ($points_exchange['products_raw'] ?? ''))
: [];
@@ -81,7 +94,7 @@ $currency = (string) ($currency_name ?? __('积分', 'aksrt'));
if (function_exists('aksrt_sort_payment_methods')) {
$points_methods = aksrt_sort_payment_methods($points_methods);
}
$points_custom_limit_html = sprintf(__('最低购买%d积分,最高购买%d积分', 'aksrt'), $pb_min_points, $pb_daily_max_points);
$points_custom_limit_html = $points_limit_html;
$points_gateway = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_payment_gateway_settings() : [];
$points_mark = (string) ($points_gateway['currency']['mark'] ?? '¥');
$points_default_product = $points_packages ? (string) $points_packages[0]['key'] : 'custom';
@@ -90,11 +103,11 @@ $currency = (string) ($currency_name ?? __('积分', 'aksrt'));
<div class="modal-dialog modal-mini full-sm" role="document">
<div class="modal-content">
<div class="modal-body">
<div class="mb10 touch"><button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><svg class="ic-close" aria-hidden="true"><use xlink:href="#icon-close"></use></svg></button><b class="modal-title flex ac"><span class="mr6 em14"><i class="fa fas fa-coins" aria-hidden="true"></i></span><?php esc_html_e('购买积分', 'aksrt'); ?></b></div>
<div class="mb10 touch"><button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><svg class="ic-close" aria-hidden="true"><use xlink:href="#icon-close"></use></svg></button><b class="modal-title flex ac"><span class="mr6 em14"><i class="fa fas fa-coins" aria-hidden="true"></i></span><?php echo esc_html($points_buy_label); ?></b></div>
<form class="balance-charge-form mini-scrollbar scroll-y max-vh7" data-aksrt-points-pay-form>
<div class="charge-box mb20">
<?php if ($points_packages) : ?>
<div class="muted-color mb6"><?php esc_html_e('请选择需购买的积分', 'aksrt'); ?></div>
<div class="muted-color mb6"><?php printf(esc_html__('请选择需购买的%s', 'aksrt'), esc_html($currency)); ?></div>
<?php foreach ($points_packages as $pidx => $ppkg) : ?>
<div class="zib-widget vip-product relative product-box<?php echo $pidx === 0 ? ' active' : ''; ?>" data-for="points_product" data-value="<?php echo esc_attr((string) $ppkg['key']); ?>">
<?php if (!empty($ppkg['tag'])) : ?>
@@ -104,7 +117,7 @@ $currency = (string) ($currency_name ?? __('积分', 'aksrt'));
<div class="c-red"><span class="px12"><?php echo esc_html($points_mark); ?></span><span class="em12"><?php echo esc_html((string) $ppkg['pay_price']); ?></span></div>
</div>
<?php endforeach; ?>
<div class="muted-color mt20 mb6"><?php printf(esc_html__('自定义积分数量(1%1$s=%2$s积分)', 'aksrt'), esc_html($points_mark), esc_html((string) $pb_rate)); ?></div>
<div class="muted-color mt20 mb6"><?php printf(esc_html__('自定义%1$s数量(1%2$s=%3$s%1$s)', 'aksrt'), esc_html($currency), esc_html($points_mark), esc_html((string) $pb_rate)); ?></div>
<div data-for="points_product" data-value="custom">
<div class="relative flex ab">
<span class="ml6 mr10 muted-color shrink0"><i class="fa fas fa-coins" aria-hidden="true"></i></span>
@@ -114,7 +127,7 @@ $currency = (string) ($currency_name ?? __('积分', 'aksrt'));
<div class="muted-2-color em09 mt6"><?php echo esc_html($points_custom_limit_html); ?></div>
</div>
<?php else : ?>
<div class="muted-color mb6"><?php esc_html_e('请输入需购买的积分数额', 'aksrt'); ?></div>
<div class="muted-color mb6"><?php printf(esc_html__('请输入需购买的%s数额', 'aksrt'), esc_html($currency)); ?></div>
<div data-for="points_product" data-value="custom">
<div class="relative flex ab">
<span class="ml6 mr10 muted-color shrink0"><i class="fa fas fa-coins" aria-hidden="true"></i></span>
@@ -88,12 +88,14 @@ $day_max = (int) \AKSRT\Credits\PointsFree::settings()['day_max'];
$tasks = \AKSRT\Credits\PointsFree::task_list_for_user($user_id);
$detail = \AKSRT\Credits\PointsFree::date_detail($user_id);
$pane = isset($points_tasks_pane) ? sanitize_key((string) $points_tasks_pane) : 'tasks';
// 文案里的货币名统一走自定义名称(后台「积分配置 → 自定义货币名称」)。
$currency = (string) ($currency_name ?? __('积分', 'aksrt'));
?>
<?php if ($pane === 'date') : ?>
<div class="uc-points-date">
<div class="flex jsb ac mb10">
<div class="font-bold"><?php esc_html_e('每日免费积分明细', 'aksrt'); ?></div>
<div class="font-bold"><?php printf(esc_html__('每日免费%s明细', 'aksrt'), esc_html($currency)); ?></div>
<button type="button" class="muted-2-color" data-aksrt-asset-tab="points_free">
<?php esc_html_e('返回任务', 'aksrt'); ?><i class="fa fas fa-angle-right ml6 em12" aria-hidden="true"></i>
</button>
@@ -106,7 +108,7 @@ $pane = isset($points_tasks_pane) ? sanitize_key((string) $points_tasks_pane)
</div>
<?php endforeach; ?>
<?php else : ?>
<div class="uc-transactions__empty"><p><?php esc_html_e('暂无免费积分获取明细', 'aksrt'); ?></p></div>
<div class="uc-transactions__empty"><p><?php printf(esc_html__('暂无免费%s获取明细', 'aksrt'), esc_html($currency)); ?></p></div>
<?php endif; ?>
</div>
<?php else : ?>
@@ -128,12 +130,12 @@ $pane = isset($points_tasks_pane) ? sanitize_key((string) $points_tasks_pane)
<?php
if ($day_max > 0) {
if ($today >= $day_max) {
printf(esc_html__('今日获取的免费积分已达到 %s,将不再获取', 'aksrt'), esc_html((string) $day_max));
printf(esc_html__('今日获取的免费%s已达到 %s,将不再获取', 'aksrt'), esc_html($currency), esc_html((string) $day_max));
} else {
printf(esc_html__('每日可免费获取 %s 积分,超过后将不再获取', 'aksrt'), esc_html((string) $day_max));
printf(esc_html__('每日可免费获取 %1$s %2$s,超过后将不再获取', 'aksrt'), esc_html((string) $day_max), esc_html($currency));
}
} else {
esc_html_e('免费积分无每日上限', 'aksrt');
printf(esc_html__('免费%s无每日上限', 'aksrt'), esc_html($currency));
}
?>
</div>
@@ -193,7 +195,7 @@ $pane = isset($points_tasks_pane) ? sanitize_key((string) $points_tasks_pane)
</div>
<?php endforeach; ?>
<?php else : ?>
<div class="uc-transactions__empty"><p><?php esc_html_e('暂无可用积分任务', 'aksrt'); ?></p></div>
<div class="uc-transactions__empty"><p><?php printf(esc_html__('暂无可用%s任务', 'aksrt'), esc_html($currency)); ?></p></div>
<?php endif; ?>
</div>
<?php endif; ?>
@@ -56,14 +56,19 @@ $status_labels = [
'pending' => __('待结算', 'aksrt'),
'settled' => __('已结算', 'aksrt'),
];
// 收益单位名跟随自定义货币名称(后台「积分配置 → 自定义货币名称」)。
$currency_name = class_exists('\\AKSRT\\Settings\\Settings')
? \AKSRT\Settings\Settings::get_currency_name()
: __('积分', 'aksrt');
$points_income_label = sprintf(__('%s收益', 'aksrt'), $currency_name);
$currency_labels = [
'CNY' => __('现金收益', 'aksrt'),
'points' => __('积分收益', 'aksrt'),
'points' => $points_income_label,
];
?>
<div class="creator-income" data-creator-income>
<section class="creator-income__cards" aria-label="<?php esc_attr_e('收益概览', 'aksrt'); ?>">
<?php foreach (['CNY' => __('现金收益', 'aksrt'), 'points' => __('积分收益', 'aksrt')] as $unit => $label) : ?>
<?php foreach ($currency_labels as $unit => $label) : ?>
<article class="creator-income-card creator-income-card--<?php echo esc_attr(strtolower($unit)); ?>">
<h2><?php echo esc_html($label); ?></h2>
<div class="creator-income-card__metrics">
@@ -126,7 +131,7 @@ $currency_labels = [
<span class="creator-income-row__currency"><?php echo esc_html($currency_labels[$unit === 'points' ? 'points' : 'CNY']); ?></span>
<span class="creator-income-row__source" title="<?php echo esc_attr($source); ?>"><?php echo esc_html($source); ?></span>
<span class="creator-income-row__detail">
<strong class="creator-income-row__amount">+<?php echo esc_html($amount . ($unit === 'points' ? __('积分', 'aksrt') : __('现金', 'aksrt'))); ?></strong>
<strong class="creator-income-row__amount">+<?php echo esc_html($amount . ($unit === 'points' ? $currency_name : __('现金', 'aksrt'))); ?></strong>
<?php if ($time_label !== '') : ?>
<time class="creator-income-row__time" datetime="<?php echo esc_attr($time_datetime); ?>"><?php echo esc_html($time_label); ?></time>
<?php endif; ?>
@@ -15,6 +15,10 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
$dir = __DIR__;
$show_wallet = !empty($balance_enabled);
$show_credits = !empty($credits_enabled);
// 记录/任务页签文案跟随自定义货币名称(后台「积分配置 → 自定义货币名称」)。
$currency_name = (string) ($currency_name ?? __('积分', 'aksrt'));
$points_record_label = sprintf(__('%s记录', 'aksrt'), $currency_name);
$points_tasks_label = sprintf(__('%s任务', 'aksrt'), $currency_name);
// Dual cards row (legacy row gutters-10).
if ($show_wallet || $show_credits) :
@@ -56,12 +60,12 @@ if ($show_wallet || $show_credits) :
<?php endif; ?>
<?php if ($show_credits) : ?>
<li class="<?php echo $active_record === 'points' ? 'active' : ''; ?>">
<a href="#record_tab_points" data-aksrt-asset-tab="points"><?php esc_html_e('积分记录', 'aksrt'); ?></a>
<a href="#record_tab_points" data-aksrt-asset-tab="points"><?php echo esc_html($points_record_label); ?></a>
</li>
<?php endif; ?>
<?php if (!empty($show_tasks)) : ?>
<li class="<?php echo in_array($active_record, ['points_free', 'points_date'], true) ? 'active' : ''; ?>">
<a href="#record_tab_points_free" data-aksrt-asset-tab="points_free"><?php esc_html_e('积分任务', 'aksrt'); ?></a>
<a href="#record_tab_points_free" data-aksrt-asset-tab="points_free"><?php echo esc_html($points_tasks_label); ?></a>
</li>
<?php endif; ?>
</ul>
@@ -28,6 +28,10 @@ if ($creation_url !== '') {
// 累计收益(pending + settled),现金与积分分开统计。
$cash_income = (float) ($income_stats['total']['CNY'] ?? 0);
$points_income = (int) ($income_stats['total']['points'] ?? 0);
// 收益单位名跟随自定义货币名称(后台「积分配置 → 自定义货币名称」)。
$currency_name = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_currency_name()
: __('积分', 'aksrt');
$centers[] = [
'url' => $creation_url,
@@ -37,7 +41,7 @@ if ($creation_url !== '') {
'first' => aksrt_cut_count($cash_income),
'first_l' => __('现金收益', 'aksrt'),
'second' => aksrt_cut_count($points_income),
'second_l' => __('积分收益', 'aksrt'),
'second_l' => sprintf(__('%s收益', 'aksrt'), $currency_name),
];
}
@@ -13,6 +13,8 @@ $transfer_recharge = class_exists('\AKSRT\Settings\Settings') && method_exists('
$transfer_all_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_all() : [];
$points_transfer_min = max(1, (int) ($transfer_all_settings['points_transfer_min'] ?? 1));
$points_transfer_fee = max(0, min(50, (int) ($transfer_all_settings['points_service_charge'] ?? 0)));
// 转账提示里的货币名跟随自定义名称(后台「积分配置 → 自定义货币名称」)。
$currency_name = (string) ($currency_name ?? __('积分', 'aksrt'));
?>
<div class="uc-modal" id="aksrt-transfer-modal" hidden data-aksrt-transfer-modal>
<div class="uc-modal__overlay" data-aksrt-transfer-close></div>
@@ -41,7 +43,7 @@ $points_transfer_fee = max(0, min(50, (int) ($transfer_all_settings['points_serv
<?php endif; ?>
</div>
<div class="muted-box em09 mb10" hidden data-aksrt-transfer-points-info>
<?php printf(esc_html__('积分转账仅支持正整数,单笔至少 %d 积分。', 'aksrt'), $points_transfer_min); ?>
<?php printf(esc_html__('%s转账仅支持正整数,单笔至少 %d %s。', 'aksrt'), esc_html($currency_name), $points_transfer_min, esc_html($currency_name)); ?>
<?php if ($points_transfer_fee > 0) : ?>
<?php printf(esc_html__(' 将扣除 %d%% 手续费。', 'aksrt'), $points_transfer_fee); ?>
<?php endif; ?>