Files
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

228 lines
7.0 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* User public URL/page API
*
* @package Jio
*/
defined('ABSPATH') || exit;
// ============================================================
// 五、公开 API 函数(兼容旧代码调用)
// ============================================================
if (!function_exists('jio_get_user_center_url')) :
/**
* 获取本人中心 URL(私有空间入口)
*
* @param string $tab 可选 tab 参数
* @return 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(['jio_user_center' => '1', 'jio_user_center_tab' => $tab], home_url('/'));
}
endif;
if (!function_exists('jio_get_new_post_url')) :
/**
* 前台写文章/投稿页 URL(模板 templates/pages/page-submit.php)。
*
* @param int $edit_id 编辑中的文章 ID;0 表示新建。
* @return string 未指派页面时返回空串。
*/
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('jio_get_template_url')
? jio_get_template_url('submit')
: home_url('/submit/');
if ($edit_id > 0) {
$url = add_query_arg('edit', $edit_id, $url);
}
return $url;
}
endif;
if (!function_exists('jio_get_messages_rewrite_slug')) :
/** 获取消息中心当前唯一的重写别名。 */
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('jio_get_messages_page_url')) :
/** 消息中心 URL。 */
function jio_get_messages_page_url(string $view = 'unread'): string {
if (class_exists('\Jio\Settings\Settings') && !\Jio\Settings\Settings::message_enabled()) {
return '';
}
$suffixes = [
'unread' => '',
'posts' => 'posts',
'like' => 'like',
'system' => 'system',
];
$view = sanitize_key($view);
$suffix = $suffixes[$view] ?? $suffixes['unread'];
$path = '/' . jio_get_messages_rewrite_slug() . ($suffix !== '' ? '/' . $suffix : '') . '/';
return home_url($path);
}
endif;
if (!function_exists('jio_get_user_home_url')) :
/**
* 获取公开用户主页 URL(/user/{nicename}/)
*
* @param WP_User|int|string|null $user 用户对象、ID、nicename 或 null(当前用户)
* @return string
*/
function jio_get_user_home_url($user = null): string {
$target = null;
$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) {
$target = get_userdata($user);
} elseif (is_numeric($user) && (int) $user > 0) {
$target = get_userdata((int) $user);
} elseif (is_string($user) && $user) {
$target = get_user_by('slug', $user);
} else {
$target = wp_get_current_user();
}
if (!$target instanceof WP_User || !$target->ID) {
return home_url('/');
}
$identifier = $mode === 'uid' ? (string) $target->ID : $target->user_nicename;
if (!get_option('permalink_structure')) {
return add_query_arg('jio_author', rawurlencode($identifier), home_url('/'));
}
return home_url('/author/' . trailingslashit($identifier));
}
endif;
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;
}
return get_user_by('slug', sanitize_title($identifier)) ?: null;
}
endif;
if (!function_exists('jio_is_user_center_page')) :
/**
* 判断当前是否为本人中心页面
*/
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('jio_is_user_home_page')) :
/**
* 判断当前是否为公开用户主页
*/
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('jio_get_sign_page_url')) :
/**
* Get the only public authentication page URL.
*
* @param string $tab
* @param array<string, scalar> $args
*/
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/'));
}
/**
* Determine whether the current request is served by the unified auth experience.
*/
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('jio_get_login_url')) :
/** 获取登录页 URL */
function jio_get_login_url($redirect = '') {
$url = jio_get_sign_page_url('signin');
if ($redirect) {
$url = add_query_arg('redirect_to', urlencode($redirect), $url);
}
return $url;
}
endif;
if (!function_exists('jio_get_register_url')) :
/** 获取注册页 URL */
function jio_get_register_url() {
return jio_get_sign_page_url('signup');
}
endif;
if (!function_exists('jio_get_bind_url')) :
/** 获取绑定账号页面 URL */
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);
}
return $url;
}
endif;
if (!function_exists('jio_get_logout_url')) :
/** 获取唯一退出登录 URL。 */
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, 'jio-logout');
}
endif;
if (!function_exists('jio_get_reset_password_url')) :
/**
* 获取重置密码页面 URL
*
* @return string
*/
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('JIO_User_Notifications', false) /* procedural module */ && file_exists(dirname(__DIR__) . '/user-notifications.php')) {
require_once dirname(__DIR__) . '/user-notifications.php';
}