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
+58
-58
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -29,13 +29,13 @@ class FrontSubmit {
|
||||
}
|
||||
|
||||
public function init(): void {
|
||||
add_action('wp_ajax_aksrt_submit_post', [$this, 'ajax_submit_post']);
|
||||
add_action('wp_ajax_aksrt_save_draft', [$this, 'ajax_save_draft']);
|
||||
add_action('wp_ajax_aksrt_delete_draft', [$this, 'ajax_delete_draft']);
|
||||
add_action('wp_ajax_aksrt_delete_post', [$this, 'ajax_delete_post']);
|
||||
add_action('wp_ajax_jio_submit_post', [$this, 'ajax_submit_post']);
|
||||
add_action('wp_ajax_jio_save_draft', [$this, 'ajax_save_draft']);
|
||||
add_action('wp_ajax_jio_delete_draft', [$this, 'ajax_delete_draft']);
|
||||
add_action('wp_ajax_jio_delete_post', [$this, 'ajax_delete_post']);
|
||||
|
||||
// Guest path (when enabled).
|
||||
add_action('wp_ajax_nopriv_aksrt_submit_post', [$this, 'ajax_submit_post']);
|
||||
add_action('wp_ajax_nopriv_jio_submit_post', [$this, 'ajax_submit_post']);
|
||||
|
||||
add_action('rest_api_init', [$this, 'register_rest_routes']);
|
||||
|
||||
@@ -44,7 +44,7 @@ class FrontSubmit {
|
||||
}
|
||||
|
||||
public function register_rest_routes(): void {
|
||||
register_rest_route('aksrt/v1', '/front-submit/media/(?P<type>image|video|file)', [
|
||||
register_rest_route('jio/v1', '/front-submit/media/(?P<type>image|video|file)', [
|
||||
'methods' => \WP_REST_Server::READABLE,
|
||||
'callback' => [$this, 'rest_list_attachments'],
|
||||
'permission_callback' => [$this, 'can_list_attachments'],
|
||||
@@ -76,7 +76,7 @@ class FrontSubmit {
|
||||
],
|
||||
]);
|
||||
|
||||
register_rest_route('aksrt/v1', '/front-submit/upload/(?P<kind>image|video|resource)', [
|
||||
register_rest_route('jio/v1', '/front-submit/upload/(?P<kind>image|video|resource)', [
|
||||
'methods' => 'POST',
|
||||
'callback' => [$this, 'rest_upload_attachment'],
|
||||
'permission_callback' => [$this, 'can_upload_attachment'],
|
||||
@@ -122,8 +122,8 @@ class FrontSubmit {
|
||||
// Kind names follow the REST route; the config rows use the reference
|
||||
// theme's naming (image / video / file).
|
||||
$config_kind = $kind === 'resource' ? 'file' : $kind;
|
||||
if (class_exists('\AKSRT\Attachment\UploadLimits')) {
|
||||
return \AKSRT\Attachment\UploadLimits::limit_bytes($config_kind);
|
||||
if (class_exists('\Jio\Attachment\UploadLimits')) {
|
||||
return \Jio\Attachment\UploadLimits::limit_bytes($config_kind);
|
||||
}
|
||||
return (int) wp_max_upload_size();
|
||||
}
|
||||
@@ -134,7 +134,7 @@ class FrontSubmit {
|
||||
$file = $files['file'] ?? null;
|
||||
|
||||
if (!is_array($file)) {
|
||||
return new \WP_Error('aksrt_upload_missing_file', __('请选择要上传的文件。', 'aksrt'), ['status' => 400]);
|
||||
return new \WP_Error('jio_upload_missing_file', __('请选择要上传的文件。', 'jio'), ['status' => 400]);
|
||||
}
|
||||
|
||||
return $this->persist_uploaded_file($kind, $file, false);
|
||||
@@ -153,27 +153,27 @@ class FrontSubmit {
|
||||
$upload_error = (int) ($file['error'] ?? UPLOAD_ERR_NO_FILE);
|
||||
if ($upload_error === UPLOAD_ERR_INI_SIZE || $upload_error === UPLOAD_ERR_FORM_SIZE) {
|
||||
return new \WP_Error(
|
||||
'aksrt_upload_too_large',
|
||||
sprintf(__('文件大小不能超过 %s。', 'aksrt'), size_format($max_size)),
|
||||
'jio_upload_too_large',
|
||||
sprintf(__('文件大小不能超过 %s。', 'jio'), size_format($max_size)),
|
||||
['status' => 413]
|
||||
);
|
||||
}
|
||||
if ($upload_error === UPLOAD_ERR_PARTIAL) {
|
||||
return new \WP_Error('aksrt_upload_partial', __('文件未完整上传,请重新选择。', 'aksrt'), ['status' => 400]);
|
||||
return new \WP_Error('jio_upload_partial', __('文件未完整上传,请重新选择。', 'jio'), ['status' => 400]);
|
||||
}
|
||||
if ($upload_error === UPLOAD_ERR_NO_FILE || empty($file['tmp_name'])) {
|
||||
return new \WP_Error('aksrt_upload_missing_file', __('请选择要上传的文件。', 'aksrt'), ['status' => 400]);
|
||||
return new \WP_Error('jio_upload_missing_file', __('请选择要上传的文件。', 'jio'), ['status' => 400]);
|
||||
}
|
||||
if ($upload_error !== UPLOAD_ERR_OK) {
|
||||
return new \WP_Error('aksrt_upload_failed', __('服务器无法保存上传文件。', 'aksrt'), ['status' => 500]);
|
||||
return new \WP_Error('jio_upload_failed', __('服务器无法保存上传文件。', 'jio'), ['status' => 500]);
|
||||
}
|
||||
|
||||
$size = (int) ($file['size'] ?? 0);
|
||||
|
||||
if ($size <= 0 || $size > $max_size) {
|
||||
return new \WP_Error(
|
||||
'aksrt_upload_too_large',
|
||||
sprintf(__('文件大小不能超过 %s。', 'aksrt'), size_format($max_size)),
|
||||
'jio_upload_too_large',
|
||||
sprintf(__('文件大小不能超过 %s。', 'jio'), size_format($max_size)),
|
||||
['status' => 413]
|
||||
);
|
||||
}
|
||||
@@ -182,25 +182,25 @@ class FrontSubmit {
|
||||
$checked = wp_check_filetype_and_ext((string) $file['tmp_name'], $filename, get_allowed_mime_types());
|
||||
$mime = (string) ($checked['type'] ?? '');
|
||||
if ($filename === '' || $mime === '') {
|
||||
return new \WP_Error('aksrt_upload_invalid_type', __('不支持的文件类型。', 'aksrt'), ['status' => 400]);
|
||||
return new \WP_Error('jio_upload_invalid_type', __('不支持的文件类型。', 'jio'), ['status' => 400]);
|
||||
}
|
||||
|
||||
if ($kind === 'image') {
|
||||
$image_info = @getimagesize((string) $file['tmp_name']);
|
||||
if ($image_info === false || strpos($mime, 'image/') !== 0) {
|
||||
return new \WP_Error('aksrt_upload_invalid_image', __('请上传有效的图片文件。', 'aksrt'), ['status' => 400]);
|
||||
return new \WP_Error('jio_upload_invalid_image', __('请上传有效的图片文件。', 'jio'), ['status' => 400]);
|
||||
}
|
||||
if (((int) $image_info[0] * (int) $image_info[1]) > 40000000) {
|
||||
return new \WP_Error('aksrt_upload_image_too_large', __('图片尺寸过大。', 'aksrt'), ['status' => 400]);
|
||||
return new \WP_Error('jio_upload_image_too_large', __('图片尺寸过大。', 'jio'), ['status' => 400]);
|
||||
}
|
||||
if (class_exists('\AKSRT\Extensions\ContentAudit')) {
|
||||
$audit = \AKSRT\Extensions\ContentAudit::get_instance()->audit_image((string) $file['tmp_name']);
|
||||
if (class_exists('\Jio\Extensions\ContentAudit')) {
|
||||
$audit = \Jio\Extensions\ContentAudit::get_instance()->audit_image((string) $file['tmp_name']);
|
||||
if (empty($audit['passed'])) {
|
||||
return new \WP_Error('aksrt_upload_image_rejected', __('图片未通过内容审核。', 'aksrt'), ['status' => 422]);
|
||||
return new \WP_Error('jio_upload_image_rejected', __('图片未通过内容审核。', 'jio'), ['status' => 422]);
|
||||
}
|
||||
}
|
||||
} elseif ($kind === 'video' && strpos($mime, 'video/') !== 0) {
|
||||
return new \WP_Error('aksrt_upload_invalid_video', __('请上传有效的视频文件。', 'aksrt'), ['status' => 400]);
|
||||
return new \WP_Error('jio_upload_invalid_video', __('请上传有效的视频文件。', 'jio'), ['status' => 400]);
|
||||
}
|
||||
|
||||
if (!function_exists('media_handle_upload')) {
|
||||
@@ -212,24 +212,24 @@ class FrontSubmit {
|
||||
// 合并产物不是 HTTP 直传文件,走 sideload 动作(copy 而非 move_uploaded_file)。
|
||||
$overrides = $sideload ? ['test_form' => false, 'action' => 'wp_handle_sideload'] : ['test_form' => false];
|
||||
|
||||
$_FILES['aksrt_front_submit_file'] = $file;
|
||||
$attachment_id = media_handle_upload('aksrt_front_submit_file', 0, [], $overrides);
|
||||
unset($_FILES['aksrt_front_submit_file']);
|
||||
$_FILES['jio_front_submit_file'] = $file;
|
||||
$attachment_id = media_handle_upload('jio_front_submit_file', 0, [], $overrides);
|
||||
unset($_FILES['jio_front_submit_file']);
|
||||
if (is_wp_error($attachment_id)) {
|
||||
return new \WP_Error('aksrt_upload_failed', $attachment_id->get_error_message(), ['status' => 400]);
|
||||
return new \WP_Error('jio_upload_failed', $attachment_id->get_error_message(), ['status' => 400]);
|
||||
}
|
||||
|
||||
$attachment_id = (int) $attachment_id;
|
||||
wp_update_post(['ID' => $attachment_id, 'post_author' => get_current_user_id()]);
|
||||
update_post_meta($attachment_id, '_aksrt_front_submit_media', $kind);
|
||||
update_post_meta($attachment_id, '_jio_front_submit_media', $kind);
|
||||
|
||||
$attachment = $this->prepare_attachment_response($attachment_id);
|
||||
if ($attachment === null) {
|
||||
wp_delete_attachment($attachment_id, true);
|
||||
return new \WP_Error('aksrt_upload_failed', __('上传后无法读取文件。', 'aksrt'), ['status' => 500]);
|
||||
return new \WP_Error('jio_upload_failed', __('上传后无法读取文件。', 'jio'), ['status' => 500]);
|
||||
}
|
||||
|
||||
\AKSRT\Attachment\PendingUploads::mark($attachment_id);
|
||||
\Jio\Attachment\PendingUploads::mark($attachment_id);
|
||||
$attachment['success'] = true;
|
||||
return new \WP_REST_Response($attachment, 201);
|
||||
}
|
||||
@@ -238,8 +238,8 @@ class FrontSubmit {
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function settings(): array {
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
return \AKSRT\Settings\Settings::get_submit_settings();
|
||||
if (class_exists('\Jio\Settings\Settings')) {
|
||||
return \Jio\Settings\Settings::get_submit_settings();
|
||||
}
|
||||
return [
|
||||
'enabled' => true,
|
||||
@@ -341,11 +341,11 @@ class FrontSubmit {
|
||||
if ($user_id > 0 && user_can($user_id, 'manage_options')) {
|
||||
return true;
|
||||
}
|
||||
if (function_exists('aksrt_user_can')) {
|
||||
return aksrt_user_can($cap, $user_id, $context);
|
||||
if (function_exists('jio_user_can')) {
|
||||
return jio_user_can($cap, $user_id, $context);
|
||||
}
|
||||
if (class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'user_can')) {
|
||||
return \AKSRT\Settings\Settings::user_can($cap, $user_id, $context);
|
||||
if (class_exists('\Jio\Settings\Settings') && method_exists('\Jio\Settings\Settings', 'user_can')) {
|
||||
return \Jio\Settings\Settings::user_can($cap, $user_id, $context);
|
||||
}
|
||||
return $user_id > 0;
|
||||
}
|
||||
@@ -356,7 +356,7 @@ class FrontSubmit {
|
||||
*/
|
||||
public function submit(array $data): array {
|
||||
$action = sanitize_key((string) ($data['action_type'] ?? $data['submit_action'] ?? 'posts_save'));
|
||||
if ($action === 'aksrt_save_draft' || ($data['status'] ?? '') === 'draft') {
|
||||
if ($action === 'jio_save_draft' || ($data['status'] ?? '') === 'draft') {
|
||||
$action = 'posts_draft';
|
||||
} else {
|
||||
$action = 'posts_save';
|
||||
@@ -386,7 +386,7 @@ class FrontSubmit {
|
||||
public function ajax_save_draft(): void {
|
||||
$this->verify_nonce();
|
||||
if (!is_user_logged_in()) {
|
||||
wp_send_json_error(['message' => __('请先登录', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('请先登录', 'jio')]);
|
||||
}
|
||||
$data = wp_unslash($_POST);
|
||||
$result = $this->persist(is_array($data) ? $data : [], 'posts_draft');
|
||||
@@ -397,18 +397,18 @@ class FrontSubmit {
|
||||
$this->verify_nonce();
|
||||
$user_id = get_current_user_id();
|
||||
if ($user_id <= 0) {
|
||||
wp_send_json_error(['message' => __('请先登录', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('请先登录', 'jio')]);
|
||||
}
|
||||
$post_id = absint($_POST['draft_id'] ?? $_POST['post_id'] ?? $_POST['id'] ?? 0);
|
||||
if ($post_id <= 0) {
|
||||
wp_send_json_error(['message' => __('草稿 ID 无效', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('草稿 ID 无效', 'jio')]);
|
||||
}
|
||||
$post = get_post($post_id);
|
||||
if (!$post || (int) $post->post_author !== $user_id) {
|
||||
wp_send_json_error(['message' => __('没有删除权限', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('没有删除权限', 'jio')]);
|
||||
}
|
||||
if ($post->post_status !== 'draft' && !$this->can_delete_post($post_id, $user_id)) {
|
||||
wp_send_json_error(['message' => __('只能删除草稿', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('只能删除草稿', 'jio')]);
|
||||
}
|
||||
if ($post->post_status === 'draft') {
|
||||
$ok = wp_delete_post($post_id, true);
|
||||
@@ -416,9 +416,9 @@ class FrontSubmit {
|
||||
$ok = wp_trash_post($post_id);
|
||||
}
|
||||
if ($ok) {
|
||||
wp_send_json_success(['message' => __('已删除', 'aksrt')]);
|
||||
wp_send_json_success(['message' => __('已删除', 'jio')]);
|
||||
}
|
||||
wp_send_json_error(['message' => __('删除失败', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('删除失败', 'jio')]);
|
||||
}
|
||||
|
||||
public function ajax_delete_post(): void {
|
||||
@@ -426,15 +426,15 @@ class FrontSubmit {
|
||||
$user_id = get_current_user_id();
|
||||
$post_id = absint($_POST['id'] ?? $_POST['post_id'] ?? 0);
|
||||
if (!$this->can_delete_post($post_id, $user_id)) {
|
||||
wp_send_json_error(['message' => __('您没有删除此内容的权限', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('您没有删除此内容的权限', 'jio')]);
|
||||
}
|
||||
$post = get_post($post_id);
|
||||
if (!$post || $post->post_status === 'trash') {
|
||||
wp_send_json_success(['message' => __('文章已经删除', 'aksrt'), 'reload' => true]);
|
||||
wp_send_json_success(['message' => __('文章已经删除', 'jio'), 'reload' => true]);
|
||||
}
|
||||
wp_trash_post($post_id);
|
||||
wp_send_json_success([
|
||||
'message' => __('文章已经删除', 'aksrt'),
|
||||
'message' => __('文章已经删除', 'jio'),
|
||||
'reload' => true,
|
||||
'goto' => home_url('/'),
|
||||
]);
|
||||
@@ -443,23 +443,23 @@ class FrontSubmit {
|
||||
private function verify_nonce(): void {
|
||||
$nonce = (string) ($_REQUEST['_nonce'] ?? $_REQUEST['nonce'] ?? $_REQUEST['_wpnonce'] ?? '');
|
||||
if ($nonce === '' || (
|
||||
!wp_verify_nonce($nonce, 'aksrt_submit')
|
||||
&& !wp_verify_nonce($nonce, 'aksrt_submit_nonce')
|
||||
!wp_verify_nonce($nonce, 'jio_submit')
|
||||
&& !wp_verify_nonce($nonce, 'jio_submit_nonce')
|
||||
)) {
|
||||
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'aksrt')], 403);
|
||||
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'jio')], 403);
|
||||
}
|
||||
}
|
||||
|
||||
private function verify_captcha(): void {
|
||||
$verify = aksrt_require_captcha('front_submit', $_POST);
|
||||
$verify = jio_require_captcha('front_submit', $_POST);
|
||||
if ($verify !== true) {
|
||||
$captcha_error = is_wp_error($verify) ? $verify : null;
|
||||
$message = $captcha_error
|
||||
? $captcha_error->get_error_message()
|
||||
: __('人机验证失败,请重试', 'aksrt');
|
||||
: __('人机验证失败,请重试', 'jio');
|
||||
wp_send_json_error([
|
||||
'code' => $captcha_error ? ($captcha_error->get_error_code() ?: 'aksrt_captcha_failed') : 'aksrt_captcha_failed',
|
||||
'message' => $message !== '' ? $message : __('人机验证失败,请重试', 'aksrt'),
|
||||
'code' => $captcha_error ? ($captcha_error->get_error_code() ?: 'jio_captcha_failed') : 'jio_captcha_failed',
|
||||
'message' => $message !== '' ? $message : __('人机验证失败,请重试', 'jio'),
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
@@ -503,7 +503,7 @@ class FrontSubmit {
|
||||
*/
|
||||
public function body_class(array $classes): array {
|
||||
if ($this->is_submit_template()) {
|
||||
$classes[] = 'aksrt-page-submit';
|
||||
$classes[] = 'jio-page-submit';
|
||||
}
|
||||
return $classes;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user