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:
1 parent
5b16bc6e15
commit
35bb96e82f
997 files changed
+28216
-28188
No files matched your search
+42
-42
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Auth;
|
||||
namespace Jio\Auth;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -36,23 +36,23 @@ final class OAuth {
|
||||
}, 30);
|
||||
add_action('template_redirect', [$this, 'handle_routes'], 8);
|
||||
add_action('rest_api_init', [$this, 'register_rest_routes']);
|
||||
add_action('wp_ajax_aksrt_oauth_unbind', [$this, 'ajax_unbind']);
|
||||
add_action('wp_ajax_jio_oauth_unbind', [$this, 'ajax_unbind']);
|
||||
}
|
||||
|
||||
public function add_rewrite_rules(): void {
|
||||
add_rewrite_rule('^oauth/start/([a-z0-9_-]+)/?$', 'index.php?aksrt_oauth=start&aksrt_oauth_provider=$matches[1]', 'top');
|
||||
add_rewrite_rule('^oauth/callback/?$', 'index.php?aksrt_oauth=callback', 'top');
|
||||
add_rewrite_rule('^oauth/clogin/?$', 'index.php?aksrt_oauth=clogin', 'top');
|
||||
add_rewrite_rule('^oauth/clogin/callback/?$', 'index.php?aksrt_oauth=clogin_callback', 'top');
|
||||
add_rewrite_rule('^oauth/start/([a-z0-9_-]+)/?$', 'index.php?jio_oauth=start&jio_oauth_provider=$matches[1]', 'top');
|
||||
add_rewrite_rule('^oauth/callback/?$', 'index.php?jio_oauth=callback', 'top');
|
||||
add_rewrite_rule('^oauth/clogin/?$', 'index.php?jio_oauth=clogin', 'top');
|
||||
add_rewrite_rule('^oauth/clogin/callback/?$', 'index.php?jio_oauth=clogin_callback', 'top');
|
||||
add_filter('query_vars', static function (array $vars): array {
|
||||
$vars[] = 'aksrt_oauth';
|
||||
$vars[] = 'aksrt_oauth_provider';
|
||||
$vars[] = 'jio_oauth';
|
||||
$vars[] = 'jio_oauth_provider';
|
||||
return $vars;
|
||||
});
|
||||
}
|
||||
|
||||
public function register_rest_routes(): void {
|
||||
register_rest_route('aksrt/v1', '/oauth/bind-pass', [
|
||||
register_rest_route('jio/v1', '/oauth/bind-pass', [
|
||||
'methods' => 'POST',
|
||||
'callback' => [$this, 'rest_issue_bind_pass'],
|
||||
'permission_callback' => static function (): bool {
|
||||
@@ -68,7 +68,7 @@ final class OAuth {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'oauth_bind_nonce_invalid',
|
||||
'message' => __('安全验证失败,请刷新页面重试', 'aksrt'),
|
||||
'message' => __('安全验证失败,请刷新页面重试', 'jio'),
|
||||
], 403);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ final class OAuth {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'oauth_bind_provider_invalid',
|
||||
'message' => __('该第三方登录方式不可用', 'aksrt'),
|
||||
'message' => __('该第三方登录方式不可用', 'jio'),
|
||||
], 400);
|
||||
}
|
||||
|
||||
@@ -88,25 +88,25 @@ final class OAuth {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'oauth_bind_provider_invalid',
|
||||
'message' => __('该第三方登录方式不可用', 'aksrt'),
|
||||
'message' => __('该第三方登录方式不可用', 'jio'),
|
||||
], 400);
|
||||
}
|
||||
$redirect = OAuthUrlPolicy::validated_redirect((string) ($payload['redirect_to'] ?? ''), home_url('/'));
|
||||
$url = add_query_arg('redirect_to', $redirect, $url);
|
||||
|
||||
if (!aksrt_is_captcha_enabled_for('bind')) {
|
||||
if (!jio_is_captcha_enabled_for('bind')) {
|
||||
return new \WP_REST_Response([
|
||||
'success' => true,
|
||||
'data' => ['url' => $url],
|
||||
], 200);
|
||||
}
|
||||
|
||||
$result = aksrt_require_captcha('bind', $payload);
|
||||
$result = jio_require_captcha('bind', $payload);
|
||||
if ($result !== true) {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => is_wp_error($result) ? $result->get_error_code() : 'aksrt_captcha_failed',
|
||||
'message' => is_wp_error($result) ? $result->get_error_message() : __('人机验证失败,请重试', 'aksrt'),
|
||||
'code' => is_wp_error($result) ? $result->get_error_code() : 'jio_captcha_failed',
|
||||
'message' => is_wp_error($result) ? $result->get_error_message() : __('人机验证失败,请重试', 'jio'),
|
||||
], 400);
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ final class OAuth {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'oauth_bind_pass_issue_failed',
|
||||
'message' => __('无法创建绑定会话,请稍后重试', 'aksrt'),
|
||||
'message' => __('无法创建绑定会话,请稍后重试', 'jio'),
|
||||
], 500);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ final class OAuth {
|
||||
}
|
||||
|
||||
public static function validate_bind_pass(string $token, string $provider, int $user_id, bool $consume = true): bool {
|
||||
if (!aksrt_is_captcha_enabled_for('bind')) {
|
||||
if (!jio_is_captcha_enabled_for('bind')) {
|
||||
return true;
|
||||
}
|
||||
if ($token === '' || $user_id <= 0) {
|
||||
@@ -155,15 +155,15 @@ final class OAuth {
|
||||
}
|
||||
|
||||
public function maybe_flush_rewrite_rules(): void {
|
||||
$version = defined('AKSRT_VERSION') ? AKSRT_VERSION . ':oauth-v2' : 'oauth-v2';
|
||||
if (get_option('aksrt_oauth_routes_flushed') !== $version) {
|
||||
$version = defined('JIO_VERSION') ? JIO_VERSION . ':oauth-v2' : 'oauth-v2';
|
||||
if (get_option('jio_oauth_routes_flushed') !== $version) {
|
||||
flush_rewrite_rules(false);
|
||||
update_option('aksrt_oauth_routes_flushed', $version, false);
|
||||
update_option('jio_oauth_routes_flushed', $version, false);
|
||||
}
|
||||
}
|
||||
|
||||
public function handle_routes(): void {
|
||||
$route = sanitize_key((string) get_query_var('aksrt_oauth'));
|
||||
$route = sanitize_key((string) get_query_var('jio_oauth'));
|
||||
if ($route === '') {
|
||||
return;
|
||||
}
|
||||
@@ -193,7 +193,7 @@ final class OAuth {
|
||||
? OAuthUrlPolicy::validated_redirect((string) wp_unslash($_GET['redirect_to']), home_url('/'))
|
||||
: '';
|
||||
if ($provider === 'weixingzh') {
|
||||
$url = function_exists('aksrt_get_sign_page_url') ? aksrt_get_sign_page_url('oauth') : home_url('/sign/?tab=oauth');
|
||||
$url = function_exists('jio_get_sign_page_url') ? jio_get_sign_page_url('oauth') : home_url('/sign/?tab=oauth');
|
||||
$url = add_query_arg('oauth_intent', $action, $url);
|
||||
return $redirect !== '' ? add_query_arg('redirect_to', $redirect, $url) : $url;
|
||||
}
|
||||
@@ -218,7 +218,7 @@ final class OAuth {
|
||||
$result[] = [
|
||||
'name' => $provider,
|
||||
'label' => OAuthProviderCatalog::label($provider),
|
||||
'icon' => function_exists('aksrt_brand_icon') ? aksrt_brand_icon(OAuthProviderCatalog::icon_key($provider)) : '',
|
||||
'icon' => function_exists('jio_brand_icon') ? jio_brand_icon(OAuthProviderCatalog::icon_key($provider)) : '',
|
||||
// Raw, matching get_frontend_bindings_data(): every surface escapes
|
||||
// once on output. esc_url() is idempotent on its own output, so
|
||||
// escaping here too was redundant rather than broken.
|
||||
@@ -242,7 +242,7 @@ final class OAuth {
|
||||
return '';
|
||||
}
|
||||
|
||||
$large = (bool) \AKSRT\Settings\Settings::get_value('oauth_button_lg', false);
|
||||
$large = (bool) \Jio\Settings\Settings::get_value('oauth_button_lg', false);
|
||||
$html = $title !== ''
|
||||
? '<p class="social-separator separator muted-3-color em09 mt10">' . esc_html($title) . '</p>'
|
||||
: '';
|
||||
@@ -263,10 +263,10 @@ final class OAuth {
|
||||
}
|
||||
$html .= '<a rel="nofollow" href="' . esc_url($url) . '" class="' . esc_attr($class) . '"'
|
||||
. ' data-provider="' . esc_attr($name) . '"'
|
||||
. ' aria-label="' . esc_attr(sprintf(__('%s登录', 'aksrt'), $label)) . '"'
|
||||
. ' title="' . esc_attr(sprintf(__('%s登录', 'aksrt'), $label)) . '">'
|
||||
. ' aria-label="' . esc_attr(sprintf(__('%s登录', 'jio'), $label)) . '"'
|
||||
. ' title="' . esc_attr(sprintf(__('%s登录', 'jio'), $label)) . '">'
|
||||
. $item['icon'] // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
. ($large ? '<span>' . esc_html(sprintf(__('%s登录', 'aksrt'), $label)) . '</span>' : '')
|
||||
. ($large ? '<span>' . esc_html(sprintf(__('%s登录', 'jio'), $label)) . '</span>' : '')
|
||||
. '</a>';
|
||||
}
|
||||
return $html . '</div>';
|
||||
@@ -294,30 +294,30 @@ final class OAuth {
|
||||
}
|
||||
|
||||
public function ajax_unbind(): void {
|
||||
check_ajax_referer('aksrt_oauth_unbind', 'nonce');
|
||||
check_ajax_referer('jio_oauth_unbind', 'nonce');
|
||||
$provider = sanitize_key((string) ($_POST['provider'] ?? ''));
|
||||
$user_id = isset($_POST['userId']) ? (int) $_POST['userId'] : 0;
|
||||
$current_id = get_current_user_id();
|
||||
if ($current_id <= 0 || $current_id !== $user_id || !current_user_can('read')) {
|
||||
wp_send_json_error(['message' => __('无权执行此操作', 'aksrt')], 403);
|
||||
wp_send_json_error(['message' => __('无权执行此操作', 'jio')], 403);
|
||||
}
|
||||
$result = OAuthAccountService::unbind($current_id, $provider);
|
||||
if (is_wp_error($result)) {
|
||||
$status = $result->get_error_code() === 'oauth_last_login_method' ? 409 : 400;
|
||||
wp_send_json_error(['message' => $result->get_error_message()], $status);
|
||||
}
|
||||
wp_send_json_success(['unbound' => true, 'message' => __('解除绑定成功', 'aksrt')]);
|
||||
wp_send_json_success(['unbound' => true, 'message' => __('解除绑定成功', 'jio')]);
|
||||
}
|
||||
|
||||
private function handle_start(): void {
|
||||
$provider = sanitize_key((string) get_query_var('aksrt_oauth_provider'));
|
||||
$provider = sanitize_key((string) get_query_var('jio_oauth_provider'));
|
||||
$action = isset($_GET['action']) && sanitize_key((string) $_GET['action']) === 'bind' ? 'bind' : 'login';
|
||||
if (!OAuthProviderCatalog::master_enabled() || !in_array($provider, OAuthProviderCatalog::enabled_login_keys(), true)) {
|
||||
$this->redirect_error('provider_disabled', $provider, $action);
|
||||
}
|
||||
$user_id = get_current_user_id();
|
||||
if ($action === 'bind' && $user_id <= 0) {
|
||||
wp_safe_redirect(function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url());
|
||||
wp_safe_redirect(function_exists('jio_get_login_url') ? jio_get_login_url() : wp_login_url());
|
||||
exit;
|
||||
}
|
||||
if ($action === 'bind') {
|
||||
@@ -380,7 +380,7 @@ final class OAuth {
|
||||
if (is_wp_error($result)) {
|
||||
throw new \RuntimeException($result->get_error_code());
|
||||
}
|
||||
$this->redirect_success('bind', $provider, function_exists('aksrt_get_user_center_url') ? aksrt_get_user_center_url('settings') : home_url('/'));
|
||||
$this->redirect_success('bind', $provider, function_exists('jio_get_user_center_url') ? jio_get_user_center_url('settings') : home_url('/'));
|
||||
}
|
||||
$this->complete_identity_login($provider, $identity, (string) ($payload['redirect_to'] ?? home_url('/')));
|
||||
} catch (\Throwable $e) {
|
||||
@@ -396,7 +396,7 @@ final class OAuth {
|
||||
$this->redirect_error('provider_disabled', 'clogin_' . $type, $action);
|
||||
}
|
||||
if ($action === 'bind' && !is_user_logged_in()) {
|
||||
wp_safe_redirect(function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url());
|
||||
wp_safe_redirect(function_exists('jio_get_login_url') ? jio_get_login_url() : wp_login_url());
|
||||
exit;
|
||||
}
|
||||
if ($action === 'bind') {
|
||||
@@ -468,7 +468,7 @@ final class OAuth {
|
||||
if (is_wp_error($result)) {
|
||||
$this->redirect_error('binding_conflict', $provider, $action);
|
||||
}
|
||||
$this->redirect_success('bind', $provider, function_exists('aksrt_get_user_center_url') ? aksrt_get_user_center_url('settings') : home_url('/'));
|
||||
$this->redirect_success('bind', $provider, function_exists('jio_get_user_center_url') ? jio_get_user_center_url('settings') : home_url('/'));
|
||||
}
|
||||
$this->complete_identity_login($provider, $identity, (string) ($payload['redirect_to'] ?? home_url('/')));
|
||||
}
|
||||
@@ -482,7 +482,7 @@ final class OAuth {
|
||||
'user_data' => $identity,
|
||||
'redirect_to' => OAuthUrlPolicy::validated_redirect($redirect, home_url('/')),
|
||||
], 15 * MINUTE_IN_SECONDS);
|
||||
$url = function_exists('aksrt_get_bind_url') ? aksrt_get_bind_url($obk) : home_url('/sign/?tab=bind&obk=' . rawurlencode($obk));
|
||||
$url = function_exists('jio_get_bind_url') ? jio_get_bind_url($obk) : home_url('/sign/?tab=bind&obk=' . rawurlencode($obk));
|
||||
wp_safe_redirect($url);
|
||||
exit;
|
||||
}
|
||||
@@ -497,7 +497,7 @@ final class OAuth {
|
||||
return [
|
||||
'key' => $provider,
|
||||
'name' => OAuthProviderCatalog::label($provider),
|
||||
'icon' => function_exists('aksrt_brand_icon') ? aksrt_brand_icon(OAuthProviderCatalog::icon_key($provider)) : '',
|
||||
'icon' => function_exists('jio_brand_icon') ? jio_brand_icon(OAuthProviderCatalog::icon_key($provider)) : '',
|
||||
'is_bound' => $bound,
|
||||
'url' => '',
|
||||
];
|
||||
@@ -512,9 +512,9 @@ final class OAuth {
|
||||
}
|
||||
|
||||
private function redirect_error(string $code, string $provider = '', string $action = 'login'): void {
|
||||
$target = $action === 'bind' && is_user_logged_in() && function_exists('aksrt_get_user_center_url')
|
||||
? aksrt_get_user_center_url('settings')
|
||||
: (function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url());
|
||||
$target = $action === 'bind' && is_user_logged_in() && function_exists('jio_get_user_center_url')
|
||||
? jio_get_user_center_url('settings')
|
||||
: (function_exists('jio_get_login_url') ? jio_get_login_url() : wp_login_url());
|
||||
wp_safe_redirect(add_query_arg([
|
||||
'oauth_action' => 'error',
|
||||
'oauth_provider' => sanitize_key($provider),
|
||||
|
||||
Reference in new issue
Block a user