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>
This commit is contained in:
kate522andClaude Opus 5 committed 2026-11-01 20:05:04 +08:00
1 parent 5b16bc6e15
commit 35bb96e82f
997 files changed
+28216 -28188

No files matched your search

+115 -115
View File
@@ -2,48 +2,48 @@
/** User profile and account settings AJAX handlers. */
defined('ABSPATH') || exit;
if (!function_exists('aksrt_account_captcha_error_data')) {
function aksrt_account_captcha_error_data($result): array {
if (!function_exists('jio_account_captcha_error_data')) {
function jio_account_captcha_error_data($result): array {
return [
'code' => is_wp_error($result) ? ($result->get_error_code() ?: 'aksrt_captcha_failed') : 'aksrt_captcha_failed',
'code' => is_wp_error($result) ? ($result->get_error_code() ?: 'jio_captcha_failed') : 'jio_captcha_failed',
'message' => is_wp_error($result)
? ($result->get_error_message() ?: __('人机验证失败,请重试', 'aksrt'))
: __('人机验证失败,请重试', 'aksrt'),
? ($result->get_error_message() ?: __('人机验证失败,请重试', 'jio'))
: __('人机验证失败,请重试', 'jio'),
];
}
}
add_action('wp_ajax_aksrt_save_profile', function (): void {
add_action('wp_ajax_jio_save_profile', function (): void {
if (
!isset($_POST['_profile_nonce'])
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_profile_nonce'])), 'aksrt_profile_save')
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_profile_nonce'])), 'jio_profile_save')
) {
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'aksrt')]);
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'jio')]);
}
$user_id = (int) ($_POST['user_id'] ?? 0);
$result = function_exists('aksrt_save_user_center_profile')
? aksrt_save_user_center_profile($user_id, $_POST)
: new WP_Error('aksrt_profile_unavailable', __('保存失败', 'aksrt'));
$result = function_exists('jio_save_user_center_profile')
? jio_save_user_center_profile($user_id, $_POST)
: new WP_Error('jio_profile_unavailable', __('保存失败', 'jio'));
if (is_wp_error($result)) wp_send_json_error(['message' => $result->get_error_message()]);
wp_send_json_success(['message' => __('保存成功!', 'aksrt')]);
wp_send_json_success(['message' => __('保存成功!', 'jio')]);
});
function aksrt_account_code_key(int $user_id, string $scene, string $target): string {
return 'aksrt_account_code_' . $user_id . '_' . sanitize_key($scene) . '_' . md5(strtolower(trim($target)));
function jio_account_code_key(int $user_id, string $scene, string $target): string {
return 'jio_account_code_' . $user_id . '_' . sanitize_key($scene) . '_' . md5(strtolower(trim($target)));
}
function aksrt_account_store_code(int $user_id, string $scene, string $target, string $code): void {
function jio_account_store_code(int $user_id, string $scene, string $target, string $code): void {
set_transient(
aksrt_account_code_key($user_id, $scene, $target),
jio_account_code_key($user_id, $scene, $target),
['hash' => wp_hash_password($code), 'attempts' => 0],
5 * MINUTE_IN_SECONDS
);
}
function aksrt_account_consume_code(int $user_id, string $scene, string $target, string $code, bool $consume = true): bool {
$key = aksrt_account_code_key($user_id, $scene, $target);
function jio_account_consume_code(int $user_id, string $scene, string $target, string $code, bool $consume = true): bool {
$key = jio_account_code_key($user_id, $scene, $target);
$stored = get_transient($key);
if (!is_array($stored) || empty($stored['hash'])) {
return false;
@@ -67,20 +67,20 @@ function aksrt_account_consume_code(int $user_id, string $scene, string $target,
return true;
}
function aksrt_account_proof_key(int $user_id, string $kind): string {
return 'aksrt_account_proof_' . sanitize_key($kind) . '_' . $user_id;
function jio_account_proof_key(int $user_id, string $kind): string {
return 'jio_account_proof_' . sanitize_key($kind) . '_' . $user_id;
}
function aksrt_account_set_proof(int $user_id, string $kind, string $target): void {
function jio_account_set_proof(int $user_id, string $kind, string $target): void {
set_transient(
aksrt_account_proof_key($user_id, $kind),
jio_account_proof_key($user_id, $kind),
['target' => strtolower(trim($target))],
30 * MINUTE_IN_SECONDS
);
}
function aksrt_account_consume_proof(int $user_id, string $kind, string $target, bool $consume = true): bool {
$key = aksrt_account_proof_key($user_id, $kind);
function jio_account_consume_proof(int $user_id, string $kind, string $target, bool $consume = true): bool {
$key = jio_account_proof_key($user_id, $kind);
$proof = get_transient($key);
if (!is_array($proof) || strtolower(trim((string) ($proof['target'] ?? ''))) !== strtolower(trim($target))) {
return false;
@@ -92,170 +92,170 @@ function aksrt_account_consume_proof(int $user_id, string $kind, string $target,
return true;
}
function aksrt_account_email_verification_required(): bool {
$settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_all() : [];
function jio_account_email_verification_required(): bool {
$settings = class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::get_all() : [];
return !empty($settings['email_set_captch']);
}
add_action('wp_ajax_aksrt_send_account_email_code', function (): void {
add_action('wp_ajax_jio_send_account_email_code', function (): void {
if (
!isset($_POST['_settings_nonce'])
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_settings_nonce'])), 'aksrt_account_settings')
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_settings_nonce'])), 'jio_account_settings')
) {
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'aksrt')]);
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'jio')]);
}
$user_id = get_current_user_id();
$user = wp_get_current_user();
if (!$user_id || !($user instanceof WP_User)) {
wp_send_json_error(['message' => __('请先登录', 'aksrt')]);
wp_send_json_error(['message' => __('请先登录', 'jio')]);
}
$scene = sanitize_key((string) wp_unslash($_POST['scene'] ?? ''));
if (!in_array($scene, ['verify_email', 'change_email'], true)) {
wp_send_json_error(['message' => __('无效的验证场景', 'aksrt')]);
wp_send_json_error(['message' => __('无效的验证场景', 'jio')]);
}
if (!aksrt_account_email_verification_required()) {
wp_send_json_error(['message' => __('邮箱验证码验证未开启', 'aksrt')]);
if (!jio_account_email_verification_required()) {
wp_send_json_error(['message' => __('邮箱验证码验证未开启', 'jio')]);
}
$target = $scene === 'verify_email'
? (string) $user->user_email
: sanitize_email((string) wp_unslash($_POST['new_email'] ?? ''));
if (!is_email($target)) {
wp_send_json_error(['message' => __('邮箱格式错误', 'aksrt')]);
wp_send_json_error(['message' => __('邮箱格式错误', 'jio')]);
}
if ($scene === 'change_email') {
if (strtolower($target) === strtolower((string) $user->user_email)) {
wp_send_json_error(['message' => __('修改邮箱不能与现邮箱相同', 'aksrt')]);
wp_send_json_error(['message' => __('修改邮箱不能与现邮箱相同', 'jio')]);
}
if (email_exists($target)) {
wp_send_json_error(['message' => __('该邮箱已有绑定账号', 'aksrt')]);
wp_send_json_error(['message' => __('该邮箱已有绑定账号', 'jio')]);
}
}
if (function_exists('aksrt_require_captcha')) {
$captcha = aksrt_require_captcha('change_email', wp_unslash($_POST));
if (function_exists('jio_require_captcha')) {
$captcha = jio_require_captcha('change_email', wp_unslash($_POST));
if ($captcha !== true) {
wp_send_json_error(aksrt_account_captcha_error_data($captcha));
wp_send_json_error(jio_account_captcha_error_data($captcha));
}
}
if (class_exists('\AKSRT\Extensions\SendLimit')) {
$limit = \AKSRT\Extensions\SendLimit::check($target);
if (class_exists('\Jio\Extensions\SendLimit')) {
$limit = \Jio\Extensions\SendLimit::check($target);
if (empty($limit['ok'])) {
wp_send_json_error(['message' => (string) $limit['message']]);
}
}
$code = str_pad((string) random_int(0, 999999), 6, '0', STR_PAD_LEFT);
$sent = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::send_event_email('change_code', $target, [
$sent = class_exists('\Jio\Settings\Settings')
? \Jio\Settings\Settings::send_event_email('change_code', $target, [
'{username}' => $user->display_name,
'{site_name}' => get_bloginfo('name'),
'{code}' => $code,
])
: false;
if (!$sent) {
wp_send_json_error(['message' => __('验证码邮件发送失败,请稍后重试', 'aksrt')]);
wp_send_json_error(['message' => __('验证码邮件发送失败,请稍后重试', 'jio')]);
}
$cooldown = class_exists('\AKSRT\Extensions\SendLimit') ? (int) \AKSRT\Extensions\SendLimit::record($target) : 0;
aksrt_account_store_code($user_id, $scene, $target, $code);
$cooldown = class_exists('\Jio\Extensions\SendLimit') ? (int) \Jio\Extensions\SendLimit::record($target) : 0;
jio_account_store_code($user_id, $scene, $target, $code);
wp_send_json_success([
'message' => $scene === 'verify_email'
? __('验证码已发送到您的老邮箱', 'aksrt')
: __('验证码已发送到新邮箱', 'aksrt'),
? __('验证码已发送到您的老邮箱', 'jio')
: __('验证码已发送到新邮箱', 'jio'),
'countdown' => $cooldown > 0 ? $cooldown : 60,
]);
});
add_action('wp_ajax_aksrt_verify_account_email', function (): void {
add_action('wp_ajax_jio_verify_account_email', function (): void {
if (
!isset($_POST['_settings_nonce'])
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_settings_nonce'])), 'aksrt_account_settings')
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_settings_nonce'])), 'jio_account_settings')
) {
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'aksrt')]);
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'jio')]);
}
$user_id = get_current_user_id();
$user = wp_get_current_user();
if (!$user_id || !($user instanceof WP_User) || !is_email((string) $user->user_email)) {
wp_send_json_error(['message' => __('当前账号未绑定有效邮箱', 'aksrt')]);
wp_send_json_error(['message' => __('当前账号未绑定有效邮箱', 'jio')]);
}
if (!aksrt_account_email_verification_required()) {
wp_send_json_error(['message' => __('邮箱验证码验证未开启', 'aksrt')]);
if (!jio_account_email_verification_required()) {
wp_send_json_error(['message' => __('邮箱验证码验证未开启', 'jio')]);
}
if (function_exists('aksrt_require_captcha')) {
$captcha = aksrt_require_captcha('change_email', wp_unslash($_POST));
if (function_exists('jio_require_captcha')) {
$captcha = jio_require_captcha('change_email', wp_unslash($_POST));
if ($captcha !== true) {
wp_send_json_error(aksrt_account_captcha_error_data($captcha));
wp_send_json_error(jio_account_captcha_error_data($captcha));
}
}
$code = sanitize_text_field((string) wp_unslash($_POST['code'] ?? ''));
if (!aksrt_account_consume_code($user_id, 'verify_email', (string) $user->user_email, $code)) {
if (class_exists('\AKSRT\Extensions\SecurityHardening')) {
\AKSRT\Extensions\SecurityHardening::error_frequency_record();
if (!jio_account_consume_code($user_id, 'verify_email', (string) $user->user_email, $code)) {
if (class_exists('\Jio\Extensions\SecurityHardening')) {
\Jio\Extensions\SecurityHardening::error_frequency_record();
}
wp_send_json_error(['message' => __('验证码错误或已过期', 'aksrt')]);
wp_send_json_error(['message' => __('验证码错误或已过期', 'jio')]);
}
if (class_exists('\AKSRT\Extensions\SecurityHardening')) {
\AKSRT\Extensions\SecurityHardening::error_frequency_clear();
if (class_exists('\Jio\Extensions\SecurityHardening')) {
\Jio\Extensions\SecurityHardening::error_frequency_clear();
}
aksrt_account_set_proof($user_id, 'email_old', (string) $user->user_email);
wp_send_json_success(['message' => __('验证成功', 'aksrt')]);
jio_account_set_proof($user_id, 'email_old', (string) $user->user_email);
wp_send_json_success(['message' => __('验证成功', 'jio')]);
});
add_action('wp_ajax_aksrt_change_password', function (): void {
add_action('wp_ajax_jio_change_password', function (): void {
if (
!isset($_POST['_settings_nonce'])
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_settings_nonce'])), 'aksrt_account_settings')
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_settings_nonce'])), 'jio_account_settings')
) {
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'aksrt')]);
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'jio')]);
}
$user_id = get_current_user_id();
if (!$user_id) {
wp_send_json_error(['message' => __('请先登录', 'aksrt')]);
wp_send_json_error(['message' => __('请先登录', 'jio')]);
}
$user = get_userdata($user_id);
if (!($user instanceof WP_User)) {
wp_send_json_error(['message' => __('账号信息读取失败,请刷新页面重试', 'aksrt')]);
wp_send_json_error(['message' => __('账号信息读取失败,请刷新页面重试', 'jio')]);
}
$oauth_new = (bool) get_user_meta($user_id, 'oauth_new', true);
$password = trim((string) wp_unslash($_POST['password'] ?? ''));
$password2 = trim((string) wp_unslash($_POST['password2'] ?? ''));
if (function_exists('aksrt_require_captcha')) {
$captcha = aksrt_require_captcha('change_password', wp_unslash($_POST));
if (function_exists('jio_require_captcha')) {
$captcha = jio_require_captcha('change_password', wp_unslash($_POST));
if ($captcha !== true) {
wp_send_json_error(aksrt_account_captcha_error_data($captcha));
wp_send_json_error(jio_account_captcha_error_data($captcha));
}
}
if (!$oauth_new) {
$old_password = trim((string) wp_unslash($_POST['passwordold'] ?? ''));
if ($old_password === '') {
wp_send_json_error(['message' => __('请输入原密码', 'aksrt')]);
wp_send_json_error(['message' => __('请输入原密码', 'jio')]);
}
if ($old_password === $password) {
wp_send_json_error(['message' => __('新密码和原密码不能相同', 'aksrt')]);
wp_send_json_error(['message' => __('新密码和原密码不能相同', 'jio')]);
}
if (class_exists('\AKSRT\Extensions\SecurityHardening') && ($wait = \AKSRT\Extensions\SecurityHardening::error_frequency_wait()) > 0) {
wp_send_json_error(['message' => sprintf(__('验证错误次数过多,请 %d 秒后再试', 'aksrt'), $wait)]);
if (class_exists('\Jio\Extensions\SecurityHardening') && ($wait = \Jio\Extensions\SecurityHardening::error_frequency_wait()) > 0) {
wp_send_json_error(['message' => sprintf(__('验证错误次数过多,请 %d 秒后再试', 'jio'), $wait)]);
}
if (!wp_check_password($old_password, $user->user_pass, $user_id)) {
if (class_exists('\AKSRT\Extensions\SecurityHardening')) {
\AKSRT\Extensions\SecurityHardening::error_frequency_record();
if (class_exists('\Jio\Extensions\SecurityHardening')) {
\Jio\Extensions\SecurityHardening::error_frequency_record();
}
wp_send_json_error(['message' => __('原密码错误', 'aksrt')]);
wp_send_json_error(['message' => __('原密码错误', 'jio')]);
}
}
$valid = class_exists('\AKSRT\Auth\Service')
? \AKSRT\Auth\Service::validate_password($password, $password2)
: __('认证服务不可用', 'aksrt');
$valid = class_exists('\Jio\Auth\Service')
? \Jio\Auth\Service::validate_password($password, $password2)
: __('认证服务不可用', 'jio');
if ($valid !== true) {
wp_send_json_error(['message' => (string) $valid]);
}
@@ -266,65 +266,65 @@ add_action('wp_ajax_aksrt_change_password', function (): void {
}
delete_user_meta($user_id, 'oauth_new');
if (class_exists('\AKSRT\Extensions\SecurityHardening')) {
\AKSRT\Extensions\SecurityHardening::error_frequency_clear();
if (class_exists('\Jio\Extensions\SecurityHardening')) {
\Jio\Extensions\SecurityHardening::error_frequency_clear();
}
wp_send_json_success([
'message' => $oauth_new
? __('密码设置成功', 'aksrt')
: __('修改成功,下次请使用新密码登录', 'aksrt'),
? __('密码设置成功', 'jio')
: __('修改成功,下次请使用新密码登录', 'jio'),
'reload' => true,
]);
});
add_action('wp_ajax_aksrt_change_email', function (): void {
add_action('wp_ajax_jio_change_email', function (): void {
if (
!isset($_POST['_settings_nonce'])
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_settings_nonce'])), 'aksrt_account_settings')
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_settings_nonce'])), 'jio_account_settings')
) {
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'aksrt')]);
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'jio')]);
}
$user_id = get_current_user_id();
$user = wp_get_current_user();
if (!$user_id || !($user instanceof WP_User)) {
wp_send_json_error(['message' => __('请先登录', 'aksrt')]);
wp_send_json_error(['message' => __('请先登录', 'jio')]);
}
$new_email = sanitize_email((string) wp_unslash($_POST['new_email'] ?? ''));
if (!is_email($new_email)) {
wp_send_json_error(['message' => __('邮箱格式错误', 'aksrt')]);
wp_send_json_error(['message' => __('邮箱格式错误', 'jio')]);
}
if ($user->user_email !== '' && strtolower($new_email) === strtolower((string) $user->user_email)) {
wp_send_json_error(['message' => __('修改邮箱不能与现邮箱相同', 'aksrt')]);
wp_send_json_error(['message' => __('修改邮箱不能与现邮箱相同', 'jio')]);
}
if (email_exists($new_email)) {
wp_send_json_error(['message' => __('该邮箱已有绑定账号', 'aksrt')]);
wp_send_json_error(['message' => __('该邮箱已有绑定账号', 'jio')]);
}
$agreement = function_exists('aksrt_get_auth_agreement_view') ? aksrt_get_auth_agreement_view() : ['enabled' => false, 'required' => false];
$agreement = function_exists('jio_get_auth_agreement_view') ? jio_get_auth_agreement_view() : ['enabled' => false, 'required' => false];
if (!empty($agreement['required']) && empty($_POST['agree_terms'])) {
wp_send_json_error(['message' => __('请先同意相关协议', 'aksrt')]);
wp_send_json_error(['message' => __('请先同意相关协议', 'jio')]);
}
if (function_exists('aksrt_require_captcha')) {
$captcha = aksrt_require_captcha('change_email', wp_unslash($_POST));
if (function_exists('jio_require_captcha')) {
$captcha = jio_require_captcha('change_email', wp_unslash($_POST));
if ($captcha !== true) {
wp_send_json_error(aksrt_account_captcha_error_data($captcha));
wp_send_json_error(jio_account_captcha_error_data($captcha));
}
}
$verification_required = aksrt_account_email_verification_required();
$verification_required = jio_account_email_verification_required();
$old_email = (string) $user->user_email;
if (
$old_email !== ''
&& $verification_required
&& !aksrt_account_consume_proof($user_id, 'email_old', $old_email, false)
&& !jio_account_consume_proof($user_id, 'email_old', $old_email, false)
) {
wp_send_json_error(['message' => __('请先验证老邮箱', 'aksrt')]);
wp_send_json_error(['message' => __('请先验证老邮箱', 'jio')]);
}
if (
$verification_required
&& !aksrt_account_consume_code(
&& !jio_account_consume_code(
$user_id,
'change_email',
$new_email,
@@ -332,29 +332,29 @@ add_action('wp_ajax_aksrt_change_email', function (): void {
false
)
) {
if (class_exists('\AKSRT\Extensions\SecurityHardening')) {
\AKSRT\Extensions\SecurityHardening::error_frequency_record();
if (class_exists('\Jio\Extensions\SecurityHardening')) {
\Jio\Extensions\SecurityHardening::error_frequency_record();
}
wp_send_json_error(['message' => __('验证码错误或已过期', 'aksrt')]);
wp_send_json_error(['message' => __('验证码错误或已过期', 'jio')]);
}
$result = wp_update_user(['ID' => $user_id, 'user_email' => $new_email]);
if (is_wp_error($result)) {
wp_send_json_error(['message' => $result->get_error_message() ?: __('邮箱更新失败,请稍后重试', 'aksrt')]);
wp_send_json_error(['message' => $result->get_error_message() ?: __('邮箱更新失败,请稍后重试', 'jio')]);
}
if ($old_email !== '' && $verification_required) {
delete_transient(aksrt_account_proof_key($user_id, 'email_old'));
delete_transient(jio_account_proof_key($user_id, 'email_old'));
}
if ($verification_required) {
delete_transient(aksrt_account_code_key($user_id, 'change_email', $new_email));
delete_transient(jio_account_code_key($user_id, 'change_email', $new_email));
}
if (class_exists('\AKSRT\Extensions\SecurityHardening')) {
\AKSRT\Extensions\SecurityHardening::error_frequency_clear();
if (class_exists('\Jio\Extensions\SecurityHardening')) {
\Jio\Extensions\SecurityHardening::error_frequency_clear();
}
update_user_meta($user_id, 'aksrt_email_verified', 1);
if ($old_email !== '' && is_email($old_email) && class_exists('\AKSRT\Settings\Settings')) {
\AKSRT\Settings\Settings::send_event_email('change_notice', $old_email, [
update_user_meta($user_id, 'jio_email_verified', 1);
if ($old_email !== '' && is_email($old_email) && class_exists('\Jio\Settings\Settings')) {
\Jio\Settings\Settings::send_event_email('change_notice', $old_email, [
'{username}' => $user->display_name,
'{site_name}' => get_bloginfo('name'),
'{new_email}' => $new_email,
@@ -362,7 +362,7 @@ add_action('wp_ajax_aksrt_change_email', function (): void {
}
wp_send_json_success([
'message' => $old_email !== '' ? __('邮箱修改成功', 'aksrt') : __('邮箱绑定成功', 'aksrt'),
'message' => $old_email !== '' ? __('邮箱修改成功', 'jio') : __('邮箱绑定成功', 'jio'),
'reload' => true,
]);
});
+57 -57
View File
@@ -2,7 +2,7 @@
/**
* User rewrite/routing/bootstrap flush + author redirects
*
* @package AKSRT
* @package Jio
*/
defined('ABSPATH') || exit;
@@ -13,10 +13,10 @@ defined('ABSPATH') || exit;
// --- 3a. /user/{昵称} 自定义重写 ---
add_filter('query_vars', function ($vars) {
$vars[] = 'aksrt_user_center';
$vars[] = 'aksrt_user_center_tab';
$vars[] = 'aksrt_author_identifier';
$vars[] = 'aksrt_message_view';
$vars[] = 'jio_user_center';
$vars[] = 'jio_user_center_tab';
$vars[] = 'jio_author_identifier';
$vars[] = 'jio_message_view';
return $vars;
});
@@ -32,7 +32,7 @@ add_action('template_redirect', function () {
nocache_headers();
return;
}
if (!get_query_var('aksrt_message_view') && is_page() && get_page_template_slug(get_queried_object_id()) === 'templates/pages/page-messages.php') {
if (!get_query_var('jio_message_view') && is_page() && get_page_template_slug(get_queried_object_id()) === 'templates/pages/page-messages.php') {
global $wp_query;
if ($wp_query instanceof WP_Query) { $wp_query->set_404(); }
status_header(404);
@@ -40,7 +40,7 @@ add_action('template_redirect', function () {
return;
}
$resolved_path = aksrt_get_current_special_template_path();
$resolved_path = jio_get_current_special_template_path();
if ($resolved_path === '') {
return;
}
@@ -56,13 +56,13 @@ add_action('template_redirect', function () {
if (is_admin() || wp_doing_ajax()) {
return;
}
$tab = (string) get_query_var('aksrt_user_center_tab');
$tab = (string) get_query_var('jio_user_center_tab');
if ($tab === '') {
return;
}
$tab = $tab === 'balance' ? 'credits' : sanitize_key($tab);
$allowed = class_exists('\\AKSRT\\User\\Center')
? array_keys(\AKSRT\User\Center::get_instance()->get_dashboard_tabs())
$allowed = class_exists('\\Jio\\User\\Center')
? array_keys(\Jio\User\Center::get_instance()->get_dashboard_tabs())
: ['profile', 'level', 'creator', 'posts', 'follow', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'revenue', 'msg', 'settings'];
if (!in_array($tab, $allowed, true)) {
global $wp_query;
@@ -73,34 +73,34 @@ add_action('template_redirect', function () {
}, 1);
add_action('init', function () {
add_rewrite_tag('%aksrt_user_center%', '([^&]+)');
add_rewrite_tag('%aksrt_user_center_tab%', '([^/]+)');
add_rewrite_tag('%aksrt_author_identifier%', '([^/]+)');
add_rewrite_tag('%aksrt_message_view%', '(unread|posts|like|system)');
$message_slug = preg_quote(aksrt_get_messages_rewrite_slug(), '#');
add_rewrite_rule('^' . $message_slug . '/?$', 'index.php?aksrt_message_view=unread', 'top');
add_rewrite_rule('^' . $message_slug . '/(posts|like|system)/?$', 'index.php?aksrt_message_view=$matches[1]', 'top');
add_rewrite_rule('^user/([a-z0-9_-]+)/?$', 'index.php?aksrt_user_center=1&aksrt_user_center_tab=$matches[1]', 'top');
add_rewrite_rule('^author/([^/]+)/?$', 'index.php?aksrt_author_identifier=$matches[1]', 'top');
add_rewrite_tag('%jio_user_center%', '([^&]+)');
add_rewrite_tag('%jio_user_center_tab%', '([^/]+)');
add_rewrite_tag('%jio_author_identifier%', '([^/]+)');
add_rewrite_tag('%jio_message_view%', '(unread|posts|like|system)');
$message_slug = preg_quote(jio_get_messages_rewrite_slug(), '#');
add_rewrite_rule('^' . $message_slug . '/?$', 'index.php?jio_message_view=unread', 'top');
add_rewrite_rule('^' . $message_slug . '/(posts|like|system)/?$', 'index.php?jio_message_view=$matches[1]', 'top');
add_rewrite_rule('^user/([a-z0-9_-]+)/?$', 'index.php?jio_user_center=1&jio_user_center_tab=$matches[1]', 'top');
add_rewrite_rule('^author/([^/]+)/?$', 'index.php?jio_author_identifier=$matches[1]', 'top');
});
// --- 3b. 统一模板拦截器(核心)---
// 拦截所有使用主题特殊模板的页面请求,确保正确加载
add_filter('template_include', function ($template) {
$resolved_path = aksrt_get_current_special_template_path();
$resolved_path = jio_get_current_special_template_path();
if ($resolved_path !== '') {
return $resolved_path;
}
// A) /user/{昵称} even if special-path helper returned empty (user missing → 404).
$identifier = (string) get_query_var('aksrt_author_identifier');
$identifier = (string) get_query_var('jio_author_identifier');
if ($identifier !== '') {
$user = function_exists('aksrt_resolve_public_user') ? aksrt_resolve_public_user($identifier) : null;
$user = function_exists('jio_resolve_public_user') ? jio_resolve_public_user($identifier) : null;
if ($user instanceof WP_User) {
$tpl = aksrt_locate_template_file('templates/pages/page-user-home.php');
$tpl = jio_locate_template_file('templates/pages/page-user-home.php');
if ($tpl) {
global $aksrt_profile_user;
$aksrt_profile_user = $user;
global $jio_profile_user;
$jio_profile_user = $user;
return $tpl;
}
}
@@ -122,7 +122,7 @@ add_filter('template_include', function ($template) {
$slug = (string) get_post_field('post_name', $page_id);
$page_template = get_post_meta($page_id, '_wp_page_template', true);
if (is_string($page_template) && strpos($page_template, 'templates/pages/') === 0) {
$tpl = aksrt_locate_template_file($page_template);
$tpl = jio_locate_template_file($page_template);
if ($tpl) {
return $tpl;
}
@@ -134,13 +134,13 @@ add_filter('template_include', function ($template) {
}, 99);
add_filter('template_include', function ($template) {
$resolved_path = aksrt_get_current_special_template_path();
$resolved_path = jio_get_current_special_template_path();
if ($resolved_path !== '') {
return $resolved_path;
}
if (get_query_var('aksrt_user_center')) {
$profile_template = aksrt_locate_template_file('templates/pages/page-profile.php');
if (get_query_var('jio_user_center')) {
$profile_template = jio_locate_template_file('templates/pages/page-profile.php');
if ($profile_template) {
return $profile_template;
}
@@ -150,13 +150,13 @@ add_filter('template_include', function ($template) {
$page_id = get_queried_object_id();
if ($page_id > 0) {
$page_template = get_post_meta($page_id, '_wp_page_template', true);
$resolved_template = aksrt_resolve_page_template_file(
$resolved_template = jio_resolve_page_template_file(
is_string($page_template) ? $page_template : '',
(string) get_post_field('post_name', $page_id)
);
if ($resolved_template !== '') {
$resolved_path = aksrt_locate_template_file($resolved_template);
$resolved_path = jio_locate_template_file($resolved_template);
if ($resolved_path) {
return $resolved_path;
}
@@ -171,26 +171,26 @@ add_filter('template_include', function ($template) {
// 四、自动维护 + flush
// ============================================================
add_action('init', function () {
global $_aksrt_special_templates;
global $_jio_special_templates;
// 后台/AJAX:检查并创建缺失页面(含 profile 用户中心)
$pages_bootstrapped = get_option('aksrt_template_pages_bootstrapped');
$requested_template_key = (!is_admin() && !wp_doing_ajax()) ? aksrt_get_requested_template_key() : '';
if (is_admin() || wp_doing_ajax() || $pages_bootstrapped !== AKSRT_VERSION) {
foreach ($_aksrt_special_templates as $key => $cfg) {
aksrt_ensure_template_page($key);
$pages_bootstrapped = get_option('jio_template_pages_bootstrapped');
$requested_template_key = (!is_admin() && !wp_doing_ajax()) ? jio_get_requested_template_key() : '';
if (is_admin() || wp_doing_ajax() || $pages_bootstrapped !== JIO_VERSION) {
foreach ($_jio_special_templates as $key => $cfg) {
jio_ensure_template_page($key);
}
if ($pages_bootstrapped !== AKSRT_VERSION) {
update_option('aksrt_template_pages_bootstrapped', AKSRT_VERSION);
if ($pages_bootstrapped !== JIO_VERSION) {
update_option('jio_template_pages_bootstrapped', JIO_VERSION);
}
} elseif ($requested_template_key !== '') {
aksrt_ensure_template_page($requested_template_key);
jio_ensure_template_page($requested_template_key);
}
// 统一 flush 检查 — bump when user-home rewrite / author override changes
$rewrite_version = AKSRT_VERSION . ':message-routing:' . aksrt_get_messages_rewrite_slug();
$flushed = get_option('aksrt_user_rules_flushed');
$rewrite_version = JIO_VERSION . ':message-routing:' . jio_get_messages_rewrite_slug();
$flushed = get_option('jio_user_rules_flushed');
$rules = get_option('rewrite_rules');
$need_flush = ($flushed !== $rewrite_version)
|| !is_array($rules)
@@ -206,37 +206,37 @@ add_action('init', function () {
if ($need_flush) {
flush_rewrite_rules(true);
update_option('aksrt_user_rules_flushed', $rewrite_version);
update_option('jio_user_rules_flushed', $rewrite_version);
}
});
// 页面变更时清缓存
add_action('save_post', function ($pid) { if (get_post_type($pid) === 'page') aksrt_clear_template_page_cache(); });
add_action('delete_post', function ($pid) { if (get_post_type($pid) === 'page') aksrt_clear_template_page_cache(); });
add_action('save_post', function ($pid) { if (get_post_type($pid) === 'page') jio_clear_template_page_cache(); });
add_action('delete_post', function ($pid) { if (get_post_type($pid) === 'page') jio_clear_template_page_cache(); });
// ============================================================
// 六、作者链接改写 — 强制覆盖 WP 默认 /author/{slug}/
// ============================================================
add_filter('author_link', function ($link, $author_id) {
$author_id = (int) $author_id;
if ($author_id > 0 && function_exists('aksrt_get_user_home_url')) {
return aksrt_get_user_home_url($author_id);
if ($author_id > 0 && function_exists('jio_get_user_home_url')) {
return jio_get_user_home_url($author_id);
}
$user = get_userdata($author_id);
$slug = $user ? $user->user_nicename : ('user-' . max(0, $author_id));
if (!get_option('permalink_structure')) {
return add_query_arg('aksrt_author', rawurlencode($slug), home_url('/'));
return add_query_arg('jio_author', rawurlencode($slug), home_url('/'));
}
return home_url('/author/' . trailingslashit($slug));
}, 99, 2);
// Accept ?user_nicename= when pretty rewrites are unavailable.
add_filter('request', function ($query_vars) {
if (empty($query_vars['aksrt_author_identifier']) && !empty($_GET['aksrt_author'])) {
$query_vars['aksrt_author_identifier'] = sanitize_text_field(wp_unslash((string) $_GET['aksrt_author']));
if (empty($query_vars['jio_author_identifier']) && !empty($_GET['jio_author'])) {
$query_vars['jio_author_identifier'] = sanitize_text_field(wp_unslash((string) $_GET['jio_author']));
}
if (empty($query_vars['aksrt_user_center']) && isset($_GET['aksrt_user_center'])) {
$query_vars['aksrt_user_center'] = '1';
if (empty($query_vars['jio_user_center']) && isset($_GET['jio_user_center'])) {
$query_vars['jio_user_center'] = '1';
}
return $query_vars;
});
@@ -256,8 +256,8 @@ add_action('template_redirect', function () {
if ($author_id <= 0) {
return;
}
$target = function_exists('aksrt_get_user_home_url')
? aksrt_get_user_home_url($author_id)
$target = function_exists('jio_get_user_home_url')
? jio_get_user_home_url($author_id)
: home_url('/user/');
if ($target === '' || $target === home_url('/')) {
return;
@@ -274,15 +274,15 @@ add_action('template_redirect', function () {
if (empty($_GET['author'])) {
return;
}
if (get_query_var('aksrt_author_identifier') || get_query_var('aksrt_user_center')) {
if (get_query_var('jio_author_identifier') || get_query_var('jio_user_center')) {
return;
}
if (is_author()) {
return; // handled above
}
$author_id = (int) $_GET['author'];
if ($author_id > 0 && function_exists('aksrt_get_user_home_url')) {
wp_safe_redirect(aksrt_get_user_home_url($author_id), 301);
if ($author_id > 0 && function_exists('jio_get_user_home_url')) {
wp_safe_redirect(jio_get_user_home_url($author_id), 301);
exit;
}
}, 2);
+52 -52
View File
@@ -2,7 +2,7 @@
/**
* User template registry + template utils
*
* @package AKSRT
* @package Jio
*/
defined('ABSPATH') || exit;
@@ -12,7 +12,7 @@ defined('ABSPATH') || exit;
// 修改此处即可增删模板页面,无需改动其他逻辑
// ============================================================
// Only true fixed template pages live in the registry.
$_aksrt_special_templates = [
$_jio_special_templates = [
'sign' => [
'file' => 'templates/pages/page-sign.php',
'slug' => 'sign',
@@ -46,7 +46,7 @@ $_aksrt_special_templates = [
];
/** @var array 缓存 key=模板文件路径 => value=WP_Post|null */
$_aksrt_template_page_cache = [];
$_jio_template_page_cache = [];
// ============================================================
@@ -59,10 +59,10 @@ $_aksrt_template_page_cache = [];
* @param string $template_file 相对于主题的模板路径
* @return WP_Post|null
*/
function aksrt_find_template_page(string $template_file) {
global $_aksrt_template_page_cache;
if (isset($_aksrt_template_page_cache[$template_file])) {
return $_aksrt_template_page_cache[$template_file];
function jio_find_template_page(string $template_file) {
global $_jio_template_page_cache;
if (isset($_jio_template_page_cache[$template_file])) {
return $_jio_template_page_cache[$template_file];
}
$page = null;
@@ -76,7 +76,7 @@ function aksrt_find_template_page(string $template_file) {
$page = $pages[0];
}
$_aksrt_template_page_cache[$template_file] = $page;
$_jio_template_page_cache[$template_file] = $page;
return $page;
}
@@ -86,18 +86,18 @@ function aksrt_find_template_page(string $template_file) {
* @param string $key 注册表 key(当前仅 profile 使用)
* @return string 页面 URL 或回退地址
*/
function aksrt_get_template_url(string $key): string {
global $_aksrt_special_templates;
if (!isset($_aksrt_special_templates[$key])) {
function jio_get_template_url(string $key): string {
global $_jio_special_templates;
if (!isset($_jio_special_templates[$key])) {
return home_url('/');
}
$cfg = $_aksrt_special_templates[$key];
$page = aksrt_find_template_page($cfg['file']);
$cfg = $_jio_special_templates[$key];
$page = jio_find_template_page($cfg['file']);
if (!$page) {
aksrt_ensure_template_page($key);
$page = aksrt_find_template_page($cfg['file']);
jio_ensure_template_page($key);
$page = jio_find_template_page($cfg['file']);
}
if ($page) {
@@ -113,18 +113,18 @@ function aksrt_get_template_url(string $key): string {
* @param string $template_file 相对于主题的路径
* @return string|false 文件绝对路径或 false
*/
function aksrt_locate_template_file(string $template_file) {
function jio_locate_template_file(string $template_file) {
$path = locate_template([$template_file]);
if ($path) return $path;
$full = AKSRT_DIR . '/' . $template_file;
$full = JIO_DIR . '/' . $template_file;
return file_exists($full) ? $full : false;
}
/**
* Resolve a public-facing page template file from stored meta or page slug.
*/
function aksrt_resolve_page_template_file(string $template_file = '', string $post_slug = ''): string {
function jio_resolve_page_template_file(string $template_file = '', string $post_slug = ''): string {
$template_file = ltrim($template_file, '/\\');
$post_slug = sanitize_title($post_slug);
@@ -136,7 +136,7 @@ function aksrt_resolve_page_template_file(string $template_file = '', string $po
return $template_file;
}
if (strpos($template_file, 'templates/pages/') === 0 && aksrt_locate_template_file($template_file)) {
if (strpos($template_file, 'templates/pages/') === 0 && jio_locate_template_file($template_file)) {
return $template_file;
}
}
@@ -152,7 +152,7 @@ function aksrt_resolve_page_template_file(string $template_file = '', string $po
'profile' => 'templates/pages/page-profile.php',
];
if (!empty($slug_map[$post_slug]) && aksrt_locate_template_file($slug_map[$post_slug])) {
if (!empty($slug_map[$post_slug]) && jio_locate_template_file($slug_map[$post_slug])) {
return $slug_map[$post_slug];
}
}
@@ -163,7 +163,7 @@ function aksrt_resolve_page_template_file(string $template_file = '', string $po
/**
* Normalize auth view keys used by the unified sign page.
*/
function aksrt_normalize_auth_tab(string $tab): string {
function jio_normalize_auth_tab(string $tab): string {
$tab = sanitize_key($tab);
switch ($tab) {
@@ -185,57 +185,57 @@ function aksrt_normalize_auth_tab(string $tab): string {
/**
* 清除模板页面缓存
*/
function aksrt_clear_template_page_cache(): void {
global $_aksrt_template_page_cache;
$_aksrt_template_page_cache = [];
function jio_clear_template_page_cache(): void {
global $_jio_template_page_cache;
$_jio_template_page_cache = [];
}
/**
* Prepare the public user-home template context and return its template path.
*/
function aksrt_get_user_home_template_path(): string {
global $_aksrt_special_templates, $aksrt_profile_user;
function jio_get_user_home_template_path(): string {
global $_jio_special_templates, $jio_profile_user;
$identifier = (string) get_query_var('aksrt_author_identifier');
$identifier = (string) get_query_var('jio_author_identifier');
if ($identifier === '') {
return '';
}
$user = function_exists('aksrt_resolve_public_user') ? aksrt_resolve_public_user($identifier) : null;
$user = function_exists('jio_resolve_public_user') ? jio_resolve_public_user($identifier) : null;
if (!$user instanceof WP_User) {
return '';
}
$template_path = aksrt_locate_template_file('templates/pages/page-user-home.php');
$template_path = jio_locate_template_file('templates/pages/page-user-home.php');
if (!$template_path) {
return '';
}
$aksrt_profile_user = $user;
$jio_profile_user = $user;
return $template_path;
}
/**
* Resolve the active special-page template path for the current request.
*/
function aksrt_get_current_special_template_path(): string {
if (get_query_var('aksrt_message_view')) {
$message_template = aksrt_locate_template_file('templates/pages/page-messages.php');
function jio_get_current_special_template_path(): string {
if (get_query_var('jio_message_view')) {
$message_template = jio_locate_template_file('templates/pages/page-messages.php');
return $message_template ?: '';
}
if (get_query_var('aksrt_author_identifier')) {
return aksrt_get_user_home_template_path();
if (get_query_var('jio_author_identifier')) {
return jio_get_user_home_template_path();
}
if (get_query_var('aksrt_user_center')) {
$profile_template = aksrt_locate_template_file('templates/pages/page-profile.php');
if (get_query_var('jio_user_center')) {
$profile_template = jio_locate_template_file('templates/pages/page-profile.php');
return $profile_template ?: '';
}
if (get_query_var('aksrt_sign')) {
$auth_template_path = aksrt_locate_template_file('templates/pages/page-sign.php');
if (get_query_var('jio_sign')) {
$auth_template_path = jio_locate_template_file('templates/pages/page-sign.php');
return $auth_template_path ?: '';
}
@@ -243,13 +243,13 @@ function aksrt_get_current_special_template_path(): string {
$page_id = get_queried_object_id();
if ($page_id > 0) {
$page_template = get_post_meta($page_id, '_wp_page_template', true);
$resolved_template = aksrt_resolve_page_template_file(
$resolved_template = jio_resolve_page_template_file(
is_string($page_template) ? $page_template : '',
(string) get_post_field('post_name', $page_id)
);
if ($resolved_template !== '') {
$resolved_path = aksrt_locate_template_file($resolved_template);
$resolved_path = jio_locate_template_file($resolved_template);
if ($resolved_path) {
return $resolved_path;
}
@@ -265,8 +265,8 @@ function aksrt_get_current_special_template_path(): string {
*
* 用于前台直接访问固定 slug 时的自动补页。
*/
function aksrt_get_requested_template_key(): string {
global $_aksrt_special_templates;
function jio_get_requested_template_key(): string {
global $_jio_special_templates;
$request_uri = isset($_SERVER['REQUEST_URI']) ? (string) $_SERVER['REQUEST_URI'] : '';
if ($request_uri === '') {
@@ -288,7 +288,7 @@ function aksrt_get_requested_template_key(): string {
return '';
}
foreach ($_aksrt_special_templates as $key => $cfg) {
foreach ($_jio_special_templates as $key => $cfg) {
$slug = isset($cfg['slug']) ? sanitize_title((string) $cfg['slug']) : '';
if ($slug !== '' && $slug === $request_slug) {
return (string) $key;
@@ -303,23 +303,23 @@ function aksrt_get_requested_template_key(): string {
*
* @param string $key 注册表 key
*/
function aksrt_ensure_template_page(string $key): void {
global $_aksrt_special_templates;
if (!isset($_aksrt_special_templates[$key])) return;
function jio_ensure_template_page(string $key): void {
global $_jio_special_templates;
if (!isset($_jio_special_templates[$key])) return;
$cfg = $_aksrt_special_templates[$key];
$cfg = $_jio_special_templates[$key];
if (array_key_exists('auto_create', $cfg) && empty($cfg['auto_create'])) {
return;
}
$desired_slug = sanitize_title($cfg['slug'] ?? $key);
// 已有页面使用此模板?仍校验模板 meta,避免空白默认页。
$found_page = aksrt_find_template_page($cfg['file']);
$found_page = jio_find_template_page($cfg['file']);
if ($found_page instanceof WP_Post) {
$current_tpl = get_post_meta((int) $found_page->ID, '_wp_page_template', true);
if ($current_tpl !== $cfg['file']) {
update_post_meta((int) $found_page->ID, '_wp_page_template', $cfg['file']);
aksrt_clear_template_page_cache();
jio_clear_template_page_cache();
}
return;
}
@@ -346,8 +346,8 @@ function aksrt_ensure_template_page(string $key): void {
if (!is_wp_error($page_id) && $page_id > 0) {
update_post_meta($page_id, '_wp_page_template', $cfg['file']);
update_post_meta($page_id, '_aksrt_managed_template_page', (string) $key);
aksrt_clear_template_page_cache();
update_post_meta($page_id, '_jio_managed_template_page', (string) $key);
jio_clear_template_page_cache();
}
}
+53 -53
View File
@@ -2,7 +2,7 @@
/**
* User public URL/page API
*
* @package AKSRT
* @package Jio
*/
defined('ABSPATH') || exit;
@@ -11,41 +11,41 @@ defined('ABSPATH') || exit;
// 五、公开 API 函数(兼容旧代码调用)
// ============================================================
if (!function_exists('aksrt_get_user_center_url')) :
if (!function_exists('jio_get_user_center_url')) :
/**
* 获取本人中心 URL(私有空间入口)
*
* @param string $tab 可选 tab 参数
* @return string
*/
function aksrt_get_user_center_url(string $tab = ''): string {
function jio_get_user_center_url(string $tab = ''): string {
$tab = sanitize_key($tab ?: 'vip');
$aliases = ['assets' => 'credits', 'signin' => 'credits', 'revenue' => 'revenue'];
$tab = $aliases[$tab] ?? $tab;
$path_tab = $tab === 'credits' ? 'balance' : $tab;
return get_option('permalink_structure')
? home_url('/user/' . trailingslashit($path_tab))
: add_query_arg(['aksrt_user_center' => '1', 'aksrt_user_center_tab' => $tab], home_url('/'));
: add_query_arg(['jio_user_center' => '1', 'jio_user_center_tab' => $tab], home_url('/'));
}
endif;
if (!function_exists('aksrt_get_new_post_url')) :
if (!function_exists('jio_get_new_post_url')) :
/**
* 前台写文章/投稿页 URL(模板 templates/pages/page-submit.php)。
*
* @param int $edit_id 编辑中的文章 ID;0 表示新建。
* @return string 未指派页面时返回空串。
*/
function aksrt_get_new_post_url(int $edit_id = 0): string {
if (class_exists('\AKSRT\Settings\Settings')) {
$submit = \AKSRT\Settings\Settings::get_submit_settings();
function jio_get_new_post_url(int $edit_id = 0): string {
if (class_exists('\Jio\Settings\Settings')) {
$submit = \Jio\Settings\Settings::get_submit_settings();
if (isset($submit['enabled']) && empty($submit['enabled'])) {
return '';
}
}
$url = function_exists('aksrt_get_template_url')
? aksrt_get_template_url('submit')
$url = function_exists('jio_get_template_url')
? jio_get_template_url('submit')
: home_url('/submit/');
if ($edit_id > 0) {
$url = add_query_arg('edit', $edit_id, $url);
@@ -54,21 +54,21 @@ function aksrt_get_new_post_url(int $edit_id = 0): string {
}
endif;
if (!function_exists('aksrt_get_messages_rewrite_slug')) :
if (!function_exists('jio_get_messages_rewrite_slug')) :
/** 获取消息中心当前唯一的重写别名。 */
function aksrt_get_messages_rewrite_slug(): string {
$settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::notification_settings()
function jio_get_messages_rewrite_slug(): string {
$settings = class_exists('\Jio\Settings\Settings')
? \Jio\Settings\Settings::notification_settings()
: [];
$slug = sanitize_key((string) ($settings['slug'] ?? 'messages'));
return $slug !== '' ? $slug : 'messages';
}
endif;
if (!function_exists('aksrt_get_messages_page_url')) :
if (!function_exists('jio_get_messages_page_url')) :
/** 消息中心 URL。 */
function aksrt_get_messages_page_url(string $view = 'unread'): string {
if (class_exists('\AKSRT\Settings\Settings') && !\AKSRT\Settings\Settings::message_enabled()) {
function jio_get_messages_page_url(string $view = 'unread'): string {
if (class_exists('\Jio\Settings\Settings') && !\Jio\Settings\Settings::message_enabled()) {
return '';
}
$suffixes = [
@@ -79,21 +79,21 @@ function aksrt_get_messages_page_url(string $view = 'unread'): string {
];
$view = sanitize_key($view);
$suffix = $suffixes[$view] ?? $suffixes['unread'];
$path = '/' . aksrt_get_messages_rewrite_slug() . ($suffix !== '' ? '/' . $suffix : '') . '/';
$path = '/' . jio_get_messages_rewrite_slug() . ($suffix !== '' ? '/' . $suffix : '') . '/';
return home_url($path);
}
endif;
if (!function_exists('aksrt_get_user_home_url')) :
if (!function_exists('jio_get_user_home_url')) :
/**
* 获取公开用户主页 URL(/user/{nicename}/)
*
* @param WP_User|int|string|null $user 用户对象、ID、nicename 或 null(当前用户)
* @return string
*/
function aksrt_get_user_home_url($user = null): string {
function jio_get_user_home_url($user = null): string {
$target = null;
$mode = class_exists('\\AKSRT\\Settings\\Settings') ? (string) (\AKSRT\Settings\Settings::get_user_home_settings()['route_identifier'] ?? 'nicename') : 'nicename';
$mode = class_exists('\\Jio\\Settings\\Settings') ? (string) (\Jio\Settings\Settings::get_user_home_settings()['route_identifier'] ?? 'nicename') : 'nicename';
if ($user instanceof WP_User) {
$target = $user;
} elseif (is_int($user) && $user > 0) {
@@ -110,15 +110,15 @@ function aksrt_get_user_home_url($user = null): string {
}
$identifier = $mode === 'uid' ? (string) $target->ID : $target->user_nicename;
if (!get_option('permalink_structure')) {
return add_query_arg('aksrt_author', rawurlencode($identifier), home_url('/'));
return add_query_arg('jio_author', rawurlencode($identifier), home_url('/'));
}
return home_url('/author/' . trailingslashit($identifier));
}
endif;
if (!function_exists('aksrt_resolve_public_user')) :
function aksrt_resolve_public_user(string $identifier): ?WP_User {
$mode = class_exists('\\AKSRT\\Settings\\Settings') ? (string) (\AKSRT\Settings\Settings::get_user_home_settings()['route_identifier'] ?? 'nicename') : 'nicename';
if (!function_exists('jio_resolve_public_user')) :
function jio_resolve_public_user(string $identifier): ?WP_User {
$mode = class_exists('\\Jio\\Settings\\Settings') ? (string) (\Jio\Settings\Settings::get_user_home_settings()['route_identifier'] ?? 'nicename') : 'nicename';
if ($mode === 'uid') {
return ctype_digit($identifier) && (int) $identifier > 0 ? get_userdata((int) $identifier) ?: null : null;
}
@@ -126,35 +126,35 @@ function aksrt_resolve_public_user(string $identifier): ?WP_User {
}
endif;
if (!function_exists('aksrt_is_user_center_page')) :
if (!function_exists('jio_is_user_center_page')) :
/**
* 判断当前是否为本人中心页面
*/
function aksrt_is_user_center_page(): bool {
return (bool) get_query_var('aksrt_user_center')
|| (is_page_template('templates/pages/page-profile.php') && !(bool) get_query_var('aksrt_author_identifier'));
function jio_is_user_center_page(): bool {
return (bool) get_query_var('jio_user_center')
|| (is_page_template('templates/pages/page-profile.php') && !(bool) get_query_var('jio_author_identifier'));
}
endif;
if (!function_exists('aksrt_is_user_home_page')) :
if (!function_exists('jio_is_user_home_page')) :
/**
* 判断当前是否为公开用户主页
*/
function aksrt_is_user_home_page(): bool {
return (bool) get_query_var('aksrt_author_identifier')
function jio_is_user_home_page(): bool {
return (bool) get_query_var('jio_author_identifier')
|| is_page_template('templates/pages/page-user-home.php');
}
endif;
if (!function_exists('aksrt_get_sign_page_url')) :
if (!function_exists('jio_get_sign_page_url')) :
/**
* Get the only public authentication page URL.
*
* @param string $tab
* @param array<string, scalar> $args
*/
function aksrt_get_sign_page_url(string $tab = 'signin', array $args = []): string {
$tab = aksrt_normalize_auth_tab($tab);
function jio_get_sign_page_url(string $tab = 'signin', array $args = []): string {
$tab = jio_normalize_auth_tab($tab);
return add_query_arg(['tab' => $tab] + $args, home_url('/sign/'));
}
@@ -162,16 +162,16 @@ function aksrt_get_sign_page_url(string $tab = 'signin', array $args = []): stri
/**
* Determine whether the current request is served by the unified auth experience.
*/
function aksrt_is_auth_page_request(): bool {
return (bool) get_query_var('aksrt_sign')
function jio_is_auth_page_request(): bool {
return (bool) get_query_var('jio_sign')
|| is_page_template('templates/pages/page-sign.php');
}
endif;
if (!function_exists('aksrt_get_login_url')) :
if (!function_exists('jio_get_login_url')) :
/** 获取登录页 URL */
function aksrt_get_login_url($redirect = '') {
$url = aksrt_get_sign_page_url('signin');
function jio_get_login_url($redirect = '') {
$url = jio_get_sign_page_url('signin');
if ($redirect) {
$url = add_query_arg('redirect_to', urlencode($redirect), $url);
}
@@ -179,17 +179,17 @@ function aksrt_get_login_url($redirect = '') {
}
endif;
if (!function_exists('aksrt_get_register_url')) :
if (!function_exists('jio_get_register_url')) :
/** 获取注册页 URL */
function aksrt_get_register_url() {
return aksrt_get_sign_page_url('signup');
function jio_get_register_url() {
return jio_get_sign_page_url('signup');
}
endif;
if (!function_exists('aksrt_get_bind_url')) :
if (!function_exists('jio_get_bind_url')) :
/** 获取绑定账号页面 URL */
function aksrt_get_bind_url($transient_key = '') {
$url = aksrt_get_sign_page_url('bind');
function jio_get_bind_url($transient_key = '') {
$url = jio_get_sign_page_url('bind');
if ($transient_key) {
$url = add_query_arg('obk', $transient_key, $url);
}
@@ -197,31 +197,31 @@ function aksrt_get_bind_url($transient_key = '') {
}
endif;
if (!function_exists('aksrt_get_logout_url')) :
if (!function_exists('jio_get_logout_url')) :
/** 获取唯一退出登录 URL。 */
function aksrt_get_logout_url($redirect = '') {
function jio_get_logout_url($redirect = '') {
$target = is_string($redirect) && $redirect !== '' ? $redirect : home_url('/');
$url = add_query_arg(
['redirect_to' => $target],
home_url('/logout/')
);
return wp_nonce_url($url, 'aksrt-logout');
return wp_nonce_url($url, 'jio-logout');
}
endif;
if (!function_exists('aksrt_get_reset_password_url')) :
if (!function_exists('jio_get_reset_password_url')) :
/**
* 获取重置密码页面 URL
*
* @return string
*/
function aksrt_get_reset_password_url(): string {
return aksrt_get_sign_page_url('resetpassword');
function jio_get_reset_password_url(): string {
return jio_get_sign_page_url('resetpassword');
}
endif;
// Notifications live in the same user/ domain; bootstrap also loads it.
if (!class_exists('AKSRT_User_Notifications', false) /* procedural module */ && file_exists(dirname(__DIR__) . '/user-notifications.php')) {
if (!class_exists('JIO_User_Notifications', false) /* procedural module */ && file_exists(dirname(__DIR__) . '/user-notifications.php')) {
require_once dirname(__DIR__) . '/user-notifications.php';
}