Files
wordpress-theme-aksrt/templates/shortcodes/profile.php
T
kate522andClaude Opus 5 35bb96e82f refactor: rename the theme brand and every identifier from AKSRT to Jio
Full-project rename. `git grep -i aksrt` is now empty apart from the
DBMigrator 3.3.0 changelog note that documents the rename itself.

Code identifiers
- PHP namespace AKSRT\ -> Jio\ (composer PSR-4 + 378 declarations)
- global constants AKSRT_* -> JIO_* (VERSION/DIR/URI, PAY_TYPE_*, CAPTCHA_*)
- procedural functions, hooks, options, meta keys, table names,
  cookies, query vars, ajax actions and nonces: aksrt_ -> jio_
- text domain aksrt -> jio; Theme Name -> Jio
- JS globals: aksrtData/aksrtAdminData/... -> jioData/jioAdminData/...,
  window.AKSRTCaptcha & friends -> window.JioCaptcha, Aksrt* -> Jio*
- Vue components Aks*.vue -> Jio*.vue (15 files renamed + imports)
- CSS classes/data-attrs/custom properties: aksrt- -> jio-
- REST namespace aksrt/v1 -> jio/v1 (incl. payment gateway callbacks)

Storage layer
- DB tables {prefix}aksrt_* -> {prefix}jio_*; SCHEMA_VERSION 3.2.0 -> 3.3.0
  so dbDelta creates the new names on install
- widget id_base aksrt_widget_* -> jio_widget_*
- uninstall.php drop list rebuilt from the actual migrator tables
  (dropped 3 stale entries, added the 17 missing ones)

Removed
- hardcoded https://api.aksrt.com/version.json default update endpoint;
  get_endpoint() now reads the 「更新端点」 setting and do_check() no-ops
  when it is empty

Files renamed: inc/helpers/aksrt-*.php -> jio-*.php (54),
assets/admin/src/components/form/Aks*.vue -> Jio*.vue (15).
Build artifacts regenerated: assets/css/build, assets/js/runtime,
assets/admin/build.

Verified: audit-psr4-paths errors=0, audit-admin-contracts errors=0
(warnings=56, unchanged baseline), 813/813 widget-system tests,
44/44 phpunit, php -l clean across all PHP.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-01 20:05:04 +08:00

59 lines
2.8 KiB
PHP

<?php
/**
* Shortcode template: [jio_profile]
*
* 当前登录用户的资料卡。供 \Jio\Core\Shortcodes::render_profile() 通过
* \Jio\Core\Templates::render_profile_shortcode() 以输出缓冲方式 include。
*
* 可用变量:$attrs(短代码属性,支持 user="<ID 或 login>" 指定用户)、$content。
*
* @package Jio
*/
defined('ABSPATH') || exit;
// 解析目标用户:属性指定 > 当前登录用户。
$target = isset($attrs['user']) ? trim((string) $attrs['user']) : '';
$user = null;
if ($target !== '') {
$user = is_numeric($target) ? get_user_by('id', (int) $target) : get_user_by('login', $target);
} elseif (is_user_logged_in()) {
$user = wp_get_current_user();
}
if (!($user instanceof WP_User) || $user->ID <= 0) {
echo '<div class="jio-profile-card jio-profile-card--shortcode jio-profile-card--guest">'
. '<p>' . esc_html__('登录后查看个人资料。', 'jio') . '</p>';
if (function_exists('jio_get_login_url')) {
echo '<a class="btn-primary btn-sm" href="' . esc_url(jio_get_login_url()) . '">' . esc_html__('登录', 'jio') . '</a>';
}
echo '</div>';
return;
}
$user_id = (int) $user->ID;
$avatar = function_exists('jio_get_avatar_url') ? jio_get_avatar_url($user_id, ['size' => 96]) : get_avatar_url($user_id, ['size' => 96]);
$home_url = function_exists('jio_get_user_home_url') ? jio_get_user_home_url($user) : get_author_posts_url($user_id);
$credits = jio_user_points($user_id);
$post_count = (int) count_user_posts($user_id, 'post', true);
$bio = function_exists('jio_get_user_description') ? jio_get_user_description($user_id) : (string) get_the_author_meta('description', $user_id);
$show_credits = class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::credits_enabled() : true;
?>
<div class="jio-profile-card jio-profile-card--shortcode">
<a class="jio-profile-card__avatar" href="<?php echo esc_url($home_url); ?>">
<img<?php echo jio_get_lazy_attr('lazy_avatar', (string) $avatar, 'avatar', jio_get_lazy_thumb('sm')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> alt="<?php echo esc_attr($user->display_name); ?>" width="64" height="64">
</a>
<div class="jio-profile-card__body">
<a class="jio-profile-card__name" href="<?php echo esc_url($home_url); ?>"><?php echo esc_html($user->display_name); ?></a>
<?php if ($bio !== '') : ?>
<p class="jio-profile-card__bio"><?php echo esc_html(wp_trim_words($bio, 24, '…')); ?></p>
<?php endif; ?>
<div class="jio-profile-card__stats">
<span class="jio-profile-card__stat"><strong><?php echo esc_html(number_format_i18n($post_count)); ?></strong><?php esc_html_e('文章', 'jio'); ?></span>
<?php if ($show_credits) : ?>
<span class="jio-profile-card__stat"><strong><?php echo esc_html(number_format_i18n($credits)); ?></strong><?php esc_html_e('积分', 'jio'); ?></span>
<?php endif; ?>
</div>
</div>
</div>