Files
wordpress-theme-aksrt/inc/helpers/user-center-renderers/profile-level.php
T
kate522 9375b1c30c refactor(assets): vendor 资产迁入标准目录并全仓去除 zibll 标识
- assets/vendor 全量迁移: fontawesome5→assets/fontawesome5, css→assets/css,
  js→assets/js/runtime(避开 14 个同名自有文件), img 合并去重→assets/img,
  fonts→assets/fonts; 删除 assets/vendor
- libs 五个与 widgets/third-party 字节相同的库不重复入库, loader paths 改指向
- 运行时切换: _win.uri=assets 根, loader baseUrl=/js/runtime, enlighter 注入
  路径同步; PHP 7 个引用文件切换并改名 $zibll_*→$runtime_*
- 去品牌: Qinver 头注释/品牌 console.log/演示链接清除, 默认文案中性化
- 功能标识符改名: zib__→aksrt__, zib_ajax→aksrt_ajax, window.zib→
  window.aksrtLegacy, zibllblock/*→aksrtblock/*, .zib-widget→.aksrt-panel,
  .zib-slider→.aksrt-slider, zib_menu_options meta 键等
- 自有 CSS 改名: legacy-utilities/compat-vars/footer shell
- admin SPA 重建; 契约测试同步(路径/断言/文件更名)
- 例外保留: tests/visual 对照环境与 fixtures 前缀(外部 Zibll 产品引用)

验证: php -l 133 个改动文件通过; runtime 86 个 JS node --check 通过;
契约测试 68/70(2 个失败经 stash 对照确认为存量问题)
2026-08-22 16:16:30 +08:00

134 lines
6.7 KiB
PHP

<?php
/**
* User center: growth level, route and experience history.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
$user_id = (int) ($context['user_id'] ?? get_current_user_id());
if ($user_id <= 0 || !class_exists('\AKSRT\User\Level')) {
return;
}
$cfg = \AKSRT\User\Level::settings();
if (empty($cfg['enabled'])) {
return;
}
$progress = \AKSRT\User\Level::get_progress($user_id);
$details = \AKSRT\User\Level::get_details($user_id);
$date_details = \AKSRT\User\Level::get_date_details($user_id);
$labels = \AKSRT\User\Level::integral_labels();
$opt = is_array($cfg['level_opt'] ?? null) ? $cfg['level_opt'] : [];
$today = current_time('Y-m-d');
$today_integral = max(0, (int) ($date_details[$today] ?? 0));
$day_max = \AKSRT\User\Level::day_max();
?>
<div class="uc-level-page">
<section class="uc-level-hero aksrt-panel">
<div class="uc-level-hero__identity">
<div class="uc-level-hero__icon">
<?php echo \AKSRT\User\Level::get_badge_html($user_id); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
<div>
<p><?php esc_html_e('我的等级', 'aksrt'); ?></p>
<h2><?php echo esc_html((string) $progress['name']); ?></h2>
</div>
</div>
<div class="uc-level-hero__stats">
<div><strong><?php echo esc_html((string) $progress['integral']); ?></strong><span><?php esc_html_e('累计经验', 'aksrt'); ?></span></div>
<div><strong><?php echo esc_html((string) $today_integral); ?><?php echo $day_max > 0 ? '/' . esc_html((string) $day_max) : ''; ?></strong><span><?php esc_html_e('今日经验', 'aksrt'); ?></span></div>
<div><strong><?php echo esc_html((string) $progress['remaining']); ?></strong><span><?php echo !empty($progress['is_max']) ? esc_html__('已达最高等级', 'aksrt') : esc_html__('升级还需', 'aksrt'); ?></span></div>
</div>
<div class="uc-level-hero__progress">
<div class="uc-level-hero__progress-meta">
<span><?php echo esc_html((string) $progress['integral']); ?> EXP</span>
<span><?php echo !empty($progress['is_max']) ? esc_html__('最高等级', 'aksrt') : esc_html((string) $progress['next_need']) . ' EXP'; ?></span>
</div>
<div class="uc-level-progress"><span style="width:<?php echo esc_attr((string) $progress['progress']); ?>%"></span></div>
</div>
</section>
<section class="uc-level-section aksrt-panel">
<div class="uc-level-section__head"><h3><?php esc_html_e('成长路线', 'aksrt'); ?></h3><span><?php printf(esc_html__('最高 %d 级', 'aksrt'), (int) $cfg['max']); ?></span></div>
<div class="uc-level-road">
<?php for ($level = 1; $level <= (int) $cfg['max']; $level++) :
$need = $level === 1 ? 0 : max(0, (int) ($opt['upgrade_integral_' . $level] ?? (($level - 1) * 500 * $level)));
$name = \AKSRT\User\Level::get_level_name($level);
$state = $level < (int) $progress['level'] ? ' is-done' : ($level === (int) $progress['level'] ? ' is-current' : '');
?>
<div class="uc-level-road__item<?php echo esc_attr($state); ?>">
<div class="uc-level-road__icon">
<?php $icon = \AKSRT\User\Level::get_level_icon_url($level); ?>
<?php if ($icon !== '') : ?><img<?php echo aksrt_get_lazy_attr('lazy_other', (string) $icon); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> alt=""><?php else : ?><span>LV<?php echo esc_html((string) $level); ?></span><?php endif; ?>
</div>
<strong><?php echo esc_html($name); ?></strong>
<small><?php echo esc_html((string) $need); ?> EXP</small>
</div>
<?php endfor; ?>
</div>
</section>
<section class="uc-level-section aksrt-panel">
<div class="uc-level-section__head"><h3><?php esc_html_e('获取经验值', 'aksrt'); ?></h3><span><?php esc_html_e('完成互动即可成长', 'aksrt'); ?></span></div>
<div class="uc-level-methods">
<?php
$methods = \AKSRT\User\Level::integral_defaults();
$methods['checkin'] = 0;
$methods['referral'] = 0;
$methods['shop_gift'] = 0;
$referral_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_referral_reward_settings() : [];
$methods['referral'] = max(0, (int) ($referral_settings['level_points'] ?? 0));
foreach ($methods as $key => $default_value) :
if ($key === 'day_max') continue;
$value = in_array($key, ['checkin', 'shop_gift'], true) ? 0 : ($key === 'referral' ? (int) $default_value : \AKSRT\User\Level::task_points($key));
if ($value <= 0 && !in_array($key, ['checkin', 'shop_gift'], true)) continue;
?>
<div class="uc-level-methods__item">
<span><i class="fa fas fa-bolt" aria-hidden="true"></i></span>
<div><strong><?php echo esc_html($labels[$key] ?? $key); ?></strong><small><?php echo in_array($key, ['checkin', 'shop_gift'], true) ? esc_html__('按活动或商品配置发放', 'aksrt') : esc_html__('完成后自动计入经验', 'aksrt'); ?></small></div>
<b><?php echo $value > 0 ? '+' . esc_html((string) $value) : esc_html__('动态', 'aksrt'); ?></b>
</div>
<?php endforeach; ?>
</div>
</section>
<div class="uc-level-history-grid">
<section class="uc-level-section aksrt-panel">
<div class="uc-level-section__head"><h3><?php esc_html_e('经验明细', 'aksrt'); ?></h3><span><?php esc_html_e('最近 50 条', 'aksrt'); ?></span></div>
<?php if ($details) : ?>
<div class="uc-level-ledger">
<?php foreach ($details as $row) :
$key = sanitize_key((string) ($row['key'] ?? ''));
$value = max(0, (int) ($row['value'] ?? 0));
?>
<div class="uc-level-ledger__row">
<span class="uc-level-ledger__icon"><i class="fa fas fa-chart-line" aria-hidden="true"></i></span>
<div><strong><?php echo esc_html($labels[$key] ?? $key); ?></strong><time><?php echo esc_html((string) ($row['time'] ?? '')); ?></time><small><?php printf(esc_html__('累计:%d', 'aksrt'), max(0, (int) ($row['integral'] ?? 0))); ?></small></div>
<b>+<?php echo esc_html((string) $value); ?></b>
</div>
<?php endforeach; ?>
</div>
<?php else : ?>
<p class="uc-level-empty"><?php esc_html_e('还没有经验获取记录。', 'aksrt'); ?></p>
<?php endif; ?>
</section>
<section class="uc-level-section aksrt-panel">
<div class="uc-level-section__head"><h3><?php esc_html_e('每日经验', 'aksrt'); ?></h3><span><?php esc_html_e('最近 30 天', 'aksrt'); ?></span></div>
<?php if ($date_details) : ?>
<div class="uc-level-dates">
<?php foreach ($date_details as $date => $value) : ?>
<div><time><?php echo esc_html((string) $date); ?></time><span>+<?php echo esc_html((string) max(0, (int) $value)); ?> EXP</span></div>
<?php endforeach; ?>
</div>
<?php else : ?>
<p class="uc-level-empty"><?php esc_html_e('还没有每日经验记录。', 'aksrt'); ?></p>
<?php endif; ?>
</section>
</div>
</div>