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
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -14,7 +14,7 @@ class CategoryRewrite {
|
||||
private function __construct() {}
|
||||
|
||||
private function rewrite_version(): string {
|
||||
return AKSRT_VERSION . ':category-rewrite-v1';
|
||||
return JIO_VERSION . ':category-rewrite-v1';
|
||||
}
|
||||
|
||||
public static function get_instance(): self {
|
||||
@@ -42,11 +42,11 @@ class CategoryRewrite {
|
||||
* Check if feature is enabled
|
||||
*/
|
||||
private function is_enabled(): bool {
|
||||
if (!class_exists('\AKSRT\Settings\Settings')) return false;
|
||||
if (!class_exists('\Jio\Settings\Settings')) return false;
|
||||
// schema key = seo_no_category; runtime alias = seo_remove_category
|
||||
return (bool) (
|
||||
\AKSRT\Settings\Settings::get_value('seo_remove_category', false)
|
||||
?: \AKSRT\Settings\Settings::get_value('seo_no_category', false)
|
||||
\Jio\Settings\Settings::get_value('seo_remove_category', false)
|
||||
?: \Jio\Settings\Settings::get_value('seo_no_category', false)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -132,10 +132,10 @@ class CategoryRewrite {
|
||||
*/
|
||||
public function maybe_flush(): void {
|
||||
$rewrite_version = $this->rewrite_version();
|
||||
$stored = (string) get_option('aksrt_category_rewrite_flushed', '');
|
||||
$stored = (string) get_option('jio_category_rewrite_flushed', '');
|
||||
if ($stored !== $rewrite_version) {
|
||||
flush_rewrite_rules();
|
||||
update_option('aksrt_category_rewrite_flushed', $rewrite_version);
|
||||
update_option('jio_category_rewrite_flushed', $rewrite_version);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,10 +143,10 @@ class CategoryRewrite {
|
||||
* Restore default rewrite rules when feature is disabled
|
||||
*/
|
||||
public function maybe_restore(): void {
|
||||
$stored = (string) get_option('aksrt_category_rewrite_flushed', '');
|
||||
$stored = (string) get_option('jio_category_rewrite_flushed', '');
|
||||
if ($stored !== '') {
|
||||
flush_rewrite_rules();
|
||||
delete_option('aksrt_category_rewrite_flushed');
|
||||
delete_option('jio_category_rewrite_flushed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,6 +155,6 @@ class CategoryRewrite {
|
||||
*/
|
||||
public static function force_flush(): void {
|
||||
flush_rewrite_rules();
|
||||
update_option('aksrt_category_rewrite_flushed', AKSRT_VERSION . ':category-rewrite-v1');
|
||||
update_option('jio_category_rewrite_flushed', JIO_VERSION . ':category-rewrite-v1');
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -4,10 +4,10 @@
|
||||
*
|
||||
* 前端对应实现:assets/admin/src/utils/color.js(normalizeColor),两端规则保持一致。
|
||||
*
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
|
||||
+67
-67
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -25,7 +25,7 @@ class CommentActions {
|
||||
}
|
||||
|
||||
public function register_routes(): void {
|
||||
register_rest_route('aksrt/v1', '/comment/list', [
|
||||
register_rest_route('jio/v1', '/comment/list', [
|
||||
'methods' => \WP_REST_Server::READABLE,
|
||||
'callback' => [$this, 'list_comments'],
|
||||
'permission_callback' => '__return_true',
|
||||
@@ -37,13 +37,13 @@ class CommentActions {
|
||||
],
|
||||
]);
|
||||
|
||||
register_rest_route('aksrt/v1', '/comment/submit', [
|
||||
register_rest_route('jio/v1', '/comment/submit', [
|
||||
'methods' => 'POST',
|
||||
'callback' => [$this, 'submit_comment'],
|
||||
'permission_callback' => '__return_true',
|
||||
]);
|
||||
|
||||
register_rest_route('aksrt/v1', '/comment/edit', [
|
||||
register_rest_route('jio/v1', '/comment/edit', [
|
||||
'methods' => 'POST',
|
||||
'callback' => [$this, 'edit_comment'],
|
||||
'permission_callback' => [$this, 'check_edit_permission'],
|
||||
@@ -53,7 +53,7 @@ class CommentActions {
|
||||
],
|
||||
]);
|
||||
|
||||
register_rest_route('aksrt/v1', '/comment/delete', [
|
||||
register_rest_route('jio/v1', '/comment/delete', [
|
||||
'methods' => 'POST',
|
||||
'callback' => [$this, 'delete_comment'],
|
||||
'permission_callback' => [$this, 'check_delete_permission'],
|
||||
@@ -62,7 +62,7 @@ class CommentActions {
|
||||
],
|
||||
]);
|
||||
|
||||
register_rest_route('aksrt/v1', '/comment/moderate', [
|
||||
register_rest_route('jio/v1', '/comment/moderate', [
|
||||
'methods' => 'POST',
|
||||
'callback' => [$this, 'moderate_comment'],
|
||||
'permission_callback' => [$this, 'check_moderate_permission'],
|
||||
@@ -72,7 +72,7 @@ class CommentActions {
|
||||
],
|
||||
]);
|
||||
|
||||
register_rest_route('aksrt/v1', '/comment/pin', [
|
||||
register_rest_route('jio/v1', '/comment/pin', [
|
||||
'methods' => 'POST',
|
||||
'callback' => [$this, 'pin_comment'],
|
||||
'permission_callback' => [$this, 'check_pin_permission'],
|
||||
@@ -82,7 +82,7 @@ class CommentActions {
|
||||
],
|
||||
]);
|
||||
|
||||
register_rest_route('aksrt/v1', '/comment/like', [
|
||||
register_rest_route('jio/v1', '/comment/like', [
|
||||
'methods' => 'POST',
|
||||
'callback' => [$this, 'like_comment'],
|
||||
// Guests may like; abuse is bounded by per-visitor toggle state.
|
||||
@@ -93,7 +93,7 @@ class CommentActions {
|
||||
],
|
||||
]);
|
||||
|
||||
register_rest_route('aksrt/v1', '/comment/get', [
|
||||
register_rest_route('jio/v1', '/comment/get', [
|
||||
'methods' => \WP_REST_Server::READABLE,
|
||||
'callback' => [$this, 'get_comment'],
|
||||
'permission_callback' => [$this, 'check_get_permission'],
|
||||
@@ -125,7 +125,7 @@ class CommentActions {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'comment_not_found',
|
||||
'message' => __('评论不存在。', 'aksrt'),
|
||||
'message' => __('评论不存在。', 'jio'),
|
||||
], 404);
|
||||
}
|
||||
return new \WP_REST_Response([
|
||||
@@ -146,8 +146,8 @@ class CommentActions {
|
||||
* @return array{can_edit:bool,can_delete:bool,can_moderate:bool,can_pin:bool}
|
||||
*/
|
||||
private function permissions(int $comment_id): array {
|
||||
if (function_exists('aksrt_comment_action_permissions')) {
|
||||
return aksrt_comment_action_permissions($comment_id);
|
||||
if (function_exists('jio_comment_action_permissions')) {
|
||||
return jio_comment_action_permissions($comment_id);
|
||||
}
|
||||
|
||||
// Defensive fallback if the helper is unavailable.
|
||||
@@ -197,15 +197,15 @@ class CommentActions {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'post_not_found',
|
||||
'message' => __('文章不存在。', 'aksrt'),
|
||||
'message' => __('文章不存在。', 'jio'),
|
||||
], 404);
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_comments_render_list_fragment')) {
|
||||
if (!function_exists('jio_comments_render_list_fragment')) {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'fragment_unavailable',
|
||||
'message' => __('评论片段渲染不可用。', 'aksrt'),
|
||||
'message' => __('评论片段渲染不可用。', 'jio'),
|
||||
], 500);
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ class CommentActions {
|
||||
$author_only = (bool) $request->get_param('author_only');
|
||||
$page = max(1, (int) ($request->get_param('page') ?: 1));
|
||||
|
||||
$fragment = aksrt_comments_render_list_fragment($post_id, [
|
||||
$fragment = jio_comments_render_list_fragment($post_id, [
|
||||
'order' => $order,
|
||||
'author_only' => $author_only,
|
||||
'page' => $page,
|
||||
@@ -253,7 +253,7 @@ class CommentActions {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'invalid_payload',
|
||||
'message' => __('请输入评论内容。', 'aksrt'),
|
||||
'message' => __('请输入评论内容。', 'jio'),
|
||||
], 400);
|
||||
}
|
||||
|
||||
@@ -262,29 +262,29 @@ class CommentActions {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'comments_closed',
|
||||
'message' => __('评论已关闭。', 'aksrt'),
|
||||
'message' => __('评论已关闭。', 'jio'),
|
||||
], 403);
|
||||
}
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
if (!function_exists('aksrt_user_can') || !aksrt_user_can('comment_add', $user_id, $post_id)) {
|
||||
if (!function_exists('jio_user_can') || !jio_user_can('comment_add', $user_id, $post_id)) {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'comment_forbidden',
|
||||
'message' => __('当前账号没有发表评论的权限。', 'aksrt'),
|
||||
'message' => __('当前账号没有发表评论的权限。', 'jio'),
|
||||
], $user_id > 0 ? 403 : 401);
|
||||
}
|
||||
|
||||
$nonce = (string) ($params['_aksrt_comment_nonce'] ?? $params['_wpnonce'] ?? '');
|
||||
if ($nonce !== '' && !wp_verify_nonce($nonce, 'aksrt_comment_nonce') && !wp_verify_nonce($nonce, 'wp_rest')) {
|
||||
$nonce = (string) ($params['_jio_comment_nonce'] ?? $params['_wpnonce'] ?? '');
|
||||
if ($nonce !== '' && !wp_verify_nonce($nonce, 'jio_comment_nonce') && !wp_verify_nonce($nonce, 'wp_rest')) {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'invalid_nonce',
|
||||
'message' => __('安全校验失败,请刷新后重试。', 'aksrt'),
|
||||
'message' => __('安全校验失败,请刷新后重试。', 'jio'),
|
||||
], 403);
|
||||
}
|
||||
|
||||
$captcha_result = aksrt_require_captcha('comment', $params);
|
||||
$captcha_result = jio_require_captcha('comment', $params);
|
||||
if ($captcha_result !== true) {
|
||||
$captcha_error = is_wp_error($captcha_result) ? $captcha_result : null;
|
||||
$captcha_data = $captcha_error ? $captcha_error->get_error_data() : null;
|
||||
@@ -293,8 +293,8 @@ class CommentActions {
|
||||
'success' => false,
|
||||
'code' => $captcha_error ? ($captcha_error->get_error_code() ?: 'captcha_failed') : 'captcha_failed',
|
||||
'message' => $captcha_error
|
||||
? ($captcha_error->get_error_message() ?: __('人机验证失败', 'aksrt'))
|
||||
: __('人机验证失败', 'aksrt'),
|
||||
? ($captcha_error->get_error_message() ?: __('人机验证失败', 'jio'))
|
||||
: __('人机验证失败', 'jio'),
|
||||
], $captcha_status > 0 ? $captcha_status : 400);
|
||||
}
|
||||
|
||||
@@ -305,8 +305,8 @@ class CommentActions {
|
||||
'comment_parent' => $parent,
|
||||
'comment_type' => '',
|
||||
// Prefer real client IP behind CDN/proxy (REMOTE_ADDR alone is often edge IP).
|
||||
'comment_author_IP' => function_exists('aksrt_get_client_ip')
|
||||
? (string) aksrt_get_client_ip()
|
||||
'comment_author_IP' => function_exists('jio_get_client_ip')
|
||||
? (string) jio_get_client_ip()
|
||||
: (isset($_SERVER['REMOTE_ADDR']) ? sanitize_text_field(wp_unslash((string) $_SERVER['REMOTE_ADDR'])) : ''),
|
||||
'comment_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? sanitize_text_field(wp_unslash((string) $_SERVER['HTTP_USER_AGENT'])) : '',
|
||||
'comment_date' => current_time('mysql'),
|
||||
@@ -327,33 +327,33 @@ class CommentActions {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'guest_fields_required',
|
||||
'message' => __('请填写昵称和邮箱。', 'aksrt'),
|
||||
'message' => __('请填写昵称和邮箱。', 'jio'),
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (['author', 'email', 'url', 'comment', 'comment_post_ID', 'comment_parent', '_aksrt_comment_nonce'] as $k) {
|
||||
foreach (['author', 'email', 'url', 'comment', 'comment_post_ID', 'comment_parent', '_jio_comment_nonce'] as $k) {
|
||||
if (isset($params[$k])) {
|
||||
$_POST[$k] = $params[$k];
|
||||
}
|
||||
}
|
||||
|
||||
$comment_id = null;
|
||||
if (class_exists('\AKSRT\Auth\Moderation')) {
|
||||
\AKSRT\Auth\Moderation::get_instance()->begin_captcha_verified_comment_request();
|
||||
if (class_exists('\Jio\Auth\Moderation')) {
|
||||
\Jio\Auth\Moderation::get_instance()->begin_captcha_verified_comment_request();
|
||||
}
|
||||
try {
|
||||
$comment_id = wp_new_comment(wp_slash($commentdata), true);
|
||||
} finally {
|
||||
if (class_exists('\AKSRT\Auth\Moderation')) {
|
||||
\AKSRT\Auth\Moderation::get_instance()->end_captcha_verified_comment_request();
|
||||
if (class_exists('\Jio\Auth\Moderation')) {
|
||||
\Jio\Auth\Moderation::get_instance()->end_captcha_verified_comment_request();
|
||||
}
|
||||
}
|
||||
if (is_wp_error($comment_id)) {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => $comment_id->get_error_code() ?: 'submit_failed',
|
||||
'message' => $comment_id->get_error_message() ?: __('评论提交失败。', 'aksrt'),
|
||||
'message' => $comment_id->get_error_message() ?: __('评论提交失败。', 'jio'),
|
||||
], 400);
|
||||
}
|
||||
|
||||
@@ -362,13 +362,13 @@ class CommentActions {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'submit_failed',
|
||||
'message' => __('评论提交失败。', 'aksrt'),
|
||||
'message' => __('评论提交失败。', 'jio'),
|
||||
], 500);
|
||||
}
|
||||
|
||||
$settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_comment_display_settings() : [];
|
||||
$html = function_exists('aksrt_comments_render_single_html')
|
||||
? aksrt_comments_render_single_html($comment, $settings)
|
||||
$settings = class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::get_comment_display_settings() : [];
|
||||
$html = function_exists('jio_comments_render_single_html')
|
||||
? jio_comments_render_single_html($comment, $settings)
|
||||
: '';
|
||||
|
||||
$needs_moderation = '0' === (string) $comment->comment_approved;
|
||||
@@ -377,7 +377,7 @@ class CommentActions {
|
||||
return new \WP_REST_Response([
|
||||
'success' => true,
|
||||
'code' => 'submitted',
|
||||
'message' => $needs_moderation ? __('评论已提交,等待管理员审核', 'aksrt') : __('评论发布成功', 'aksrt'),
|
||||
'message' => $needs_moderation ? __('评论已提交,等待管理员审核', 'jio') : __('评论发布成功', 'jio'),
|
||||
'html' => $html,
|
||||
'is_reply'=> $parent > 0,
|
||||
'parent_id' => $parent,
|
||||
@@ -402,7 +402,7 @@ class CommentActions {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'comment_not_found',
|
||||
'message' => __('评论不存在。', 'aksrt'),
|
||||
'message' => __('评论不存在。', 'jio'),
|
||||
], 404);
|
||||
}
|
||||
|
||||
@@ -427,18 +427,18 @@ class CommentActions {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'update_failed',
|
||||
'message' => __('更新失败。', 'aksrt'),
|
||||
'message' => __('更新失败。', 'jio'),
|
||||
], 500);
|
||||
}
|
||||
|
||||
$rendered = function_exists('aksrt_render_comment_content')
|
||||
? aksrt_render_comment_content($clean_content)
|
||||
$rendered = function_exists('jio_render_comment_content')
|
||||
? jio_render_comment_content($clean_content)
|
||||
: wpautop($clean_content);
|
||||
|
||||
return new \WP_REST_Response([
|
||||
'success' => true,
|
||||
'code' => 'updated',
|
||||
'message' => __('评论已更新。', 'aksrt'),
|
||||
'message' => __('评论已更新。', 'jio'),
|
||||
'data' => [
|
||||
'content' => $rendered,
|
||||
],
|
||||
@@ -456,7 +456,7 @@ class CommentActions {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'comment_not_found',
|
||||
'message' => __('评论不存在。', 'aksrt'),
|
||||
'message' => __('评论不存在。', 'jio'),
|
||||
], 404);
|
||||
}
|
||||
|
||||
@@ -465,14 +465,14 @@ class CommentActions {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'delete_failed',
|
||||
'message' => __('删除失败。', 'aksrt'),
|
||||
'message' => __('删除失败。', 'jio'),
|
||||
], 500);
|
||||
}
|
||||
|
||||
return new \WP_REST_Response([
|
||||
'success' => true,
|
||||
'code' => 'deleted',
|
||||
'message' => __('评论已删除。', 'aksrt'),
|
||||
'message' => __('评论已删除。', 'jio'),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -488,7 +488,7 @@ class CommentActions {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'invalid_status',
|
||||
'message' => __('无效状态。', 'aksrt'),
|
||||
'message' => __('无效状态。', 'jio'),
|
||||
], 400);
|
||||
}
|
||||
|
||||
@@ -497,7 +497,7 @@ class CommentActions {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'comment_not_found',
|
||||
'message' => __('评论不存在。', 'aksrt'),
|
||||
'message' => __('评论不存在。', 'jio'),
|
||||
], 404);
|
||||
}
|
||||
|
||||
@@ -512,14 +512,14 @@ class CommentActions {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'moderate_failed',
|
||||
'message' => __('操作失败。', 'aksrt'),
|
||||
'message' => __('操作失败。', 'jio'),
|
||||
], 500);
|
||||
}
|
||||
|
||||
return new \WP_REST_Response([
|
||||
'success' => true,
|
||||
'code' => 'moderated',
|
||||
'message' => __('操作成功。', 'aksrt'),
|
||||
'message' => __('操作成功。', 'jio'),
|
||||
'data' => [
|
||||
'status' => $status_map[$status],
|
||||
],
|
||||
@@ -536,7 +536,7 @@ class CommentActions {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'comment_not_found',
|
||||
'message' => __('评论不存在。', 'aksrt'),
|
||||
'message' => __('评论不存在。', 'jio'),
|
||||
], 404);
|
||||
}
|
||||
|
||||
@@ -544,25 +544,25 @@ class CommentActions {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'cannot_pin_reply',
|
||||
'message' => __('仅顶层评论可置顶。', 'aksrt'),
|
||||
'message' => __('仅顶层评论可置顶。', 'jio'),
|
||||
], 400);
|
||||
}
|
||||
|
||||
$current = '1' === (string) get_comment_meta($comment_id, '_aksrt_comment_pinned', true);
|
||||
$current = '1' === (string) get_comment_meta($comment_id, '_jio_comment_pinned', true);
|
||||
$target = null !== $request->get_param('pinned')
|
||||
? (bool) $request->get_param('pinned')
|
||||
: !$current;
|
||||
|
||||
if ($target) {
|
||||
update_comment_meta($comment_id, '_aksrt_comment_pinned', '1');
|
||||
update_comment_meta($comment_id, '_jio_comment_pinned', '1');
|
||||
} else {
|
||||
delete_comment_meta($comment_id, '_aksrt_comment_pinned');
|
||||
delete_comment_meta($comment_id, '_jio_comment_pinned');
|
||||
}
|
||||
|
||||
return new \WP_REST_Response([
|
||||
'success' => true,
|
||||
'code' => 'pinned',
|
||||
'message' => $target ? __('评论已置顶。', 'aksrt') : __('已取消置顶。', 'aksrt'),
|
||||
'message' => $target ? __('评论已置顶。', 'jio') : __('已取消置顶。', 'jio'),
|
||||
'data' => [
|
||||
'pinned' => $target,
|
||||
],
|
||||
@@ -579,31 +579,31 @@ class CommentActions {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'comment_unavailable',
|
||||
'message' => __('评论不存在或未通过审核。', 'aksrt'),
|
||||
'message' => __('评论不存在或未通过审核。', 'jio'),
|
||||
], 404);
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_is_comment_liked') || !function_exists('aksrt_set_comment_like_state') || !function_exists('aksrt_update_comment_counter')) {
|
||||
if (!function_exists('jio_is_comment_liked') || !function_exists('jio_set_comment_like_state') || !function_exists('jio_update_comment_counter')) {
|
||||
return new \WP_REST_Response([
|
||||
'success' => false,
|
||||
'code' => 'like_unavailable',
|
||||
'message' => __('点赞功能不可用。', 'aksrt'),
|
||||
'message' => __('点赞功能不可用。', 'jio'),
|
||||
], 500);
|
||||
}
|
||||
|
||||
$current = aksrt_is_comment_liked($comment_id);
|
||||
$current = jio_is_comment_liked($comment_id);
|
||||
$target = null !== $request->get_param('active')
|
||||
? (bool) $request->get_param('active')
|
||||
: !$current;
|
||||
|
||||
if ($target !== $current) {
|
||||
aksrt_set_comment_like_state($comment_id, $target);
|
||||
$count = aksrt_update_comment_counter($comment_id, 'aksrt_comment_likes', $target ? 1 : -1);
|
||||
jio_set_comment_like_state($comment_id, $target);
|
||||
$count = jio_update_comment_counter($comment_id, 'jio_comment_likes', $target ? 1 : -1);
|
||||
if (is_user_logged_in()) {
|
||||
do_action('aksrt_comment_liked', $comment_id, get_current_user_id(), (bool) $target);
|
||||
do_action('jio_comment_liked', $comment_id, get_current_user_id(), (bool) $target);
|
||||
}
|
||||
} else {
|
||||
$count = aksrt_get_comment_likes($comment_id);
|
||||
$count = jio_get_comment_likes($comment_id);
|
||||
}
|
||||
|
||||
return new \WP_REST_Response([
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -21,14 +21,16 @@ class DBMigrator {
|
||||
// 2.6.0: order_aftersale 新增 handling_log 列(处理记录:每次状态提交一条
|
||||
// 「状态 + 备注 + 来源 + 时间」),取代单一的 admin_note / reviewed_at / completed_at,
|
||||
// 并移除从未被写入的 gateway_request_id / gateway_refund_id / gateway_result。
|
||||
// 3.0.0: 售后(order_aftersale)整体替换为工单系统(6 张 aksrt_ticket* 表)。
|
||||
// 3.0.0: 售后(order_aftersale)整体替换为工单系统(6 张 jio_ticket* 表)。
|
||||
// 工单不再绑定订单退款流程:标题 + 部门 + 描述为必填,关联订单为可选项;
|
||||
// 沟通记录从工单上的 JSON 日志升级为独立的 ticket_reply 行(支持引用回复)。
|
||||
// 3.1.0: aksrt_ticket 新增 urge_count / last_urge_time(催单次数与最近催单时间),
|
||||
// 3.1.0: jio_ticket 新增 urge_count / last_urge_time(催单次数与最近催单时间),
|
||||
// 催单冷却改由 last_urge_time 判定,不再依赖 transient;催单同时写入 system 类型的 ticket_reply。
|
||||
const SCHEMA_VERSION = '3.2.0';
|
||||
// 3.3.0: 主题品牌由 AKSRT 更名为 Jio,表名前缀 aksrt_ → jio_。dbDelta 只建不删,
|
||||
// 因此版本必须提升,否则既有安装仍读旧表;新安装直接建 jio_* 表。
|
||||
const SCHEMA_VERSION = '3.3.0';
|
||||
|
||||
const OPT_KEY = 'aksrt_db_schema_version';
|
||||
const OPT_KEY = 'jio_db_schema_version';
|
||||
|
||||
/**
|
||||
* Register hooks.
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
/**
|
||||
* Identity verification tables.
|
||||
*
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
trait DBMigratorIdentity {
|
||||
|
||||
private static function migrate_identity_tables(string $prefix, string $charset_collate): void {
|
||||
$application = "CREATE TABLE {$prefix}aksrt_identity_application (
|
||||
$application = "CREATE TABLE {$prefix}jio_identity_application (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
application_uuid CHAR(36) NOT NULL,
|
||||
client_request_id CHAR(36) NOT NULL,
|
||||
@@ -39,7 +39,7 @@ trait DBMigratorIdentity {
|
||||
) ENGINE=InnoDB {$charset_collate};";
|
||||
dbDelta($application);
|
||||
|
||||
$event = "CREATE TABLE {$prefix}aksrt_identity_event (
|
||||
$event = "CREATE TABLE {$prefix}jio_identity_event (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
application_id BIGINT UNSIGNED NOT NULL,
|
||||
event_uuid CHAR(36) NOT NULL,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -21,7 +21,7 @@ trait DBMigratorPart2 {
|
||||
$prefix = $wpdb->prefix;
|
||||
|
||||
// ---------- 1. 统一资产账户与不可变账本 ----------
|
||||
$sql_asset_account = "CREATE TABLE {$prefix}aksrt_asset_account (
|
||||
$sql_asset_account = "CREATE TABLE {$prefix}jio_asset_account (
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
asset VARCHAR(16) NOT NULL,
|
||||
balance_minor BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
@@ -32,7 +32,7 @@ trait DBMigratorPart2 {
|
||||
) ENGINE=InnoDB {$charset_collate};";
|
||||
dbDelta($sql_asset_account);
|
||||
|
||||
$sql_asset_transaction = "CREATE TABLE {$prefix}aksrt_asset_transaction (
|
||||
$sql_asset_transaction = "CREATE TABLE {$prefix}jio_asset_transaction (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
operation_key VARCHAR(191) NOT NULL,
|
||||
payload_hash CHAR(64) NOT NULL,
|
||||
@@ -51,7 +51,7 @@ trait DBMigratorPart2 {
|
||||
) ENGINE=InnoDB {$charset_collate};";
|
||||
dbDelta($sql_asset_transaction);
|
||||
|
||||
$sql_asset_entry = "CREATE TABLE {$prefix}aksrt_asset_entry (
|
||||
$sql_asset_entry = "CREATE TABLE {$prefix}jio_asset_entry (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
transaction_id BIGINT UNSIGNED NOT NULL,
|
||||
line_no SMALLINT UNSIGNED NOT NULL,
|
||||
@@ -74,7 +74,7 @@ trait DBMigratorPart2 {
|
||||
// 外加同条件的 COUNT(*),且界面上的日期区间筛选也只有 created_at 可用。
|
||||
// 索引必须能以 created_at 为前导列,否则每次翻页都是全表扫描 + filesort,
|
||||
// 而 idx_flow_event_time 的前导列是 event_type(筛选时可空),救不了这两条查询。
|
||||
$sql_financial_flow = "CREATE TABLE {$prefix}aksrt_financial_flow (
|
||||
$sql_financial_flow = "CREATE TABLE {$prefix}jio_financial_flow (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
flow_number VARCHAR(32) NOT NULL,
|
||||
operation_key VARCHAR(191) NOT NULL,
|
||||
@@ -100,7 +100,7 @@ trait DBMigratorPart2 {
|
||||
) ENGINE=InnoDB {$charset_collate};";
|
||||
dbDelta($sql_financial_flow);
|
||||
|
||||
$sql_financial_flow_entry = "CREATE TABLE {$prefix}aksrt_financial_flow_entry (
|
||||
$sql_financial_flow_entry = "CREATE TABLE {$prefix}jio_financial_flow_entry (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
flow_id BIGINT UNSIGNED NOT NULL,
|
||||
line_no SMALLINT UNSIGNED NOT NULL,
|
||||
@@ -122,7 +122,7 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_financial_flow_entry);
|
||||
|
||||
// ---------- 2. 签到 ----------
|
||||
$sql_signin = "CREATE TABLE {$prefix}aksrt_signin_log (
|
||||
$sql_signin = "CREATE TABLE {$prefix}jio_signin_log (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
signin_date DATE NOT NULL,
|
||||
@@ -135,7 +135,7 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_signin);
|
||||
|
||||
// ---------- 3. 下载 token ----------
|
||||
$sql_dl_token = "CREATE TABLE {$prefix}aksrt_dl_token (
|
||||
$sql_dl_token = "CREATE TABLE {$prefix}jio_dl_token (
|
||||
token CHAR(48) NOT NULL,
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
post_id BIGINT UNSIGNED NOT NULL,
|
||||
@@ -155,7 +155,7 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_dl_token);
|
||||
|
||||
// ---------- 5. 用户通知收件箱 ----------
|
||||
$sql_notification = "CREATE TABLE {$prefix}aksrt_notification (
|
||||
$sql_notification = "CREATE TABLE {$prefix}jio_notification (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
type VARCHAR(32) NOT NULL,
|
||||
@@ -172,7 +172,7 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_notification);
|
||||
|
||||
// ---------- 8. 订单表 ----------
|
||||
$sql_order = "CREATE TABLE {$prefix}aksrt_order (
|
||||
$sql_order = "CREATE TABLE {$prefix}jio_order (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
order_number VARCHAR(32) NOT NULL,
|
||||
request_key VARCHAR(191) DEFAULT NULL,
|
||||
@@ -205,7 +205,7 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_order);
|
||||
|
||||
// ---------- 9. 作者收益台账 ----------
|
||||
$sql_revenue = "CREATE TABLE {$prefix}aksrt_revenue (
|
||||
$sql_revenue = "CREATE TABLE {$prefix}jio_revenue (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
author_id BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
order_number VARCHAR(32) NOT NULL DEFAULT '',
|
||||
@@ -237,7 +237,7 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_revenue);
|
||||
|
||||
// ---------- 10. 提现台账 ----------
|
||||
$sql_withdrawal = "CREATE TABLE {$prefix}aksrt_withdrawal (
|
||||
$sql_withdrawal = "CREATE TABLE {$prefix}jio_withdrawal (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
withdrawal_number VARCHAR(32) NOT NULL,
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
@@ -263,7 +263,7 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_withdrawal);
|
||||
|
||||
// ---------- 11. 举报工单 ----------
|
||||
$sql_report = "CREATE TABLE {$prefix}aksrt_report (
|
||||
$sql_report = "CREATE TABLE {$prefix}jio_report (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
reporter_id BIGINT UNSIGNED NOT NULL,
|
||||
target_type VARCHAR(20) NOT NULL,
|
||||
@@ -283,7 +283,7 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_report);
|
||||
|
||||
// ---------- 12. 用户限制/封禁 ----------
|
||||
$sql_restriction = "CREATE TABLE {$prefix}aksrt_user_restriction (
|
||||
$sql_restriction = "CREATE TABLE {$prefix}jio_user_restriction (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
type VARCHAR(20) NOT NULL DEFAULT 'warn',
|
||||
@@ -302,7 +302,7 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_restriction);
|
||||
|
||||
// ── follow ──
|
||||
$sql_follow = "CREATE TABLE {$prefix}aksrt_follow (
|
||||
$sql_follow = "CREATE TABLE {$prefix}jio_follow (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
follower_id BIGINT UNSIGNED NOT NULL,
|
||||
following_id BIGINT UNSIGNED NOT NULL,
|
||||
@@ -315,7 +315,7 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_follow);
|
||||
|
||||
// ── coupon ──
|
||||
$sql_coupon = "CREATE TABLE {$prefix}aksrt_coupon (
|
||||
$sql_coupon = "CREATE TABLE {$prefix}jio_coupon (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
code VARCHAR(60) NOT NULL DEFAULT '',
|
||||
type VARCHAR(20) NOT NULL DEFAULT 'fixed',
|
||||
@@ -337,7 +337,7 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_coupon);
|
||||
|
||||
// ── coupon_usage (R68) ──
|
||||
$sql_coupon_usage = "CREATE TABLE {$prefix}aksrt_coupon_usage (
|
||||
$sql_coupon_usage = "CREATE TABLE {$prefix}jio_coupon_usage (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
coupon_id BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
user_id BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
@@ -352,7 +352,7 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_coupon_usage);
|
||||
|
||||
// ── typed charge cards ──
|
||||
$sql_charge_card = "CREATE TABLE {$prefix}aksrt_charge_card (
|
||||
$sql_charge_card = "CREATE TABLE {$prefix}jio_charge_card (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
card VARCHAR(60) NOT NULL DEFAULT '',
|
||||
password VARCHAR(80) NOT NULL DEFAULT '',
|
||||
@@ -379,7 +379,7 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_charge_card);
|
||||
|
||||
// ── one-time invite codes (registration gate + per-batch rewards) ──
|
||||
$sql_invite_code = "CREATE TABLE {$prefix}aksrt_invite_code (
|
||||
$sql_invite_code = "CREATE TABLE {$prefix}jio_invite_code (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
code VARCHAR(32) NOT NULL,
|
||||
batch_id VARCHAR(32) NOT NULL DEFAULT '',
|
||||
@@ -401,7 +401,7 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_invite_code);
|
||||
|
||||
// ── invite-code usage log (who consumed which code) ──
|
||||
$sql_invite_code_usage = "CREATE TABLE {$prefix}aksrt_invite_code_usage (
|
||||
$sql_invite_code_usage = "CREATE TABLE {$prefix}jio_invite_code_usage (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
code_id BIGINT UNSIGNED NOT NULL,
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
@@ -414,7 +414,7 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_invite_code_usage);
|
||||
|
||||
// ── canonical Ref attribution and permanent user binding ──
|
||||
$sql_affiliate_relation = "CREATE TABLE {$prefix}aksrt_affiliate_relation (
|
||||
$sql_affiliate_relation = "CREATE TABLE {$prefix}jio_affiliate_relation (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
referral_code VARCHAR(32) NOT NULL,
|
||||
promoter_id BIGINT UNSIGNED NOT NULL,
|
||||
@@ -439,7 +439,7 @@ trait DBMigratorPart2 {
|
||||
// ── immutable commission ledger ──
|
||||
// 佣金即时入账(无冻结/结算期):下单支付即 credit 到 COMMISSION 资金池,
|
||||
// 本表仅作佣金明细账 + 退款冲正的溯源记录。status: credited | cancelled。
|
||||
$sql_commission_ledger = "CREATE TABLE {$prefix}aksrt_commission_ledger (
|
||||
$sql_commission_ledger = "CREATE TABLE {$prefix}jio_commission_ledger (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
promoter_id BIGINT UNSIGNED NOT NULL,
|
||||
source_user_id BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
@@ -466,7 +466,7 @@ trait DBMigratorPart2 {
|
||||
|
||||
// 佣金欠款挂账:退款全额收回后,若佣金池不足产生的差额记为欠款,
|
||||
// 后续新增佣金先抵扣欠款再入池。每用户一行。
|
||||
$sql_commission_debt = "CREATE TABLE {$prefix}aksrt_commission_debt (
|
||||
$sql_commission_debt = "CREATE TABLE {$prefix}jio_commission_debt (
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
debt_minor BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
updated_at DATETIME NOT NULL,
|
||||
@@ -475,7 +475,7 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_commission_debt);
|
||||
|
||||
// ── immutable commission adjustments (refund/debt/manual) ──
|
||||
$sql_commission_adjustment = "CREATE TABLE {$prefix}aksrt_commission_adjustment (
|
||||
$sql_commission_adjustment = "CREATE TABLE {$prefix}jio_commission_adjustment (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
ledger_id BIGINT UNSIGNED NOT NULL,
|
||||
promoter_id BIGINT UNSIGNED NOT NULL,
|
||||
@@ -493,7 +493,7 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_commission_adjustment);
|
||||
|
||||
// ── payout account snapshots ──
|
||||
$sql_payout_account = "CREATE TABLE {$prefix}aksrt_payout_account (
|
||||
$sql_payout_account = "CREATE TABLE {$prefix}jio_payout_account (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
channel VARCHAR(20) NOT NULL,
|
||||
@@ -509,7 +509,7 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_payout_account);
|
||||
|
||||
// ── order_items (§6.5 多商品多商家) ──
|
||||
$sql_order_items = "CREATE TABLE {$prefix}aksrt_order_item (
|
||||
$sql_order_items = "CREATE TABLE {$prefix}jio_order_item (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
order_number VARCHAR(32) NOT NULL DEFAULT '',
|
||||
product_id BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -16,40 +16,40 @@ trait DBMigratorPart3 {
|
||||
public static function table(string $name): string {
|
||||
global $wpdb;
|
||||
$allowed = [
|
||||
'asset_account' => 'aksrt_asset_account',
|
||||
'asset_transaction' => 'aksrt_asset_transaction',
|
||||
'asset_entry' => 'aksrt_asset_entry',
|
||||
'financial_flow' => 'aksrt_financial_flow',
|
||||
'financial_flow_entry' => 'aksrt_financial_flow_entry',
|
||||
'signin_log' => 'aksrt_signin_log',
|
||||
'dl_token' => 'aksrt_dl_token',
|
||||
'notification' => 'aksrt_notification',
|
||||
'order' => 'aksrt_order',
|
||||
'order_item' => 'aksrt_order_item',
|
||||
'ticket' => 'aksrt_ticket',
|
||||
'ticket_reply' => 'aksrt_ticket_reply',
|
||||
'ticket_status' => 'aksrt_ticket_status',
|
||||
'ticket_type' => 'aksrt_ticket_type',
|
||||
'ticket_prereply' => 'aksrt_ticket_prereply',
|
||||
'ticket_note' => 'aksrt_ticket_note',
|
||||
'revenue' => 'aksrt_revenue',
|
||||
'withdrawal' => 'aksrt_withdrawal',
|
||||
'report' => 'aksrt_report',
|
||||
'follow' => 'aksrt_follow',
|
||||
'coupon' => 'aksrt_coupon',
|
||||
'charge_card' => 'aksrt_charge_card',
|
||||
'invite_code' => 'aksrt_invite_code',
|
||||
'invite_code_usage' => 'aksrt_invite_code_usage',
|
||||
'affiliate_relation' => 'aksrt_affiliate_relation',
|
||||
'commission_ledger' => 'aksrt_commission_ledger',
|
||||
'commission_adjustment' => 'aksrt_commission_adjustment',
|
||||
'commission_debt' => 'aksrt_commission_debt',
|
||||
'payout_account' => 'aksrt_payout_account',
|
||||
'coupon_usage' => 'aksrt_coupon_usage',
|
||||
'user_restriction' => 'aksrt_user_restriction',
|
||||
'identity_application' => 'aksrt_identity_application',
|
||||
'identity_event' => 'aksrt_identity_event',
|
||||
'vip_membership_event' => 'aksrt_vip_membership_event',
|
||||
'asset_account' => 'jio_asset_account',
|
||||
'asset_transaction' => 'jio_asset_transaction',
|
||||
'asset_entry' => 'jio_asset_entry',
|
||||
'financial_flow' => 'jio_financial_flow',
|
||||
'financial_flow_entry' => 'jio_financial_flow_entry',
|
||||
'signin_log' => 'jio_signin_log',
|
||||
'dl_token' => 'jio_dl_token',
|
||||
'notification' => 'jio_notification',
|
||||
'order' => 'jio_order',
|
||||
'order_item' => 'jio_order_item',
|
||||
'ticket' => 'jio_ticket',
|
||||
'ticket_reply' => 'jio_ticket_reply',
|
||||
'ticket_status' => 'jio_ticket_status',
|
||||
'ticket_type' => 'jio_ticket_type',
|
||||
'ticket_prereply' => 'jio_ticket_prereply',
|
||||
'ticket_note' => 'jio_ticket_note',
|
||||
'revenue' => 'jio_revenue',
|
||||
'withdrawal' => 'jio_withdrawal',
|
||||
'report' => 'jio_report',
|
||||
'follow' => 'jio_follow',
|
||||
'coupon' => 'jio_coupon',
|
||||
'charge_card' => 'jio_charge_card',
|
||||
'invite_code' => 'jio_invite_code',
|
||||
'invite_code_usage' => 'jio_invite_code_usage',
|
||||
'affiliate_relation' => 'jio_affiliate_relation',
|
||||
'commission_ledger' => 'jio_commission_ledger',
|
||||
'commission_adjustment' => 'jio_commission_adjustment',
|
||||
'commission_debt' => 'jio_commission_debt',
|
||||
'payout_account' => 'jio_payout_account',
|
||||
'coupon_usage' => 'jio_coupon_usage',
|
||||
'user_restriction' => 'jio_user_restriction',
|
||||
'identity_application' => 'jio_identity_application',
|
||||
'identity_event' => 'jio_identity_event',
|
||||
'vip_membership_event' => 'jio_vip_membership_event',
|
||||
];
|
||||
if (!isset($allowed[$name])) {
|
||||
return '';
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
/**
|
||||
* Ticket (工单) tables.
|
||||
*
|
||||
* 6 张表取代旧的 aksrt_order_aftersale:工单不再绑定订单退款流程,
|
||||
* 6 张表取代旧的 jio_order_aftersale:工单不再绑定订单退款流程,
|
||||
* 标题 + 部门 + 描述为必填,关联订单为可选项。
|
||||
*
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
trait DBMigratorTicket {
|
||||
|
||||
private static function migrate_ticket_tables(string $prefix, string $charset_collate): void {
|
||||
$ticket = "CREATE TABLE {$prefix}aksrt_ticket (
|
||||
$ticket = "CREATE TABLE {$prefix}jio_ticket (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
ticket_num VARCHAR(32) NOT NULL,
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
@@ -44,7 +44,7 @@ trait DBMigratorTicket {
|
||||
) ENGINE=InnoDB {$charset_collate};";
|
||||
dbDelta($ticket);
|
||||
|
||||
$reply = "CREATE TABLE {$prefix}aksrt_ticket_reply (
|
||||
$reply = "CREATE TABLE {$prefix}jio_ticket_reply (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
ticket_id BIGINT UNSIGNED NOT NULL,
|
||||
author_type VARCHAR(16) NOT NULL DEFAULT 'user',
|
||||
@@ -59,9 +59,9 @@ trait DBMigratorTicket {
|
||||
) ENGINE=InnoDB {$charset_collate};";
|
||||
dbDelta($reply);
|
||||
|
||||
// status_key 是工单上 aksrt_ticket.status 的外延键:管理员改状态名只动 name,
|
||||
// status_key 是工单上 jio_ticket.status 的外延键:管理员改状态名只动 name,
|
||||
// 存量工单的 status 不受影响。默认状态(is_default)不可改删。
|
||||
$status = "CREATE TABLE {$prefix}aksrt_ticket_status (
|
||||
$status = "CREATE TABLE {$prefix}jio_ticket_status (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
status_key VARCHAR(24) NOT NULL,
|
||||
name VARCHAR(60) NOT NULL,
|
||||
@@ -76,7 +76,7 @@ trait DBMigratorTicket {
|
||||
) ENGINE=InnoDB {$charset_collate};";
|
||||
dbDelta($status);
|
||||
|
||||
$type = "CREATE TABLE {$prefix}aksrt_ticket_type (
|
||||
$type = "CREATE TABLE {$prefix}jio_ticket_type (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
name VARCHAR(120) NOT NULL,
|
||||
description TEXT DEFAULT NULL,
|
||||
@@ -88,7 +88,7 @@ trait DBMigratorTicket {
|
||||
) ENGINE=InnoDB {$charset_collate};";
|
||||
dbDelta($type);
|
||||
|
||||
$prereply = "CREATE TABLE {$prefix}aksrt_ticket_prereply (
|
||||
$prereply = "CREATE TABLE {$prefix}jio_ticket_prereply (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
content TEXT NOT NULL,
|
||||
sort_order INT NOT NULL DEFAULT 0,
|
||||
@@ -97,7 +97,7 @@ trait DBMigratorTicket {
|
||||
) ENGINE=InnoDB {$charset_collate};";
|
||||
dbDelta($prereply);
|
||||
|
||||
$note = "CREATE TABLE {$prefix}aksrt_ticket_note (
|
||||
$note = "CREATE TABLE {$prefix}jio_ticket_note (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
ticket_id BIGINT UNSIGNED NOT NULL,
|
||||
admin_id BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
@@ -120,7 +120,7 @@ trait DBMigratorTicket {
|
||||
*/
|
||||
private static function seed_ticket_statuses(string $prefix): void {
|
||||
global $wpdb;
|
||||
$table = $prefix . 'aksrt_ticket_status';
|
||||
$table = $prefix . 'jio_ticket_status';
|
||||
$now = current_time('mysql');
|
||||
$seeds = [
|
||||
['pending', '待接单', '#f59e0b', 0, 1],
|
||||
@@ -155,7 +155,7 @@ trait DBMigratorTicket {
|
||||
/** 工单部门 seeds:按 name 幂等补齐。 */
|
||||
private static function seed_ticket_types(string $prefix): void {
|
||||
global $wpdb;
|
||||
$table = $prefix . 'aksrt_ticket_type';
|
||||
$table = $prefix . 'jio_ticket_type';
|
||||
$now = current_time('mysql');
|
||||
$seeds = ['技术支持', '账号问题', '财务问题', '产品建议', '其他'];
|
||||
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
/**
|
||||
* VIP membership audit table.
|
||||
*
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
trait DBMigratorVip {
|
||||
|
||||
private static function migrate_vip_tables(string $prefix, string $charset_collate): void {
|
||||
$event = "CREATE TABLE {$prefix}aksrt_vip_membership_event (
|
||||
$event = "CREATE TABLE {$prefix}jio_vip_membership_event (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
event_uuid CHAR(36) NOT NULL,
|
||||
batch_uuid CHAR(36) NOT NULL DEFAULT '',
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
|
||||
+29
-29
@@ -1,28 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
class DomainModel {
|
||||
|
||||
public const POST_META_KEY = 'aksrt_post_meta';
|
||||
public const TERM_META_KEY = 'aksrt_term_meta';
|
||||
public const POST_META_KEY = 'jio_post_meta';
|
||||
public const TERM_META_KEY = 'jio_term_meta';
|
||||
|
||||
public const PAY_META_KEY = '_aksrt_pay';
|
||||
public const PAY_TYPE_KEY = '_aksrt_pay_type';
|
||||
public const PAY_PRICE_KEY = '_aksrt_pay_price';
|
||||
public const PAY_META_KEY = '_jio_pay';
|
||||
public const PAY_TYPE_KEY = '_jio_pay_type';
|
||||
public const PAY_PRICE_KEY = '_jio_pay_price';
|
||||
|
||||
public const RESOURCE_MARKER_KEY = '_aksrt_is_resource';
|
||||
public const RESOURCE_DOWNLOAD_COUNT_KEY = '_aksrt_res_download_count';
|
||||
public const RESOURCE_VIEW_COUNT_KEY = '_aksrt_res_view_count';
|
||||
public const RESOURCE_SALES_VOLUME_KEY = '_aksrt_sales_volume';
|
||||
public const POST_VIEW_COUNT_KEY = 'aksrt_post_views';
|
||||
public const RESOURCE_MARKER_KEY = '_jio_is_resource';
|
||||
public const RESOURCE_DOWNLOAD_COUNT_KEY = '_jio_res_download_count';
|
||||
public const RESOURCE_VIEW_COUNT_KEY = '_jio_res_view_count';
|
||||
public const RESOURCE_SALES_VOLUME_KEY = '_jio_sales_volume';
|
||||
public const POST_VIEW_COUNT_KEY = 'jio_post_views';
|
||||
|
||||
public const RESOURCE_PAY_META_MIGRATED = 'aksrt_resource_pay_meta_migrated';
|
||||
public const RESOURCE_PAY_META_MIGRATED = 'jio_resource_pay_meta_migrated';
|
||||
|
||||
/**
|
||||
* Allowed download-button color classes (legacy .but swatch system).
|
||||
@@ -49,19 +49,19 @@ class DomainModel {
|
||||
public const ORDER_PRODUCT_POINTS = 'points';
|
||||
|
||||
/**
|
||||
* Human labels for aksrt_order.product_type (front-end order center).
|
||||
* Human labels for jio_order.product_type (front-end order center).
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function order_product_type_labels(): array {
|
||||
return [
|
||||
self::ORDER_PRODUCT_READING => __('付费阅读', 'aksrt'),
|
||||
self::ORDER_PRODUCT_DOWNLOAD => __('付费下载', 'aksrt'),
|
||||
self::ORDER_PRODUCT_IMAGE => __('付费图片', 'aksrt'),
|
||||
self::ORDER_PRODUCT_VIDEO => __('付费视频', 'aksrt'),
|
||||
self::ORDER_PRODUCT_VIP => __('购买会员', 'aksrt'),
|
||||
self::ORDER_PRODUCT_RECHARGE => __('余额充值', 'aksrt'),
|
||||
self::ORDER_PRODUCT_POINTS => __('购买积分', 'aksrt'),
|
||||
self::ORDER_PRODUCT_READING => __('付费阅读', 'jio'),
|
||||
self::ORDER_PRODUCT_DOWNLOAD => __('付费下载', 'jio'),
|
||||
self::ORDER_PRODUCT_IMAGE => __('付费图片', 'jio'),
|
||||
self::ORDER_PRODUCT_VIDEO => __('付费视频', 'jio'),
|
||||
self::ORDER_PRODUCT_VIP => __('购买会员', 'jio'),
|
||||
self::ORDER_PRODUCT_RECHARGE => __('余额充值', 'jio'),
|
||||
self::ORDER_PRODUCT_POINTS => __('购买积分', 'jio'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ class DomainModel {
|
||||
'show_sales' => true,
|
||||
// legacy: free daily quota overbuy price (cash or points by pay_modo).
|
||||
'download_limit_over_price' => '0.00',
|
||||
// Content cashier: coupon + buyer-facing 推广折扣 (legacy posts_aksrtpay).
|
||||
// Content cashier: coupon + buyer-facing 推广折扣 (legacy posts_jiopay).
|
||||
'coupon_s' => false,
|
||||
'coupon_desc' => '',
|
||||
'pay_rebate_discount' => '0.00',
|
||||
@@ -302,8 +302,8 @@ class DomainModel {
|
||||
'extract_code' => $extract_code,
|
||||
'copy_key' => isset($row['copy_key']) ? sanitize_text_field((string) $row['copy_key']) : '',
|
||||
'copy_val' => isset($row['copy_val']) ? sanitize_text_field((string) $row['copy_val']) : '',
|
||||
'icon' => isset($row['icon']) && function_exists('aksrt_sanitize_icon_value')
|
||||
? aksrt_sanitize_icon_value((string) $row['icon'])
|
||||
'icon' => isset($row['icon']) && function_exists('jio_sanitize_icon_value')
|
||||
? jio_sanitize_icon_value((string) $row['icon'])
|
||||
: (isset($row['icon']) ? sanitize_text_field((string) $row['icon']) : ''),
|
||||
'class' => isset($row['class']) && in_array($row['class'], $allowed_classes, true)
|
||||
? (string) $row['class']
|
||||
@@ -455,7 +455,7 @@ class DomainModel {
|
||||
return '0.00';
|
||||
}
|
||||
try {
|
||||
return \AKSRT\Ledger\AssetAmount::balance($value)->decimal();
|
||||
return \Jio\Ledger\AssetAmount::balance($value)->decimal();
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
return '0.00';
|
||||
}
|
||||
@@ -482,10 +482,10 @@ class DomainModel {
|
||||
*/
|
||||
public static function order_status_labels(): array {
|
||||
return [
|
||||
self::ORDER_STATUS_PENDING => __('待支付', 'aksrt'),
|
||||
self::ORDER_STATUS_PAID => __('已支付', 'aksrt'),
|
||||
self::ORDER_STATUS_REFUNDED => __('已退款', 'aksrt'),
|
||||
self::ORDER_STATUS_CLOSED => __('已关闭', 'aksrt'),
|
||||
self::ORDER_STATUS_PENDING => __('待支付', 'jio'),
|
||||
self::ORDER_STATUS_PAID => __('已支付', 'jio'),
|
||||
self::ORDER_STATUS_REFUNDED => __('已退款', 'jio'),
|
||||
self::ORDER_STATUS_CLOSED => __('已关闭', 'jio'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
+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;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -26,7 +26,7 @@ trait FrontSubmitChunk {
|
||||
},
|
||||
];
|
||||
|
||||
register_rest_route('aksrt/v1', '/front-submit/upload-chunk/(?P<kind>image|video|resource)', [
|
||||
register_rest_route('jio/v1', '/front-submit/upload-chunk/(?P<kind>image|video|resource)', [
|
||||
'methods' => 'POST',
|
||||
'callback' => [$this, 'rest_upload_chunk'],
|
||||
'permission_callback' => [$this, 'can_upload_attachment'],
|
||||
@@ -39,7 +39,7 @@ trait FrontSubmitChunk {
|
||||
],
|
||||
]);
|
||||
|
||||
register_rest_route('aksrt/v1', '/front-submit/upload-merge/(?P<kind>image|video|resource)', [
|
||||
register_rest_route('jio/v1', '/front-submit/upload-merge/(?P<kind>image|video|resource)', [
|
||||
'methods' => 'POST',
|
||||
'callback' => [$this, 'rest_upload_chunk_merge'],
|
||||
'permission_callback' => [$this, 'can_upload_attachment'],
|
||||
@@ -51,7 +51,7 @@ trait FrontSubmitChunk {
|
||||
],
|
||||
]);
|
||||
|
||||
register_rest_route('aksrt/v1', '/front-submit/upload-status/(?P<kind>image|video|resource)', [
|
||||
register_rest_route('jio/v1', '/front-submit/upload-status/(?P<kind>image|video|resource)', [
|
||||
'methods' => \WP_REST_Server::READABLE,
|
||||
'callback' => [$this, 'rest_upload_chunk_status'],
|
||||
'permission_callback' => [$this, 'can_upload_attachment'],
|
||||
@@ -69,7 +69,7 @@ trait FrontSubmitChunk {
|
||||
public function rest_upload_chunk(\WP_REST_Request $request) {
|
||||
$file = $request->get_file_params()['file'] ?? null;
|
||||
if (!is_array($file) || empty($file['tmp_name']) || (int) ($file['error'] ?? UPLOAD_ERR_NO_FILE) !== UPLOAD_ERR_OK) {
|
||||
return new \WP_Error('aksrt_chunk_missing_file', __('上传信息错误,请重新选择文件', 'aksrt'), ['status' => 400]);
|
||||
return new \WP_Error('jio_chunk_missing_file', __('上传信息错误,请重新选择文件', 'jio'), ['status' => 400]);
|
||||
}
|
||||
|
||||
$params = $this->chunk_params($request, true);
|
||||
@@ -79,12 +79,12 @@ trait FrontSubmitChunk {
|
||||
|
||||
$max_size = self::upload_limit_bytes($params['kind']);
|
||||
if ($params['size'] <= 0 || $params['size'] > $max_size) {
|
||||
return new \WP_Error('aksrt_upload_too_large', sprintf(__('文件大小不能超过 %s。', 'aksrt'), size_format($max_size)), ['status' => 413]);
|
||||
return new \WP_Error('jio_upload_too_large', sprintf(__('文件大小不能超过 %s。', 'jio'), size_format($max_size)), ['status' => 413]);
|
||||
}
|
||||
|
||||
$chunk_bytes = (int) @filesize((string) $file['tmp_name']);
|
||||
if ($chunk_bytes <= 0 || $chunk_bytes > self::CHUNK_SIZE_BYTES) {
|
||||
return new \WP_Error('aksrt_chunk_invalid_size', __('分片大小异常,请重新上传', 'aksrt'), ['status' => 400]);
|
||||
return new \WP_Error('jio_chunk_invalid_size', __('分片大小异常,请重新上传', 'jio'), ['status' => 400]);
|
||||
}
|
||||
|
||||
$temp_dir = $this->chunk_temp_dir();
|
||||
@@ -98,7 +98,7 @@ trait FrontSubmitChunk {
|
||||
$uploaded += (int) @filesize($path);
|
||||
}
|
||||
if ($uploaded + $chunk_bytes > $max_size) {
|
||||
return new \WP_Error('aksrt_upload_too_large', sprintf(__('文件大小不能超过 %s。', 'aksrt'), size_format($max_size)), ['status' => 413]);
|
||||
return new \WP_Error('jio_upload_too_large', sprintf(__('文件大小不能超过 %s。', 'jio'), size_format($max_size)), ['status' => 413]);
|
||||
}
|
||||
|
||||
$target = $temp_dir . '/' . $this->chunk_part_name($params['key'], $params['chunk']);
|
||||
@@ -108,7 +108,7 @@ trait FrontSubmitChunk {
|
||||
@unlink((string) $file['tmp_name']);
|
||||
}
|
||||
if (!$moved) {
|
||||
return new \WP_Error('aksrt_chunk_save_failed', __('分片保存失败,请重新上传', 'aksrt'), ['status' => 500]);
|
||||
return new \WP_Error('jio_chunk_save_failed', __('分片保存失败,请重新上传', 'jio'), ['status' => 500]);
|
||||
}
|
||||
|
||||
return new \WP_REST_Response([
|
||||
@@ -156,7 +156,7 @@ trait FrontSubmitChunk {
|
||||
|
||||
$fp = @fopen($merge_path, 'wb');
|
||||
if (!$fp) {
|
||||
return new \WP_Error('aksrt_chunk_merge_failed', __('分片合并失败,请重新上传', 'aksrt'), ['status' => 500]);
|
||||
return new \WP_Error('jio_chunk_merge_failed', __('分片合并失败,请重新上传', 'jio'), ['status' => 500]);
|
||||
}
|
||||
|
||||
$missing = 0;
|
||||
@@ -172,17 +172,17 @@ trait FrontSubmitChunk {
|
||||
|
||||
if ($missing) {
|
||||
@unlink($merge_path);
|
||||
return new \WP_Error('aksrt_chunk_missing', __('文件缺少分片,正在重新上传缺失分片', 'aksrt'), ['status' => 409]);
|
||||
return new \WP_Error('jio_chunk_missing', __('文件缺少分片,正在重新上传缺失分片', 'jio'), ['status' => 409]);
|
||||
}
|
||||
|
||||
$merged_size = (int) @filesize($merge_path);
|
||||
if ($merged_size <= 0 || ($params['size'] > 0 && $merged_size !== $params['size'])) {
|
||||
@unlink($merge_path);
|
||||
return new \WP_Error('aksrt_chunk_size_mismatch', __('合并后的文件大小校验失败,请重新上传', 'aksrt'), ['status' => 400]);
|
||||
return new \WP_Error('jio_chunk_size_mismatch', __('合并后的文件大小校验失败,请重新上传', 'jio'), ['status' => 400]);
|
||||
}
|
||||
if ($merged_size > $max_size) {
|
||||
@unlink($merge_path);
|
||||
return new \WP_Error('aksrt_upload_too_large', sprintf(__('文件大小不能超过 %s。', 'aksrt'), size_format($max_size)), ['status' => 413]);
|
||||
return new \WP_Error('jio_upload_too_large', sprintf(__('文件大小不能超过 %s。', 'jio'), size_format($max_size)), ['status' => 413]);
|
||||
}
|
||||
|
||||
$name = sanitize_file_name($params['name']);
|
||||
@@ -212,10 +212,10 @@ trait FrontSubmitChunk {
|
||||
$chunk = (int) $request->get_param('chunk');
|
||||
|
||||
if ($name === '' || $chunks < 1 || $chunks > 20480) {
|
||||
return new \WP_Error('aksrt_chunk_invalid_params', __('分片参数异常', 'aksrt'), ['status' => 400]);
|
||||
return new \WP_Error('jio_chunk_invalid_params', __('分片参数异常', 'jio'), ['status' => 400]);
|
||||
}
|
||||
if ($with_index && ($chunk < 0 || $chunk >= $chunks)) {
|
||||
return new \WP_Error('aksrt_chunk_invalid_params', __('分片参数异常', 'aksrt'), ['status' => 400]);
|
||||
return new \WP_Error('jio_chunk_invalid_params', __('分片参数异常', 'jio'), ['status' => 400]);
|
||||
}
|
||||
|
||||
return [
|
||||
@@ -231,7 +231,7 @@ trait FrontSubmitChunk {
|
||||
|
||||
/** 分片临时目录(参考主题为 wp-content/zib-temp,带 index.php 保护和 48h 清理)。 */
|
||||
private function chunk_temp_dir(): string {
|
||||
$temp_dir = (string) apply_filters('aksrt_temp_dir', WP_CONTENT_DIR . '/aksrt-temp');
|
||||
$temp_dir = (string) apply_filters('jio_temp_dir', WP_CONTENT_DIR . '/jio-temp');
|
||||
if (!@is_dir($temp_dir)) {
|
||||
wp_mkdir_p($temp_dir);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
use AKSRT\Attachment\PendingUploads;
|
||||
use Jio\Attachment\PendingUploads;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -195,8 +195,8 @@ trait FrontSubmitMedia {
|
||||
}
|
||||
}
|
||||
|
||||
$pay_meta = function_exists('aksrt_get_pay_meta')
|
||||
? aksrt_get_pay_meta($post_id)
|
||||
$pay_meta = function_exists('jio_get_pay_meta')
|
||||
? jio_get_pay_meta($post_id)
|
||||
: get_post_meta($post_id, DomainModel::PAY_META_KEY, true);
|
||||
$pay_meta = is_array($pay_meta) ? $pay_meta : [];
|
||||
$download_urls = [];
|
||||
@@ -239,18 +239,18 @@ trait FrontSubmitMedia {
|
||||
'posts_per_page' => -1,
|
||||
'fields' => 'ids',
|
||||
'no_found_rows' => true,
|
||||
'meta_key' => '_aksrt_front_submit_media',
|
||||
'meta_key' => '_jio_front_submit_media',
|
||||
]);
|
||||
foreach (array_map('absint', $existing) as $attachment_id) {
|
||||
if (!isset($desired[$attachment_id])) {
|
||||
$wpdb->update($wpdb->posts, ['post_parent' => 0], ['ID' => $attachment_id], ['%d'], ['%d']);
|
||||
clean_post_cache($attachment_id);
|
||||
delete_post_meta($attachment_id, '_aksrt_front_submit_media');
|
||||
delete_post_meta($attachment_id, '_jio_front_submit_media');
|
||||
}
|
||||
}
|
||||
foreach ($desired as $attachment_id => $kind) {
|
||||
$attachment_id = (int) $attachment_id;
|
||||
update_post_meta($attachment_id, '_aksrt_front_submit_media', $kind);
|
||||
update_post_meta($attachment_id, '_jio_front_submit_media', $kind);
|
||||
$wpdb->update($wpdb->posts, ['post_parent' => $post_id], ['ID' => $attachment_id], ['%d'], ['%d']);
|
||||
clean_post_cache($attachment_id);
|
||||
}
|
||||
@@ -267,7 +267,7 @@ trait FrontSubmitMedia {
|
||||
private function extract_attachment_ids(string $content, string $type): array {
|
||||
$ids = [];
|
||||
if ($type === 'file') {
|
||||
preg_match_all('/data-aksrt-file-id\s*=\s*["\']([^"\']+)["\']/i', $content, $matches);
|
||||
preg_match_all('/data-jio-file-id\s*=\s*["\']([^"\']+)["\']/i', $content, $matches);
|
||||
} elseif ($type === 'image') {
|
||||
preg_match_all('/<img\b[^>]*data-edit-file-id\s*=\s*["\']([^"\']+)["\'][^>]*>/i', $content, $matches);
|
||||
} else {
|
||||
|
||||
+27
-27
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -23,15 +23,15 @@ trait FrontSubmitPay {
|
||||
}
|
||||
|
||||
// Only touch pay meta when the form sent pay fields.
|
||||
$has_pay_payload = isset($data['aksrt_pay']) || isset($data['pay_enabled']);
|
||||
$has_pay_payload = isset($data['jio_pay']) || isset($data['pay_enabled']);
|
||||
if (!$has_pay_payload) {
|
||||
return ['success' => true];
|
||||
}
|
||||
|
||||
$raw = is_array($data['aksrt_pay'] ?? null) ? $data['aksrt_pay'] : [];
|
||||
$raw = is_array($data['jio_pay'] ?? null) ? $data['jio_pay'] : [];
|
||||
$enabled = !empty($data['pay_enabled']);
|
||||
|
||||
$existing = function_exists('aksrt_get_pay_meta') ? aksrt_get_pay_meta($post_id) : DomainModel::default_pay_meta();
|
||||
$existing = function_exists('jio_get_pay_meta') ? jio_get_pay_meta($post_id) : DomainModel::default_pay_meta();
|
||||
$meta = is_array($existing) ? $existing : DomainModel::default_pay_meta();
|
||||
|
||||
if (!$enabled) {
|
||||
@@ -76,16 +76,16 @@ trait FrontSubmitPay {
|
||||
$min = max(0, (int) ($settings['pay_points_min'] ?? 0));
|
||||
$max = max(0, (int) ($settings['pay_points_max'] ?? 0));
|
||||
if ($points === null) {
|
||||
return ['success' => false, 'message' => __('请设置正确的积分价格', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('请设置正确的积分价格', 'jio')];
|
||||
}
|
||||
if (!$allow_free && $points <= 0) {
|
||||
return ['success' => false, 'message' => __('请设置付费内容的积分价格', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('请设置付费内容的积分价格', 'jio')];
|
||||
}
|
||||
if ($min > 0 && $points < $min) {
|
||||
return ['success' => false, 'message' => sprintf(__('积分价格不能低于:%s', 'aksrt'), (string) $min)];
|
||||
return ['success' => false, 'message' => sprintf(__('积分价格不能低于:%s', 'jio'), (string) $min)];
|
||||
}
|
||||
if ($max > 0 && $points > $max) {
|
||||
return ['success' => false, 'message' => sprintf(__('积分价格不能高于:%s', 'aksrt'), (string) $max)];
|
||||
return ['success' => false, 'message' => sprintf(__('积分价格不能高于:%s', 'jio'), (string) $max)];
|
||||
}
|
||||
|
||||
if ($vip_manual) {
|
||||
@@ -96,13 +96,13 @@ trait FrontSubmitPay {
|
||||
? $this->parse_front_points($raw['vip2_points'] ?? null)
|
||||
: 0;
|
||||
if (($vip1_enabled && $vip1 === null) || ($vip2_enabled && $vip2 === null)) {
|
||||
return ['success' => false, 'message' => __('请设置正确的会员积分价格', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('请设置正确的会员积分价格', 'jio')];
|
||||
}
|
||||
if ($vip1_enabled && $vip1 > $points) {
|
||||
return ['success' => false, 'message' => __('会员积分价格不能高于普通积分价格', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('会员积分价格不能高于普通积分价格', 'jio')];
|
||||
}
|
||||
if ($vip2_enabled && $vip2 > ($vip1_enabled ? $vip1 : $points)) {
|
||||
return ['success' => false, 'message' => __('更高等级会员积分价格不能高于较低等级会员积分价格', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('更高等级会员积分价格不能高于较低等级会员积分价格', 'jio')];
|
||||
}
|
||||
} else {
|
||||
$vip1 = (intdiv($points, 100) * $vip1_disc) + intdiv(($points % 100) * $vip1_disc, 100);
|
||||
@@ -121,19 +121,19 @@ trait FrontSubmitPay {
|
||||
$price_minor = $this->parse_front_cash_minor($raw['price'] ?? null);
|
||||
$min_yuan = max(0, (int) ($settings['pay_price_min'] ?? 0));
|
||||
$max_yuan = max(0, (int) ($settings['pay_price_max'] ?? 0));
|
||||
$min_minor = $min_yuan > 0 ? \AKSRT\Ledger\AssetAmount::balance((string) $min_yuan)->minor() : 0;
|
||||
$max_minor = $max_yuan > 0 ? \AKSRT\Ledger\AssetAmount::balance((string) $max_yuan)->minor() : 0;
|
||||
$min_minor = $min_yuan > 0 ? \Jio\Ledger\AssetAmount::balance((string) $min_yuan)->minor() : 0;
|
||||
$max_minor = $max_yuan > 0 ? \Jio\Ledger\AssetAmount::balance((string) $max_yuan)->minor() : 0;
|
||||
if ($price_minor === null) {
|
||||
return ['success' => false, 'message' => __('请设置正确的价格', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('请设置正确的价格', 'jio')];
|
||||
}
|
||||
if (!$allow_free && $price_minor <= 0) {
|
||||
return ['success' => false, 'message' => __('请设置付费内容的价格', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('请设置付费内容的价格', 'jio')];
|
||||
}
|
||||
if ($min_minor > 0 && $price_minor < $min_minor) {
|
||||
return ['success' => false, 'message' => sprintf(__('价格不能低于:%s', 'aksrt'), \AKSRT\Ledger\AssetAmount::decimal_from_minor($min_minor))];
|
||||
return ['success' => false, 'message' => sprintf(__('价格不能低于:%s', 'jio'), \Jio\Ledger\AssetAmount::decimal_from_minor($min_minor))];
|
||||
}
|
||||
if ($max_minor > 0 && $price_minor > $max_minor) {
|
||||
return ['success' => false, 'message' => sprintf(__('价格不能高于:%s', 'aksrt'), \AKSRT\Ledger\AssetAmount::decimal_from_minor($max_minor))];
|
||||
return ['success' => false, 'message' => sprintf(__('价格不能高于:%s', 'jio'), \Jio\Ledger\AssetAmount::decimal_from_minor($max_minor))];
|
||||
}
|
||||
|
||||
if ($vip_manual) {
|
||||
@@ -144,25 +144,25 @@ trait FrontSubmitPay {
|
||||
? $this->parse_front_cash_minor($raw['vip2_price'] ?? null)
|
||||
: 0;
|
||||
if (($vip1_enabled && $vip1_minor === null) || ($vip2_enabled && $vip2_minor === null)) {
|
||||
return ['success' => false, 'message' => __('请设置正确的会员价格', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('请设置正确的会员价格', 'jio')];
|
||||
}
|
||||
if ($vip1_enabled && $vip1_minor > $price_minor) {
|
||||
return ['success' => false, 'message' => __('会员价不能高于普通价', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('会员价不能高于普通价', 'jio')];
|
||||
}
|
||||
if ($vip2_enabled && $vip2_minor > ($vip1_enabled ? $vip1_minor : $price_minor)) {
|
||||
return ['success' => false, 'message' => __('更高等级会员价不能高于较低等级会员价', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('更高等级会员价不能高于较低等级会员价', 'jio')];
|
||||
}
|
||||
} else {
|
||||
$vip1_minor = \AKSRT\Ledger\AssetAmount::percentage($price_minor, max(0, min(100, $vip1_disc)));
|
||||
$vip2_minor = \AKSRT\Ledger\AssetAmount::percentage($price_minor, max(0, min(100, $vip2_disc)));
|
||||
$vip1_minor = \Jio\Ledger\AssetAmount::percentage($price_minor, max(0, min(100, $vip1_disc)));
|
||||
$vip2_minor = \Jio\Ledger\AssetAmount::percentage($price_minor, max(0, min(100, $vip2_disc)));
|
||||
}
|
||||
$vip1_minor = max(0, min($price_minor, (int) $vip1_minor));
|
||||
$vip2_minor = max(0, min($vip1_enabled ? $vip1_minor : $price_minor, (int) $vip2_minor));
|
||||
|
||||
$meta['price'] = \AKSRT\Ledger\AssetAmount::decimal_from_minor($price_minor);
|
||||
$meta['price'] = \Jio\Ledger\AssetAmount::decimal_from_minor($price_minor);
|
||||
$meta['points_price'] = 0;
|
||||
$meta['vip1_price'] = \AKSRT\Ledger\AssetAmount::decimal_from_minor($vip1_minor);
|
||||
$meta['vip2_price'] = \AKSRT\Ledger\AssetAmount::decimal_from_minor($vip2_minor);
|
||||
$meta['vip1_price'] = \Jio\Ledger\AssetAmount::decimal_from_minor($vip1_minor);
|
||||
$meta['vip2_price'] = \Jio\Ledger\AssetAmount::decimal_from_minor($vip2_minor);
|
||||
$meta['vip1_points'] = 0;
|
||||
$meta['vip2_points'] = 0;
|
||||
}
|
||||
@@ -195,7 +195,7 @@ trait FrontSubmitPay {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return \AKSRT\Ledger\AssetAmount::balance_minor($value);
|
||||
return \Jio\Ledger\AssetAmount::balance_minor($value);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -28,25 +28,25 @@ trait FrontSubmitSave {
|
||||
$is_draft = $action === 'posts_draft';
|
||||
|
||||
if (empty($settings['enabled'])) {
|
||||
return ['success' => false, 'message' => __('投稿功能已关闭', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('投稿功能已关闭', 'jio')];
|
||||
}
|
||||
|
||||
if ($is_guest) {
|
||||
if ((int) $settings['default_user_id'] <= 0) {
|
||||
return ['success' => false, 'message' => __('请先登录', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('请先登录', 'jio')];
|
||||
}
|
||||
if ($is_draft) {
|
||||
return ['success' => false, 'message' => __('未登录无法保存草稿', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('未登录无法保存草稿', 'jio')];
|
||||
}
|
||||
if ($is_edit) {
|
||||
return ['success' => false, 'message' => __('未登录无法编辑文章', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('未登录无法编辑文章', 'jio')];
|
||||
}
|
||||
}
|
||||
|
||||
// 小黑屋(suspend):剥夺发布权限,发帖/草稿/编辑均拦截(对齐参考主题)。
|
||||
if (!$is_guest && \AKSRT\User\Restriction::get_instance()->is_suspended($user_id)) {
|
||||
$suspend = \AKSRT\User\Restriction::get_instance()->get_active_suspend($user_id);
|
||||
$message = __('您已被关入小黑屋,暂时无法发布内容', 'aksrt');
|
||||
if (!$is_guest && \Jio\User\Restriction::get_instance()->is_suspended($user_id)) {
|
||||
$suspend = \Jio\User\Restriction::get_instance()->get_active_suspend($user_id);
|
||||
$message = __('您已被关入小黑屋,暂时无法发布内容', 'jio');
|
||||
if (!empty($suspend['reason'])) {
|
||||
$message .= ',原因:' . $suspend['reason'];
|
||||
}
|
||||
@@ -55,10 +55,10 @@ trait FrontSubmitSave {
|
||||
|
||||
if ($is_edit) {
|
||||
if (!$this->can_edit_post($posts_id, $user_id)) {
|
||||
return ['success' => false, 'message' => __('没有编辑权限', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('没有编辑权限', 'jio')];
|
||||
}
|
||||
} elseif (!$this->can_submit($is_guest ? 0 : $user_id)) {
|
||||
return ['success' => false, 'message' => __('没有投稿权限', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('没有投稿权限', 'jio')];
|
||||
}
|
||||
|
||||
$title = sanitize_text_field((string) ($data['post_title'] ?? $data['title'] ?? ''));
|
||||
@@ -66,10 +66,10 @@ trait FrontSubmitSave {
|
||||
$excerpt = sanitize_textarea_field((string) ($data['excerpt'] ?? $data['post_excerpt'] ?? ''));
|
||||
|
||||
if ($title === '') {
|
||||
return ['success' => false, 'message' => __('请填写文章标题', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('请填写文章标题', 'jio')];
|
||||
}
|
||||
if (trim(wp_strip_all_tags($content)) === '') {
|
||||
return ['success' => false, 'message' => __('还未填写任何内容', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('还未填写任何内容', 'jio')];
|
||||
}
|
||||
|
||||
$categories = $this->normalize_category_ids($data);
|
||||
@@ -78,23 +78,23 @@ trait FrontSubmitSave {
|
||||
if (!$is_draft) {
|
||||
$title_len = $this->text_length($title);
|
||||
if ($title_len < (int) $settings['title_min']) {
|
||||
return ['success' => false, 'message' => __('标题太短!', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('标题太短!', 'jio')];
|
||||
}
|
||||
if ($title_len > (int) $settings['title_max']) {
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => sprintf(
|
||||
/* translators: %d: max title length */
|
||||
__('标题太长了,不能超过%d个字', 'aksrt'),
|
||||
__('标题太长了,不能超过%d个字', 'jio'),
|
||||
(int) $settings['title_max']
|
||||
),
|
||||
];
|
||||
}
|
||||
if ($this->text_length(wp_strip_all_tags($content)) < 10) {
|
||||
return ['success' => false, 'message' => __('文章内容过少', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('文章内容过少', 'jio')];
|
||||
}
|
||||
if (empty($categories)) {
|
||||
return ['success' => false, 'message' => __('请选择文章分类', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('请选择文章分类', 'jio')];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ trait FrontSubmitSave {
|
||||
if (!empty($allowed) && !empty($categories)) {
|
||||
$categories = array_values(array_intersect($categories, $allowed));
|
||||
if (!$is_draft && empty($categories)) {
|
||||
return ['success' => false, 'message' => __('所选分类不可用', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('所选分类不可用', 'jio')];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,23 +111,23 @@ trait FrontSubmitSave {
|
||||
if ($is_guest) {
|
||||
$guest_name = sanitize_text_field((string) ($data['user_name'] ?? ''));
|
||||
if ($guest_name === '') {
|
||||
return ['success' => false, 'message' => __('请输入昵称', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('请输入昵称', 'jio')];
|
||||
}
|
||||
$contact = sanitize_text_field((string) ($data['contact_details'] ?? ''));
|
||||
$suffix = $contact !== ''
|
||||
? sprintf(__('[投稿-姓名:%1$s,联系:%2$s]', 'aksrt'), $guest_name, $contact)
|
||||
: sprintf(__('[投稿-姓名:%s]', 'aksrt'), $guest_name);
|
||||
? sprintf(__('[投稿-姓名:%1$s,联系:%2$s]', 'jio'), $guest_name, $contact)
|
||||
: sprintf(__('[投稿-姓名:%s]', 'jio'), $guest_name);
|
||||
$title = $title . $suffix;
|
||||
$author_id = (int) $settings['default_user_id'];
|
||||
}
|
||||
|
||||
// [防刷机制]发布限制(后台「扩展&增强 → 网站安全」),管理员不受限。
|
||||
if (!$is_edit && !current_user_can('manage_options') && class_exists('\AKSRT\Extensions\SecurityHardening')) {
|
||||
$security = \AKSRT\Settings\ExtensionRuntime::get_security_settings();
|
||||
if (!$is_edit && !current_user_can('manage_options') && class_exists('\Jio\Extensions\SecurityHardening')) {
|
||||
$security = \Jio\Settings\ExtensionRuntime::get_security_settings();
|
||||
$brush_subject = $is_guest
|
||||
? (string) (function_exists('aksrt_get_client_ip') ? aksrt_get_client_ip() : ($_SERVER['REMOTE_ADDR'] ?? ''))
|
||||
? (string) (function_exists('jio_get_client_ip') ? jio_get_client_ip() : ($_SERVER['REMOTE_ADDR'] ?? ''))
|
||||
: (string) $user_id;
|
||||
$brush = \AKSRT\Extensions\SecurityHardening::brush_allow('post', $brush_subject, (int) $security['security_brush_post_10min'], (int) $security['security_brush_post_day']);
|
||||
$brush = \Jio\Extensions\SecurityHardening::brush_allow('post', $brush_subject, (int) $security['security_brush_post_10min'], (int) $security['security_brush_post_day']);
|
||||
if ($brush !== true) {
|
||||
return ['success' => false, 'message' => (string) $brush];
|
||||
}
|
||||
@@ -178,7 +178,7 @@ trait FrontSubmitSave {
|
||||
return ['success' => false, 'message' => $in_id->get_error_message()];
|
||||
}
|
||||
if (!$in_id) {
|
||||
return ['success' => false, 'message' => __('文章保存失败,请稍后再试', 'aksrt')];
|
||||
return ['success' => false, 'message' => __('文章保存失败,请稍后再试', 'jio')];
|
||||
}
|
||||
|
||||
// Re-apply categories when empty update should clear (logged-in only).
|
||||
@@ -206,9 +206,9 @@ trait FrontSubmitSave {
|
||||
}
|
||||
|
||||
if ($post instanceof \WP_Post) {
|
||||
do_action($is_edit ? 'aksrt_new_edit_posts' : 'aksrt_new_add_posts', $post);
|
||||
do_action($is_edit ? 'jio_new_edit_posts' : 'jio_new_add_posts', $post);
|
||||
if ($status === 'pending') {
|
||||
do_action('aksrt_new_posts_pending', $post);
|
||||
do_action('jio_new_posts_pending', $post);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,21 +222,21 @@ trait FrontSubmitSave {
|
||||
|
||||
switch ($status) {
|
||||
case 'pending':
|
||||
$send['message'] = __('内容已提交,正在等待审核', 'aksrt');
|
||||
if ($user_id > 0 && function_exists('aksrt_get_user_home_url')) {
|
||||
$send['message'] = __('内容已提交,正在等待审核', 'jio');
|
||||
if ($user_id > 0 && function_exists('jio_get_user_home_url')) {
|
||||
$send['reload'] = true;
|
||||
$send['goto'] = add_query_arg(
|
||||
['tab' => 'post', 'post_status' => 'pending'],
|
||||
aksrt_get_user_home_url($user_id)
|
||||
jio_get_user_home_url($user_id)
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'draft':
|
||||
$send['message'] = __('草稿已保存', 'aksrt');
|
||||
$send['message'] = __('草稿已保存', 'jio');
|
||||
$send['time'] = current_time('mysql');
|
||||
break;
|
||||
default:
|
||||
$send['message'] = __('文章已发布', 'aksrt');
|
||||
$send['message'] = __('文章已发布', 'jio');
|
||||
$send['reload'] = true;
|
||||
$send['goto'] = $url;
|
||||
break;
|
||||
@@ -289,8 +289,8 @@ trait FrontSubmitSave {
|
||||
}
|
||||
|
||||
$dims = [];
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
$filter_all = \AKSRT\Settings\Settings::get_post_filter_settings();
|
||||
if (class_exists('\Jio\Settings\Settings')) {
|
||||
$filter_all = \Jio\Settings\Settings::get_post_filter_settings();
|
||||
$dims = is_array($filter_all['custom_filter'] ?? null) ? $filter_all['custom_filter'] : [];
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ trait FrontSubmitSave {
|
||||
$dim_key = '';
|
||||
if (strpos((string) $key, 'cf_') === 0) {
|
||||
$dim_key = sanitize_key(substr((string) $key, 3));
|
||||
} elseif (strpos((string) $key, '_aksrt_cf_') === 0) {
|
||||
} elseif (strpos((string) $key, '_jio_cf_') === 0) {
|
||||
$dim_key = sanitize_key(substr((string) $key, 10));
|
||||
} elseif (in_array(sanitize_key((string) $key), $allowed_keys, true)) {
|
||||
$dim_key = sanitize_key((string) $key);
|
||||
@@ -313,7 +313,7 @@ trait FrontSubmitSave {
|
||||
if ($dim_key === '' || (!empty($allowed_keys) && !in_array($dim_key, $allowed_keys, true))) {
|
||||
continue;
|
||||
}
|
||||
$meta_key = '_aksrt_cf_' . $dim_key;
|
||||
$meta_key = '_jio_cf_' . $dim_key;
|
||||
if (is_array($val)) {
|
||||
$vals = array_values(array_filter(array_map('sanitize_key', $val)));
|
||||
if ($vals) {
|
||||
|
||||
+30
-30
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -30,19 +30,19 @@ class GoRedirect {
|
||||
* Register rewrite rule for /go/ endpoint
|
||||
*/
|
||||
public function register_rewrite(): void {
|
||||
add_rewrite_rule('^go/?$', 'index.php?aksrt_go_redirect=1', 'top');
|
||||
add_rewrite_tag('%aksrt_go_redirect%', '([0-1])');
|
||||
add_rewrite_rule('^go/?$', 'index.php?jio_go_redirect=1', 'top');
|
||||
add_rewrite_tag('%jio_go_redirect%', '([0-1])');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if go redirect feature is enabled
|
||||
*/
|
||||
private function is_enabled(): bool {
|
||||
if (!class_exists('\AKSRT\Settings\Settings')) return false;
|
||||
if (!class_exists('\Jio\Settings\Settings')) return false;
|
||||
// schema key = seo_go_link; runtime alias = go_redirect_enabled
|
||||
return (bool) (
|
||||
\AKSRT\Settings\Settings::get_value('go_redirect_enabled', false)
|
||||
?: \AKSRT\Settings\Settings::get_value('seo_go_link', false)
|
||||
\Jio\Settings\Settings::get_value('go_redirect_enabled', false)
|
||||
?: \Jio\Settings\Settings::get_value('seo_go_link', false)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -50,10 +50,10 @@ class GoRedirect {
|
||||
* Get excluded domains list
|
||||
*/
|
||||
private function get_excluded_domains(): array {
|
||||
if (!class_exists('\AKSRT\Settings\Settings')) return [];
|
||||
if (!class_exists('\Jio\Settings\Settings')) return [];
|
||||
// schema key = seo_go_link_exclude; runtime alias = go_redirect_exclude_domains
|
||||
$domains = \AKSRT\Settings\Settings::get_value('go_redirect_exclude_domains', '')
|
||||
?: \AKSRT\Settings\Settings::get_value('seo_go_link_exclude', '');
|
||||
$domains = \Jio\Settings\Settings::get_value('go_redirect_exclude_domains', '')
|
||||
?: \Jio\Settings\Settings::get_value('seo_go_link_exclude', '');
|
||||
if (empty($domains)) return [];
|
||||
return array_filter(array_map('trim', explode("\n", $domains)));
|
||||
}
|
||||
@@ -85,7 +85,7 @@ class GoRedirect {
|
||||
* Generate signed go link with time-limited nonce
|
||||
*/
|
||||
public function create_go_link(string $url): string {
|
||||
$token = wp_create_nonce('aksrt_go_' . $url);
|
||||
$token = wp_create_nonce('jio_go_' . $url);
|
||||
return add_query_arg([
|
||||
'url' => rawurlencode($url),
|
||||
'token' => $token,
|
||||
@@ -96,27 +96,27 @@ class GoRedirect {
|
||||
* Handle the /go/ confirmation page
|
||||
*/
|
||||
public function handle_go_page(): void {
|
||||
if (!get_query_var('aksrt_go_redirect')) return;
|
||||
if (!get_query_var('jio_go_redirect')) return;
|
||||
|
||||
$url = isset($_GET['url']) ? wp_unslash(rawurldecode($_GET['url'])) : '';
|
||||
$token = isset($_GET['token']) ? sanitize_text_field(wp_unslash($_GET['token'])) : '';
|
||||
|
||||
if (empty($url) || empty($token)) {
|
||||
wp_die(
|
||||
esc_html__('无效的跳转链接。', 'aksrt'),
|
||||
esc_html__('跳转错误', 'aksrt'),
|
||||
esc_html__('无效的跳转链接。', 'jio'),
|
||||
esc_html__('跳转错误', 'jio'),
|
||||
['response' => 400]
|
||||
);
|
||||
}
|
||||
|
||||
// Validate nonce (gated by seo_go_link_nonce schema setting)
|
||||
$require_nonce = class_exists('\AKSRT\Settings\Settings')
|
||||
? !empty(\AKSRT\Settings\Settings::get_value('seo_go_link_nonce', true))
|
||||
$require_nonce = class_exists('\Jio\Settings\Settings')
|
||||
? !empty(\Jio\Settings\Settings::get_value('seo_go_link_nonce', true))
|
||||
: true;
|
||||
if ($require_nonce && !wp_verify_nonce($token, 'aksrt_go_' . $url)) {
|
||||
if ($require_nonce && !wp_verify_nonce($token, 'jio_go_' . $url)) {
|
||||
wp_die(
|
||||
esc_html__('链接已过期或无效,请返回原页面重新点击。', 'aksrt'),
|
||||
esc_html__('链接过期', 'aksrt'),
|
||||
esc_html__('链接已过期或无效,请返回原页面重新点击。', 'jio'),
|
||||
esc_html__('链接过期', 'jio'),
|
||||
['response' => 403]
|
||||
);
|
||||
}
|
||||
@@ -125,8 +125,8 @@ class GoRedirect {
|
||||
$url = esc_url_raw($url);
|
||||
if (empty($url) || !wp_http_validate_url($url)) {
|
||||
wp_die(
|
||||
esc_html__('无效的目标地址。', 'aksrt'),
|
||||
esc_html__('跳转错误', 'aksrt'),
|
||||
esc_html__('无效的目标地址。', 'jio'),
|
||||
esc_html__('跳转错误', 'jio'),
|
||||
['response' => 400]
|
||||
);
|
||||
}
|
||||
@@ -148,9 +148,9 @@ class GoRedirect {
|
||||
$domain = wp_parse_url($url, PHP_URL_HOST) ?: $url;
|
||||
$protocol = wp_parse_url($url, PHP_URL_SCHEME) ?: 'https';
|
||||
|
||||
set_query_var('aksrt_go_target_url', esc_url($url));
|
||||
set_query_var('aksrt_go_target_domain', (string) $domain);
|
||||
set_query_var('aksrt_go_target_protocol', (string) $protocol);
|
||||
set_query_var('jio_go_target_url', esc_url($url));
|
||||
set_query_var('jio_go_target_domain', (string) $domain);
|
||||
set_query_var('jio_go_target_protocol', (string) $protocol);
|
||||
|
||||
$template = locate_template('go.php', false, false);
|
||||
if ($template) {
|
||||
@@ -171,7 +171,7 @@ class GoRedirect {
|
||||
<head>
|
||||
<meta charset="<?php bloginfo('charset'); ?>">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title><?php esc_html_e('外部链接跳转', 'aksrt'); ?></title>
|
||||
<title><?php esc_html_e('外部链接跳转', 'jio'); ?></title>
|
||||
<style>
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #f5f6f7; margin: 0; padding: 0; display: flex; align-items: center; justify-content: center; min-height: 100vh; }
|
||||
.go-card { background: #fff; border-radius: 12px; padding: 40px; max-width: 500px; width: 90%; box-shadow: 0 4px 20px rgba(0,0,0,0.08); text-align: center; }
|
||||
@@ -189,13 +189,13 @@ class GoRedirect {
|
||||
</head>
|
||||
<body>
|
||||
<div class="go-card">
|
||||
<h1><?php esc_html_e('即将离开本站', 'aksrt'); ?></h1>
|
||||
<h1><?php esc_html_e('即将离开本站', 'jio'); ?></h1>
|
||||
<div class="go-domain"><?php echo $safe_protocol; ?>://<?php echo $safe_domain; ?></div>
|
||||
<div class="go-url"><?php echo $safe_url; ?></div>
|
||||
<div class="go-warn"><?php esc_html_e('请注意:外部链接内容不受本站控制,请谨慎访问。', 'aksrt'); ?></div>
|
||||
<div class="go-warn"><?php esc_html_e('请注意:外部链接内容不受本站控制,请谨慎访问。', 'jio'); ?></div>
|
||||
<div class="go-btns">
|
||||
<a href="<?php echo $safe_url; ?>" class="go-btn go-btn--primary" rel="nofollow noopener noreferrer" target="_blank"><?php esc_html_e('继续访问', 'aksrt'); ?></a>
|
||||
<a href="javascript:history.back()" class="go-btn go-btn--ghost"><?php esc_html_e('返回', 'aksrt'); ?></a>
|
||||
<a href="<?php echo $safe_url; ?>" class="go-btn go-btn--primary" rel="nofollow noopener noreferrer" target="_blank"><?php esc_html_e('继续访问', 'jio'); ?></a>
|
||||
<a href="javascript:history.back()" class="go-btn go-btn--ghost"><?php esc_html_e('返回', 'jio'); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
@@ -212,7 +212,7 @@ class GoRedirect {
|
||||
if (is_admin()) return $content;
|
||||
if (!is_singular()) return $content;
|
||||
// seo_go_link_post: whether to replace links in post content (default true)
|
||||
if (class_exists('\AKSRT\Settings\Settings') && empty(\AKSRT\Settings\Settings::get_value('seo_go_link_post', true))) {
|
||||
if (class_exists('\Jio\Settings\Settings') && empty(\Jio\Settings\Settings::get_value('seo_go_link_post', true))) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
+77
-77
@@ -2,10 +2,10 @@
|
||||
/**
|
||||
* Article extension fields shared by the block and classic editors.
|
||||
*
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -33,7 +33,7 @@ class PostMetaBox {
|
||||
$defaults = DomainModel::default_post_meta();
|
||||
$meta = array_merge($defaults, is_array($saved) ? array_intersect_key($saved, $defaults) : []);
|
||||
$meta['views'] = max(0, (int) get_post_meta($post_id, DomainModel::POST_VIEW_COUNT_KEY, true));
|
||||
$meta['like'] = max(0, (int) get_post_meta($post_id, '_aksrt_like_count', true));
|
||||
$meta['like'] = max(0, (int) get_post_meta($post_id, '_jio_like_count', true));
|
||||
$meta['featured_video_episode'] = self::sanitize_video_episodes($meta['featured_video_episode'] ?? []);
|
||||
return $meta;
|
||||
}
|
||||
@@ -69,15 +69,15 @@ class PostMetaBox {
|
||||
}
|
||||
|
||||
public function register_meta_boxes(): void {
|
||||
add_meta_box('post_main', __('文章扩展', 'aksrt'), [$this, 'render_meta_box'], 'post', 'side', 'high');
|
||||
add_meta_box('post_main', __('文章扩展', 'jio'), [$this, 'render_meta_box'], 'post', 'side', 'high');
|
||||
|
||||
$settings = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::get_post_filter_settings()
|
||||
$settings = class_exists('\Jio\Settings\Settings')
|
||||
? \Jio\Settings\Settings::get_post_filter_settings()
|
||||
: [];
|
||||
if (!empty($settings['custom_filter'])) {
|
||||
add_meta_box(
|
||||
'aksrt_custom_filter_meta',
|
||||
__('高级自定义筛选', 'aksrt'),
|
||||
'jio_custom_filter_meta',
|
||||
__('高级自定义筛选', 'jio'),
|
||||
[$this, 'render_custom_filter_meta_box'],
|
||||
'post',
|
||||
'side',
|
||||
@@ -96,19 +96,19 @@ class PostMetaBox {
|
||||
}
|
||||
|
||||
wp_enqueue_media();
|
||||
$css = AKSRT_DIR . '/assets/css/admin/post-extension.css';
|
||||
$js = AKSRT_DIR . '/assets/js/admin-post-extension.js';
|
||||
$css = JIO_DIR . '/assets/css/admin/post-extension.css';
|
||||
$js = JIO_DIR . '/assets/js/admin-post-extension.js';
|
||||
if (is_file($css)) {
|
||||
wp_enqueue_style('aksrt-post-extension', AKSRT_URI . '/assets/css/admin/post-extension.css', [], (string) filemtime($css));
|
||||
wp_enqueue_style('jio-post-extension', JIO_URI . '/assets/css/admin/post-extension.css', [], (string) filemtime($css));
|
||||
}
|
||||
if (is_file($js)) {
|
||||
wp_enqueue_script('aksrt-post-extension', AKSRT_URI . '/assets/js/admin-post-extension.js', ['jquery'], (string) filemtime($js), true);
|
||||
wp_enqueue_script('jio-post-extension', JIO_URI . '/assets/js/admin-post-extension.js', ['jquery'], (string) filemtime($js), true);
|
||||
}
|
||||
}
|
||||
|
||||
public function render_meta_box(\WP_Post $post): void {
|
||||
$meta = self::get_meta($post->ID);
|
||||
$settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_all() : [];
|
||||
$settings = class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::get_all() : [];
|
||||
$show_image = !array_key_exists('article_image_cover', $settings) || !empty($settings['article_image_cover']);
|
||||
$show_slide = !array_key_exists('list_thumb_slides_s', $settings)
|
||||
|| !empty($settings['list_thumb_slides_s'])
|
||||
@@ -117,97 +117,97 @@ class PostMetaBox {
|
||||
|| !empty($settings['list_thumb_video_s'])
|
||||
|| !empty($settings['article_video_cover']);
|
||||
|
||||
wp_nonce_field('aksrt_post_extension_save', 'aksrt_post_extension_nonce');
|
||||
wp_nonce_field('jio_post_extension_save', 'jio_post_extension_nonce');
|
||||
?>
|
||||
<div class="aksrt-post-extension csf-fields" data-aksrt-post-extension>
|
||||
<div class="jio-post-extension csf-fields" data-jio-post-extension>
|
||||
<?php
|
||||
$this->render_upload_field(
|
||||
'thumbnail_url',
|
||||
__('外链特色图像', 'aksrt'),
|
||||
__('外链特色图像', 'jio'),
|
||||
(string) $meta['thumbnail_url'],
|
||||
'image',
|
||||
__('支持直接输入链接用作特色图像', 'aksrt') . '<br><span class="aksrt-post-extension__danger">' . __('此处设置仅在未设置 WordPress 特色图片时有效', 'aksrt') . '</span>'
|
||||
__('支持直接输入链接用作特色图像', 'jio') . '<br><span class="jio-post-extension__danger">' . __('此处设置仅在未设置 WordPress 特色图片时有效', 'jio') . '</span>'
|
||||
);
|
||||
if ($show_image) {
|
||||
$this->render_upload_field('cover_image', __('封面图', 'aksrt'), (string) $meta['cover_image'], 'image', __('在文章页顶部显示封面图', 'aksrt'));
|
||||
$this->render_upload_field('cover_image', __('封面图', 'jio'), (string) $meta['cover_image'], 'image', __('在文章页顶部显示封面图', 'jio'));
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ($show_slide) : ?>
|
||||
<div class="aksrt-post-extension__field">
|
||||
<div class="aksrt-post-extension__title"><label for="aksrt-featured-slide"><?php esc_html_e('特色幻灯片', 'aksrt'); ?></label></div>
|
||||
<div class="aksrt-post-extension__control">
|
||||
<input id="aksrt-featured-slide" type="hidden" name="aksrt_post_extension[featured_slide]" value="<?php echo esc_attr((string) $meta['featured_slide']); ?>" data-gallery-input>
|
||||
<div class="aksrt-post-extension__gallery" data-gallery-preview></div>
|
||||
<div class="aksrt-post-extension__buttons">
|
||||
<button type="button" class="button" data-gallery-select><?php esc_html_e('添加图像', 'aksrt'); ?></button>
|
||||
<button type="button" class="button-link-delete" data-gallery-clear><?php esc_html_e('清空图像', 'aksrt'); ?></button>
|
||||
<div class="jio-post-extension__field">
|
||||
<div class="jio-post-extension__title"><label for="jio-featured-slide"><?php esc_html_e('特色幻灯片', 'jio'); ?></label></div>
|
||||
<div class="jio-post-extension__control">
|
||||
<input id="jio-featured-slide" type="hidden" name="jio_post_extension[featured_slide]" value="<?php echo esc_attr((string) $meta['featured_slide']); ?>" data-gallery-input>
|
||||
<div class="jio-post-extension__gallery" data-gallery-preview></div>
|
||||
<div class="jio-post-extension__buttons">
|
||||
<button type="button" class="button" data-gallery-select><?php esc_html_e('添加图像', 'jio'); ?></button>
|
||||
<button type="button" class="button-link-delete" data-gallery-clear><?php esc_html_e('清空图像', 'jio'); ?></button>
|
||||
</div>
|
||||
<p class="description"><?php esc_html_e('为该文章显示幻灯片封面或幻灯片缩略图(优先级 > 特色图像及封面图)', 'aksrt'); ?></p>
|
||||
<p class="description"><?php esc_html_e('为该文章显示幻灯片封面或幻灯片缩略图(优先级 > 特色图像及封面图)', 'jio'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($show_video) : ?>
|
||||
<?php $this->render_upload_field('featured_video', __('特色视频', 'aksrt'), (string) $meta['featured_video'], 'video', __('为该文章显示视频封面(优先级 > 幻灯片封面)', 'aksrt'), __('选择视频或填写视频地址', 'aksrt')); ?>
|
||||
<div class="aksrt-post-extension__field compact" data-video-dependent>
|
||||
<div class="aksrt-post-extension__title"><span><?php esc_html_e('本集标题', 'aksrt'); ?></span></div>
|
||||
<div class="aksrt-post-extension__control">
|
||||
<input type="text" name="aksrt_post_extension[featured_video_title]" value="<?php echo esc_attr((string) $meta['featured_video_title']); ?>" placeholder="<?php esc_attr_e('第1集', 'aksrt'); ?>">
|
||||
<p class="description"><?php esc_html_e('如需添加剧集则需填写此处', 'aksrt'); ?></p>
|
||||
<?php $this->render_upload_field('featured_video', __('特色视频', 'jio'), (string) $meta['featured_video'], 'video', __('为该文章显示视频封面(优先级 > 幻灯片封面)', 'jio'), __('选择视频或填写视频地址', 'jio')); ?>
|
||||
<div class="jio-post-extension__field compact" data-video-dependent>
|
||||
<div class="jio-post-extension__title"><span><?php esc_html_e('本集标题', 'jio'); ?></span></div>
|
||||
<div class="jio-post-extension__control">
|
||||
<input type="text" name="jio_post_extension[featured_video_title]" value="<?php echo esc_attr((string) $meta['featured_video_title']); ?>" placeholder="<?php esc_attr_e('第1集', 'jio'); ?>">
|
||||
<p class="description"><?php esc_html_e('如需添加剧集则需填写此处', 'jio'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="aksrt-post-extension__field compact" data-video-dependent>
|
||||
<div class="aksrt-post-extension__title"><span><?php esc_html_e('视频剧集', 'aksrt'); ?></span></div>
|
||||
<div class="aksrt-post-extension__control">
|
||||
<p class="description"><?php esc_html_e('为视频封面添加更多剧集', 'aksrt'); ?></p>
|
||||
<div class="jio-post-extension__field compact" data-video-dependent>
|
||||
<div class="jio-post-extension__title"><span><?php esc_html_e('视频剧集', 'jio'); ?></span></div>
|
||||
<div class="jio-post-extension__control">
|
||||
<p class="description"><?php esc_html_e('为视频封面添加更多剧集', 'jio'); ?></p>
|
||||
<div data-episode-list>
|
||||
<?php foreach ((array) $meta['featured_video_episode'] as $index => $episode) : ?>
|
||||
<?php $this->render_episode_row((int) $index, (array) $episode); ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<button type="button" class="button" data-episode-add><?php esc_html_e('添加剧集', 'aksrt'); ?></button>
|
||||
<button type="button" class="button" data-episode-add><?php esc_html_e('添加剧集', 'jio'); ?></button>
|
||||
<template data-episode-template><?php $this->render_episode_row('__INDEX__', []); ?></template>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $this->render_text_field('subtitle', __('副标题', 'aksrt'), (string) $meta['subtitle']); ?>
|
||||
<?php $this->render_number_field('views', __('阅读量', 'aksrt'), (int) $meta['views']); ?>
|
||||
<?php $this->render_number_field('like', __('点赞数', 'aksrt'), (int) $meta['like']); ?>
|
||||
<?php $this->render_text_field('subtitle', __('副标题', 'jio'), (string) $meta['subtitle']); ?>
|
||||
<?php $this->render_number_field('views', __('阅读量', 'jio'), (int) $meta['views']); ?>
|
||||
<?php $this->render_number_field('like', __('点赞数', 'jio'), (int) $meta['like']); ?>
|
||||
|
||||
<fieldset class="aksrt-post-extension__field">
|
||||
<legend class="aksrt-post-extension__title"><?php esc_html_e('显示布局', 'aksrt'); ?></legend>
|
||||
<div class="aksrt-post-extension__control aksrt-post-extension__radios">
|
||||
<fieldset class="jio-post-extension__field">
|
||||
<legend class="jio-post-extension__title"><?php esc_html_e('显示布局', 'jio'); ?></legend>
|
||||
<div class="jio-post-extension__control jio-post-extension__radios">
|
||||
<?php
|
||||
$layouts = [
|
||||
'false' => __('跟随主题', 'aksrt'),
|
||||
'no_sidebar' => __('无侧边栏', 'aksrt'),
|
||||
'sidebar_left' => __('侧边栏靠左', 'aksrt'),
|
||||
'sidebar_right' => __('侧边栏靠右', 'aksrt'),
|
||||
'false' => __('跟随主题', 'jio'),
|
||||
'no_sidebar' => __('无侧边栏', 'jio'),
|
||||
'sidebar_left' => __('侧边栏靠左', 'jio'),
|
||||
'sidebar_right' => __('侧边栏靠右', 'jio'),
|
||||
];
|
||||
foreach ($layouts as $value => $label) :
|
||||
?>
|
||||
<label><input type="radio" name="aksrt_post_extension[show_layout]" value="<?php echo esc_attr($value); ?>" <?php checked((string) $meta['show_layout'], $value); ?>> <?php echo esc_html($label); ?></label>
|
||||
<label><input type="radio" name="jio_post_extension[show_layout]" value="<?php echo esc_attr($value); ?>" <?php checked((string) $meta['show_layout'], $value); ?>> <?php echo esc_html($label); ?></label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div class="aksrt-post-extension__field aksrt-post-extension__field--check"><div class="aksrt-post-extension__control"><label><input type="checkbox" name="aksrt_post_extension[no_article-navs]" value="1" <?php checked(!empty($meta['no_article-navs'])); ?>> <?php esc_html_e('不显示目录树', 'aksrt'); ?></label></div></div>
|
||||
<div class="aksrt-post-extension__field aksrt-post-extension__field--check"><div class="aksrt-post-extension__control"><label><input type="checkbox" name="aksrt_post_extension[article_maxheight_xz]" value="1" <?php checked(!empty($meta['article_maxheight_xz'])); ?>> <?php esc_html_e('限制内容最大高度', 'aksrt'); ?></label></div></div>
|
||||
<div class="jio-post-extension__field jio-post-extension__field--check"><div class="jio-post-extension__control"><label><input type="checkbox" name="jio_post_extension[no_article-navs]" value="1" <?php checked(!empty($meta['no_article-navs'])); ?>> <?php esc_html_e('不显示目录树', 'jio'); ?></label></div></div>
|
||||
<div class="jio-post-extension__field jio-post-extension__field--check"><div class="jio-post-extension__control"><label><input type="checkbox" name="jio_post_extension[article_maxheight_xz]" value="1" <?php checked(!empty($meta['article_maxheight_xz'])); ?>> <?php esc_html_e('限制内容最大高度', 'jio'); ?></label></div></div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
private function render_upload_field(string $id, string $title, string $value, string $library, string $description, string $placeholder = ''): void {
|
||||
?>
|
||||
<div class="aksrt-post-extension__field">
|
||||
<div class="aksrt-post-extension__title"><label for="aksrt-post-<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></label></div>
|
||||
<div class="aksrt-post-extension__control">
|
||||
<div class="aksrt-post-extension__upload">
|
||||
<input id="aksrt-post-<?php echo esc_attr($id); ?>" type="url" name="aksrt_post_extension[<?php echo esc_attr($id); ?>]" value="<?php echo esc_attr($value); ?>" placeholder="<?php echo esc_attr($placeholder); ?>" data-media-input>
|
||||
<button type="button" class="button" data-media-select data-library="<?php echo esc_attr($library); ?>"><?php esc_html_e('选择', 'aksrt'); ?></button>
|
||||
<button type="button" class="button-link-delete" data-media-clear><?php esc_html_e('移除', 'aksrt'); ?></button>
|
||||
<div class="jio-post-extension__field">
|
||||
<div class="jio-post-extension__title"><label for="jio-post-<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></label></div>
|
||||
<div class="jio-post-extension__control">
|
||||
<div class="jio-post-extension__upload">
|
||||
<input id="jio-post-<?php echo esc_attr($id); ?>" type="url" name="jio_post_extension[<?php echo esc_attr($id); ?>]" value="<?php echo esc_attr($value); ?>" placeholder="<?php echo esc_attr($placeholder); ?>" data-media-input>
|
||||
<button type="button" class="button" data-media-select data-library="<?php echo esc_attr($library); ?>"><?php esc_html_e('选择', 'jio'); ?></button>
|
||||
<button type="button" class="button-link-delete" data-media-clear><?php esc_html_e('移除', 'jio'); ?></button>
|
||||
</div>
|
||||
<p class="description"><?php echo wp_kses_post($description); ?></p>
|
||||
</div>
|
||||
@@ -217,30 +217,30 @@ class PostMetaBox {
|
||||
|
||||
private function render_text_field(string $id, string $title, string $value): void {
|
||||
?>
|
||||
<div class="aksrt-post-extension__field"><div class="aksrt-post-extension__title"><label for="aksrt-post-<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></label></div><div class="aksrt-post-extension__control"><input id="aksrt-post-<?php echo esc_attr($id); ?>" type="text" name="aksrt_post_extension[<?php echo esc_attr($id); ?>]" value="<?php echo esc_attr($value); ?>"></div></div>
|
||||
<div class="jio-post-extension__field"><div class="jio-post-extension__title"><label for="jio-post-<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></label></div><div class="jio-post-extension__control"><input id="jio-post-<?php echo esc_attr($id); ?>" type="text" name="jio_post_extension[<?php echo esc_attr($id); ?>]" value="<?php echo esc_attr($value); ?>"></div></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
private function render_number_field(string $id, string $title, int $value): void {
|
||||
?>
|
||||
<div class="aksrt-post-extension__field"><div class="aksrt-post-extension__title"><label for="aksrt-post-<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></label></div><div class="aksrt-post-extension__control"><input id="aksrt-post-<?php echo esc_attr($id); ?>" type="number" min="0" step="1" name="aksrt_post_extension[<?php echo esc_attr($id); ?>]" value="<?php echo esc_attr((string) $value); ?>"></div></div>
|
||||
<div class="jio-post-extension__field"><div class="jio-post-extension__title"><label for="jio-post-<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></label></div><div class="jio-post-extension__control"><input id="jio-post-<?php echo esc_attr($id); ?>" type="number" min="0" step="1" name="jio_post_extension[<?php echo esc_attr($id); ?>]" value="<?php echo esc_attr((string) $value); ?>"></div></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/** @param int|string $index */
|
||||
private function render_episode_row($index, array $episode): void {
|
||||
?>
|
||||
<div class="aksrt-post-extension__episode" data-episode-row>
|
||||
<input type="text" name="aksrt_post_extension[featured_video_episode][<?php echo esc_attr((string) $index); ?>][title]" value="<?php echo esc_attr((string) ($episode['title'] ?? '')); ?>" placeholder="<?php esc_attr_e('剧集标题', 'aksrt'); ?>">
|
||||
<div class="aksrt-post-extension__upload"><input type="url" name="aksrt_post_extension[featured_video_episode][<?php echo esc_attr((string) $index); ?>][url]" value="<?php echo esc_attr((string) ($episode['url'] ?? '')); ?>" placeholder="<?php esc_attr_e('选择视频或填写视频地址', 'aksrt'); ?>" data-media-input><button type="button" class="button" data-media-select data-library="video"><?php esc_html_e('选择', 'aksrt'); ?></button></div>
|
||||
<button type="button" class="button-link-delete" data-episode-remove><?php esc_html_e('移除', 'aksrt'); ?></button>
|
||||
<div class="jio-post-extension__episode" data-episode-row>
|
||||
<input type="text" name="jio_post_extension[featured_video_episode][<?php echo esc_attr((string) $index); ?>][title]" value="<?php echo esc_attr((string) ($episode['title'] ?? '')); ?>" placeholder="<?php esc_attr_e('剧集标题', 'jio'); ?>">
|
||||
<div class="jio-post-extension__upload"><input type="url" name="jio_post_extension[featured_video_episode][<?php echo esc_attr((string) $index); ?>][url]" value="<?php echo esc_attr((string) ($episode['url'] ?? '')); ?>" placeholder="<?php esc_attr_e('选择视频或填写视频地址', 'jio'); ?>" data-media-input><button type="button" class="button" data-media-select data-library="video"><?php esc_html_e('选择', 'jio'); ?></button></div>
|
||||
<button type="button" class="button-link-delete" data-episode-remove><?php esc_html_e('移除', 'jio'); ?></button>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function render_custom_filter_meta_box(\WP_Post $post): void {
|
||||
wp_nonce_field('aksrt_custom_filter_save', 'aksrt_custom_filter_nonce');
|
||||
$settings = \AKSRT\Settings\Settings::get_post_filter_settings();
|
||||
wp_nonce_field('jio_custom_filter_save', 'jio_custom_filter_nonce');
|
||||
$settings = \Jio\Settings\Settings::get_post_filter_settings();
|
||||
$dimensions = is_array($settings['custom_filter'] ?? null) ? $settings['custom_filter'] : [];
|
||||
|
||||
foreach ($dimensions as $dimension) {
|
||||
@@ -250,15 +250,15 @@ class PostMetaBox {
|
||||
if ($key === '') {
|
||||
continue;
|
||||
}
|
||||
$current = (array) get_post_meta($post->ID, '_aksrt_cf_' . $key, true);
|
||||
echo '<div class="aksrt-custom-filter-field"><strong>' . esc_html($name) . '</strong>';
|
||||
$current = (array) get_post_meta($post->ID, '_jio_cf_' . $key, true);
|
||||
echo '<div class="jio-custom-filter-field"><strong>' . esc_html($name) . '</strong>';
|
||||
foreach ($vals as $value) {
|
||||
$value_key = sanitize_key((string) ($value['key'] ?? ''));
|
||||
$value_name = sanitize_text_field((string) ($value['name'] ?? $value_key));
|
||||
if ($value_key === '') {
|
||||
continue;
|
||||
}
|
||||
printf('<label><input type="checkbox" name="aksrt_custom_filter[%s][]" value="%s"%s> %s</label>', esc_attr($key), esc_attr($value_key), checked(in_array($value_key, array_map('strval', $current), true), true, false), esc_html($value_name));
|
||||
printf('<label><input type="checkbox" name="jio_custom_filter[%s][]" value="%s"%s> %s</label>', esc_attr($key), esc_attr($value_key), checked(in_array($value_key, array_map('strval', $current), true), true, false), esc_html($value_name));
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
@@ -269,8 +269,8 @@ class PostMetaBox {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($_POST['aksrt_post_extension_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash((string) $_POST['aksrt_post_extension_nonce'])), 'aksrt_post_extension_save')) {
|
||||
$raw = isset($_POST['aksrt_post_extension']) && is_array($_POST['aksrt_post_extension']) ? wp_unslash($_POST['aksrt_post_extension']) : [];
|
||||
if (isset($_POST['jio_post_extension_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash((string) $_POST['jio_post_extension_nonce'])), 'jio_post_extension_save')) {
|
||||
$raw = isset($_POST['jio_post_extension']) && is_array($_POST['jio_post_extension']) ? wp_unslash($_POST['jio_post_extension']) : [];
|
||||
$layout = sanitize_key((string) ($raw['show_layout'] ?? 'false'));
|
||||
if (!in_array($layout, ['false', 'no_sidebar', 'sidebar_left', 'sidebar_right'], true)) {
|
||||
$layout = 'false';
|
||||
@@ -290,13 +290,13 @@ class PostMetaBox {
|
||||
];
|
||||
update_post_meta($post_id, self::META_KEY, $meta);
|
||||
update_post_meta($post_id, DomainModel::POST_VIEW_COUNT_KEY, max(0, (int) ($raw['views'] ?? 0)));
|
||||
update_post_meta($post_id, '_aksrt_like_count', max(0, (int) ($raw['like'] ?? 0)));
|
||||
update_post_meta($post_id, '_jio_like_count', max(0, (int) ($raw['like'] ?? 0)));
|
||||
}
|
||||
|
||||
if (isset($_POST['aksrt_custom_filter_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash((string) $_POST['aksrt_custom_filter_nonce'])), 'aksrt_custom_filter_save')) {
|
||||
$settings = \AKSRT\Settings\Settings::get_post_filter_settings();
|
||||
if (isset($_POST['jio_custom_filter_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash((string) $_POST['jio_custom_filter_nonce'])), 'jio_custom_filter_save')) {
|
||||
$settings = \Jio\Settings\Settings::get_post_filter_settings();
|
||||
$dimensions = is_array($settings['custom_filter'] ?? null) ? $settings['custom_filter'] : [];
|
||||
$submitted = isset($_POST['aksrt_custom_filter']) && is_array($_POST['aksrt_custom_filter']) ? wp_unslash($_POST['aksrt_custom_filter']) : [];
|
||||
$submitted = isset($_POST['jio_custom_filter']) && is_array($_POST['jio_custom_filter']) ? wp_unslash($_POST['jio_custom_filter']) : [];
|
||||
foreach ($dimensions as $dimension) {
|
||||
$key = sanitize_key((string) ($dimension['key'] ?? ''));
|
||||
if ($key === '') {
|
||||
@@ -305,9 +305,9 @@ class PostMetaBox {
|
||||
$allowed = array_values(array_filter(array_map(static fn($value): string => sanitize_key((string) ($value['key'] ?? '')), (array) ($dimension['vals'] ?? []))));
|
||||
$values = array_values(array_intersect($allowed, array_map('sanitize_key', (array) ($submitted[$key] ?? []))));
|
||||
if ($values) {
|
||||
update_post_meta($post_id, '_aksrt_cf_' . $key, $values);
|
||||
update_post_meta($post_id, '_jio_cf_' . $key, $values);
|
||||
} else {
|
||||
delete_post_meta($post_id, '_aksrt_cf_' . $key);
|
||||
delete_post_meta($post_id, '_jio_cf_' . $key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
/**
|
||||
* 文章导航页设置 AJAX(legacy action/post_navs.php parity).
|
||||
*
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -21,7 +21,7 @@ class PostsNavs {
|
||||
}
|
||||
|
||||
public function init(): void {
|
||||
add_action('wp_ajax_aksrt_post_navs_settings', [$this, 'ajax_save_settings']);
|
||||
add_action('wp_ajax_jio_post_navs_settings', [$this, 'ajax_save_settings']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,15 +29,15 @@ class PostsNavs {
|
||||
*/
|
||||
public function ajax_save_settings(): void {
|
||||
if (!current_user_can('manage_options')) {
|
||||
wp_send_json(['error' => 1, 'ys' => 'danger', 'msg' => __('权限不足', 'aksrt')]);
|
||||
wp_send_json(['error' => 1, 'ys' => 'danger', 'msg' => __('权限不足', 'jio')]);
|
||||
}
|
||||
if (!check_ajax_referer('aksrt_post_navs_settings', '_wpnonce', false)) {
|
||||
wp_send_json(['error' => 1, 'ys' => 'danger', 'msg' => __('安全校验失败', 'aksrt')]);
|
||||
if (!check_ajax_referer('jio_post_navs_settings', '_wpnonce', false)) {
|
||||
wp_send_json(['error' => 1, 'ys' => 'danger', 'msg' => __('安全校验失败', 'jio')]);
|
||||
}
|
||||
|
||||
$page_id = isset($_POST['page_id']) ? absint($_POST['page_id']) : 0;
|
||||
if ($page_id <= 0 || get_post_type($page_id) !== 'page') {
|
||||
wp_send_json(['error' => 1, 'ys' => 'danger', 'msg' => __('无效页面', 'aksrt')]);
|
||||
wp_send_json(['error' => 1, 'ys' => 'danger', 'msg' => __('无效页面', 'jio')]);
|
||||
}
|
||||
|
||||
$cat_ids = [];
|
||||
@@ -56,7 +56,7 @@ class PostsNavs {
|
||||
}
|
||||
|
||||
if (empty($cat_ids)) {
|
||||
wp_send_json(['error' => 1, 'ys' => 'danger', 'msg' => __('请选择需要显示的分类', 'aksrt')]);
|
||||
wp_send_json(['error' => 1, 'ys' => 'danger', 'msg' => __('请选择需要显示的分类', 'jio')]);
|
||||
}
|
||||
|
||||
if (isset($_POST['navs_page_name'])) {
|
||||
@@ -69,7 +69,7 @@ class PostsNavs {
|
||||
|
||||
wp_send_json([
|
||||
'error' => 0,
|
||||
'msg' => __('保存成功', 'aksrt'),
|
||||
'msg' => __('保存成功', 'jio'),
|
||||
'reload'=> true,
|
||||
'ids' => $cat_ids,
|
||||
]);
|
||||
|
||||
+114
-114
@@ -2,10 +2,10 @@
|
||||
/**
|
||||
* Article paid-content fields shared by the block and classic editors.
|
||||
*
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -29,7 +29,7 @@ class ResourceMetaBox {
|
||||
}
|
||||
|
||||
public function register_meta_box(): void {
|
||||
add_meta_box('aksrt_pay_meta', __('付费功能', 'aksrt'), [$this, 'render'], 'post', 'normal', 'high');
|
||||
add_meta_box('jio_pay_meta', __('付费功能', 'jio'), [$this, 'render'], 'post', 'normal', 'high');
|
||||
}
|
||||
|
||||
public function enqueue_assets(string $hook): void {
|
||||
@@ -42,31 +42,31 @@ class ResourceMetaBox {
|
||||
}
|
||||
|
||||
wp_enqueue_media();
|
||||
if (function_exists('aksrt_icon_picker_assets')) {
|
||||
// Declares aksrt-icon-picker -> aksrt-pay-meta-box; the reverse edge
|
||||
if (function_exists('jio_icon_picker_assets')) {
|
||||
// Declares jio-icon-picker -> jio-pay-meta-box; the reverse edge
|
||||
// must not be added here or WP's resolver recurses until OOM.
|
||||
aksrt_icon_picker_assets(['aksrt-pay-meta-box']);
|
||||
jio_icon_picker_assets(['jio-pay-meta-box']);
|
||||
}
|
||||
$css = AKSRT_DIR . '/assets/css/admin/pay-meta-box.css';
|
||||
$js = AKSRT_DIR . '/assets/js/admin-pay-meta-box.js';
|
||||
$css = JIO_DIR . '/assets/css/admin/pay-meta-box.css';
|
||||
$js = JIO_DIR . '/assets/js/admin-pay-meta-box.js';
|
||||
if (is_file($css)) {
|
||||
wp_enqueue_style('aksrt-pay-meta-box', AKSRT_URI . '/assets/css/admin/pay-meta-box.css', ['aksrt-font-awesome'], (string) filemtime($css));
|
||||
wp_enqueue_style('jio-pay-meta-box', JIO_URI . '/assets/css/admin/pay-meta-box.css', ['jio-font-awesome'], (string) filemtime($css));
|
||||
}
|
||||
if (is_file($js)) {
|
||||
wp_enqueue_script('aksrt-pay-meta-box', AKSRT_URI . '/assets/js/admin-pay-meta-box.js', [], (string) filemtime($js), true);
|
||||
wp_enqueue_script('jio-pay-meta-box', JIO_URI . '/assets/js/admin-pay-meta-box.js', [], (string) filemtime($js), true);
|
||||
}
|
||||
wp_localize_script('aksrt-pay-meta-box', 'aksrtPayMetaBox', [
|
||||
wp_localize_script('jio-pay-meta-box', 'jioPayMetaBox', [
|
||||
'buttonClasses' => DomainModel::DOWNLOAD_BUTTON_CLASSES,
|
||||
'i18n' => [
|
||||
'resource' => __('资源', 'aksrt'),
|
||||
'downloadUrl' => __('下载地址', 'aksrt'),
|
||||
'resource' => __('资源', 'jio'),
|
||||
'downloadUrl' => __('下载地址', 'jio'),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function render(\WP_Post $post): void {
|
||||
wp_nonce_field('aksrt_pay_meta_save', 'aksrt_pay_meta_nonce');
|
||||
$meta = function_exists('aksrt_get_pay_meta') ? aksrt_get_pay_meta($post) : DomainModel::default_pay_meta();
|
||||
wp_nonce_field('jio_pay_meta_save', 'jio_pay_meta_nonce');
|
||||
$meta = function_exists('jio_get_pay_meta') ? jio_get_pay_meta($post) : DomainModel::default_pay_meta();
|
||||
$gallery_ids = [];
|
||||
foreach ((array) ($meta['gallery'] ?? []) as $url) {
|
||||
$id = attachment_url_to_postid((string) $url);
|
||||
@@ -75,86 +75,86 @@ class ResourceMetaBox {
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="aksrt-pay-meta" data-aksrt-pay-meta>
|
||||
<?php $this->radio('pay_type', __('付费模式', 'aksrt'), (string) ($meta['pay_type'] ?? 'no'), aksrt_get_pay_types()); ?>
|
||||
<div class="jio-pay-meta" data-jio-pay-meta>
|
||||
<?php $this->radio('pay_type', __('付费模式', 'jio'), (string) ($meta['pay_type'] ?? 'no'), jio_get_pay_types()); ?>
|
||||
<div data-pay-enabled>
|
||||
<?php
|
||||
$this->radio('pay_limit', __('购买权限', 'aksrt'), (string) ($meta['pay_limit'] ?? 0), [
|
||||
'0' => __('所有人可购买', 'aksrt'),
|
||||
'1' => __('VIP1 及以上会员可购买', 'aksrt'),
|
||||
'2' => __('仅 VIP2 可购买', 'aksrt'),
|
||||
], __('设置会员专享资源时,请同时配置对应的会员价格。', 'aksrt'));
|
||||
$this->radio('pay_modo', __('支付类型', 'aksrt'), (string) ($meta['pay_modo'] ?? '0'), [
|
||||
'0' => __('普通商品(金钱购买)', 'aksrt'),
|
||||
'points' => __('积分商品(积分购买,依赖于用户积分功能)', 'aksrt'),
|
||||
$this->radio('pay_limit', __('购买权限', 'jio'), (string) ($meta['pay_limit'] ?? 0), [
|
||||
'0' => __('所有人可购买', 'jio'),
|
||||
'1' => __('VIP1 及以上会员可购买', 'jio'),
|
||||
'2' => __('仅 VIP2 可购买', 'jio'),
|
||||
], __('设置会员专享资源时,请同时配置对应的会员价格。', 'jio'));
|
||||
$this->radio('pay_modo', __('支付类型', 'jio'), (string) ($meta['pay_modo'] ?? '0'), [
|
||||
'0' => __('普通商品(金钱购买)', 'jio'),
|
||||
'points' => __('积分商品(积分购买,依赖于用户积分功能)', 'jio'),
|
||||
]);
|
||||
?>
|
||||
|
||||
<div class="aksrt-pay-meta__field">
|
||||
<div class="aksrt-pay-meta__title"><?php esc_html_e('订单时效', 'aksrt'); ?></div>
|
||||
<div class="aksrt-pay-meta__control">
|
||||
<label><input type="checkbox" name="aksrt_pay[order_expired_s]" value="1" <?php checked(!empty($meta['order_expired_s'])); ?> data-order-expired> <?php esc_html_e('启用订单有效期', 'aksrt'); ?></label>
|
||||
<p class="description"><?php esc_html_e('购买后仅在有效期内可查看内容,超时后需再次购买。', 'aksrt'); ?></p>
|
||||
<div class="jio-pay-meta__field">
|
||||
<div class="jio-pay-meta__title"><?php esc_html_e('订单时效', 'jio'); ?></div>
|
||||
<div class="jio-pay-meta__control">
|
||||
<label><input type="checkbox" name="jio_pay[order_expired_s]" value="1" <?php checked(!empty($meta['order_expired_s'])); ?> data-order-expired> <?php esc_html_e('启用订单有效期', 'jio'); ?></label>
|
||||
<p class="description"><?php esc_html_e('购买后仅在有效期内可查看内容,超时后需再次购买。', 'jio'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="aksrt-pay-meta__field compact" data-order-expired-fields>
|
||||
<div class="aksrt-pay-meta__title"><?php esc_html_e('有效时间', 'aksrt'); ?></div>
|
||||
<div class="aksrt-pay-meta__control aksrt-pay-meta__inline">
|
||||
<input type="number" min="0" step="1" name="aksrt_pay[order_expired_time]" value="<?php echo esc_attr((string) ($meta['order_expired_time'] ?? 0)); ?>">
|
||||
<select name="aksrt_pay[order_expired_unit]">
|
||||
<option value="day" <?php selected((string) ($meta['order_expired_unit'] ?? 'day'), 'day'); ?>><?php esc_html_e('天', 'aksrt'); ?></option>
|
||||
<option value="hour" <?php selected((string) ($meta['order_expired_unit'] ?? 'day'), 'hour'); ?>><?php esc_html_e('小时', 'aksrt'); ?></option>
|
||||
<option value="minute" <?php selected((string) ($meta['order_expired_unit'] ?? 'day'), 'minute'); ?>><?php esc_html_e('分钟', 'aksrt'); ?></option>
|
||||
<div class="jio-pay-meta__field compact" data-order-expired-fields>
|
||||
<div class="jio-pay-meta__title"><?php esc_html_e('有效时间', 'jio'); ?></div>
|
||||
<div class="jio-pay-meta__control jio-pay-meta__inline">
|
||||
<input type="number" min="0" step="1" name="jio_pay[order_expired_time]" value="<?php echo esc_attr((string) ($meta['order_expired_time'] ?? 0)); ?>">
|
||||
<select name="jio_pay[order_expired_unit]">
|
||||
<option value="day" <?php selected((string) ($meta['order_expired_unit'] ?? 'day'), 'day'); ?>><?php esc_html_e('天', 'jio'); ?></option>
|
||||
<option value="hour" <?php selected((string) ($meta['order_expired_unit'] ?? 'day'), 'hour'); ?>><?php esc_html_e('小时', 'jio'); ?></option>
|
||||
<option value="minute" <?php selected((string) ($meta['order_expired_unit'] ?? 'day'), 'minute'); ?>><?php esc_html_e('分钟', 'jio'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-pay-modo="points">
|
||||
<?php $this->number('points_price', __('积分售价', 'aksrt'), (string) ($meta['points_price'] ?? 0), '1', __('积分', 'aksrt')); ?>
|
||||
<?php $this->number('vip1_points', __('VIP1 积分售价', 'aksrt'), (string) ($meta['vip1_points'] ?? 0), '1', __('积分', 'aksrt'), __('填 0 则为 VIP1 免费', 'aksrt')); ?>
|
||||
<?php $this->number('vip2_points', __('VIP2 积分售价', 'aksrt'), (string) ($meta['vip2_points'] ?? 0), '1', __('积分', 'aksrt'), __('会员价格不能高于售价,填 0 则为 VIP2 免费。', 'aksrt')); ?>
|
||||
<?php $this->number('points_price', __('积分售价', 'jio'), (string) ($meta['points_price'] ?? 0), '1', __('积分', 'jio')); ?>
|
||||
<?php $this->number('vip1_points', __('VIP1 积分售价', 'jio'), (string) ($meta['vip1_points'] ?? 0), '1', __('积分', 'jio'), __('填 0 则为 VIP1 免费', 'jio')); ?>
|
||||
<?php $this->number('vip2_points', __('VIP2 积分售价', 'jio'), (string) ($meta['vip2_points'] ?? 0), '1', __('积分', 'jio'), __('会员价格不能高于售价,填 0 则为 VIP2 免费。', 'jio')); ?>
|
||||
</div>
|
||||
<div data-pay-modo="0">
|
||||
<?php $this->number('price', __('执行价', 'aksrt'), (string) ($meta['price'] ?? '0.00'), '0.01', '', __('填 0 则为免费', 'aksrt')); ?>
|
||||
<?php $this->number('original_price', __('原价', 'aksrt'), (string) ($meta['original_price'] ?? '0.00'), '0.01', '', __('显示在执行价格前面,并划掉。', 'aksrt')); ?>
|
||||
<?php $this->textarea('promotion_tag', __('促销标签', 'aksrt'), (string) ($meta['promotion_tag'] ?? ''), 1); ?>
|
||||
<?php $this->number('vip1_price', __('VIP1 价格', 'aksrt'), (string) ($meta['vip1_price'] ?? '0.00'), '0.01', '', __('填 0 则为 VIP1 免费', 'aksrt')); ?>
|
||||
<?php $this->number('vip2_price', __('VIP2 价格', 'aksrt'), (string) ($meta['vip2_price'] ?? '0.00'), '0.01', '', __('会员价格不能高于执行价,填 0 则为 VIP2 免费。', 'aksrt')); ?>
|
||||
<?php $this->number('price', __('执行价', 'jio'), (string) ($meta['price'] ?? '0.00'), '0.01', '', __('填 0 则为免费', 'jio')); ?>
|
||||
<?php $this->number('original_price', __('原价', 'jio'), (string) ($meta['original_price'] ?? '0.00'), '0.01', '', __('显示在执行价格前面,并划掉。', 'jio')); ?>
|
||||
<?php $this->textarea('promotion_tag', __('促销标签', 'jio'), (string) ($meta['promotion_tag'] ?? ''), 1); ?>
|
||||
<?php $this->number('vip1_price', __('VIP1 价格', 'jio'), (string) ($meta['vip1_price'] ?? '0.00'), '0.01', '', __('填 0 则为 VIP1 免费', 'jio')); ?>
|
||||
<?php $this->number('vip2_price', __('VIP2 价格', 'jio'), (string) ($meta['vip2_price'] ?? '0.00'), '0.01', '', __('会员价格不能高于执行价,填 0 则为 VIP2 免费。', 'jio')); ?>
|
||||
</div>
|
||||
|
||||
<?php $this->number('pay_count', __('销量浮动', 'aksrt'), (string) ($meta['pay_count'] ?? 0), '1', '', __('为真实销量增加或减少的数量。', 'aksrt'), false); ?>
|
||||
<?php $this->number('pay_count', __('销量浮动', 'jio'), (string) ($meta['pay_count'] ?? 0), '1', '', __('为真实销量增加或减少的数量。', 'jio'), false); ?>
|
||||
|
||||
<div data-pay-type="gallery">
|
||||
<div class="aksrt-pay-meta__field">
|
||||
<div class="aksrt-pay-meta__title"><?php esc_html_e('付费图片', 'aksrt'); ?></div>
|
||||
<div class="aksrt-pay-meta__control">
|
||||
<input type="hidden" name="aksrt_pay[gallery_ids]" value="<?php echo esc_attr(implode(',', $gallery_ids)); ?>" data-gallery-input>
|
||||
<div class="aksrt-pay-meta__gallery" data-gallery-preview></div>
|
||||
<div class="aksrt-pay-meta__buttons"><button type="button" class="button" data-gallery-select><?php esc_html_e('新增图片', 'aksrt'); ?></button><button type="button" class="button-link-delete" data-gallery-clear><?php esc_html_e('清空图片', 'aksrt'); ?></button></div>
|
||||
<div class="jio-pay-meta__field">
|
||||
<div class="jio-pay-meta__title"><?php esc_html_e('付费图片', 'jio'); ?></div>
|
||||
<div class="jio-pay-meta__control">
|
||||
<input type="hidden" name="jio_pay[gallery_ids]" value="<?php echo esc_attr(implode(',', $gallery_ids)); ?>" data-gallery-input>
|
||||
<div class="jio-pay-meta__gallery" data-gallery-preview></div>
|
||||
<div class="jio-pay-meta__buttons"><button type="button" class="button" data-gallery-select><?php esc_html_e('新增图片', 'jio'); ?></button><button type="button" class="button-link-delete" data-gallery-clear><?php esc_html_e('清空图片', 'jio'); ?></button></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php $this->number('gallery_show', __('免费查看', 'aksrt'), (string) ($meta['gallery_show'] ?? 1), '1', __('张', 'aksrt'), __('不能大于付费图片数量,否则无效。', 'aksrt')); ?>
|
||||
<?php $this->number('gallery_show', __('免费查看', 'jio'), (string) ($meta['gallery_show'] ?? 1), '1', __('张', 'jio'), __('不能大于付费图片数量,否则无效。', 'jio')); ?>
|
||||
</div>
|
||||
|
||||
<div data-pay-type="video">
|
||||
<?php $this->upload('video_url', __('视频资源', 'aksrt'), (string) ($meta['video_url'] ?? ''), 'video', __('输入视频地址或选择、上传本地视频。', 'aksrt')); ?>
|
||||
<?php $this->upload('video_pic', __('视频封面(可选)', 'aksrt'), (string) ($meta['video_pic'] ?? ''), 'image'); ?>
|
||||
<?php $this->text('video_title', __('本集标题', 'aksrt'), (string) ($meta['video_title'] ?? ''), __('如需添加剧集则需填写此处', 'aksrt'), __('第1集', 'aksrt')); ?>
|
||||
<?php $this->group('video_episode', __('更多剧集', 'aksrt'), (array) ($meta['video_episode'] ?? []), 'video_row', __('添加剧集', 'aksrt'), __('为付费视频添加更多剧集。', 'aksrt')); ?>
|
||||
<?php $this->upload('video_url', __('视频资源', 'jio'), (string) ($meta['video_url'] ?? ''), 'video', __('输入视频地址或选择、上传本地视频。', 'jio')); ?>
|
||||
<?php $this->upload('video_pic', __('视频封面(可选)', 'jio'), (string) ($meta['video_pic'] ?? ''), 'image'); ?>
|
||||
<?php $this->text('video_title', __('本集标题', 'jio'), (string) ($meta['video_title'] ?? ''), __('如需添加剧集则需填写此处', 'jio'), __('第1集', 'jio')); ?>
|
||||
<?php $this->group('video_episode', __('更多剧集', 'jio'), (array) ($meta['video_episode'] ?? []), 'video_row', __('添加剧集', 'jio'), __('为付费视频添加更多剧集。', 'jio')); ?>
|
||||
</div>
|
||||
|
||||
<div data-pay-type="download">
|
||||
<?php $this->group('downloads', __('资源下载', 'aksrt'), (array) ($meta['downloads'] ?? []), 'download_row', __('添加资源', 'aksrt'), __('每个资源一张卡片,点击标题展开配置;拖动卡片左上角的手柄可调整下载源的显示顺序。', 'aksrt')); ?>
|
||||
<?php $this->group('attributes', __('资源属性', 'aksrt'), (array) ($meta['attributes'] ?? []), 'attribute_row', __('添加属性', 'aksrt')); ?>
|
||||
<?php $this->text('demo_url', __('演示地址', 'aksrt'), (string) ($meta['demo_url'] ?? ''), '', 'https://', 'url'); ?>
|
||||
<?php $this->group('downloads', __('资源下载', 'jio'), (array) ($meta['downloads'] ?? []), 'download_row', __('添加资源', 'jio'), __('每个资源一张卡片,点击标题展开配置;拖动卡片左上角的手柄可调整下载源的显示顺序。', 'jio')); ?>
|
||||
<?php $this->group('attributes', __('资源属性', 'jio'), (array) ($meta['attributes'] ?? []), 'attribute_row', __('添加属性', 'jio')); ?>
|
||||
<?php $this->text('demo_url', __('演示地址', 'jio'), (string) ($meta['demo_url'] ?? ''), '', 'https://', 'url'); ?>
|
||||
</div>
|
||||
|
||||
<?php $this->text('pay_title', __('商品标题', 'aksrt'), (string) ($meta['pay_title'] ?? ''), __('可选,如需单独显示付费内容标题请填写。', 'aksrt')); ?>
|
||||
<?php $this->textarea('pay_doc', __('商品简介', 'aksrt'), (string) ($meta['pay_doc'] ?? ''), 1, __('可选,如需单独显示付费内容介绍请填写。', 'aksrt')); ?>
|
||||
<?php $this->textarea('pay_details', __('更多详情', 'aksrt'), (string) ($meta['pay_details'] ?? ''), 3, __('显示在付费内容卡片下方,支持安全 HTML。', 'aksrt')); ?>
|
||||
<?php $this->textarea('pay_extra_hide', __('额外隐藏内容', 'aksrt'), (string) ($meta['pay_extra_hide'] ?? ''), 3, __('付费后显示的额外隐藏内容,支持安全 HTML。', 'aksrt')); ?>
|
||||
<?php $this->text('pay_title', __('商品标题', 'jio'), (string) ($meta['pay_title'] ?? ''), __('可选,如需单独显示付费内容标题请填写。', 'jio')); ?>
|
||||
<?php $this->textarea('pay_doc', __('商品简介', 'jio'), (string) ($meta['pay_doc'] ?? ''), 1, __('可选,如需单独显示付费内容介绍请填写。', 'jio')); ?>
|
||||
<?php $this->textarea('pay_details', __('更多详情', 'jio'), (string) ($meta['pay_details'] ?? ''), 3, __('显示在付费内容卡片下方,支持安全 HTML。', 'jio')); ?>
|
||||
<?php $this->textarea('pay_extra_hide', __('额外隐藏内容', 'jio'), (string) ($meta['pay_extra_hide'] ?? ''), 3, __('付费后显示的额外隐藏内容,支持安全 HTML。', 'jio')); ?>
|
||||
|
||||
<div class="aksrt-pay-meta__notice"><strong><?php esc_html_e('付费阅读', 'aksrt'); ?></strong> <?php esc_html_e('需配合古腾堡“隐藏内容块”或经典编辑器短代码使用:', 'aksrt'); ?> <code>[hidecontent type="payshow"]</code> <?php esc_html_e('隐藏内容', 'aksrt'); ?> <code>[/hidecontent]</code></div>
|
||||
<div class="jio-pay-meta__notice"><strong><?php esc_html_e('付费阅读', 'jio'); ?></strong> <?php esc_html_e('需配合古腾堡“隐藏内容块”或经典编辑器短代码使用:', 'jio'); ?> <code>[hidecontent type="payshow"]</code> <?php esc_html_e('隐藏内容', 'jio'); ?> <code>[/hidecontent]</code></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
@@ -163,8 +163,8 @@ class ResourceMetaBox {
|
||||
/** @param array<string, string> $options */
|
||||
private function radio(string $id, string $title, string $value, array $options, string $description = ''): void {
|
||||
?>
|
||||
<fieldset class="aksrt-pay-meta__field"><legend class="aksrt-pay-meta__title"><?php echo esc_html($title); ?></legend><div class="aksrt-pay-meta__control aksrt-pay-meta__radios">
|
||||
<?php foreach ($options as $option => $label) : ?><label><input type="radio" name="aksrt_pay[<?php echo esc_attr($id); ?>]" value="<?php echo esc_attr((string) $option); ?>" <?php checked($value, (string) $option); ?>> <?php echo esc_html($label); ?></label><?php endforeach; ?>
|
||||
<fieldset class="jio-pay-meta__field"><legend class="jio-pay-meta__title"><?php echo esc_html($title); ?></legend><div class="jio-pay-meta__control jio-pay-meta__radios">
|
||||
<?php foreach ($options as $option => $label) : ?><label><input type="radio" name="jio_pay[<?php echo esc_attr($id); ?>]" value="<?php echo esc_attr((string) $option); ?>" <?php checked($value, (string) $option); ?>> <?php echo esc_html($label); ?></label><?php endforeach; ?>
|
||||
<?php if ($description !== '') : ?><p class="description"><?php echo esc_html($description); ?></p><?php endif; ?>
|
||||
</div></fieldset>
|
||||
<?php
|
||||
@@ -172,39 +172,39 @@ class ResourceMetaBox {
|
||||
|
||||
private function number(string $id, string $title, string $value, string $step, string $unit = '', string $description = '', bool $non_negative = true): void {
|
||||
?>
|
||||
<div class="aksrt-pay-meta__field"><div class="aksrt-pay-meta__title"><label for="aksrt-pay-<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></label></div><div class="aksrt-pay-meta__control"><div class="aksrt-pay-meta__number"><input id="aksrt-pay-<?php echo esc_attr($id); ?>" type="number" <?php echo $non_negative ? 'min="0"' : ''; ?> step="<?php echo esc_attr($step); ?>" name="aksrt_pay[<?php echo esc_attr($id); ?>]" value="<?php echo esc_attr($value); ?>"><?php if ($unit !== '') : ?><span><?php echo esc_html($unit); ?></span><?php endif; ?></div><?php if ($description !== '') : ?><p class="description"><?php echo esc_html($description); ?></p><?php endif; ?></div></div>
|
||||
<div class="jio-pay-meta__field"><div class="jio-pay-meta__title"><label for="jio-pay-<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></label></div><div class="jio-pay-meta__control"><div class="jio-pay-meta__number"><input id="jio-pay-<?php echo esc_attr($id); ?>" type="number" <?php echo $non_negative ? 'min="0"' : ''; ?> step="<?php echo esc_attr($step); ?>" name="jio_pay[<?php echo esc_attr($id); ?>]" value="<?php echo esc_attr($value); ?>"><?php if ($unit !== '') : ?><span><?php echo esc_html($unit); ?></span><?php endif; ?></div><?php if ($description !== '') : ?><p class="description"><?php echo esc_html($description); ?></p><?php endif; ?></div></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
private function text(string $id, string $title, string $value, string $description = '', string $placeholder = '', string $type = 'text'): void {
|
||||
?>
|
||||
<div class="aksrt-pay-meta__field"><div class="aksrt-pay-meta__title"><label for="aksrt-pay-<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></label></div><div class="aksrt-pay-meta__control"><input id="aksrt-pay-<?php echo esc_attr($id); ?>" type="<?php echo esc_attr($type); ?>" name="aksrt_pay[<?php echo esc_attr($id); ?>]" value="<?php echo esc_attr($value); ?>" placeholder="<?php echo esc_attr($placeholder); ?>"><?php if ($description !== '') : ?><p class="description"><?php echo esc_html($description); ?></p><?php endif; ?></div></div>
|
||||
<div class="jio-pay-meta__field"><div class="jio-pay-meta__title"><label for="jio-pay-<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></label></div><div class="jio-pay-meta__control"><input id="jio-pay-<?php echo esc_attr($id); ?>" type="<?php echo esc_attr($type); ?>" name="jio_pay[<?php echo esc_attr($id); ?>]" value="<?php echo esc_attr($value); ?>" placeholder="<?php echo esc_attr($placeholder); ?>"><?php if ($description !== '') : ?><p class="description"><?php echo esc_html($description); ?></p><?php endif; ?></div></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
private function textarea(string $id, string $title, string $value, int $rows, string $description = ''): void {
|
||||
?>
|
||||
<div class="aksrt-pay-meta__field"><div class="aksrt-pay-meta__title"><label for="aksrt-pay-<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></label></div><div class="aksrt-pay-meta__control"><textarea id="aksrt-pay-<?php echo esc_attr($id); ?>" rows="<?php echo esc_attr((string) $rows); ?>" name="aksrt_pay[<?php echo esc_attr($id); ?>]"><?php echo esc_textarea($value); ?></textarea><?php if ($description !== '') : ?><p class="description"><?php echo esc_html($description); ?></p><?php endif; ?></div></div>
|
||||
<div class="jio-pay-meta__field"><div class="jio-pay-meta__title"><label for="jio-pay-<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></label></div><div class="jio-pay-meta__control"><textarea id="jio-pay-<?php echo esc_attr($id); ?>" rows="<?php echo esc_attr((string) $rows); ?>" name="jio_pay[<?php echo esc_attr($id); ?>]"><?php echo esc_textarea($value); ?></textarea><?php if ($description !== '') : ?><p class="description"><?php echo esc_html($description); ?></p><?php endif; ?></div></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
private function upload(string $id, string $title, string $value, string $library, string $description = ''): void {
|
||||
?>
|
||||
<div class="aksrt-pay-meta__field"><div class="aksrt-pay-meta__title"><label for="aksrt-pay-<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></label></div><div class="aksrt-pay-meta__control"><div class="aksrt-pay-meta__upload"><input id="aksrt-pay-<?php echo esc_attr($id); ?>" type="url" name="aksrt_pay[<?php echo esc_attr($id); ?>]" value="<?php echo esc_attr($value); ?>" data-media-input><button type="button" class="button" data-media-select data-library="<?php echo esc_attr($library); ?>"><?php esc_html_e('选择', 'aksrt'); ?></button><button type="button" class="button-link-delete" data-media-clear><?php esc_html_e('移除', 'aksrt'); ?></button></div><?php if ($description !== '') : ?><p class="description"><?php echo esc_html($description); ?></p><?php endif; ?></div></div>
|
||||
<div class="jio-pay-meta__field"><div class="jio-pay-meta__title"><label for="jio-pay-<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></label></div><div class="jio-pay-meta__control"><div class="jio-pay-meta__upload"><input id="jio-pay-<?php echo esc_attr($id); ?>" type="url" name="jio_pay[<?php echo esc_attr($id); ?>]" value="<?php echo esc_attr($value); ?>" data-media-input><button type="button" class="button" data-media-select data-library="<?php echo esc_attr($library); ?>"><?php esc_html_e('选择', 'jio'); ?></button><button type="button" class="button-link-delete" data-media-clear><?php esc_html_e('移除', 'jio'); ?></button></div><?php if ($description !== '') : ?><p class="description"><?php echo esc_html($description); ?></p><?php endif; ?></div></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/** @param array<int, array<string, mixed>> $rows */
|
||||
private function group(string $id, string $title, array $rows, string $renderer, string $button, string $description = ''): void {
|
||||
?>
|
||||
<div class="aksrt-pay-meta__field"><div class="aksrt-pay-meta__title"><?php echo esc_html($title); ?></div><div class="aksrt-pay-meta__control"><?php if ($description !== '') : ?><p class="description"><?php echo esc_html($description); ?></p><?php endif; ?><div data-group-list="<?php echo esc_attr($id); ?>"><?php foreach ($rows as $index => $row) { $this->{$renderer}((int) $index, (array) $row); } ?></div><button type="button" class="button" data-group-add="<?php echo esc_attr($id); ?>"><?php echo esc_html($button); ?></button><template data-group-template="<?php echo esc_attr($id); ?>"><?php $this->{$renderer}('__INDEX__', []); ?></template></div></div>
|
||||
<div class="jio-pay-meta__field"><div class="jio-pay-meta__title"><?php echo esc_html($title); ?></div><div class="jio-pay-meta__control"><?php if ($description !== '') : ?><p class="description"><?php echo esc_html($description); ?></p><?php endif; ?><div data-group-list="<?php echo esc_attr($id); ?>"><?php foreach ($rows as $index => $row) { $this->{$renderer}((int) $index, (array) $row); } ?></div><button type="button" class="button" data-group-add="<?php echo esc_attr($id); ?>"><?php echo esc_html($button); ?></button><template data-group-template="<?php echo esc_attr($id); ?>"><?php $this->{$renderer}('__INDEX__', []); ?></template></div></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/** @param int|string $index */
|
||||
private function video_row($index, array $row): void {
|
||||
?>
|
||||
<div class="aksrt-pay-meta__group" data-group-row><input type="text" name="aksrt_pay[video_episode][<?php echo esc_attr((string) $index); ?>][title]" value="<?php echo esc_attr((string) ($row['title'] ?? '')); ?>" placeholder="<?php esc_attr_e('剧集标题', 'aksrt'); ?>"><div class="aksrt-pay-meta__upload"><input type="url" name="aksrt_pay[video_episode][<?php echo esc_attr((string) $index); ?>][url]" value="<?php echo esc_attr((string) ($row['url'] ?? '')); ?>" placeholder="<?php esc_attr_e('选择视频或填写视频地址', 'aksrt'); ?>" data-media-input><button type="button" class="button" data-media-select data-library="video"><?php esc_html_e('选择', 'aksrt'); ?></button></div><button type="button" class="button-link-delete" data-group-remove><?php esc_html_e('移除', 'aksrt'); ?></button></div>
|
||||
<div class="jio-pay-meta__group" data-group-row><input type="text" name="jio_pay[video_episode][<?php echo esc_attr((string) $index); ?>][title]" value="<?php echo esc_attr((string) ($row['title'] ?? '')); ?>" placeholder="<?php esc_attr_e('剧集标题', 'jio'); ?>"><div class="jio-pay-meta__upload"><input type="url" name="jio_pay[video_episode][<?php echo esc_attr((string) $index); ?>][url]" value="<?php echo esc_attr((string) ($row['url'] ?? '')); ?>" placeholder="<?php esc_attr_e('选择视频或填写视频地址', 'jio'); ?>" data-media-input><button type="button" class="button" data-media-select data-library="video"><?php esc_html_e('选择', 'jio'); ?></button></div><button type="button" class="button-link-delete" data-group-remove><?php esc_html_e('移除', 'jio'); ?></button></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -217,48 +217,48 @@ class ResourceMetaBox {
|
||||
$copy_val = (string) ($row['copy_val'] ?? '');
|
||||
$icon = (string) ($row['icon'] ?? '');
|
||||
$class = (string) ($row['class'] ?? '');
|
||||
$name = 'aksrt_pay[downloads][' . $index . ']';
|
||||
$title = $label !== '' ? $label : ($url !== '' ? $url : __('下载地址', 'aksrt'));
|
||||
$name = 'jio_pay[downloads][' . $index . ']';
|
||||
$title = $label !== '' ? $label : ($url !== '' ? $url : __('下载地址', 'jio'));
|
||||
?>
|
||||
<div class="aksrt-pay-meta__group is-open" data-group-row>
|
||||
<div class="aksrt-pay-meta__group-head">
|
||||
<span class="aksrt-pay-meta__group-drag" data-group-drag title="<?php esc_attr_e('拖拽排序', 'aksrt'); ?>"><span class="dashicons dashicons-move"></span></span>
|
||||
<button type="button" class="aksrt-pay-meta__group-toggle" data-group-toggle aria-expanded="true">
|
||||
<span class="aksrt-pay-meta__group-title" data-group-title><?php echo esc_html($title); ?></span>
|
||||
<span class="aksrt-pay-meta__group-caret dashicons dashicons-arrow-down"></span>
|
||||
<div class="jio-pay-meta__group is-open" data-group-row>
|
||||
<div class="jio-pay-meta__group-head">
|
||||
<span class="jio-pay-meta__group-drag" data-group-drag title="<?php esc_attr_e('拖拽排序', 'jio'); ?>"><span class="dashicons dashicons-move"></span></span>
|
||||
<button type="button" class="jio-pay-meta__group-toggle" data-group-toggle aria-expanded="true">
|
||||
<span class="jio-pay-meta__group-title" data-group-title><?php echo esc_html($title); ?></span>
|
||||
<span class="jio-pay-meta__group-caret dashicons dashicons-arrow-down"></span>
|
||||
</button>
|
||||
<button type="button" class="button-link-delete" data-group-remove><?php esc_html_e('移除', 'aksrt'); ?></button>
|
||||
<button type="button" class="button-link-delete" data-group-remove><?php esc_html_e('移除', 'jio'); ?></button>
|
||||
</div>
|
||||
<div class="aksrt-pay-meta__group-body">
|
||||
<div class="aksrt-pay-meta__group-field">
|
||||
<label><?php esc_html_e('下载地址', 'aksrt'); ?></label>
|
||||
<div class="aksrt-pay-meta__upload">
|
||||
<input type="url" name="<?php echo esc_attr($name); ?>[url]" value="<?php echo esc_attr($url); ?>" placeholder="<?php esc_attr_e('上传文件或输入下载地址', 'aksrt'); ?>" data-media-input data-group-url>
|
||||
<button type="button" class="button" data-media-select data-library=""><?php esc_html_e('选择', 'aksrt'); ?></button>
|
||||
<div class="jio-pay-meta__group-body">
|
||||
<div class="jio-pay-meta__group-field">
|
||||
<label><?php esc_html_e('下载地址', 'jio'); ?></label>
|
||||
<div class="jio-pay-meta__upload">
|
||||
<input type="url" name="<?php echo esc_attr($name); ?>[url]" value="<?php echo esc_attr($url); ?>" placeholder="<?php esc_attr_e('上传文件或输入下载地址', 'jio'); ?>" data-media-input data-group-url>
|
||||
<button type="button" class="button" data-media-select data-library=""><?php esc_html_e('选择', 'jio'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="aksrt-pay-meta__group-field">
|
||||
<label><?php esc_html_e('资源备注', 'aksrt'); ?></label>
|
||||
<textarea rows="1" name="<?php echo esc_attr($name); ?>[extract_code]" placeholder="<?php esc_attr_e('按钮旁边的额外内容,例如提取码、解压密码等', 'aksrt'); ?>"><?php echo esc_textarea($extract_code); ?></textarea>
|
||||
<div class="jio-pay-meta__group-field">
|
||||
<label><?php esc_html_e('资源备注', 'jio'); ?></label>
|
||||
<textarea rows="1" name="<?php echo esc_attr($name); ?>[extract_code]" placeholder="<?php esc_attr_e('按钮旁边的额外内容,例如提取码、解压密码等', 'jio'); ?>"><?php echo esc_textarea($extract_code); ?></textarea>
|
||||
</div>
|
||||
<div class="aksrt-pay-meta__group-field aksrt-pay-meta__group-field--split">
|
||||
<div class="jio-pay-meta__group-field jio-pay-meta__group-field--split">
|
||||
<div>
|
||||
<label><?php esc_html_e('复制的名称', 'aksrt'); ?></label>
|
||||
<input type="text" name="<?php echo esc_attr($name); ?>[copy_key]" value="<?php echo esc_attr($copy_key); ?>" placeholder="<?php esc_attr_e('例如:提取码', 'aksrt'); ?>">
|
||||
<label><?php esc_html_e('复制的名称', 'jio'); ?></label>
|
||||
<input type="text" name="<?php echo esc_attr($name); ?>[copy_key]" value="<?php echo esc_attr($copy_key); ?>" placeholder="<?php esc_attr_e('例如:提取码', 'jio'); ?>">
|
||||
</div>
|
||||
<div>
|
||||
<label><?php esc_html_e('复制的内容', 'aksrt'); ?></label>
|
||||
<input type="text" name="<?php echo esc_attr($name); ?>[copy_val]" value="<?php echo esc_attr($copy_val); ?>" placeholder="<?php esc_attr_e('例如:a1b2', 'aksrt'); ?>">
|
||||
<label><?php esc_html_e('复制的内容', 'jio'); ?></label>
|
||||
<input type="text" name="<?php echo esc_attr($name); ?>[copy_val]" value="<?php echo esc_attr($copy_val); ?>" placeholder="<?php esc_attr_e('例如:a1b2', 'jio'); ?>">
|
||||
</div>
|
||||
</div>
|
||||
<p class="description"><?php esc_html_e('为“资源备注”按钮添加点击复制功能,请设置复制名称和复制内容。', 'aksrt'); ?></p>
|
||||
<div class="aksrt-pay-meta__group-field">
|
||||
<label><?php esc_html_e('自定义按钮图标', 'aksrt'); ?></label>
|
||||
<p class="description"><?php esc_html_e('为“资源备注”按钮添加点击复制功能,请设置复制名称和复制内容。', 'jio'); ?></p>
|
||||
<div class="jio-pay-meta__group-field">
|
||||
<label><?php esc_html_e('自定义按钮图标', 'jio'); ?></label>
|
||||
<?php
|
||||
if (function_exists('aksrt_icon_picker_field')) {
|
||||
echo aksrt_icon_picker_field( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
if (function_exists('jio_icon_picker_field')) {
|
||||
echo jio_icon_picker_field( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
$name . '[icon]',
|
||||
'aksrt-pay-download-icon-' . $index,
|
||||
'jio-pay-download-icon-' . $index,
|
||||
$icon,
|
||||
['placeholder' => 'fa fas fa-download']
|
||||
);
|
||||
@@ -269,19 +269,19 @@ class ResourceMetaBox {
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="aksrt-pay-meta__group-field">
|
||||
<label><?php esc_html_e('自定义按钮文案', 'aksrt'); ?></label>
|
||||
<textarea rows="1" name="<?php echo esc_attr($name); ?>[label]" placeholder="<?php esc_attr_e('例如:立即下载', 'aksrt'); ?>" data-group-label><?php echo esc_textarea($label); ?></textarea>
|
||||
<div class="jio-pay-meta__group-field">
|
||||
<label><?php esc_html_e('自定义按钮文案', 'jio'); ?></label>
|
||||
<textarea rows="1" name="<?php echo esc_attr($name); ?>[label]" placeholder="<?php esc_attr_e('例如:立即下载', 'jio'); ?>" data-group-label><?php echo esc_textarea($label); ?></textarea>
|
||||
</div>
|
||||
<div class="aksrt-pay-meta__group-field">
|
||||
<label><?php esc_html_e('自定义按钮颜色', 'aksrt'); ?></label>
|
||||
<div class="aksrt-pay-meta__class-swatches" data-group-classes>
|
||||
<div class="jio-pay-meta__group-field">
|
||||
<label><?php esc_html_e('自定义按钮颜色', 'jio'); ?></label>
|
||||
<div class="jio-pay-meta__class-swatches" data-group-classes>
|
||||
<?php foreach (DomainModel::DOWNLOAD_BUTTON_CLASSES as $swatch) : ?>
|
||||
<button type="button" class="aksrt-pay-meta__class-swatch <?php echo $swatch !== '' ? esc_attr($swatch) : 'b-theme'; ?><?php echo $swatch === $class ? ' is-active' : ''; ?>" data-group-class="<?php echo esc_attr($swatch); ?>" aria-label="<?php echo $swatch !== '' ? esc_attr($swatch) : esc_attr__('默认', 'aksrt'); ?>" aria-pressed="<?php echo $swatch === $class ? 'true' : 'false'; ?>"></button>
|
||||
<button type="button" class="jio-pay-meta__class-swatch <?php echo $swatch !== '' ? esc_attr($swatch) : 'b-theme'; ?><?php echo $swatch === $class ? ' is-active' : ''; ?>" data-group-class="<?php echo esc_attr($swatch); ?>" aria-label="<?php echo $swatch !== '' ? esc_attr($swatch) : esc_attr__('默认', 'jio'); ?>" aria-pressed="<?php echo $swatch === $class ? 'true' : 'false'; ?>"></button>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<input type="hidden" name="<?php echo esc_attr($name); ?>[class]" value="<?php echo esc_attr($class); ?>" data-group-class-input>
|
||||
<p class="description"><?php esc_html_e('按钮图标、文案、颜色默认均会自动获取,建议为空即可。', 'aksrt'); ?></p>
|
||||
<p class="description"><?php esc_html_e('按钮图标、文案、颜色默认均会自动获取,建议为空即可。', 'jio'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -291,7 +291,7 @@ class ResourceMetaBox {
|
||||
/** @param int|string $index */
|
||||
private function attribute_row($index, array $row): void {
|
||||
?>
|
||||
<div class="aksrt-pay-meta__group aksrt-pay-meta__group--inline" data-group-row><input type="text" name="aksrt_pay[attributes][<?php echo esc_attr((string) $index); ?>][key]" value="<?php echo esc_attr((string) ($row['key'] ?? '')); ?>" placeholder="<?php esc_attr_e('属性名称', 'aksrt'); ?>"><input type="text" name="aksrt_pay[attributes][<?php echo esc_attr((string) $index); ?>][value]" value="<?php echo esc_attr((string) ($row['value'] ?? '')); ?>" placeholder="<?php esc_attr_e('属性内容', 'aksrt'); ?>"><button type="button" class="button-link-delete" data-group-remove><?php esc_html_e('移除', 'aksrt'); ?></button></div>
|
||||
<div class="jio-pay-meta__group jio-pay-meta__group--inline" data-group-row><input type="text" name="jio_pay[attributes][<?php echo esc_attr((string) $index); ?>][key]" value="<?php echo esc_attr((string) ($row['key'] ?? '')); ?>" placeholder="<?php esc_attr_e('属性名称', 'jio'); ?>"><input type="text" name="jio_pay[attributes][<?php echo esc_attr((string) $index); ?>][value]" value="<?php echo esc_attr((string) ($row['value'] ?? '')); ?>" placeholder="<?php esc_attr_e('属性内容', 'jio'); ?>"><button type="button" class="button-link-delete" data-group-remove><?php esc_html_e('移除', 'jio'); ?></button></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -299,11 +299,11 @@ class ResourceMetaBox {
|
||||
if ($post->post_type !== 'post' || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || wp_is_post_revision($post_id) || !current_user_can('edit_post', $post_id)) {
|
||||
return;
|
||||
}
|
||||
if (empty($_POST['aksrt_pay_meta_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash((string) $_POST['aksrt_pay_meta_nonce'])), 'aksrt_pay_meta_save')) {
|
||||
if (empty($_POST['jio_pay_meta_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash((string) $_POST['jio_pay_meta_nonce'])), 'jio_pay_meta_save')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$raw = isset($_POST['aksrt_pay']) && is_array($_POST['aksrt_pay']) ? wp_unslash($_POST['aksrt_pay']) : [];
|
||||
$raw = isset($_POST['jio_pay']) && is_array($_POST['jio_pay']) ? wp_unslash($_POST['jio_pay']) : [];
|
||||
$gallery = [];
|
||||
$ids = array_values(array_filter(array_map('absint', preg_split('/[\s,]+/', (string) ($raw['gallery_ids'] ?? '')) ?: [])));
|
||||
foreach (array_slice($ids, 0, 100) as $attachment_id) {
|
||||
|
||||
+21
-21
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -20,8 +20,8 @@ class SEOHead {
|
||||
|
||||
public function init(): void {
|
||||
// seo_enabled 主开关:关闭时不挂载任何 wp_head 输出
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
$seo = \AKSRT\Settings\Settings::get_seo_settings();
|
||||
if (class_exists('\Jio\Settings\Settings')) {
|
||||
$seo = \Jio\Settings\Settings::get_seo_settings();
|
||||
if (empty($seo['seo_enabled'])) return;
|
||||
}
|
||||
// 单一出口:所有 SEO/OG/JSON-LD 输出集中在 priority 2。
|
||||
@@ -39,8 +39,8 @@ class SEOHead {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
$s = \AKSRT\Settings\Settings::get_all();
|
||||
if (class_exists('\Jio\Settings\Settings')) {
|
||||
$s = \Jio\Settings\Settings::get_all();
|
||||
} else {
|
||||
$s = [];
|
||||
}
|
||||
@@ -144,7 +144,7 @@ class SEOHead {
|
||||
*
|
||||
* @param array $payload 规范 SEO 负载。
|
||||
*/
|
||||
return apply_filters('aksrt_seo_head_payload', $payload);
|
||||
return apply_filters('jio_seo_head_payload', $payload);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,9 +159,9 @@ class SEOHead {
|
||||
};
|
||||
|
||||
return [
|
||||
'title' => $get('_aksrt_seo_title'),
|
||||
'description' => $get('_aksrt_seo_description'),
|
||||
'keywords' => $get('_aksrt_seo_keywords'),
|
||||
'title' => $get('_jio_seo_title'),
|
||||
'description' => $get('_jio_seo_description'),
|
||||
'keywords' => $get('_jio_seo_keywords'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -176,9 +176,9 @@ class SEOHead {
|
||||
};
|
||||
|
||||
return [
|
||||
'title' => $get('_aksrt_seo_title'),
|
||||
'description' => $get('_aksrt_seo_description'),
|
||||
'keywords' => $get('_aksrt_seo_keywords'),
|
||||
'title' => $get('_jio_seo_title'),
|
||||
'description' => $get('_jio_seo_description'),
|
||||
'keywords' => $get('_jio_seo_keywords'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -212,8 +212,8 @@ class SEOHead {
|
||||
return $image;
|
||||
}
|
||||
}
|
||||
if (function_exists('aksrt_get_first_content_image_url')) {
|
||||
$image = (string) aksrt_get_first_content_image_url($post->ID);
|
||||
if (function_exists('jio_get_first_content_image_url')) {
|
||||
$image = (string) jio_get_first_content_image_url($post->ID);
|
||||
if ($image !== '') {
|
||||
return $image;
|
||||
}
|
||||
@@ -221,8 +221,8 @@ class SEOHead {
|
||||
if ($cfg['default_image'] !== '') {
|
||||
return $cfg['default_image'];
|
||||
}
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
return (string) \AKSRT\Settings\Settings::logo_url();
|
||||
if (class_exists('\Jio\Settings\Settings')) {
|
||||
return (string) \Jio\Settings\Settings::logo_url();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
@@ -234,11 +234,11 @@ class SEOHead {
|
||||
$cfg = $this->config();
|
||||
$payload = $this->resolve_payload();
|
||||
|
||||
echo "\n<!-- AKSRT SEO -->\n";
|
||||
echo "\n<!-- Jio SEO -->\n";
|
||||
|
||||
// Favicon(无站点图标时回退)。
|
||||
if (function_exists('aksrt_get_favicon_url')) {
|
||||
$favicon = (string) aksrt_get_favicon_url();
|
||||
if (function_exists('jio_get_favicon_url')) {
|
||||
$favicon = (string) jio_get_favicon_url();
|
||||
if ($favicon !== '' && !has_site_icon()) {
|
||||
printf('<link rel="icon" href="%s">' . "\n", esc_url($favicon));
|
||||
}
|
||||
@@ -267,7 +267,7 @@ class SEOHead {
|
||||
$this->render_jsonld($payload, $cfg);
|
||||
}
|
||||
|
||||
echo "<!-- /AKSRT SEO -->\n";
|
||||
echo "<!-- /Jio SEO -->\n";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+87
-87
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -11,9 +11,9 @@ class SEOMetaBox {
|
||||
|
||||
private static $instance = null;
|
||||
|
||||
public const META_TITLE = '_aksrt_seo_title';
|
||||
public const META_KEYWORDS = '_aksrt_seo_keywords';
|
||||
public const META_DESCRIPTION = '_aksrt_seo_description';
|
||||
public const META_TITLE = '_jio_seo_title';
|
||||
public const META_KEYWORDS = '_jio_seo_keywords';
|
||||
public const META_DESCRIPTION = '_jio_seo_description';
|
||||
|
||||
public static function get_instance(): self {
|
||||
if (null === self::$instance) {
|
||||
@@ -37,8 +37,8 @@ class SEOMetaBox {
|
||||
public function register_meta_box(): void {
|
||||
foreach (['post', 'page'] as $screen) {
|
||||
add_meta_box(
|
||||
'aksrt_seo_meta',
|
||||
__('独立SEO', 'aksrt'),
|
||||
'jio_seo_meta',
|
||||
__('独立SEO', 'jio'),
|
||||
[$this, 'render_meta_box'],
|
||||
$screen,
|
||||
'normal',
|
||||
@@ -48,7 +48,7 @@ class SEOMetaBox {
|
||||
}
|
||||
|
||||
public function render_meta_box(\WP_Post $post): void {
|
||||
wp_nonce_field('aksrt_seo_meta_save', 'aksrt_seo_meta_nonce');
|
||||
wp_nonce_field('jio_seo_meta_save', 'jio_seo_meta_nonce');
|
||||
|
||||
$title = (string) get_post_meta($post->ID, self::META_TITLE, true);
|
||||
$keywords = (string) get_post_meta($post->ID, self::META_KEYWORDS, true);
|
||||
@@ -57,38 +57,38 @@ class SEOMetaBox {
|
||||
$ai_btn = $this->render_ai_button('post', (int) $post->ID);
|
||||
$summary_btn = $this->render_summary_button((int) $post->ID);
|
||||
?>
|
||||
<div class="aksrt-seo-meta-box">
|
||||
<div class="notice notice-warning inline"><p><?php esc_html_e('系统默认调用标题、分类标签、描述等自动生成SEO内容,一般无需单独设置SEO内容;如需覆盖,请在下方自定义。', 'aksrt'); ?></p></div>
|
||||
<div class="aksrt-seo-preview">
|
||||
<strong><?php esc_html_e('SEO预览', 'aksrt'); ?></strong>
|
||||
<div class="aksrt-seo-preview__title"><?php echo esc_html($title !== '' ? $title : get_the_title($post)); ?></div>
|
||||
<div class="aksrt-seo-preview__url"><?php echo esc_html(get_permalink($post)); ?></div>
|
||||
<div class="aksrt-seo-preview__description"><?php echo esc_html($description !== '' ? $description : wp_trim_words(wp_strip_all_tags((string) $post->post_content), 38, '…')); ?></div>
|
||||
<div class="jio-seo-meta-box">
|
||||
<div class="notice notice-warning inline"><p><?php esc_html_e('系统默认调用标题、分类标签、描述等自动生成SEO内容,一般无需单独设置SEO内容;如需覆盖,请在下方自定义。', 'jio'); ?></p></div>
|
||||
<div class="jio-seo-preview">
|
||||
<strong><?php esc_html_e('SEO预览', 'jio'); ?></strong>
|
||||
<div class="jio-seo-preview__title"><?php echo esc_html($title !== '' ? $title : get_the_title($post)); ?></div>
|
||||
<div class="jio-seo-preview__url"><?php echo esc_html(get_permalink($post)); ?></div>
|
||||
<div class="jio-seo-preview__description"><?php echo esc_html($description !== '' ? $description : wp_trim_words(wp_strip_all_tags((string) $post->post_content), 38, '…')); ?></div>
|
||||
</div>
|
||||
<p>
|
||||
<label for="aksrt_seo_title"><strong><?php esc_html_e('自定义SEO标题', 'aksrt'); ?></strong></label>
|
||||
<input type="text" class="widefat" id="aksrt_seo_title" name="aksrt_seo_title" value="<?php echo esc_attr($title); ?>" />
|
||||
<span class="description"><?php esc_html_e('Title 一般建议15到30个字符', 'aksrt'); ?></span>
|
||||
<label for="jio_seo_title"><strong><?php esc_html_e('自定义SEO标题', 'jio'); ?></strong></label>
|
||||
<input type="text" class="widefat" id="jio_seo_title" name="jio_seo_title" value="<?php echo esc_attr($title); ?>" />
|
||||
<span class="description"><?php esc_html_e('Title 一般建议15到30个字符', 'jio'); ?></span>
|
||||
</p>
|
||||
<p>
|
||||
<label for="aksrt_seo_keywords"><strong><?php esc_html_e('自定义SEO关键词', 'aksrt'); ?></strong></label>
|
||||
<input type="text" class="widefat" id="aksrt_seo_keywords" name="aksrt_seo_keywords" value="<?php echo esc_attr($keywords); ?>" placeholder="<?php esc_attr_e('多个关键词用英文逗号分隔', 'aksrt'); ?>" />
|
||||
<span class="description"><?php esc_html_e('Keywords 每个关键词用逗号隔开', 'aksrt'); ?></span>
|
||||
<label for="jio_seo_keywords"><strong><?php esc_html_e('自定义SEO关键词', 'jio'); ?></strong></label>
|
||||
<input type="text" class="widefat" id="jio_seo_keywords" name="jio_seo_keywords" value="<?php echo esc_attr($keywords); ?>" placeholder="<?php esc_attr_e('多个关键词用英文逗号分隔', 'jio'); ?>" />
|
||||
<span class="description"><?php esc_html_e('Keywords 每个关键词用逗号隔开', 'jio'); ?></span>
|
||||
</p>
|
||||
<p>
|
||||
<label for="aksrt_seo_description"><strong><?php esc_html_e('自定义SEO描述', 'aksrt'); ?></strong></label>
|
||||
<textarea class="widefat" rows="3" id="aksrt_seo_description" name="aksrt_seo_description"><?php echo esc_textarea($description); ?></textarea>
|
||||
<span class="description"><?php esc_html_e('Description 一般建议50到150个字符', 'aksrt'); ?><?php echo $ai_btn; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span>
|
||||
<label for="jio_seo_description"><strong><?php esc_html_e('自定义SEO描述', 'jio'); ?></strong></label>
|
||||
<textarea class="widefat" rows="3" id="jio_seo_description" name="jio_seo_description"><?php echo esc_textarea($description); ?></textarea>
|
||||
<span class="description"><?php esc_html_e('Description 一般建议50到150个字符', 'jio'); ?><?php echo $ai_btn; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span>
|
||||
</p>
|
||||
<details class="aksrt-seo-advice"><summary><span class="dashicons dashicons-star-filled"></span> <?php esc_html_e('SEO优化建议', 'aksrt'); ?></summary><div>
|
||||
<p><strong><?php esc_html_e('SEO标题:', 'aksrt'); ?></strong><?php esc_html_e('标题应紧扣主要内容,重要关键词靠前,避免关键词堆砌。', 'aksrt'); ?></p>
|
||||
<p><strong><?php esc_html_e('SEO关键词:', 'aksrt'); ?></strong><?php esc_html_e('一般建议4到8个,并与网站定位及正文保持一致。', 'aksrt'); ?></p>
|
||||
<p><strong><?php esc_html_e('SEO描述:', 'aksrt'); ?></strong><?php esc_html_e('使用一段通顺、有吸引力的文字精炼概括页面内容。', 'aksrt'); ?></p>
|
||||
<p class="description"><?php esc_html_e('优化建议来自互联网,仅供参考。', 'aksrt'); ?></p>
|
||||
<details class="jio-seo-advice"><summary><span class="dashicons dashicons-star-filled"></span> <?php esc_html_e('SEO优化建议', 'jio'); ?></summary><div>
|
||||
<p><strong><?php esc_html_e('SEO标题:', 'jio'); ?></strong><?php esc_html_e('标题应紧扣主要内容,重要关键词靠前,避免关键词堆砌。', 'jio'); ?></p>
|
||||
<p><strong><?php esc_html_e('SEO关键词:', 'jio'); ?></strong><?php esc_html_e('一般建议4到8个,并与网站定位及正文保持一致。', 'jio'); ?></p>
|
||||
<p><strong><?php esc_html_e('SEO描述:', 'jio'); ?></strong><?php esc_html_e('使用一段通顺、有吸引力的文字精炼概括页面内容。', 'jio'); ?></p>
|
||||
<p class="description"><?php esc_html_e('优化建议来自互联网,仅供参考。', 'jio'); ?></p>
|
||||
</div></details>
|
||||
<?php if ($summary_btn !== '') : ?>
|
||||
<p class="aksrt-ai-summary-row">
|
||||
<span class="description"><?php esc_html_e('写作辅助:根据正文生成摘要并填入「摘要」字段(不自动保存)。', 'aksrt'); ?></span>
|
||||
<p class="jio-ai-summary-row">
|
||||
<span class="description"><?php esc_html_e('写作辅助:根据正文生成摘要并填入「摘要」字段(不自动保存)。', 'jio'); ?></span>
|
||||
<?php echo $summary_btn; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
@@ -97,7 +97,7 @@ class SEOMetaBox {
|
||||
}
|
||||
|
||||
public function save_meta_box(int $post_id, $post = null): void {
|
||||
if (!isset($_POST['aksrt_seo_meta_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['aksrt_seo_meta_nonce'])), 'aksrt_seo_meta_save')) {
|
||||
if (!isset($_POST['jio_seo_meta_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['jio_seo_meta_nonce'])), 'jio_seo_meta_save')) {
|
||||
return;
|
||||
}
|
||||
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
|
||||
@@ -111,9 +111,9 @@ class SEOMetaBox {
|
||||
}
|
||||
|
||||
$map = [
|
||||
self::META_TITLE => 'aksrt_seo_title',
|
||||
self::META_KEYWORDS => 'aksrt_seo_keywords',
|
||||
self::META_DESCRIPTION => 'aksrt_seo_description',
|
||||
self::META_TITLE => 'jio_seo_title',
|
||||
self::META_KEYWORDS => 'jio_seo_keywords',
|
||||
self::META_DESCRIPTION => 'jio_seo_description',
|
||||
];
|
||||
|
||||
foreach ($map as $meta_key => $field) {
|
||||
@@ -142,22 +142,22 @@ class SEOMetaBox {
|
||||
$ai_btn = $this->render_ai_button('term', (int) $term->term_id);
|
||||
?>
|
||||
<tr class="form-field">
|
||||
<th scope="row"><label for="aksrt_seo_title"><?php esc_html_e('SEO 标题', 'aksrt'); ?></label></th>
|
||||
<th scope="row"><label for="jio_seo_title"><?php esc_html_e('SEO 标题', 'jio'); ?></label></th>
|
||||
<td>
|
||||
<input type="text" name="aksrt_seo_title" id="aksrt_seo_title" class="aksrt-term-seo-title" value="<?php echo esc_attr($title); ?>" />
|
||||
<input type="text" name="jio_seo_title" id="jio_seo_title" class="jio-term-seo-title" value="<?php echo esc_attr($title); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="form-field">
|
||||
<th scope="row"><label for="aksrt_seo_keywords"><?php esc_html_e('SEO 关键词', 'aksrt'); ?></label></th>
|
||||
<th scope="row"><label for="jio_seo_keywords"><?php esc_html_e('SEO 关键词', 'jio'); ?></label></th>
|
||||
<td>
|
||||
<input type="text" name="aksrt_seo_keywords" id="aksrt_seo_keywords" class="aksrt-term-seo-keywords" value="<?php echo esc_attr($keywords); ?>" />
|
||||
<input type="text" name="jio_seo_keywords" id="jio_seo_keywords" class="jio-term-seo-keywords" value="<?php echo esc_attr($keywords); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="form-field">
|
||||
<th scope="row"><label for="aksrt_seo_description"><?php esc_html_e('SEO 描述', 'aksrt'); ?></label></th>
|
||||
<th scope="row"><label for="jio_seo_description"><?php esc_html_e('SEO 描述', 'jio'); ?></label></th>
|
||||
<td>
|
||||
<textarea name="aksrt_seo_description" id="aksrt_seo_description" class="aksrt-term-seo-description" rows="4"><?php echo esc_textarea($description); ?></textarea>
|
||||
<p class="description"><?php esc_html_e('主题默认会自动设置 SEO 内容,如需单独设置请在此输入。', 'aksrt'); ?><?php echo $ai_btn; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
|
||||
<textarea name="jio_seo_description" id="jio_seo_description" class="jio-term-seo-description" rows="4"><?php echo esc_textarea($description); ?></textarea>
|
||||
<p class="description"><?php esc_html_e('主题默认会自动设置 SEO 内容,如需单独设置请在此输入。', 'jio'); ?><?php echo $ai_btn; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
@@ -169,9 +169,9 @@ class SEOMetaBox {
|
||||
}
|
||||
|
||||
$map = [
|
||||
self::META_TITLE => 'aksrt_seo_title',
|
||||
self::META_KEYWORDS => 'aksrt_seo_keywords',
|
||||
self::META_DESCRIPTION => 'aksrt_seo_description',
|
||||
self::META_TITLE => 'jio_seo_title',
|
||||
self::META_KEYWORDS => 'jio_seo_keywords',
|
||||
self::META_DESCRIPTION => 'jio_seo_description',
|
||||
];
|
||||
|
||||
foreach ($map as $meta_key => $field) {
|
||||
@@ -197,24 +197,24 @@ class SEOMetaBox {
|
||||
return;
|
||||
}
|
||||
|
||||
$path = AKSRT_DIR . '/assets/js/admin-ai-seo.js';
|
||||
$path = JIO_DIR . '/assets/js/admin-ai-seo.js';
|
||||
if (!is_file($path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_enqueue_script(
|
||||
'aksrt-admin-ai-seo',
|
||||
AKSRT_URI . '/assets/js/admin-ai-seo.js',
|
||||
'jio-admin-ai-seo',
|
||||
JIO_URI . '/assets/js/admin-ai-seo.js',
|
||||
[],
|
||||
(string) filemtime($path),
|
||||
true
|
||||
);
|
||||
|
||||
$ai_available = class_exists('\AKSRT\Ai\AI') && \AKSRT\Ai\AI::get_instance()->is_available();
|
||||
$seo = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_seo_settings() : [];
|
||||
$ai_available = class_exists('\Jio\Ai\AI') && \Jio\Ai\AI::get_instance()->is_available();
|
||||
$seo = class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::get_seo_settings() : [];
|
||||
|
||||
wp_localize_script('aksrt-admin-ai-seo', 'aksrtAiSeo', [
|
||||
'restUrl' => esc_url_raw(rest_url('aksrt/v1')),
|
||||
wp_localize_script('jio-admin-ai-seo', 'jioAiSeo', [
|
||||
'restUrl' => esc_url_raw(rest_url('jio/v1')),
|
||||
'nonce' => wp_create_nonce('wp_rest'),
|
||||
'ai' => [
|
||||
'available' => $ai_available,
|
||||
@@ -222,56 +222,56 @@ class SEOMetaBox {
|
||||
'write_assist' => $ai_available,
|
||||
],
|
||||
'i18n' => [
|
||||
'generating' => __('生成中…', 'aksrt'),
|
||||
'generate' => __('AI 生成 SEO', 'aksrt'),
|
||||
'generateSummary' => __('AI 生成摘要', 'aksrt'),
|
||||
'success' => __('已填入 SEO 字段,请检查后更新保存', 'aksrt'),
|
||||
'summarySuccess' => __('已填入摘要字段,请检查后更新保存', 'aksrt'),
|
||||
'failed' => __('生成失败', 'aksrt'),
|
||||
'needSave' => __('请先保存后再生成 SEO', 'aksrt'),
|
||||
'needContent' => __('请先填写正文内容', 'aksrt'),
|
||||
'notAvailable' => __('AI 未配置或未启用', 'aksrt'),
|
||||
'noExcerptField' => __('未找到摘要字段,请展开「摘要」面板', 'aksrt'),
|
||||
'generating' => __('生成中…', 'jio'),
|
||||
'generate' => __('AI 生成 SEO', 'jio'),
|
||||
'generateSummary' => __('AI 生成摘要', 'jio'),
|
||||
'success' => __('已填入 SEO 字段,请检查后更新保存', 'jio'),
|
||||
'summarySuccess' => __('已填入摘要字段,请检查后更新保存', 'jio'),
|
||||
'failed' => __('生成失败', 'jio'),
|
||||
'needSave' => __('请先保存后再生成 SEO', 'jio'),
|
||||
'needContent' => __('请先填写正文内容', 'jio'),
|
||||
'notAvailable' => __('AI 未配置或未启用', 'jio'),
|
||||
'noExcerptField' => __('未找到摘要字段,请展开「摘要」面板', 'jio'),
|
||||
],
|
||||
]);
|
||||
|
||||
wp_add_inline_style('wp-admin', '
|
||||
.aksrt-ai-seo-button{display:inline-block;margin-left:8px;vertical-align:middle}
|
||||
.aksrt-ai-seo-generate,.aksrt-ai-summary-generate{cursor:pointer}
|
||||
.aksrt-ai-seo-generate.is-loading,.aksrt-ai-summary-generate.is-loading{opacity:.6;pointer-events:none}
|
||||
.aksrt-ai-seo-msg{display:block;margin-top:6px;font-size:12px}
|
||||
.aksrt-ai-seo-msg.is-error{color:#b32d2e}
|
||||
.aksrt-ai-seo-msg.is-ok{color:#007017}
|
||||
.aksrt-ai-summary-row{margin-top:8px;padding-top:8px;border-top:1px solid #eee}
|
||||
.aksrt-seo-preview{margin:12px 0;padding:14px;border:1px solid #e5e5e5;border-radius:4px;background:#fff}
|
||||
.aksrt-seo-preview__title{margin-top:8px;color:#1a0dab;font-size:18px;line-height:1.3}
|
||||
.aksrt-seo-preview__url{margin:4px 0;color:#188038;font-size:13px;word-break:break-all}
|
||||
.aksrt-seo-preview__description{color:#4d5156;line-height:1.5}
|
||||
.aksrt-seo-advice{margin-top:12px;border:1px solid #e5e5e5;border-radius:4px}
|
||||
.aksrt-seo-advice summary{padding:10px 12px;cursor:pointer;font-weight:600}
|
||||
.aksrt-seo-advice>div{padding:0 12px 10px}
|
||||
.jio-ai-seo-button{display:inline-block;margin-left:8px;vertical-align:middle}
|
||||
.jio-ai-seo-generate,.jio-ai-summary-generate{cursor:pointer}
|
||||
.jio-ai-seo-generate.is-loading,.jio-ai-summary-generate.is-loading{opacity:.6;pointer-events:none}
|
||||
.jio-ai-seo-msg{display:block;margin-top:6px;font-size:12px}
|
||||
.jio-ai-seo-msg.is-error{color:#b32d2e}
|
||||
.jio-ai-seo-msg.is-ok{color:#007017}
|
||||
.jio-ai-summary-row{margin-top:8px;padding-top:8px;border-top:1px solid #eee}
|
||||
.jio-seo-preview{margin:12px 0;padding:14px;border:1px solid #e5e5e5;border-radius:4px;background:#fff}
|
||||
.jio-seo-preview__title{margin-top:8px;color:#1a0dab;font-size:18px;line-height:1.3}
|
||||
.jio-seo-preview__url{margin:4px 0;color:#188038;font-size:13px;word-break:break-all}
|
||||
.jio-seo-preview__description{color:#4d5156;line-height:1.5}
|
||||
.jio-seo-advice{margin-top:12px;border:1px solid #e5e5e5;border-radius:4px}
|
||||
.jio-seo-advice summary{padding:10px 12px;cursor:pointer;font-weight:600}
|
||||
.jio-seo-advice>div{padding:0 12px 10px}
|
||||
');
|
||||
}
|
||||
|
||||
private function render_ai_button(string $type, int $id): string {
|
||||
$seo = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_seo_settings() : [];
|
||||
$seo = class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::get_seo_settings() : [];
|
||||
if (empty($seo['seo_enabled']) || empty($seo['seo_ai_enabled'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$available = class_exists('\AKSRT\Ai\AI') && \AKSRT\Ai\AI::get_instance()->is_available();
|
||||
$available = class_exists('\Jio\Ai\AI') && \Jio\Ai\AI::get_instance()->is_available();
|
||||
$disabled = (!$available || $id <= 0) ? ' disabled' : '';
|
||||
$title = !$available
|
||||
? esc_attr__('请先配置 WordPress AI Connectors', 'aksrt')
|
||||
: ($id <= 0 ? esc_attr__('请先保存后再生成', 'aksrt') : '');
|
||||
? esc_attr__('请先配置 WordPress AI Connectors', 'jio')
|
||||
: ($id <= 0 ? esc_attr__('请先保存后再生成', 'jio') : '');
|
||||
|
||||
return sprintf(
|
||||
'<span class="aksrt-ai-seo-button"><button type="button" class="button aksrt-ai-seo-generate"%s data-type="%s" data-id="%d" title="%s">%s</button></span>',
|
||||
'<span class="jio-ai-seo-button"><button type="button" class="button jio-ai-seo-generate"%s data-type="%s" data-id="%d" title="%s">%s</button></span>',
|
||||
$disabled,
|
||||
esc_attr($type),
|
||||
$id,
|
||||
$title,
|
||||
esc_html__('AI 生成 SEO', 'aksrt')
|
||||
esc_html__('AI 生成 SEO', 'jio')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -279,22 +279,22 @@ class SEOMetaBox {
|
||||
* 后台「AI 生成摘要」→ 写入 WP 摘要字段(#excerpt / 块编辑器)。
|
||||
*/
|
||||
private function render_summary_button(int $post_id): string {
|
||||
$available = class_exists('\AKSRT\Ai\AI') && \AKSRT\Ai\AI::get_instance()->is_available();
|
||||
$available = class_exists('\Jio\Ai\AI') && \Jio\Ai\AI::get_instance()->is_available();
|
||||
if (!$available) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$disabled = $post_id <= 0 ? ' disabled' : '';
|
||||
$title = $post_id <= 0
|
||||
? esc_attr__('请先保存后再生成', 'aksrt')
|
||||
: esc_attr__('根据正文生成摘要,填入摘要框', 'aksrt');
|
||||
? esc_attr__('请先保存后再生成', 'jio')
|
||||
: esc_attr__('根据正文生成摘要,填入摘要框', 'jio');
|
||||
|
||||
return sprintf(
|
||||
'<span class="aksrt-ai-seo-button"><button type="button" class="button aksrt-ai-summary-generate"%s data-post-id="%d" title="%s">%s</button></span>',
|
||||
'<span class="jio-ai-seo-button"><button type="button" class="button jio-ai-summary-generate"%s data-post-id="%d" title="%s">%s</button></span>',
|
||||
$disabled,
|
||||
$post_id,
|
||||
$title,
|
||||
esc_html__('AI 生成摘要', 'aksrt')
|
||||
esc_html__('AI 生成摘要', 'jio')
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -31,10 +31,10 @@ class Scripts {
|
||||
add_action('wp_head', [$this, 'output_custom_codes']);
|
||||
add_action('wp_body_open', [$this, 'output_loading_overlay'], 1);
|
||||
add_action('wp_footer', [$this, 'output_custom_footer_codes'], 99);
|
||||
add_action('wp_ajax_aksrt_frontend_debug', [$this, 'handle_frontend_debug']);
|
||||
add_action('wp_ajax_nopriv_aksrt_frontend_debug', [$this, 'handle_frontend_debug']);
|
||||
add_action('wp_ajax_aksrt_search_suggestions', [$this, 'handle_search_suggestions']);
|
||||
add_action('wp_ajax_nopriv_aksrt_search_suggestions', [$this, 'handle_search_suggestions']);
|
||||
add_action('wp_ajax_jio_frontend_debug', [$this, 'handle_frontend_debug']);
|
||||
add_action('wp_ajax_nopriv_jio_frontend_debug', [$this, 'handle_frontend_debug']);
|
||||
add_action('wp_ajax_jio_search_suggestions', [$this, 'handle_search_suggestions']);
|
||||
add_action('wp_ajax_nopriv_jio_search_suggestions', [$this, 'handle_search_suggestions']);
|
||||
add_filter('body_class', [$this, 'body_classes']);
|
||||
}
|
||||
|
||||
|
||||
+118
-118
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -11,7 +11,7 @@ trait ScriptsPart1b {
|
||||
|
||||
public function enqueue_public(): void {
|
||||
$base_uri = get_template_directory_uri();
|
||||
$version = AKSRT_VERSION;
|
||||
$version = JIO_VERSION;
|
||||
|
||||
// Keep WordPress's managed jQuery so core and plugin UI scripts share one compatible API.
|
||||
wp_enqueue_script('jquery');
|
||||
@@ -25,47 +25,47 @@ trait ScriptsPart1b {
|
||||
[],
|
||||
'3.4.1'
|
||||
);
|
||||
aksrt_enqueue_fontawesome(['bootstrap']);
|
||||
jio_enqueue_fontawesome(['bootstrap']);
|
||||
$main_css_path = get_template_directory() . '/assets/css/main.min.css';
|
||||
wp_enqueue_style(
|
||||
'aksrt-main',
|
||||
'jio-main',
|
||||
$base_uri . '/assets/css/main.min.css',
|
||||
['aksrt-font-awesome'],
|
||||
['jio-font-awesome'],
|
||||
file_exists($main_css_path) ? (string) filemtime($main_css_path) : $version
|
||||
);
|
||||
wp_enqueue_style(
|
||||
'aksrt-public',
|
||||
'jio-public',
|
||||
$base_uri . '/assets/css/build/' . $public_filename,
|
||||
['aksrt-main'],
|
||||
['jio-main'],
|
||||
file_exists($public_bundle) ? (string) filemtime($public_bundle) : $version
|
||||
);
|
||||
|
||||
$lazy_animation = class_exists('\AKSRT\Settings\Settings')
|
||||
? (string) \AKSRT\Settings\Settings::get_value('lazy_animation', 'blur')
|
||||
$lazy_animation = class_exists('\Jio\Settings\Settings')
|
||||
? (string) \Jio\Settings\Settings::get_value('lazy_animation', 'blur')
|
||||
: 'blur';
|
||||
if ($lazy_animation === 'fade') {
|
||||
wp_add_inline_style('aksrt-public', '.lazyloaded{--lazy-animation:lazy_fade!important;}');
|
||||
wp_add_inline_style('jio-public', '.lazyloaded{--lazy-animation:lazy_fade!important;}');
|
||||
} elseif ($lazy_animation === 'scale') {
|
||||
wp_add_inline_style('aksrt-public', '.lazyloaded{--lazy-animation:lazy_scale!important;}');
|
||||
wp_add_inline_style('jio-public', '.lazyloaded{--lazy-animation:lazy_scale!important;}');
|
||||
}
|
||||
|
||||
$core_dep = 'aksrt-public';
|
||||
$core_dep = 'jio-public';
|
||||
|
||||
$deps = [$core_dep];
|
||||
$enqueue_module = function ($slug) use ($base_uri, $version, $deps) {
|
||||
$path = get_template_directory() . '/assets/css/frontend/' . $slug . '.css';
|
||||
wp_enqueue_style(
|
||||
'aksrt-' . $slug,
|
||||
'jio-' . $slug,
|
||||
$base_uri . '/assets/css/frontend/' . $slug . '.css',
|
||||
$deps,
|
||||
(file_exists($path) ? (string) filemtime($path) : $version)
|
||||
);
|
||||
};
|
||||
|
||||
if (!is_user_logged_in() || (bool) get_query_var('aksrt_sign')) {
|
||||
if (!is_user_logged_in() || (bool) get_query_var('jio_sign')) {
|
||||
$auth_css = get_template_directory() . '/assets/css/routes/sign.css';
|
||||
wp_enqueue_style(
|
||||
'aksrt-auth',
|
||||
'jio-auth',
|
||||
$base_uri . '/assets/css/routes/sign.css',
|
||||
[$core_dep],
|
||||
file_exists($auth_css) ? (string) filemtime($auth_css) : $version
|
||||
@@ -73,24 +73,24 @@ trait ScriptsPart1b {
|
||||
}
|
||||
|
||||
// Shared VIP purchase/poll coordinator for modal and credits surfaces.
|
||||
$vip_on = class_exists('\AKSRT\Settings\Settings')
|
||||
&& !empty(\AKSRT\Settings\Settings::get_payment_vip_settings()['enabled']);
|
||||
$vip_on = class_exists('\Jio\Settings\Settings')
|
||||
&& !empty(\Jio\Settings\Settings::get_payment_vip_settings()['enabled']);
|
||||
$credits_on = is_user_logged_in()
|
||||
&& class_exists('\AKSRT\Settings\Settings')
|
||||
&& \AKSRT\Settings\Settings::credits_enabled();
|
||||
&& class_exists('\Jio\Settings\Settings')
|
||||
&& \Jio\Settings\Settings::credits_enabled();
|
||||
$balance_on = is_user_logged_in()
|
||||
&& !empty(\AKSRT\Settings\Settings::get_payment_recharge_settings()['enabled']);
|
||||
&& !empty(\Jio\Settings\Settings::get_payment_recharge_settings()['enabled']);
|
||||
$affiliate_on = is_user_logged_in()
|
||||
&& class_exists('\\AKSRT\\Settings\\Settings')
|
||||
&& !empty(\AKSRT\Settings\Settings::get_affiliate_settings()['enabled']);
|
||||
&& class_exists('\\Jio\\Settings\\Settings')
|
||||
&& !empty(\Jio\Settings\Settings::get_affiliate_settings()['enabled']);
|
||||
$signin_on = is_user_logged_in()
|
||||
&& class_exists('\AKSRT\Credits\Signin')
|
||||
&& class_exists('\AKSRT\Settings\Settings')
|
||||
&& !empty(\AKSRT\Settings\Settings::get_signin_reward_settings()['enabled']);
|
||||
&& class_exists('\Jio\Credits\Signin')
|
||||
&& class_exists('\Jio\Settings\Settings')
|
||||
&& !empty(\Jio\Settings\Settings::get_signin_reward_settings()['enabled']);
|
||||
// 统一收银台(站内二维码 / 当前页跳转 / 表单提交 / JSAPI):按需作为依赖入队。
|
||||
$qrcode_js_path = get_template_directory() . '/assets/js/vendor/qrcode.min.js';
|
||||
wp_register_script(
|
||||
'aksrt-qrcode',
|
||||
'jio-qrcode',
|
||||
$base_uri . '/assets/js/vendor/qrcode.min.js',
|
||||
[],
|
||||
file_exists($qrcode_js_path) ? (string) filemtime($qrcode_js_path) : $version,
|
||||
@@ -98,9 +98,9 @@ trait ScriptsPart1b {
|
||||
);
|
||||
$pay_cashier_js = get_template_directory() . '/assets/js/pay-cashier.js';
|
||||
wp_register_script(
|
||||
'aksrt-pay-cashier',
|
||||
'jio-pay-cashier',
|
||||
$base_uri . '/assets/js/pay-cashier.js',
|
||||
['loader_js', 'aksrt-qrcode'],
|
||||
['loader_js', 'jio-qrcode'],
|
||||
file_exists($pay_cashier_js) ? (string) filemtime($pay_cashier_js) : $version,
|
||||
true
|
||||
);
|
||||
@@ -108,7 +108,7 @@ trait ScriptsPart1b {
|
||||
$vip_coordinator = get_template_directory() . '/assets/js/vip-purchase-coordinator.js';
|
||||
if ((($vip_on && is_user_logged_in()) || $credits_on || $affiliate_on) && file_exists($vip_coordinator)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-vip-coordinator',
|
||||
'jio-vip-coordinator',
|
||||
$base_uri . '/assets/js/vip-purchase-coordinator.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($vip_coordinator),
|
||||
@@ -121,7 +121,7 @@ trait ScriptsPart1b {
|
||||
$vip_css = get_template_directory() . '/assets/css/frontend/vip-modal.css';
|
||||
if (file_exists($vip_css)) {
|
||||
wp_enqueue_style(
|
||||
'aksrt-vip-modal',
|
||||
'jio-vip-modal',
|
||||
$base_uri . '/assets/css/frontend/vip-modal.css',
|
||||
[$core_dep],
|
||||
(string) filemtime($vip_css)
|
||||
@@ -130,9 +130,9 @@ trait ScriptsPart1b {
|
||||
$vip_js = get_template_directory() . '/assets/js/pay-vip.js';
|
||||
if (file_exists($vip_js)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-pay-vip',
|
||||
'jio-pay-vip',
|
||||
$base_uri . '/assets/js/pay-vip.js',
|
||||
['loader_js', 'aksrt-vip-coordinator', 'aksrt-pay-cashier'],
|
||||
['loader_js', 'jio-vip-coordinator', 'jio-pay-cashier'],
|
||||
(string) filemtime($vip_js),
|
||||
true
|
||||
);
|
||||
@@ -141,8 +141,8 @@ trait ScriptsPart1b {
|
||||
|
||||
// 4b. 路由判定
|
||||
$is_home_or_archive = is_home() || is_front_page() || is_archive() || is_search();
|
||||
// 资源单页(post + _aksrt_is_resource)
|
||||
$is_single_resource = (function_exists('aksrt_is_resource_post') && is_singular() && aksrt_is_resource_post(get_queried_object_id()));
|
||||
// 资源单页(post + _jio_is_resource)
|
||||
$is_single_resource = (function_exists('jio_is_resource_post') && is_singular() && jio_is_resource_post(get_queried_object_id()));
|
||||
// 普通博客 single(排除资源型 post)
|
||||
$is_single_post = is_singular('post') && !$is_single_resource;
|
||||
// 付费下载/付费墙:任意 singular 需收银台/下载脚本
|
||||
@@ -150,12 +150,12 @@ trait ScriptsPart1b {
|
||||
if (is_singular()) {
|
||||
$qid = (int) get_queried_object_id();
|
||||
if ($qid > 0) {
|
||||
if (function_exists('aksrt_is_downloadable_content') && aksrt_is_downloadable_content($qid)) {
|
||||
if (function_exists('jio_is_downloadable_content') && jio_is_downloadable_content($qid)) {
|
||||
$is_paid_content_single = true;
|
||||
} elseif (function_exists('aksrt_is_paid_post') && aksrt_is_paid_post($qid)) {
|
||||
} elseif (function_exists('jio_is_paid_post') && jio_is_paid_post($qid)) {
|
||||
$is_paid_content_single = true;
|
||||
} elseif (function_exists('aksrt_get_pay_meta')) {
|
||||
$pm = aksrt_get_pay_meta($qid);
|
||||
} elseif (function_exists('jio_get_pay_meta')) {
|
||||
$pm = jio_get_pay_meta($qid);
|
||||
$pt = (string) ($pm['pay_type'] ?? 'no');
|
||||
$is_paid_content_single = ($pt !== '' && $pt !== 'no');
|
||||
}
|
||||
@@ -164,24 +164,24 @@ trait ScriptsPart1b {
|
||||
// 独立下载页模板
|
||||
$is_download_file_page = is_page_template('templates/pages/page-download-file.php');
|
||||
// 资源虚拟列表 /resources/
|
||||
$is_resource_archive = function_exists('aksrt_is_resource_archive') && aksrt_is_resource_archive();
|
||||
// /user/{nicename}/ 自定义重写路由(class-aksrt-user.php 注册)
|
||||
$is_resource_archive = function_exists('jio_is_resource_archive') && jio_is_resource_archive();
|
||||
// /user/{nicename}/ 自定义重写路由(class-jio-user.php 注册)
|
||||
// 此路径下 is_page() / is_page_template() 均为 false,需手动识别以正确入队 CSS
|
||||
$is_profile_route = (bool) get_query_var('aksrt_author_identifier');
|
||||
$is_user_center_route = (bool) get_query_var('aksrt_user_center');
|
||||
$is_profile_route = (bool) get_query_var('jio_author_identifier');
|
||||
$is_user_center_route = (bool) get_query_var('jio_user_center');
|
||||
$is_static_page = is_page() || is_singular('page') || $is_profile_route || $is_user_center_route;
|
||||
$is_auth_route = (bool) get_query_var('aksrt_sign');
|
||||
$is_auth_route = (bool) get_query_var('jio_sign');
|
||||
$is_auth_page = $is_auth_route
|
||||
|| (function_exists('aksrt_is_auth_page_request') && aksrt_is_auth_page_request());
|
||||
|| (function_exists('jio_is_auth_page_request') && jio_is_auth_page_request());
|
||||
$is_profile_page = $is_profile_route
|
||||
|| (function_exists('aksrt_is_user_home_page') && aksrt_is_user_home_page())
|
||||
|| (function_exists('aksrt_is_user_center_page') && aksrt_is_user_center_page())
|
||||
|| (function_exists('jio_is_user_home_page') && jio_is_user_home_page())
|
||||
|| (function_exists('jio_is_user_center_page') && jio_is_user_center_page())
|
||||
|| is_page_template('templates/pages/page-profile.php')
|
||||
|| is_page_template('templates/pages/page-user-home.php');
|
||||
$is_fixed_homepage = function_exists('aksrt_is_fixed_homepage_request') && aksrt_is_fixed_homepage_request();
|
||||
$is_fixed_homepage = function_exists('jio_is_fixed_homepage_request') && jio_is_fixed_homepage_request();
|
||||
|
||||
// CMS route detection.
|
||||
$is_cms_mode = function_exists('aksrt_is_cms_mode') ? aksrt_is_cms_mode() : false;
|
||||
$is_cms_mode = function_exists('jio_is_cms_mode') ? jio_is_cms_mode() : false;
|
||||
$singular_assets = $this->resolve_singular_asset_requirements(
|
||||
$is_single_post,
|
||||
$is_single_resource,
|
||||
@@ -192,7 +192,7 @@ trait ScriptsPart1b {
|
||||
if ($is_single_post || $is_single_resource || $is_static_page) {
|
||||
$print_path = get_template_directory() . '/assets/css/frontend/print.css';
|
||||
wp_enqueue_style(
|
||||
'aksrt-print',
|
||||
'jio-print',
|
||||
$base_uri . '/assets/css/frontend/print.css',
|
||||
[],
|
||||
file_exists($print_path) ? (string) filemtime($print_path) : $version,
|
||||
@@ -214,7 +214,7 @@ trait ScriptsPart1b {
|
||||
: 'single.css';
|
||||
$single_path = get_template_directory() . '/assets/css/build/' . $single_filename;
|
||||
wp_enqueue_style(
|
||||
'aksrt-single-core',
|
||||
'jio-single-core',
|
||||
$base_uri . '/assets/css/build/' . $single_filename,
|
||||
[$core_dep],
|
||||
file_exists($single_path) ? (string) filemtime($single_path) : $version
|
||||
@@ -237,11 +237,11 @@ trait ScriptsPart1b {
|
||||
if (!file_exists($path)) {
|
||||
continue;
|
||||
}
|
||||
$handle = 'aksrt-' . str_replace('/', '-', $part);
|
||||
$handle = 'jio-' . str_replace('/', '-', $part);
|
||||
wp_enqueue_style(
|
||||
$handle,
|
||||
$base_uri . '/assets/css/frontend/' . $part . '.css',
|
||||
['aksrt-single-core'],
|
||||
['jio-single-core'],
|
||||
(string) filemtime($path)
|
||||
);
|
||||
$single_feature_handles[] = $handle;
|
||||
@@ -249,12 +249,12 @@ trait ScriptsPart1b {
|
||||
|
||||
// Preserve the public aggregate handle without requesting its @import file.
|
||||
wp_register_style(
|
||||
'aksrt-single-post',
|
||||
'jio-single-post',
|
||||
false,
|
||||
array_merge(['aksrt-single-core'], $single_feature_handles),
|
||||
array_merge(['jio-single-core'], $single_feature_handles),
|
||||
$version
|
||||
);
|
||||
wp_enqueue_style('aksrt-single-post');
|
||||
wp_enqueue_style('jio-single-post');
|
||||
|
||||
if (!empty($singular_assets['needs_post_card'])) {
|
||||
$enqueue_module('post-card');
|
||||
@@ -277,7 +277,7 @@ trait ScriptsPart1b {
|
||||
: 'comments.css';
|
||||
$comments_path = get_template_directory() . '/assets/css/build/' . $comments_filename;
|
||||
wp_enqueue_style(
|
||||
'aksrt-comments',
|
||||
'jio-comments',
|
||||
$base_uri . '/assets/css/build/' . $comments_filename,
|
||||
[$core_dep],
|
||||
file_exists($comments_path) ? (string) filemtime($comments_path) : $version
|
||||
@@ -302,13 +302,13 @@ trait ScriptsPart1b {
|
||||
if (file_exists($report_js_path)) {
|
||||
$report_css_path = get_template_directory() . '/assets/css/frontend/report.css';
|
||||
wp_enqueue_style(
|
||||
'aksrt-report',
|
||||
'jio-report',
|
||||
$base_uri . '/assets/css/frontend/report.css',
|
||||
[$core_dep],
|
||||
file_exists($report_css_path) ? (string) filemtime($report_css_path) : $version
|
||||
);
|
||||
wp_enqueue_script(
|
||||
'aksrt-report',
|
||||
'jio-report',
|
||||
$base_uri . '/assets/js/report.js',
|
||||
['loader_js'],
|
||||
filemtime($report_js_path) ?: $version,
|
||||
@@ -318,7 +318,7 @@ trait ScriptsPart1b {
|
||||
$user_ban_js_path = get_template_directory() . '/assets/js/user-ban.js';
|
||||
if (file_exists($user_ban_js_path)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-user-ban',
|
||||
'jio-user-ban',
|
||||
$base_uri . '/assets/js/user-ban.js',
|
||||
['loader_js'],
|
||||
filemtime($user_ban_js_path) ?: $version,
|
||||
@@ -329,13 +329,13 @@ trait ScriptsPart1b {
|
||||
|
||||
// 用户中心 / 公开主页:路由专属 CSS
|
||||
if ($is_profile_page) {
|
||||
// 关注脚本已在全局栈注册(ScriptsPart1c),data-aksrt-follow 按钮
|
||||
// 关注脚本已在全局栈注册(ScriptsPart1c),data-jio-follow 按钮
|
||||
// 也渲染于文章页作者栏与各处用户卡片,不能仅限本路由加载。
|
||||
|
||||
$author_js_path = get_template_directory() . '/assets/js/author.js';
|
||||
if (file_exists($author_js_path)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-author',
|
||||
'jio-author',
|
||||
$base_uri . '/assets/js/author.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($author_js_path),
|
||||
@@ -350,7 +350,7 @@ trait ScriptsPart1b {
|
||||
foreach ($profile_parts as $part_index => $part) {
|
||||
$part_path = get_template_directory() . '/assets/css/routes/profile/' . $part . '.css';
|
||||
$is_last_part = $part_index === count($profile_parts) - 1;
|
||||
$part_handle = $is_last_part ? 'aksrt-route-profile' : 'aksrt-route-profile-' . $part;
|
||||
$part_handle = $is_last_part ? 'jio-route-profile' : 'jio-route-profile-' . $part;
|
||||
wp_enqueue_style(
|
||||
$part_handle,
|
||||
$base_uri . '/assets/css/routes/profile/' . $part . '.css',
|
||||
@@ -362,15 +362,15 @@ trait ScriptsPart1b {
|
||||
|
||||
// 本人中心 vs 公开主页拆分加载
|
||||
$is_public_user_home = $is_profile_route
|
||||
|| (function_exists('aksrt_is_user_home_page') && aksrt_is_user_home_page())
|
||||
|| (function_exists('jio_is_user_home_page') && jio_is_user_home_page())
|
||||
|| is_page_template('templates/pages/page-user-home.php');
|
||||
if ($is_public_user_home) {
|
||||
// /user/{nicename}/ 公开主页
|
||||
$user_home_css_path = get_template_directory() . '/assets/css/routes/user-home.css';
|
||||
wp_enqueue_style(
|
||||
'aksrt-route-user-home',
|
||||
'jio-route-user-home',
|
||||
$base_uri . '/assets/css/routes/user-home.css',
|
||||
['aksrt-route-profile'],
|
||||
['jio-route-profile'],
|
||||
file_exists($user_home_css_path) ? (string) filemtime($user_home_css_path) : $version
|
||||
);
|
||||
} else {
|
||||
@@ -386,13 +386,13 @@ trait ScriptsPart1b {
|
||||
'user-center/revenue-earnings',
|
||||
'user-center/responsive',
|
||||
];
|
||||
$user_center_deps = ['aksrt-route-profile'];
|
||||
$user_center_deps = ['jio-route-profile'];
|
||||
foreach ($user_center_parts as $part_index => $part) {
|
||||
$part_path = get_template_directory() . '/assets/css/routes/' . $part . '.css';
|
||||
$is_last_part = $part_index === count($user_center_parts) - 1;
|
||||
$part_handle = $is_last_part
|
||||
? 'aksrt-route-user-center'
|
||||
: 'aksrt-route-' . str_replace('/', '-', $part);
|
||||
? 'jio-route-user-center'
|
||||
: 'jio-route-' . str_replace('/', '-', $part);
|
||||
wp_enqueue_style(
|
||||
$part_handle,
|
||||
$base_uri . '/assets/css/routes/' . $part . '.css',
|
||||
@@ -405,8 +405,8 @@ trait ScriptsPart1b {
|
||||
// be ready before client-side panel replacement can insert its markup.
|
||||
$has_orders_panel = false;
|
||||
$has_tickets_panel = false;
|
||||
if (class_exists('\AKSRT\User\Center')) {
|
||||
$dashboard_tabs = \AKSRT\User\Center::get_instance()->get_dashboard_tabs();
|
||||
if (class_exists('\Jio\User\Center')) {
|
||||
$dashboard_tabs = \Jio\User\Center::get_instance()->get_dashboard_tabs();
|
||||
$has_orders_panel = isset($dashboard_tabs['orders']);
|
||||
$has_tickets_panel = isset($dashboard_tabs['tickets']);
|
||||
}
|
||||
@@ -414,7 +414,7 @@ trait ScriptsPart1b {
|
||||
$orders_css = get_template_directory() . '/assets/css/routes/orders.css';
|
||||
if (file_exists($orders_css)) {
|
||||
wp_enqueue_style(
|
||||
'aksrt-orders',
|
||||
'jio-orders',
|
||||
$base_uri . '/assets/css/routes/orders.css',
|
||||
[$core_dep],
|
||||
(string) filemtime($orders_css)
|
||||
@@ -424,9 +424,9 @@ trait ScriptsPart1b {
|
||||
$order_center_js = get_template_directory() . '/assets/js/order-center.js';
|
||||
if (file_exists($order_center_js)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-order-center',
|
||||
'jio-order-center',
|
||||
$base_uri . '/assets/js/order-center.js',
|
||||
['loader_js', 'aksrt-pay-cashier'],
|
||||
['loader_js', 'jio-pay-cashier'],
|
||||
(string) filemtime($order_center_js),
|
||||
true
|
||||
);
|
||||
@@ -437,7 +437,7 @@ trait ScriptsPart1b {
|
||||
$tickets_css = get_template_directory() . '/assets/css/routes/tickets.css';
|
||||
if (file_exists($tickets_css)) {
|
||||
wp_enqueue_style(
|
||||
'aksrt-tickets',
|
||||
'jio-tickets',
|
||||
$base_uri . '/assets/css/routes/tickets.css',
|
||||
[$core_dep],
|
||||
(string) filemtime($tickets_css)
|
||||
@@ -447,9 +447,9 @@ trait ScriptsPart1b {
|
||||
$tickets_compose_css = get_template_directory() . '/assets/css/routes/tickets-compose.css';
|
||||
if (file_exists($tickets_compose_css)) {
|
||||
wp_enqueue_style(
|
||||
'aksrt-tickets-compose',
|
||||
'jio-tickets-compose',
|
||||
$base_uri . '/assets/css/routes/tickets-compose.css',
|
||||
['aksrt-tickets'],
|
||||
['jio-tickets'],
|
||||
(string) filemtime($tickets_compose_css)
|
||||
);
|
||||
}
|
||||
@@ -457,7 +457,7 @@ trait ScriptsPart1b {
|
||||
$ticket_core_js = get_template_directory() . '/assets/js/ticket-center-core.js';
|
||||
if (file_exists($ticket_core_js)) {
|
||||
wp_register_script(
|
||||
'aksrt-ticket-center-core',
|
||||
'jio-ticket-center-core',
|
||||
$base_uri . '/assets/js/ticket-center-core.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($ticket_core_js),
|
||||
@@ -467,9 +467,9 @@ trait ScriptsPart1b {
|
||||
$ticket_center_js = get_template_directory() . '/assets/js/ticket-center.js';
|
||||
if (file_exists($ticket_center_js)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-ticket-center',
|
||||
'jio-ticket-center',
|
||||
$base_uri . '/assets/js/ticket-center.js',
|
||||
['loader_js', 'aksrt-ticket-center-core'],
|
||||
['loader_js', 'jio-ticket-center-core'],
|
||||
(string) filemtime($ticket_center_js),
|
||||
true
|
||||
);
|
||||
@@ -480,7 +480,7 @@ trait ScriptsPart1b {
|
||||
$identity_js = get_template_directory() . '/assets/js/routes/user-center-auth.js';
|
||||
if (file_exists($identity_js)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-route-user-center-auth',
|
||||
'jio-route-user-center-auth',
|
||||
$base_uri . '/assets/js/routes/user-center-auth.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($identity_js),
|
||||
@@ -488,16 +488,16 @@ trait ScriptsPart1b {
|
||||
);
|
||||
}
|
||||
$user_center_deps = file_exists($identity_js)
|
||||
? ['loader_js', 'aksrt-route-user-center-auth']
|
||||
? ['loader_js', 'jio-route-user-center-auth']
|
||||
: ['loader_js'];
|
||||
if ($has_orders_panel && wp_script_is('aksrt-order-center', 'registered')) {
|
||||
$user_center_deps[] = 'aksrt-order-center';
|
||||
if ($has_orders_panel && wp_script_is('jio-order-center', 'registered')) {
|
||||
$user_center_deps[] = 'jio-order-center';
|
||||
}
|
||||
if ($has_tickets_panel && wp_script_is('aksrt-ticket-center', 'registered')) {
|
||||
$user_center_deps[] = 'aksrt-ticket-center';
|
||||
if ($has_tickets_panel && wp_script_is('jio-ticket-center', 'registered')) {
|
||||
$user_center_deps[] = 'jio-ticket-center';
|
||||
}
|
||||
wp_enqueue_script(
|
||||
'aksrt-route-user-center',
|
||||
'jio-route-user-center',
|
||||
$base_uri . '/assets/js/routes/user-center.js',
|
||||
$user_center_deps,
|
||||
file_exists(get_template_directory() . '/assets/js/routes/user-center.js')
|
||||
@@ -511,9 +511,9 @@ trait ScriptsPart1b {
|
||||
// 分类汇总页:路由专属 CSS
|
||||
if (is_page_template('templates/pages/page-categories.php')) {
|
||||
wp_enqueue_style(
|
||||
'aksrt-route-categories',
|
||||
'jio-route-categories',
|
||||
$base_uri . '/assets/css/routes/categories.css',
|
||||
['aksrt-public'],
|
||||
['jio-public'],
|
||||
$version
|
||||
);
|
||||
}
|
||||
@@ -521,9 +521,9 @@ trait ScriptsPart1b {
|
||||
// 友情链接页:路由专属 CSS
|
||||
if (is_page_template('templates/pages/page-friends.php')) {
|
||||
wp_enqueue_style(
|
||||
'aksrt-route-friends',
|
||||
'jio-route-friends',
|
||||
$base_uri . '/assets/css/routes/friends.css',
|
||||
['aksrt-public'],
|
||||
['jio-public'],
|
||||
file_exists(get_template_directory() . '/assets/css/routes/friends.css')
|
||||
? (string) filemtime(get_template_directory() . '/assets/css/routes/friends.css')
|
||||
: $version
|
||||
@@ -536,7 +536,7 @@ trait ScriptsPart1b {
|
||||
$page_navs_js = get_template_directory() . '/assets/js/page-navs.js';
|
||||
if (file_exists($page_navs_js)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-page-navs',
|
||||
'jio-page-navs',
|
||||
$base_uri . '/assets/js/page-navs.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($page_navs_js),
|
||||
@@ -547,16 +547,16 @@ trait ScriptsPart1b {
|
||||
$pn_css = get_template_directory() . '/assets/css/routes/posts-navs.css';
|
||||
if (file_exists($pn_css)) {
|
||||
wp_enqueue_style(
|
||||
'aksrt-route-posts-navs',
|
||||
'jio-route-posts-navs',
|
||||
$base_uri . '/assets/css/routes/posts-navs.css',
|
||||
['aksrt-public'],
|
||||
['jio-public'],
|
||||
(string) filemtime($pn_css)
|
||||
);
|
||||
}
|
||||
$pn_js = get_template_directory() . '/assets/js/posts-navs-page.js';
|
||||
if (file_exists($pn_js)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-posts-navs-page',
|
||||
'jio-posts-navs-page',
|
||||
$base_uri . '/assets/js/posts-navs-page.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($pn_js),
|
||||
@@ -570,29 +570,29 @@ trait ScriptsPart1b {
|
||||
$ar_css = get_template_directory() . '/assets/css/routes/archives.css';
|
||||
if (file_exists($ar_css)) {
|
||||
wp_enqueue_style(
|
||||
'aksrt-route-archives',
|
||||
'jio-route-archives',
|
||||
$base_uri . '/assets/css/routes/archives.css',
|
||||
['aksrt-public'],
|
||||
['jio-public'],
|
||||
(string) filemtime($ar_css)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 消息中心页
|
||||
if (get_query_var('aksrt_message_view')) {
|
||||
if (get_query_var('jio_message_view')) {
|
||||
$messages_css = get_template_directory() . '/assets/css/frontend/messages.css';
|
||||
if (file_exists($messages_css)) {
|
||||
wp_enqueue_style(
|
||||
'aksrt-messages',
|
||||
'jio-messages',
|
||||
$base_uri . '/assets/css/frontend/messages.css',
|
||||
['aksrt-public'],
|
||||
['jio-public'],
|
||||
(string) filemtime($messages_css)
|
||||
);
|
||||
}
|
||||
$messages_js = get_template_directory() . '/assets/js/messages.js';
|
||||
if (file_exists($messages_js)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-messages',
|
||||
'jio-messages',
|
||||
$base_uri . '/assets/js/messages.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($messages_js),
|
||||
@@ -630,7 +630,7 @@ trait ScriptsPart1b {
|
||||
$single_cover_path = get_template_directory() . '/assets/css/frontend/single-post/cover.css';
|
||||
if (file_exists($single_cover_path)) {
|
||||
wp_enqueue_style(
|
||||
'aksrt-single-post-cover',
|
||||
'jio-single-post-cover',
|
||||
$base_uri . '/assets/css/frontend/single-post/cover.css',
|
||||
$deps,
|
||||
(string) filemtime($single_cover_path)
|
||||
@@ -639,7 +639,7 @@ trait ScriptsPart1b {
|
||||
}
|
||||
$resource_meta_path = get_template_directory() . '/assets/css/frontend/resource-meta/part.css';
|
||||
wp_enqueue_style(
|
||||
'aksrt-resource-meta',
|
||||
'jio-resource-meta',
|
||||
$base_uri . '/assets/css/frontend/resource-meta/part.css',
|
||||
$deps,
|
||||
file_exists($resource_meta_path) ? (string) filemtime($resource_meta_path) : $version
|
||||
@@ -656,7 +656,7 @@ trait ScriptsPart1b {
|
||||
if ($is_single_resource || $is_paid_content_single || $is_download_file_page) {
|
||||
$cms_download_css_path = get_template_directory() . '/assets/css/frontend/cms-download.css';
|
||||
wp_enqueue_style(
|
||||
'aksrt-cms-download',
|
||||
'jio-cms-download',
|
||||
$base_uri . '/assets/css/frontend/cms-download.css',
|
||||
[$core_dep],
|
||||
file_exists($cms_download_css_path) ? (string) filemtime($cms_download_css_path) : $version
|
||||
@@ -664,9 +664,9 @@ trait ScriptsPart1b {
|
||||
|
||||
$cms_download_js_path = get_template_directory() . '/assets/js/cms-download.js';
|
||||
wp_enqueue_script(
|
||||
'aksrt-cms-download',
|
||||
'jio-cms-download',
|
||||
$base_uri . '/assets/js/cms-download.js',
|
||||
['loader_js', 'aksrt-pay-cashier'],
|
||||
['loader_js', 'jio-pay-cashier'],
|
||||
file_exists($cms_download_js_path) ? (string) filemtime($cms_download_js_path) : $version,
|
||||
true
|
||||
);
|
||||
@@ -678,9 +678,9 @@ trait ScriptsPart1b {
|
||||
: 'homepage.css';
|
||||
$homepage_bundle = get_template_directory() . '/assets/css/build/' . $homepage_filename;
|
||||
wp_enqueue_style(
|
||||
'aksrt-homepage-fixed',
|
||||
'jio-homepage-fixed',
|
||||
$base_uri . '/assets/css/build/' . $homepage_filename,
|
||||
['aksrt-public'],
|
||||
['jio-public'],
|
||||
file_exists($homepage_bundle) ? (string) filemtime($homepage_bundle) : $version
|
||||
);
|
||||
}
|
||||
@@ -691,19 +691,19 @@ trait ScriptsPart1b {
|
||||
|
||||
// profile 页:加载 credits.js(签到 + 邀请 + 提现交互)
|
||||
if ($is_profile_page) {
|
||||
// aksrt-pay-cashier 依赖 aksrt-qrcode(推广海报二维码同用)。
|
||||
// jio-pay-cashier 依赖 jio-qrcode(推广海报二维码同用)。
|
||||
$credits_js_path = get_template_directory() . '/assets/js/credits.js';
|
||||
wp_enqueue_script(
|
||||
'aksrt-credits',
|
||||
'jio-credits',
|
||||
$base_uri . '/assets/js/credits.js',
|
||||
['loader_js', 'aksrt-vip-coordinator', 'aksrt-pay-cashier'],
|
||||
['loader_js', 'jio-vip-coordinator', 'jio-pay-cashier'],
|
||||
file_exists($credits_js_path) ? (string) filemtime($credits_js_path) : $version,
|
||||
true
|
||||
);
|
||||
foreach (['credits-withdraw-history' => ['loader_js']] + ($affiliate_on ? ['credits-affiliate' => ['loader_js', 'aksrt-qrcode']] : []) as $credits_part => $credits_part_deps) {
|
||||
foreach (['credits-withdraw-history' => ['loader_js']] + ($affiliate_on ? ['credits-affiliate' => ['loader_js', 'jio-qrcode']] : []) as $credits_part => $credits_part_deps) {
|
||||
$credits_part_path = get_template_directory() . '/assets/js/' . $credits_part . '.js';
|
||||
wp_enqueue_script(
|
||||
'aksrt-' . $credits_part,
|
||||
'jio-' . $credits_part,
|
||||
$base_uri . '/assets/js/' . $credits_part . '.js',
|
||||
$credits_part_deps,
|
||||
file_exists($credits_part_path) ? (string) filemtime($credits_part_path) : $version,
|
||||
@@ -716,7 +716,7 @@ trait ScriptsPart1b {
|
||||
if ($signin_on) {
|
||||
$signin_js_path = get_template_directory() . '/assets/js/signin.js';
|
||||
wp_enqueue_script(
|
||||
'aksrt-signin',
|
||||
'jio-signin',
|
||||
$base_uri . '/assets/js/signin.js',
|
||||
['loader_js'],
|
||||
file_exists($signin_js_path) ? (string) filemtime($signin_js_path) : $version,
|
||||
@@ -725,17 +725,17 @@ trait ScriptsPart1b {
|
||||
}
|
||||
|
||||
// Badges UI: user center + public profile (legacy medal modal/list).
|
||||
if (class_exists('\AKSRT\User\Badges') && \AKSRT\User\Badges::enabled()) {
|
||||
if (class_exists('\Jio\User\Badges') && \Jio\User\Badges::enabled()) {
|
||||
$is_badge_surface = $is_profile_page
|
||||
|| is_author()
|
||||
|| (function_exists('aksrt_is_user_home_page') && aksrt_is_user_home_page())
|
||||
|| (function_exists('aksrt_is_user_center_page') && aksrt_is_user_center_page());
|
||||
|| (function_exists('jio_is_user_home_page') && jio_is_user_home_page())
|
||||
|| (function_exists('jio_is_user_center_page') && jio_is_user_center_page());
|
||||
if ($is_badge_surface) {
|
||||
$enqueue_module('medal');
|
||||
$badge_actions_path = get_template_directory() . '/assets/js/user-badge-actions.js';
|
||||
if (file_exists($badge_actions_path)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-user-badge-actions',
|
||||
'jio-user-badge-actions',
|
||||
$base_uri . '/assets/js/user-badge-actions.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($badge_actions_path),
|
||||
|
||||
+133
-133
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -12,7 +12,7 @@ defined('ABSPATH') || exit;
|
||||
/**
|
||||
* Scripts public enqueue continuation: fonts, icons, global JS, localize.
|
||||
*
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
trait ScriptsPart1c {
|
||||
|
||||
@@ -54,11 +54,11 @@ trait ScriptsPart1c {
|
||||
}
|
||||
|
||||
$is_docs_article = $is_single_post
|
||||
&& function_exists('aksrt_single_is_docs_page')
|
||||
&& aksrt_single_is_docs_page($post_id);
|
||||
&& function_exists('jio_single_is_docs_page')
|
||||
&& jio_single_is_docs_page($post_id);
|
||||
$is_article = ($is_single_post || $is_single_resource) && !$is_docs_article;
|
||||
$settings = function_exists('aksrt_resolve_single_post_display_settings')
|
||||
? aksrt_resolve_single_post_display_settings($post_id)
|
||||
$settings = function_exists('jio_resolve_single_post_display_settings')
|
||||
? jio_resolve_single_post_display_settings($post_id)
|
||||
: [];
|
||||
$content = (string) $post->post_content;
|
||||
$display_content = $content
|
||||
@@ -66,15 +66,15 @@ trait ScriptsPart1c {
|
||||
. (string) ($settings['after_content'] ?? '');
|
||||
|
||||
$has_code = (bool) preg_match(
|
||||
'/(?:<!--\s*wp:(?:code|preformatted|aksrt\/enlighter)\b|<pre\b|data-enlighter-language)/i',
|
||||
'/(?:<!--\s*wp:(?:code|preformatted|jio\/enlighter)\b|<pre\b|data-enlighter-language)/i',
|
||||
$display_content
|
||||
);
|
||||
$has_hidden_content = $is_paid_content_single || (bool) preg_match(
|
||||
'/(?:<!--\s*wp:aksrt\/paid-fragment\b|\[(?:aksrt_hide|hide|reply|vip|payshow|hidecontent|content)\b|aksrt-(?:hidden-content|paywall))/i',
|
||||
'/(?:<!--\s*wp:jio\/paid-fragment\b|\[(?:jio_hide|hide|reply|vip|payshow|hidecontent|content)\b|jio-(?:hidden-content|paywall))/i',
|
||||
$content
|
||||
);
|
||||
$comment_settings = class_exists('\\AKSRT\\Settings\\Settings')
|
||||
? \AKSRT\Settings\Settings::get_comment_display_settings()
|
||||
$comment_settings = class_exists('\\Jio\\Settings\\Settings')
|
||||
? \Jio\Settings\Settings::get_comment_display_settings()
|
||||
: [];
|
||||
$comments_disabled = $is_docs_article
|
||||
|| post_password_required($post_id)
|
||||
@@ -91,7 +91,7 @@ trait ScriptsPart1c {
|
||||
$show_cover = !empty($settings['show_cover']) && (string) ($settings['cover_url'] ?? '') !== '';
|
||||
$has_video = $is_article && (
|
||||
($show_cover && (string) ($settings['cover_type'] ?? '') === 'video')
|
||||
|| str_contains($content, 'data-aksrt-video')
|
||||
|| str_contains($content, 'data-jio-video')
|
||||
);
|
||||
$has_yiyan = $is_article && (
|
||||
!empty($settings['yiyan_header'])
|
||||
@@ -102,8 +102,8 @@ trait ScriptsPart1c {
|
||||
|| trim((string) ($settings['after_content'] ?? '')) !== '';
|
||||
$has_page_break = (bool) preg_match('/<!--\s*nextpage\s*-->/i', $content);
|
||||
$has_related = $is_article && !empty($settings['related_enabled']);
|
||||
$layout = function_exists('aksrt_get_post_show_layout')
|
||||
? (string) aksrt_get_post_show_layout($post_id)
|
||||
$layout = function_exists('jio_get_post_show_layout')
|
||||
? (string) jio_get_post_show_layout($post_id)
|
||||
: '';
|
||||
$article_nav_enabled = !array_key_exists('article_nav', $settings) || !empty($settings['article_nav']);
|
||||
if ($article_nav_enabled && function_exists('get_post_meta') && class_exists(DomainModel::class)) {
|
||||
@@ -116,7 +116,7 @@ trait ScriptsPart1c {
|
||||
$requirements['has_toc'] = $is_article && $article_nav_enabled;
|
||||
$requirements['has_video'] = $has_video;
|
||||
$requirements['has_hidden_content'] = $has_hidden_content || $has_yiyan || $has_inserted_content;
|
||||
$requirements['needs_pay_box'] = $is_paid_content_single || (bool) preg_match('/\[(?:payshow|hidecontent)\b|wp:aksrt\/paid-fragment/i', $content);
|
||||
$requirements['needs_pay_box'] = $is_paid_content_single || (bool) preg_match('/\[(?:payshow|hidecontent)\b|wp:jio\/paid-fragment/i', $content);
|
||||
$requirements['needs_cover'] = $is_article && (
|
||||
$show_cover
|
||||
|| !empty($settings['breadcrumbs'])
|
||||
@@ -133,8 +133,8 @@ trait ScriptsPart1c {
|
||||
$requirements['needs_sidebar'] = $is_article
|
||||
&& get_post_type($post_id) === 'post'
|
||||
&& $layout !== 'no_sidebar'
|
||||
&& function_exists('aksrt_is_show_sidebar')
|
||||
&& aksrt_is_show_sidebar();
|
||||
&& function_exists('jio_is_show_sidebar')
|
||||
&& jio_is_show_sidebar();
|
||||
$requirements['needs_breadcrumb'] = $is_article && !empty($settings['breadcrumbs']);
|
||||
$requirements['needs_comments'] = $has_comments;
|
||||
$requirements['needs_comment_tools'] = $can_use_comment_form;
|
||||
@@ -147,7 +147,7 @@ trait ScriptsPart1c {
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonts / FA / global JS stack / aksrtData (split from enqueue_public).
|
||||
* Fonts / FA / global JS stack / jioData (split from enqueue_public).
|
||||
*/
|
||||
private function enqueue_public_fonts_js_and_data($base_uri, $core_dep, $deps, $is_fixed_homepage, $is_home_or_archive, $is_single_post, $is_single_resource, $version, array $singular_assets): void {
|
||||
$runtime_uri = $base_uri . '/assets';
|
||||
@@ -159,8 +159,8 @@ trait ScriptsPart1c {
|
||||
$runtime_version = $runtime_mtimes !== [] ? (string) max($runtime_mtimes) : $version;
|
||||
$loader_path = get_template_directory() . '/assets/js/runtime/loader.js';
|
||||
$bootstrap_path = get_template_directory() . '/assets/js/runtime/libs/bootstrap.min.js';
|
||||
$post_page_settings = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::get_post_page_settings()
|
||||
$post_page_settings = class_exists('\Jio\Settings\Settings')
|
||||
? \Jio\Settings\Settings::get_post_page_settings()
|
||||
: [];
|
||||
$lightbox_on = !isset($post_page_settings['lightbox']) || !empty($post_page_settings['lightbox']);
|
||||
$lightbox_type = sanitize_key((string) ($post_page_settings['lightbox_type'] ?? 'group'));
|
||||
@@ -190,12 +190,12 @@ trait ScriptsPart1c {
|
||||
'uri' => $runtime_uri,
|
||||
'ver' => $runtime_version,
|
||||
// 货币符号 / 单位来自「收款接口」页配置(pay_currency_mark / pay_currency_unit)。
|
||||
'pay_mark' => class_exists('\AKSRT\Settings\Settings') && class_exists('\AKSRT\Settings\PaymentRuntime')
|
||||
? \AKSRT\Settings\PaymentRuntime::get_paid_content_settings()['display']['currency_symbol']
|
||||
'pay_mark' => class_exists('\Jio\Settings\Settings') && class_exists('\Jio\Settings\PaymentRuntime')
|
||||
? \Jio\Settings\PaymentRuntime::get_paid_content_settings()['display']['currency_symbol']
|
||||
: '¥',
|
||||
'pay_currency_unit' => class_exists('\AKSRT\Settings\Settings') && class_exists('\AKSRT\Settings\PaymentRuntime')
|
||||
? \AKSRT\Settings\PaymentRuntime::get_paid_content_settings()['display']['currency_unit']
|
||||
: __('元', 'aksrt'),
|
||||
'pay_currency_unit' => class_exists('\Jio\Settings\Settings') && class_exists('\Jio\Settings\PaymentRuntime')
|
||||
? \Jio\Settings\PaymentRuntime::get_paid_content_settings()['display']['currency_unit']
|
||||
: __('元', 'jio'),
|
||||
'imgbox' => $lightbox_on,
|
||||
'imgbox_type' => $lightbox_on ? $lightbox_type : 'group',
|
||||
'imgbox_thumbs' => $lightbox_on && (!isset($post_page_settings['lightbox_thumbs']) || !empty($post_page_settings['lightbox_thumbs'])),
|
||||
@@ -205,9 +205,9 @@ trait ScriptsPart1c {
|
||||
'imgbox_down' => $lightbox_on && !empty($post_page_settings['lightbox_down']),
|
||||
'ajax_url' => admin_url('admin-ajax.php'),
|
||||
'ajaxpager' => '',
|
||||
'ajax_trigger' => __('加载更多', 'aksrt'),
|
||||
'ajax_nomore' => __('没有更多了', 'aksrt'),
|
||||
'qj_loading' => __('加载中...', 'aksrt'),
|
||||
'ajax_trigger' => __('加载更多', 'jio'),
|
||||
'ajax_nomore' => __('没有更多了', 'jio'),
|
||||
'qj_loading' => __('加载中...', 'jio'),
|
||||
'highlight_kg' => false,
|
||||
'highlight_hh' => false,
|
||||
'highlight_btn' => false,
|
||||
@@ -223,22 +223,22 @@ trait ScriptsPart1c {
|
||||
'post_action_nonce' => wp_create_nonce('post_action'),
|
||||
'translate_config' => [],
|
||||
'i18n' => [
|
||||
'load_more' => __('加载更多', 'aksrt'),
|
||||
'processing' => __('处理中...', 'aksrt'),
|
||||
'please_wait' => __('请稍候', 'aksrt'),
|
||||
'done' => __('操作完成', 'aksrt'),
|
||||
'confirm_clear_search' => __('确认清空搜索记录?', 'aksrt'),
|
||||
'search_loading' => __('搜索中...', 'aksrt'),
|
||||
'search_min_chars' => __('至少输入 %s 个字符', 'aksrt'),
|
||||
'load_more' => __('加载更多', 'jio'),
|
||||
'processing' => __('处理中...', 'jio'),
|
||||
'please_wait' => __('请稍候', 'jio'),
|
||||
'done' => __('操作完成', 'jio'),
|
||||
'confirm_clear_search' => __('确认清空搜索记录?', 'jio'),
|
||||
'search_loading' => __('搜索中...', 'jio'),
|
||||
'search_min_chars' => __('至少输入 %s 个字符', 'jio'),
|
||||
],
|
||||
]
|
||||
);
|
||||
// AJAX 调试(WP_DEBUG 或 ?aksrt_ajax_debug=1):记录所有失败的
|
||||
// AJAX 调试(WP_DEBUG 或 ?jio_ajax_debug=1):记录所有失败的
|
||||
// jQuery ajax / fetch 请求,用于定位 vendor main.min.js 的 400 "0" 来源。
|
||||
if (function_exists('aksrt_ajax_debug_enabled') && aksrt_ajax_debug_enabled()) {
|
||||
if (function_exists('jio_ajax_debug_enabled') && jio_ajax_debug_enabled()) {
|
||||
$ajax_debug_path = get_template_directory() . '/assets/js/core/ajax-debug.js';
|
||||
wp_enqueue_script(
|
||||
'aksrt-ajax-debug',
|
||||
'jio-ajax-debug',
|
||||
$base_uri . '/assets/js/core/ajax-debug.js',
|
||||
['loader_js'],
|
||||
file_exists($ajax_debug_path) ? (string) filemtime($ajax_debug_path) : $version,
|
||||
@@ -250,7 +250,7 @@ trait ScriptsPart1c {
|
||||
$precode_js = get_template_directory() . '/assets/js/precode.js';
|
||||
if (!empty($singular_assets['has_code']) && file_exists($precode_js)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-precode',
|
||||
'jio-precode',
|
||||
$base_uri . '/assets/js/precode.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($precode_js),
|
||||
@@ -260,12 +260,12 @@ trait ScriptsPart1c {
|
||||
|
||||
// Input field enhancements (auto-resize, counter, validation)
|
||||
$input_expand_js = get_template_directory() . '/assets/js/input-expand.js';
|
||||
$needs_input_enhancements = (bool) get_query_var('aksrt_sign')
|
||||
|| (bool) get_query_var('aksrt_user_center')
|
||||
|| (bool) get_query_var('aksrt_author_identifier');
|
||||
$needs_input_enhancements = (bool) get_query_var('jio_sign')
|
||||
|| (bool) get_query_var('jio_user_center')
|
||||
|| (bool) get_query_var('jio_author_identifier');
|
||||
if ($needs_input_enhancements && file_exists($input_expand_js)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-input-expand',
|
||||
'jio-input-expand',
|
||||
$base_uri . '/assets/js/input-expand.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($input_expand_js),
|
||||
@@ -277,7 +277,7 @@ trait ScriptsPart1c {
|
||||
$section_navs_js = get_template_directory() . '/assets/js/section-navs.js';
|
||||
if (!empty($singular_assets['has_toc']) && file_exists($section_navs_js)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-section-navs',
|
||||
'jio-section-navs',
|
||||
$base_uri . '/assets/js/section-navs.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($section_navs_js),
|
||||
@@ -289,7 +289,7 @@ trait ScriptsPart1c {
|
||||
$video_player_js = get_template_directory() . '/assets/js/video-player.js';
|
||||
if (!empty($singular_assets['has_video']) && file_exists($video_player_js)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-video-player',
|
||||
'jio-video-player',
|
||||
$base_uri . '/assets/js/video-player.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($video_player_js),
|
||||
@@ -301,7 +301,7 @@ trait ScriptsPart1c {
|
||||
$reward_js = get_template_directory() . '/assets/js/reward.js';
|
||||
if (!empty($singular_assets['needs_reward']) && file_exists($reward_js)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-reward',
|
||||
'jio-reward',
|
||||
$base_uri . '/assets/js/reward.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($reward_js),
|
||||
@@ -313,7 +313,7 @@ trait ScriptsPart1c {
|
||||
$yiyan_js = get_template_directory() . '/assets/js/yiyan.js';
|
||||
if (!empty($singular_assets['needs_yiyan']) && file_exists($yiyan_js)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-yiyan',
|
||||
'jio-yiyan',
|
||||
$base_uri . '/assets/js/yiyan.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($yiyan_js),
|
||||
@@ -323,18 +323,18 @@ trait ScriptsPart1c {
|
||||
|
||||
// Frontend translate (默认关)
|
||||
// Content protection (copy notice / right-click / F12)
|
||||
$content_protect = class_exists('\AKSRT\Settings\Settings')
|
||||
$content_protect = class_exists('\Jio\Settings\Settings')
|
||||
? [
|
||||
'enabled' => (bool) \AKSRT\Settings\Settings::get_value('content_protect_enabled', false),
|
||||
'copy' => (bool) \AKSRT\Settings\Settings::get_value('content_protect_copy_notice', false),
|
||||
'right_click' => (bool) \AKSRT\Settings\Settings::get_value('content_protect_right_click', false),
|
||||
'devtools' => (bool) \AKSRT\Settings\Settings::get_value('content_protect_f12', false),
|
||||
'enabled' => (bool) \Jio\Settings\Settings::get_value('content_protect_enabled', false),
|
||||
'copy' => (bool) \Jio\Settings\Settings::get_value('content_protect_copy_notice', false),
|
||||
'right_click' => (bool) \Jio\Settings\Settings::get_value('content_protect_right_click', false),
|
||||
'devtools' => (bool) \Jio\Settings\Settings::get_value('content_protect_f12', false),
|
||||
]
|
||||
: [];
|
||||
$content_protect_js = get_template_directory() . '/assets/js/content-protect.js';
|
||||
if (in_array(true, $content_protect, true) && file_exists($content_protect_js)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-content-protect',
|
||||
'jio-content-protect',
|
||||
$base_uri . '/assets/js/content-protect.js',
|
||||
[],
|
||||
(string) filemtime($content_protect_js),
|
||||
@@ -343,15 +343,15 @@ trait ScriptsPart1c {
|
||||
}
|
||||
|
||||
// Site notice popup (global, controlled by Settings)
|
||||
$site_notice_config = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::get_system_notice_config()
|
||||
$site_notice_config = class_exists('\Jio\Settings\Settings')
|
||||
? \Jio\Settings\Settings::get_system_notice_config()
|
||||
: [];
|
||||
$site_notice_enabled = !empty($site_notice_config['enabled'])
|
||||
&& trim((string) ($site_notice_config['content'] ?? '')) !== '';
|
||||
$site_notice_css = get_template_directory() . '/assets/css/frontend/site-notice.css';
|
||||
if ($site_notice_enabled && file_exists($site_notice_css)) {
|
||||
wp_enqueue_style(
|
||||
'aksrt-site-notice',
|
||||
'jio-site-notice',
|
||||
$base_uri . '/assets/css/frontend/site-notice.css',
|
||||
[$core_dep],
|
||||
(string) filemtime($site_notice_css)
|
||||
@@ -360,7 +360,7 @@ trait ScriptsPart1c {
|
||||
$site_notice_js = get_template_directory() . '/assets/js/site-notice.js';
|
||||
if ($site_notice_enabled && file_exists($site_notice_js)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-site-notice',
|
||||
'jio-site-notice',
|
||||
$base_uri . '/assets/js/site-notice.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($site_notice_js),
|
||||
@@ -370,9 +370,9 @@ trait ScriptsPart1c {
|
||||
|
||||
// One state machine owns modal and /sign/ authentication.
|
||||
$auth_js = get_template_directory() . '/assets/js/auth.js';
|
||||
if ((!is_user_logged_in() || (bool) get_query_var('aksrt_sign')) && file_exists($auth_js)) {
|
||||
if ((!is_user_logged_in() || (bool) get_query_var('jio_sign')) && file_exists($auth_js)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-auth',
|
||||
'jio-auth',
|
||||
$base_uri . '/assets/js/auth.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($auth_js),
|
||||
@@ -385,7 +385,7 @@ trait ScriptsPart1c {
|
||||
if ($load_comment_tools) {
|
||||
$comment_tools_path = get_template_directory() . '/assets/js/comment-tools.js';
|
||||
wp_enqueue_script(
|
||||
'aksrt-comment-tools',
|
||||
'jio-comment-tools',
|
||||
$base_uri . '/assets/js/comment-tools.js',
|
||||
['loader_js'],
|
||||
file_exists($comment_tools_path) ? (string) filemtime($comment_tools_path) : $version,
|
||||
@@ -394,9 +394,9 @@ trait ScriptsPart1c {
|
||||
$comment_tools_css = get_template_directory() . '/assets/css/frontend/comment-tools.css';
|
||||
if (file_exists($comment_tools_css)) {
|
||||
wp_enqueue_style(
|
||||
'aksrt-comment-tools',
|
||||
'jio-comment-tools',
|
||||
$base_uri . '/assets/css/frontend/comment-tools.css',
|
||||
['aksrt-comments'],
|
||||
['jio-comments'],
|
||||
(string) filemtime($comment_tools_css)
|
||||
);
|
||||
}
|
||||
@@ -408,7 +408,7 @@ trait ScriptsPart1c {
|
||||
$comment_ajax_path = get_template_directory() . '/assets/js/comment-ajax.js';
|
||||
if (file_exists($comment_ajax_path)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-comment-ajax',
|
||||
'jio-comment-ajax',
|
||||
$base_uri . '/assets/js/comment-ajax.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($comment_ajax_path),
|
||||
@@ -421,7 +421,7 @@ trait ScriptsPart1c {
|
||||
$page_template_path = get_template_directory() . '/assets/js/page-template.js';
|
||||
if (file_exists($page_template_path)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-page-template',
|
||||
'jio-page-template',
|
||||
$base_uri . '/assets/js/page-template.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($page_template_path),
|
||||
@@ -436,7 +436,7 @@ trait ScriptsPart1c {
|
||||
$poster_share_path = get_template_directory() . '/assets/js/poster-share.js';
|
||||
if (file_exists($poster_share_path)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-poster-share',
|
||||
'jio-poster-share',
|
||||
$base_uri . '/assets/js/poster-share.js',
|
||||
['loader_js'],
|
||||
(string) filemtime($poster_share_path),
|
||||
@@ -451,59 +451,59 @@ trait ScriptsPart1c {
|
||||
|
||||
$runtime_routes = $this->resolve_frontend_routes();
|
||||
|
||||
// 数据注入 - 全站统一消费 window.aksrtData
|
||||
// 数据注入 - 全站统一消费 window.jioData
|
||||
// Attach to loader_js (bootstraps runtime/main) so ajaxUrl/nonce exist
|
||||
// before pagination/search/article handlers run.
|
||||
wp_localize_script('loader_js', 'aksrtData', [
|
||||
wp_localize_script('loader_js', 'jioData', [
|
||||
'ajaxUrl' => admin_url('admin-ajax.php'),
|
||||
'nonce' => wp_create_nonce('aksrt_public_nonce'),
|
||||
'nonce' => wp_create_nonce('jio_public_nonce'),
|
||||
'restNonce' => wp_create_nonce('wp_rest'),
|
||||
'smsNumberLimitCh' => class_exists('\\AKSRT\\Settings\\Settings') ? !empty(\AKSRT\Settings\Settings::get_sms_settings()['sms_number_limit_ch']) : true,
|
||||
'captchaSignin' => function_exists('aksrt_is_captcha_enabled_for') && aksrt_is_captcha_enabled_for('signin'),
|
||||
'smsNumberLimitCh' => class_exists('\\Jio\\Settings\\Settings') ? !empty(\Jio\Settings\Settings::get_sms_settings()['sms_number_limit_ch']) : true,
|
||||
'captchaSignin' => function_exists('jio_is_captcha_enabled_for') && jio_is_captcha_enabled_for('signin'),
|
||||
// 已签到详情弹窗(签到成功后就地替换入口按钮用)。
|
||||
'signinDetailsUrl' => esc_url_raw(rest_url('aksrt/v1/signin/details')),
|
||||
'signinDetailsUrl' => esc_url_raw(rest_url('jio/v1/signin/details')),
|
||||
// 自定义货币名称(后台「积分配置 → 自定义货币名称」),供前端
|
||||
// 无法服务端渲染的文案(签到状态行、购买/转账提示)复用同一命名。
|
||||
'currencyName' => class_exists('\\AKSRT\\Settings\\Settings') ? \AKSRT\Settings\Settings::get_currency_name() : __('积分', 'aksrt'),
|
||||
'visibilityNonce' => wp_create_nonce('aksrt_visibility'),
|
||||
'currencyName' => class_exists('\\Jio\\Settings\\Settings') ? \Jio\Settings\Settings::get_currency_name() : __('积分', 'jio'),
|
||||
'visibilityNonce' => wp_create_nonce('jio_visibility'),
|
||||
'siteUrl' => home_url('/'),
|
||||
'themeUrl' => AKSRT_URI,
|
||||
'themeMode' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::theme_mode_js_value() : 'auto',
|
||||
'themeUrl' => JIO_URI,
|
||||
'themeMode' => class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::theme_mode_js_value() : 'auto',
|
||||
'debug' => defined('WP_DEBUG') && WP_DEBUG,
|
||||
'debugLog' => defined('WP_DEBUG') && WP_DEBUG && defined('WP_DEBUG_LOG') && WP_DEBUG_LOG,
|
||||
'postPaginationMode' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_pagination_mode() : 'load_more',
|
||||
'commentPaginationMode' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_comment_pagination_mode() : 'numbered',
|
||||
'postPaginationMode' => class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::get_post_pagination_mode() : 'load_more',
|
||||
'commentPaginationMode' => class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::get_comment_pagination_mode() : 'numbered',
|
||||
// AJAX 翻页文案(参考主题 zib__('load_more') / 'ajax_nomore')
|
||||
'ajaxTrigger' => (class_exists('\AKSRT\Settings\Settings') && ($t = \AKSRT\Settings\Settings::get_post_list_style_settings()['ajax_trigger'] ?? '') !== '') ? $t : '<i class="fa fas fa-angle-right"></i>' . __('加载更多', 'aksrt'),
|
||||
'ajaxNomore' => (class_exists('\AKSRT\Settings\Settings') && ($n = \AKSRT\Settings\Settings::get_post_list_style_settings()['ajax_nomore'] ?? '') !== '') ? $n : __('没有更多内容了', 'aksrt'),
|
||||
'ajaxTrigger' => (class_exists('\Jio\Settings\Settings') && ($t = \Jio\Settings\Settings::get_post_list_style_settings()['ajax_trigger'] ?? '') !== '') ? $t : '<i class="fa fas fa-angle-right"></i>' . __('加载更多', 'jio'),
|
||||
'ajaxNomore' => (class_exists('\Jio\Settings\Settings') && ($n = \Jio\Settings\Settings::get_post_list_style_settings()['ajax_nomore'] ?? '') !== '') ? $n : __('没有更多内容了', 'jio'),
|
||||
// 骨架兜底文案,仅在没有 post_ajax_loader 时使用(参考主题 zib__('loading'))。
|
||||
'ajaxLoading' => __('加载中...', 'aksrt'),
|
||||
'iasMax' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['ias_max'] : 3,
|
||||
'commentIasAuto' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_comment_display_settings()['paging_ajax_ias'] : true,
|
||||
'commentUploadUrl' => esc_url_raw(rest_url('aksrt/v1/comment/upload-image')),
|
||||
'ajaxLoading' => __('加载中...', 'jio'),
|
||||
'iasMax' => class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::get_post_list_style_settings()['ias_max'] : 3,
|
||||
'commentIasAuto' => class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::get_comment_display_settings()['paging_ajax_ias'] : true,
|
||||
'commentUploadUrl' => esc_url_raw(rest_url('jio/v1/comment/upload-image')),
|
||||
'commentUploadMaxSize' => (function () {
|
||||
return class_exists('\AKSRT\Attachment\UploadLimits')
|
||||
? \AKSRT\Attachment\UploadLimits::limit_bytes('image')
|
||||
return class_exists('\Jio\Attachment\UploadLimits')
|
||||
? \Jio\Attachment\UploadLimits::limit_bytes('image')
|
||||
: (int) wp_max_upload_size();
|
||||
})(),
|
||||
'commentIasMax' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_comment_display_settings()['paging_ajax_ias_max'] : 3,
|
||||
'restUrl' => esc_url_raw(rest_url('aksrt/v1')),
|
||||
'commentIasMax' => class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::get_comment_display_settings()['paging_ajax_ias_max'] : 3,
|
||||
'restUrl' => esc_url_raw(rest_url('jio/v1')),
|
||||
// Alias used by modal-auth / follow / report (same value as restUrl).
|
||||
'apiUrl' => esc_url_raw(rest_url('aksrt/v1')),
|
||||
'apiUrl' => esc_url_raw(rest_url('jio/v1')),
|
||||
// 举报弹窗数据(report.js):预置原因读取后台“禁封/举报”的 ban_preset_reason
|
||||
// (UserRuntime::ban_settings,参考主题 _pz('ban_preset_reason') 同源),
|
||||
// 图片举证开关与举报说明读取 user_report_img_s / user_report_desc。
|
||||
'reportCategories' => (function () {
|
||||
if (!class_exists('\AKSRT\Settings\UserRuntime')) {
|
||||
if (!class_exists('\Jio\Settings\UserRuntime')) {
|
||||
return [];
|
||||
}
|
||||
return \AKSRT\Settings\UserRuntime::ban_settings()['reasons'] ?? [];
|
||||
return \Jio\Settings\UserRuntime::ban_settings()['reasons'] ?? [];
|
||||
})(),
|
||||
'report' => (function () {
|
||||
if (!class_exists('\AKSRT\Settings\UserRuntime')) {
|
||||
if (!class_exists('\Jio\Settings\UserRuntime')) {
|
||||
return ['imgEnabled' => false, 'desc' => ''];
|
||||
}
|
||||
$report = \AKSRT\Settings\UserRuntime::report_settings();
|
||||
$report = \Jio\Settings\UserRuntime::report_settings();
|
||||
return [
|
||||
'imgEnabled' => !empty($report['img_enabled']),
|
||||
'desc' => (string) ($report['desc'] ?? ''),
|
||||
@@ -511,38 +511,38 @@ trait ScriptsPart1c {
|
||||
})(),
|
||||
// 工单配置(ticket-center.js):附件开关与上限、提交公告、催单冷却、字数上限。
|
||||
'ticket' => (function () {
|
||||
if (!class_exists('\AKSRT\Ticket\TicketSettings')) {
|
||||
if (!class_exists('\Jio\Ticket\TicketSettings')) {
|
||||
return ['enabled' => false, 'attachmentEnabled' => false, 'attachmentMax' => 5, 'notice' => ['open' => false, 'text' => ''], 'urgeInterval' => 15, 'titleMax' => 200, 'contentMax' => 5000, 'replyMax' => 3000];
|
||||
}
|
||||
return [
|
||||
'enabled' => \AKSRT\Ticket\TicketSettings::enabled(),
|
||||
'attachmentEnabled' => \AKSRT\Ticket\TicketSettings::attachment_enabled(),
|
||||
'attachmentMax' => \AKSRT\Ticket\TicketSettings::attachment_max(),
|
||||
'enabled' => \Jio\Ticket\TicketSettings::enabled(),
|
||||
'attachmentEnabled' => \Jio\Ticket\TicketSettings::attachment_enabled(),
|
||||
'attachmentMax' => \Jio\Ticket\TicketSettings::attachment_max(),
|
||||
'notice' => [
|
||||
'open' => \AKSRT\Ticket\TicketSettings::notice_open(),
|
||||
'text' => \AKSRT\Ticket\TicketSettings::notice_text(),
|
||||
'open' => \Jio\Ticket\TicketSettings::notice_open(),
|
||||
'text' => \Jio\Ticket\TicketSettings::notice_text(),
|
||||
],
|
||||
'urgeInterval' => \AKSRT\Ticket\TicketSettings::urge_interval(),
|
||||
'titleMax' => \AKSRT\Ticket\TicketSettings::title_max(),
|
||||
'contentMax' => \AKSRT\Ticket\TicketSettings::content_max(),
|
||||
'replyMax' => \AKSRT\Ticket\TicketSettings::reply_max(),
|
||||
'urgeInterval' => \Jio\Ticket\TicketSettings::urge_interval(),
|
||||
'titleMax' => \Jio\Ticket\TicketSettings::title_max(),
|
||||
'contentMax' => \Jio\Ticket\TicketSettings::content_max(),
|
||||
'replyMax' => \Jio\Ticket\TicketSettings::reply_max(),
|
||||
];
|
||||
})(),
|
||||
'stickyEnabled' => class_exists('\AKSRT\Settings\Settings') ? !empty(\AKSRT\Settings\Settings::get_post_list_style_settings()['sticky_s']) : true,
|
||||
'stickyPages' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['sticky_s'] : ['home', 'cat'],
|
||||
'badgeShow' => class_exists('\AKSRT\Settings\Settings') ? !empty(\AKSRT\Settings\Settings::get_post_list_style_settings()['list_badge_show']) : true,
|
||||
'badgeTypes' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['list_badge_show'] : ['pay', 'tag', 'cat'],
|
||||
'stickyEnabled' => class_exists('\Jio\Settings\Settings') ? !empty(\Jio\Settings\Settings::get_post_list_style_settings()['sticky_s']) : true,
|
||||
'stickyPages' => class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::get_post_list_style_settings()['sticky_s'] : ['home', 'cat'],
|
||||
'badgeShow' => class_exists('\Jio\Settings\Settings') ? !empty(\Jio\Settings\Settings::get_post_list_style_settings()['list_badge_show']) : true,
|
||||
'badgeTypes' => class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::get_post_list_style_settings()['list_badge_show'] : ['pay', 'tag', 'cat'],
|
||||
// 用户状态
|
||||
'isLoggedIn' => is_user_logged_in(),
|
||||
'userId' => get_current_user_id(),
|
||||
'ordersUrl' => $runtime_routes['orders'],
|
||||
'userCenterUrl' => function_exists('aksrt_get_user_center_url') ? aksrt_get_user_center_url() : home_url('/'),
|
||||
'userCenterUrl' => function_exists('jio_get_user_center_url') ? jio_get_user_center_url() : home_url('/'),
|
||||
'routes' => [
|
||||
'home' => home_url('/'),
|
||||
'login' => function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(),
|
||||
'register' => function_exists('aksrt_get_register_url') ? aksrt_get_register_url() : wp_registration_url(),
|
||||
'resetPassword' => function_exists('aksrt_get_reset_password_url') ? aksrt_get_reset_password_url() : wp_lostpassword_url(),
|
||||
'profile' => function_exists('aksrt_get_user_center_url') ? aksrt_get_user_center_url() : home_url('/profile/'),
|
||||
'login' => function_exists('jio_get_login_url') ? jio_get_login_url() : wp_login_url(),
|
||||
'register' => function_exists('jio_get_register_url') ? jio_get_register_url() : wp_registration_url(),
|
||||
'resetPassword' => function_exists('jio_get_reset_password_url') ? jio_get_reset_password_url() : wp_lostpassword_url(),
|
||||
'profile' => function_exists('jio_get_user_center_url') ? jio_get_user_center_url() : home_url('/profile/'),
|
||||
'orders' => $runtime_routes['orders'],
|
||||
'resources' => $runtime_routes['resources'],
|
||||
],
|
||||
@@ -556,35 +556,35 @@ trait ScriptsPart1c {
|
||||
],
|
||||
'themeUri' => get_template_directory_uri(),
|
||||
'lazyScopes' => [
|
||||
'lazy_posts_thumb' => aksrt_is_lazy('lazy_posts_thumb'),
|
||||
'lazy_avatar' => aksrt_is_lazy('lazy_avatar'),
|
||||
'lazy_posts_content' => aksrt_is_lazy('lazy_posts_content'),
|
||||
'lazy_comment' => aksrt_is_lazy('lazy_comment'),
|
||||
'lazy_sider' => aksrt_is_lazy('lazy_sider'),
|
||||
'lazy_cover' => aksrt_is_lazy('lazy_cover'),
|
||||
'lazy_other' => aksrt_is_lazy('lazy_other'),
|
||||
'lazy_posts_thumb' => jio_is_lazy('lazy_posts_thumb'),
|
||||
'lazy_avatar' => jio_is_lazy('lazy_avatar'),
|
||||
'lazy_posts_content' => jio_is_lazy('lazy_posts_content'),
|
||||
'lazy_comment' => jio_is_lazy('lazy_comment'),
|
||||
'lazy_sider' => jio_is_lazy('lazy_sider'),
|
||||
'lazy_cover' => jio_is_lazy('lazy_cover'),
|
||||
'lazy_other' => jio_is_lazy('lazy_other'),
|
||||
],
|
||||
'lazyThumbs' => [
|
||||
'default' => aksrt_get_lazy_thumb(),
|
||||
'sm' => aksrt_get_lazy_thumb('sm'),
|
||||
'lg' => aksrt_get_lazy_thumb('lg'),
|
||||
'default' => jio_get_lazy_thumb(),
|
||||
'sm' => jio_get_lazy_thumb('sm'),
|
||||
'lg' => jio_get_lazy_thumb('lg'),
|
||||
],
|
||||
'lazyAvatar' => aksrt_get_default_avatar_url(),
|
||||
'codeHighlight' => class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::get_code_highlight_config()
|
||||
'lazyAvatar' => jio_get_default_avatar_url(),
|
||||
'codeHighlight' => class_exists('\Jio\Settings\Settings')
|
||||
? \Jio\Settings\Settings::get_code_highlight_config()
|
||||
: ['enabled' => true, 'lightTheme' => 'enlighter', 'darkTheme' => 'monokai', 'lineNumbers' => false, 'showButtons' => true, 'maxHeight' => 500],
|
||||
'systemNotice' => class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::get_system_notice_config()
|
||||
'systemNotice' => class_exists('\Jio\Settings\Settings')
|
||||
? \Jio\Settings\Settings::get_system_notice_config()
|
||||
: ['enabled' => false],
|
||||
'contentProtect' => [
|
||||
'enabled' => class_exists('\AKSRT\Settings\Settings') && (bool) \AKSRT\Settings\Settings::get_value('content_protect_enabled', false),
|
||||
'copyNotice' => class_exists('\AKSRT\Settings\Settings') && (bool) \AKSRT\Settings\Settings::get_value('content_protect_copy_notice', false),
|
||||
'copyNoticeText' => class_exists('\AKSRT\Settings\Settings') ? (string) \AKSRT\Settings\Settings::get_value('content_protect_copy_text', '来自本站,请尊重原创版权。') : '',
|
||||
'disableRightClick'=> class_exists('\AKSRT\Settings\Settings') && (bool) \AKSRT\Settings\Settings::get_value('content_protect_right_click', false),
|
||||
'detectDevTools' => class_exists('\AKSRT\Settings\Settings') && (bool) \AKSRT\Settings\Settings::get_value('content_protect_f12', false),
|
||||
'enabled' => class_exists('\Jio\Settings\Settings') && (bool) \Jio\Settings\Settings::get_value('content_protect_enabled', false),
|
||||
'copyNotice' => class_exists('\Jio\Settings\Settings') && (bool) \Jio\Settings\Settings::get_value('content_protect_copy_notice', false),
|
||||
'copyNoticeText' => class_exists('\Jio\Settings\Settings') ? (string) \Jio\Settings\Settings::get_value('content_protect_copy_text', '来自本站,请尊重原创版权。') : '',
|
||||
'disableRightClick'=> class_exists('\Jio\Settings\Settings') && (bool) \Jio\Settings\Settings::get_value('content_protect_right_click', false),
|
||||
'detectDevTools' => class_exists('\Jio\Settings\Settings') && (bool) \Jio\Settings\Settings::get_value('content_protect_f12', false),
|
||||
],
|
||||
'translate' => class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::get_i18n_config()
|
||||
'translate' => class_exists('\Jio\Settings\Settings')
|
||||
? \Jio\Settings\Settings::get_i18n_config()
|
||||
: ['enabled' => false, 'autoDetect' => true, 'defaultLang' => 'zh-CN'],
|
||||
]);
|
||||
}
|
||||
|
||||
+38
-38
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -14,7 +14,7 @@ trait ScriptsPart2 {
|
||||
* 前端 debug 上报入口(仅在 WP_DEBUG 模式下写日志)
|
||||
*/
|
||||
public function handle_frontend_debug(): void {
|
||||
check_ajax_referer('aksrt_public_nonce', 'nonce');
|
||||
check_ajax_referer('jio_public_nonce', 'nonce');
|
||||
if (!defined('WP_DEBUG') || !WP_DEBUG) {
|
||||
wp_send_json_success(['ignored' => true]);
|
||||
}
|
||||
@@ -31,24 +31,24 @@ trait ScriptsPart2 {
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载后台资源 — 仅在 AKSRT 设置页面加载(与前端样式完全隔离)
|
||||
* 加载后台资源 — 仅在 Jio 设置页面加载(与前端样式完全隔离)
|
||||
*/
|
||||
public function enqueue_admin($hook): void {
|
||||
// 只在 AKSRT 设置页面 (SPA 容器) 加载
|
||||
// 只在 Jio 设置页面 (SPA 容器) 加载
|
||||
$screen = get_current_screen();
|
||||
if (!$screen || $screen->base !== 'toplevel_page_aksrt-settings') {
|
||||
if (!$screen || $screen->base !== 'toplevel_page_jio-settings') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Admin 专用面板样式 — 独立于前端,不受前端 CSS 影响
|
||||
wp_enqueue_style(
|
||||
'aksrt-admin-panel',
|
||||
AKSRT_URI . '/assets/css/admin/admin-panel.css',
|
||||
'jio-admin-panel',
|
||||
JIO_URI . '/assets/css/admin/admin-panel.css',
|
||||
[], // 无依赖,不加载任何前端样式
|
||||
AKSRT_VERSION
|
||||
JIO_VERSION
|
||||
);
|
||||
|
||||
// 注意: SPA 主资源 (Vue3 build) 由 \AKSRT\Admin\Admin::enqueue_admin_assets() 负责加载
|
||||
// 注意: SPA 主资源 (Vue3 build) 由 \Jio\Admin\Admin::enqueue_admin_assets() 负责加载
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,25 +58,25 @@ trait ScriptsPart2 {
|
||||
* 主体宽度统一使用固定 token:1280 / 1080 / 300。
|
||||
*/
|
||||
public function inline_css_vars(): void {
|
||||
(new \AKSRT\Frontend\InlineStyleBuilder())->output();
|
||||
(new \Jio\Frontend\InlineStyleBuilder())->output();
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出自定义头部/底部代码
|
||||
*/
|
||||
public function output_custom_codes(): void {
|
||||
(new \AKSRT\Frontend\CustomCodeRenderer())->output_header();
|
||||
(new \Jio\Frontend\CustomCodeRenderer())->output_header();
|
||||
}
|
||||
|
||||
public function output_loading_overlay(): void {
|
||||
(new \AKSRT\Frontend\LoadingOverlayRenderer())->output();
|
||||
(new \Jio\Frontend\LoadingOverlayRenderer())->output();
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出自定义底部代码
|
||||
*/
|
||||
public function output_custom_footer_codes(): void {
|
||||
(new \AKSRT\Frontend\CustomCodeRenderer())->output_footer();
|
||||
(new \Jio\Frontend\CustomCodeRenderer())->output_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,9 +86,9 @@ trait ScriptsPart2 {
|
||||
if (is_front_page()) {
|
||||
$classes[] = 'front-page';
|
||||
}
|
||||
if (function_exists('aksrt_is_fixed_homepage_request') && aksrt_is_fixed_homepage_request()) {
|
||||
$classes[] = 'aksrt-homepage-layout';
|
||||
$classes[] = 'aksrt-homepage-active';
|
||||
if (function_exists('jio_is_fixed_homepage_request') && jio_is_fixed_homepage_request()) {
|
||||
$classes[] = 'jio-homepage-layout';
|
||||
$classes[] = 'jio-homepage-active';
|
||||
}
|
||||
if (is_singular()) {
|
||||
$classes[] = 'single-post-' . get_the_ID();
|
||||
@@ -96,30 +96,30 @@ trait ScriptsPart2 {
|
||||
if (is_archive()) {
|
||||
$classes[] = 'archive-page';
|
||||
}
|
||||
if ((function_exists('aksrt_is_user_center_page') && aksrt_is_user_center_page())
|
||||
|| (function_exists('aksrt_is_user_home_page') && aksrt_is_user_home_page())
|
||||
|| get_query_var('aksrt_author_identifier')) {
|
||||
$classes[] = 'aksrt-profile';
|
||||
if ((function_exists('jio_is_user_center_page') && jio_is_user_center_page())
|
||||
|| (function_exists('jio_is_user_home_page') && jio_is_user_home_page())
|
||||
|| get_query_var('jio_author_identifier')) {
|
||||
$classes[] = 'jio-profile';
|
||||
}
|
||||
// 区分本人中心与公开主页的 body class
|
||||
if (function_exists('aksrt_is_user_center_page') && aksrt_is_user_center_page()) {
|
||||
$classes[] = 'aksrt-user-center';
|
||||
if (function_exists('jio_is_user_center_page') && jio_is_user_center_page()) {
|
||||
$classes[] = 'jio-user-center';
|
||||
}
|
||||
if (function_exists('aksrt_is_user_home_page') && aksrt_is_user_home_page()) {
|
||||
$classes[] = 'aksrt-user-home';
|
||||
if (function_exists('jio_is_user_home_page') && jio_is_user_home_page()) {
|
||||
$classes[] = 'jio-user-home';
|
||||
}
|
||||
if (function_exists('aksrt_is_auth_page_request') && aksrt_is_auth_page_request()) {
|
||||
if (function_exists('jio_is_auth_page_request') && jio_is_auth_page_request()) {
|
||||
$classes[] = 'auth-page';
|
||||
}
|
||||
|
||||
// 对齐参考主题 close_backdrop:fps-accelerat 由 main.css 统一关闭 backdrop-filter。
|
||||
if (class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::close_backdrop()) {
|
||||
if (class_exists('\Jio\Settings\Settings') && \Jio\Settings\Settings::close_backdrop()) {
|
||||
$classes[] = 'fps-accelerat';
|
||||
}
|
||||
|
||||
// legacy site-layout-1/2/3 (no sidebar / right / left).
|
||||
if (function_exists('aksrt_body_layout_classes')) {
|
||||
foreach (aksrt_body_layout_classes() as $layout_class) {
|
||||
if (function_exists('jio_body_layout_classes')) {
|
||||
foreach (jio_body_layout_classes() as $layout_class) {
|
||||
$classes[] = $layout_class;
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ trait ScriptsPart2 {
|
||||
* 搜索历史同步(登录用户)
|
||||
*/
|
||||
public function handle_search_history(): void {
|
||||
check_ajax_referer('aksrt_public_nonce', 'nonce');
|
||||
check_ajax_referer('jio_public_nonce', 'nonce');
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
if (!$user_id) {
|
||||
@@ -139,7 +139,7 @@ trait ScriptsPart2 {
|
||||
}
|
||||
|
||||
$mode = isset($_POST['mode']) ? sanitize_key(wp_unslash($_POST['mode'])) : 'get';
|
||||
$meta_key = 'aksrt_search_history';
|
||||
$meta_key = 'jio_search_history';
|
||||
|
||||
if ($mode === 'save') {
|
||||
$raw = isset($_POST['items']) ? wp_unslash($_POST['items']) : '[]';
|
||||
@@ -169,7 +169,7 @@ trait ScriptsPart2 {
|
||||
* 搜索建议(实时搜索提示)
|
||||
*/
|
||||
public function handle_search_suggestions(): void {
|
||||
check_ajax_referer('aksrt_public_nonce', 'nonce');
|
||||
check_ajax_referer('jio_public_nonce', 'nonce');
|
||||
|
||||
$q = isset($_POST['q']) ? sanitize_text_field(wp_unslash($_POST['q'])) : '';
|
||||
$type = isset($_POST['type']) ? sanitize_key(wp_unslash($_POST['type'])) : 'post';
|
||||
@@ -209,7 +209,7 @@ trait ScriptsPart2 {
|
||||
$items[] = [
|
||||
'title' => $t->name,
|
||||
'url' => get_term_link($t),
|
||||
'meta' => sprintf(__('%d 篇文章', 'aksrt'), $t->count),
|
||||
'meta' => sprintf(__('%d 篇文章', 'jio'), $t->count),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -226,7 +226,7 @@ trait ScriptsPart2 {
|
||||
$items[] = [
|
||||
'title' => $t->name,
|
||||
'url' => get_term_link($t),
|
||||
'meta' => sprintf(__('%d 篇文章', 'aksrt'), $t->count),
|
||||
'meta' => sprintf(__('%d 篇文章', 'jio'), $t->count),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -239,7 +239,7 @@ trait ScriptsPart2 {
|
||||
if (!defined('WP_DEBUG') || !WP_DEBUG) {
|
||||
return;
|
||||
}
|
||||
$payload = '[AKSRT Scripts] ' . $message;
|
||||
$payload = '[Jio Scripts] ' . $message;
|
||||
if (!empty($context)) {
|
||||
$json = wp_json_encode($context, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
if (false !== $json) {
|
||||
@@ -256,7 +256,7 @@ trait ScriptsPart2 {
|
||||
*/
|
||||
private function resolve_frontend_routes(): array {
|
||||
return [
|
||||
'orders' => function_exists('aksrt_get_user_center_tab_url') ? aksrt_get_user_center_tab_url('orders') : home_url('/user/orders/'),
|
||||
'orders' => function_exists('jio_get_user_center_tab_url') ? jio_get_user_center_tab_url('orders') : home_url('/user/orders/'),
|
||||
'resources' => home_url('/resources/'),
|
||||
];
|
||||
}
|
||||
@@ -265,8 +265,8 @@ trait ScriptsPart2 {
|
||||
* Resolve the permalink for a template-owned page with a stable fallback.
|
||||
*/
|
||||
private function resolve_template_page_url(string $template_file, string $fallback): string {
|
||||
if (function_exists('aksrt_find_template_page')) {
|
||||
$page = aksrt_find_template_page($template_file);
|
||||
if (function_exists('jio_find_template_page')) {
|
||||
$page = jio_find_template_page($template_file);
|
||||
if ($page instanceof \WP_Post) {
|
||||
return get_permalink($page);
|
||||
}
|
||||
|
||||
+28
-28
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -30,13 +30,13 @@ class Setup {
|
||||
add_action('init', [$this, 'register_post_types'], 1);
|
||||
add_action('init', [$this, 'register_meta_fields'], 5);
|
||||
// 文章浏览量统计(单次访问)
|
||||
add_action('wp', 'aksrt_set_post_views');
|
||||
add_action('wp', 'jio_set_post_views');
|
||||
// 隐藏默认WordPress管理菜单
|
||||
add_action('admin_menu', [$this, 'hide_default_menus'], 999);
|
||||
}
|
||||
|
||||
public function load_textdomain(): void {
|
||||
load_theme_textdomain('aksrt', AKSRT_DIR . '/languages');
|
||||
load_theme_textdomain('jio', JIO_DIR . '/languages');
|
||||
}
|
||||
|
||||
public function setup_theme(): void {
|
||||
@@ -66,9 +66,9 @@ class Setup {
|
||||
add_theme_support('post-formats', ['aside', 'image', 'video', 'quote', 'link', 'gallery']);
|
||||
|
||||
// 图片尺寸
|
||||
add_image_size('aksrt-cover', 1200, 675, true);
|
||||
add_image_size('aksrt-card', 400, 260, true);
|
||||
add_image_size('aksrt-thumb', 150, 150, true);
|
||||
add_image_size('jio-cover', 1200, 675, true);
|
||||
add_image_size('jio-card', 400, 260, true);
|
||||
add_image_size('jio-thumb', 150, 150, true);
|
||||
|
||||
// 内容宽度(用于区块编辑器)
|
||||
if (!isset($GLOBALS['content_width'])) {
|
||||
@@ -78,11 +78,11 @@ class Setup {
|
||||
|
||||
public function register_nav_menus(): void {
|
||||
register_nav_menus([
|
||||
'primary' => __('主导航', 'aksrt'),
|
||||
'mobile' => __('移动端菜单', 'aksrt'),
|
||||
'footer' => __('页脚菜单', 'aksrt'),
|
||||
'social' => __('社交链接', 'aksrt'),
|
||||
'header_actions' => __('顶部右侧入口', 'aksrt'),
|
||||
'primary' => __('主导航', 'jio'),
|
||||
'mobile' => __('移动端菜单', 'jio'),
|
||||
'footer' => __('页脚菜单', 'jio'),
|
||||
'social' => __('社交链接', 'jio'),
|
||||
'header_actions' => __('顶部右侧入口', 'jio'),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -90,23 +90,23 @@ class Setup {
|
||||
* 注册自定义文章类型
|
||||
*
|
||||
* 资源不是 CPT:元数据挂在普通 post 上,
|
||||
* 通过 _aksrt_is_resource meta 标记是否为资源。
|
||||
* 通过 _jio_is_resource meta 标记是否为资源。
|
||||
*/
|
||||
public function register_post_types(): void {
|
||||
// 项目展示
|
||||
register_post_type('project', [
|
||||
'labels' => [
|
||||
'name' => __('项目展示', 'aksrt'),
|
||||
'singular_name' => __('项目', 'aksrt'),
|
||||
'add_new' => __('新建项目', 'aksrt'),
|
||||
'add_new_item' => __('新建项目', 'aksrt'),
|
||||
'edit_item' => __('编辑项目', 'aksrt'),
|
||||
'new_item' => __('新项目', 'aksrt'),
|
||||
'view_item' => __('查看项目', 'aksrt'),
|
||||
'search_items' => __('搜索项目', 'aksrt'),
|
||||
'not_found' => __('未找到项目', 'aksrt'),
|
||||
'not_found_in_trash' => __('回收站中无项目', 'aksrt'),
|
||||
'menu_name' => __('项目展示', 'aksrt'),
|
||||
'name' => __('项目展示', 'jio'),
|
||||
'singular_name' => __('项目', 'jio'),
|
||||
'add_new' => __('新建项目', 'jio'),
|
||||
'add_new_item' => __('新建项目', 'jio'),
|
||||
'edit_item' => __('编辑项目', 'jio'),
|
||||
'new_item' => __('新项目', 'jio'),
|
||||
'view_item' => __('查看项目', 'jio'),
|
||||
'search_items' => __('搜索项目', 'jio'),
|
||||
'not_found' => __('未找到项目', 'jio'),
|
||||
'not_found_in_trash' => __('回收站中无项目', 'jio'),
|
||||
'menu_name' => __('项目展示', 'jio'),
|
||||
],
|
||||
'public' => true,
|
||||
'publicly_queryable' => true,
|
||||
@@ -125,11 +125,11 @@ class Setup {
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册资源 post meta + 分类 term meta(aksrt_flow)
|
||||
* 注册资源 post meta + 分类 term meta(jio_flow)
|
||||
*
|
||||
* 全部 show_in_rest,便于 Block Editor + Vue SPA 读写。
|
||||
*
|
||||
* v3.4: 资源元数据全部挂在 post 上,配合 _aksrt_is_resource 开关使用。
|
||||
* v3.4: 资源元数据全部挂在 post 上,配合 _jio_is_resource 开关使用。
|
||||
*/
|
||||
public function register_meta_fields(): void {
|
||||
$post_edit_auth = static function () {
|
||||
@@ -238,7 +238,7 @@ class Setup {
|
||||
return '0.00';
|
||||
}
|
||||
try {
|
||||
return \AKSRT\Ledger\AssetAmount::balance($value)->decimal();
|
||||
return \Jio\Ledger\AssetAmount::balance($value)->decimal();
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
return '0.00';
|
||||
}
|
||||
@@ -262,7 +262,7 @@ class Setup {
|
||||
]);
|
||||
}
|
||||
|
||||
register_term_meta('category', 'aksrt_flow', [
|
||||
register_term_meta('category', 'jio_flow', [
|
||||
'type' => 'string',
|
||||
'description' => 'Category flow mode: inherit/blog/cms',
|
||||
'single' => true,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
|
||||
+45
-45
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -22,8 +22,8 @@ class Shortcodes {
|
||||
* 注册全部短代码。在 `init` 上调用一次。
|
||||
*/
|
||||
public function register(): void {
|
||||
// 隐藏内容(评论/登录/密码可见)→ \AKSRT\Content\Visibility
|
||||
add_shortcode('aksrt_hide', [$this, 'render_hide']);
|
||||
// 隐藏内容(评论/登录/密码可见)→ \Jio\Content\Visibility
|
||||
add_shortcode('jio_hide', [$this, 'render_hide']);
|
||||
// §3.8 用户友好短代码别名
|
||||
add_shortcode('hide', [$this, 'render_hide_comment']);
|
||||
add_shortcode('reply', [$this, 'render_reply']);
|
||||
@@ -33,20 +33,20 @@ class Shortcodes {
|
||||
add_shortcode('hidecontent', [$this, 'render_hidecontent']);
|
||||
add_shortcode('content', [$this, 'render_content_gate']);
|
||||
// 文章归档 / 个人资料卡 → Templates 模板
|
||||
add_shortcode('aksrt_archive', [$this, 'render_archive']);
|
||||
add_shortcode('aksrt_profile', [$this, 'render_profile']);
|
||||
add_shortcode('jio_archive', [$this, 'render_archive']);
|
||||
add_shortcode('jio_profile', [$this, 'render_profile']);
|
||||
// 文章列表(统一渲染器)
|
||||
add_shortcode('aksrt_posts', [$this, 'render_posts']);
|
||||
add_shortcode('jio_posts', [$this, 'render_posts']);
|
||||
}
|
||||
|
||||
/**
|
||||
* [aksrt_hide mode="comment|login|password"]...[/aksrt_hide]
|
||||
* [jio_hide mode="comment|login|password"]...[/jio_hide]
|
||||
*/
|
||||
public function render_hide(array $atts, string $content = ''): string {
|
||||
if (!class_exists('\AKSRT\Content\Visibility')) {
|
||||
if (!class_exists('\Jio\Content\Visibility')) {
|
||||
return '';
|
||||
}
|
||||
return \AKSRT\Content\Visibility::get_instance()->render_hide_shortcode($atts, $content);
|
||||
return \Jio\Content\Visibility::get_instance()->render_hide_shortcode($atts, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +62,7 @@ class Shortcodes {
|
||||
*/
|
||||
public function render_reply(array $atts = [], string $content = ''): string {
|
||||
$atts = shortcode_atts(['message' => ''], $atts, 'reply');
|
||||
$msg = $atts['message'] ?: __('回复本文后可查看隐藏内容', 'aksrt');
|
||||
$msg = $atts['message'] ?: __('回复本文后可查看隐藏内容', 'jio');
|
||||
return $this->render_hide(['mode' => 'comment', 'message' => $msg], $content);
|
||||
}
|
||||
|
||||
@@ -73,22 +73,22 @@ class Shortcodes {
|
||||
$atts = shortcode_atts(['message' => ''], $atts, 'vip');
|
||||
$uid = get_current_user_id();
|
||||
|
||||
$is_vip = $uid > 0 && function_exists('aksrt_is_vip') && aksrt_is_vip($uid);
|
||||
$is_vip = $uid > 0 && function_exists('jio_is_vip') && jio_is_vip($uid);
|
||||
|
||||
if ($is_vip) {
|
||||
return '<div class="aksrt-hidden-content aksrt-hidden-content--unlocked aksrt-hidden-content--vip">'
|
||||
return '<div class="jio-hidden-content jio-hidden-content--unlocked jio-hidden-content--vip">'
|
||||
. do_shortcode($content) . '</div>';
|
||||
}
|
||||
|
||||
$message = $atts['message'] ?: __('此内容仅 VIP 用户可见', 'aksrt');
|
||||
$html = '<div class="aksrt-hidden-content aksrt-hidden-content--locked aksrt-hidden-content--vip">';
|
||||
$html .= '<div class="aksrt-hidden-content__message">';
|
||||
$message = $atts['message'] ?: __('此内容仅 VIP 用户可见', 'jio');
|
||||
$html = '<div class="jio-hidden-content jio-hidden-content--locked jio-hidden-content--vip">';
|
||||
$html .= '<div class="jio-hidden-content__message">';
|
||||
$html .= '<i class="fa fas fa-certificate" aria-hidden="true"></i> ';
|
||||
$html .= '<span>' . esc_html($message) . '</span>';
|
||||
$html .= '</div>';
|
||||
if ($uid <= 0) {
|
||||
$html .= '<a href="' . esc_url(wp_login_url(get_permalink())) . '" class="aksrt-hidden-content__login-btn btn-primary btn-sm">';
|
||||
$html .= esc_html__('登录后查看', 'aksrt') . '</a>';
|
||||
$html .= '<a href="' . esc_url(wp_login_url(get_permalink())) . '" class="jio-hidden-content__login-btn btn-primary btn-sm">';
|
||||
$html .= esc_html__('登录后查看', 'jio') . '</a>';
|
||||
}
|
||||
$html .= '</div>';
|
||||
return $html;
|
||||
@@ -106,21 +106,21 @@ class Shortcodes {
|
||||
// Until the post has an active reading price, keep its content public
|
||||
// so authors can compose and publish before completing price setup.
|
||||
if (!($post instanceof \WP_Post)
|
||||
|| !function_exists('aksrt_is_payshow_purchase_enabled')
|
||||
|| !aksrt_is_payshow_purchase_enabled($post)) {
|
||||
return '<div class="aksrt-hidden-content aksrt-hidden-content--unlocked aksrt-hidden-content--payshow">'
|
||||
|| !function_exists('jio_is_payshow_purchase_enabled')
|
||||
|| !jio_is_payshow_purchase_enabled($post)) {
|
||||
return '<div class="jio-hidden-content jio-hidden-content--unlocked jio-hidden-content--payshow">'
|
||||
. do_shortcode($content) . '</div>';
|
||||
}
|
||||
|
||||
$can_view = $this->viewer_can_see_paid_block($pid);
|
||||
|
||||
if ($can_view) {
|
||||
return '<div class="aksrt-hidden-content aksrt-hidden-content--unlocked aksrt-hidden-content--payshow">'
|
||||
return '<div class="jio-hidden-content jio-hidden-content--unlocked jio-hidden-content--payshow">'
|
||||
. do_shortcode($content) . '</div>';
|
||||
}
|
||||
|
||||
$message = $atts['message'] ?: __('此内容需付费后查看', 'aksrt');
|
||||
return aksrt_get_paywall_html($post, ['message' => $message]);
|
||||
$message = $atts['message'] ?: __('此内容需付费后查看', 'jio');
|
||||
return jio_get_paywall_html($post, ['message' => $message]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +143,7 @@ class Shortcodes {
|
||||
case 'signin':
|
||||
return $this->render_hide([
|
||||
'mode' => 'login',
|
||||
'message' => $msg !== '' ? $msg : __('登录后可查看隐藏内容', 'aksrt'),
|
||||
'message' => $msg !== '' ? $msg : __('登录后可查看隐藏内容', 'jio'),
|
||||
], $content);
|
||||
case 'password':
|
||||
case 'pass':
|
||||
@@ -178,8 +178,8 @@ class Shortcodes {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (class_exists('\AKSRT\Content\Visibility')) {
|
||||
return \AKSRT\Content\Visibility::can_view_paid_content($pid);
|
||||
if (class_exists('\Jio\Content\Visibility')) {
|
||||
return \Jio\Content\Visibility::can_view_paid_content($pid);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -205,7 +205,7 @@ class Shortcodes {
|
||||
}
|
||||
break;
|
||||
case 'vip':
|
||||
$allowed = $uid > 0 && function_exists('aksrt_is_vip') && aksrt_is_vip($uid);
|
||||
$allowed = $uid > 0 && function_exists('jio_is_vip') && jio_is_vip($uid);
|
||||
break;
|
||||
case 'login':
|
||||
$allowed = $uid > 0;
|
||||
@@ -213,19 +213,19 @@ class Shortcodes {
|
||||
}
|
||||
|
||||
if ($allowed) {
|
||||
return '<div class="aksrt-hidden-content aksrt-hidden-content--unlocked aksrt-hidden-content--role">'
|
||||
return '<div class="jio-hidden-content jio-hidden-content--unlocked jio-hidden-content--role">'
|
||||
. do_shortcode($content) . '</div>';
|
||||
}
|
||||
|
||||
$default_msgs = [
|
||||
'admin' => __('此内容仅管理员可见', 'aksrt'),
|
||||
'author' => __('此内容仅作者可见', 'aksrt'),
|
||||
'vip' => __('此内容仅 VIP 用户可见', 'aksrt'),
|
||||
'login' => __('此内容仅登录用户可见', 'aksrt'),
|
||||
'admin' => __('此内容仅管理员可见', 'jio'),
|
||||
'author' => __('此内容仅作者可见', 'jio'),
|
||||
'vip' => __('此内容仅 VIP 用户可见', 'jio'),
|
||||
'login' => __('此内容仅登录用户可见', 'jio'),
|
||||
];
|
||||
$message = $atts['message'] ?: ($default_msgs[$type] ?? __('此内容已隐藏', 'aksrt'));
|
||||
$html = '<div class="aksrt-hidden-content aksrt-hidden-content--locked aksrt-hidden-content--role">';
|
||||
$html .= '<div class="aksrt-hidden-content__message">';
|
||||
$message = $atts['message'] ?: ($default_msgs[$type] ?? __('此内容已隐藏', 'jio'));
|
||||
$html = '<div class="jio-hidden-content jio-hidden-content--locked jio-hidden-content--role">';
|
||||
$html .= '<div class="jio-hidden-content__message">';
|
||||
$html .= '<i class="fa fas fa-eye-slash" aria-hidden="true"></i> ';
|
||||
$html .= '<span>' . esc_html($message) . '</span>';
|
||||
$html .= '</div>';
|
||||
@@ -234,27 +234,27 @@ class Shortcodes {
|
||||
}
|
||||
|
||||
/**
|
||||
* [aksrt_archive] 文章归档
|
||||
* [jio_archive] 文章归档
|
||||
*/
|
||||
public function render_archive(array $atts = [], string $content = ''): string {
|
||||
if (!class_exists('AKSRT\\Core\\Templates')) {
|
||||
if (!class_exists('Jio\\Core\\Templates')) {
|
||||
return '';
|
||||
}
|
||||
return Templates::get_instance()->render_archive_shortcode($atts, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* [aksrt_profile] 个人资料卡
|
||||
* [jio_profile] 个人资料卡
|
||||
*/
|
||||
public function render_profile(array $atts = [], string $content = ''): string {
|
||||
if (!class_exists('AKSRT\\Core\\Templates')) {
|
||||
if (!class_exists('Jio\\Core\\Templates')) {
|
||||
return '';
|
||||
}
|
||||
return Templates::get_instance()->render_profile_shortcode($atts, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* [aksrt_posts count="6" cat="" tag="" orderby="date" order="DESC" mode="card"]
|
||||
* [jio_posts count="6" cat="" tag="" orderby="date" order="DESC" mode="card"]
|
||||
*
|
||||
* 用统一渲染器输出文章列表,避免内容里手写卡片循环。
|
||||
*/
|
||||
@@ -266,7 +266,7 @@ class Shortcodes {
|
||||
'orderby' => 'date',
|
||||
'order' => 'DESC',
|
||||
'mode' => 'card',
|
||||
], $atts, 'aksrt_posts');
|
||||
], $atts, 'jio_posts');
|
||||
|
||||
$query_args = [
|
||||
'post_type' => 'post',
|
||||
@@ -291,14 +291,14 @@ class Shortcodes {
|
||||
|
||||
$query = new \WP_Query($query_args);
|
||||
if ($mode === 'mini') {
|
||||
$html = aksrt_render_mini_list($query, [], false);
|
||||
$html = jio_render_mini_list($query, [], false);
|
||||
} else {
|
||||
$html = aksrt_render_post_list([
|
||||
$html = jio_render_post_list([
|
||||
'type' => $mode === 'card' ? 'card' : 'list',
|
||||
], $query, false);
|
||||
}
|
||||
wp_reset_postdata();
|
||||
|
||||
return '<div class="aksrt-shortcode-posts">' . $html . '</div>';
|
||||
return '<div class="jio-shortcode-posts">' . $html . '</div>';
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -51,10 +51,10 @@ class StatsTracker {
|
||||
$scheduled = true;
|
||||
|
||||
$today = current_time('Y-m-d');
|
||||
$option_key = 'aksrt_daily_stats_' . $today;
|
||||
$option_key = 'jio_daily_stats_' . $today;
|
||||
|
||||
// 检查是否已统计过该访客
|
||||
$visitor_cookie = 'aksrt_visitor_' . $today;
|
||||
$visitor_cookie = 'jio_visitor_' . $today;
|
||||
$is_unique = empty($_COOKIE[$visitor_cookie]);
|
||||
|
||||
if ($is_unique) {
|
||||
@@ -100,8 +100,8 @@ class StatsTracker {
|
||||
$threshold = date('Y-m-d', strtotime('-30 days'));
|
||||
$wpdb->query($wpdb->prepare(
|
||||
"DELETE FROM {$wpdb->options} WHERE option_name LIKE %s AND option_name < %s",
|
||||
$wpdb->esc_like('aksrt_daily_stats_') . '%',
|
||||
'aksrt_daily_stats_' . $threshold
|
||||
$wpdb->esc_like('jio_daily_stats_') . '%',
|
||||
'jio_daily_stats_' . $threshold
|
||||
));
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ class StatsTracker {
|
||||
*/
|
||||
public static function get_today_stats(): array {
|
||||
$today = current_time('Y-m-d');
|
||||
$stats = get_option('aksrt_daily_stats_' . $today, ['visitors' => 0, 'pageviews' => 0]);
|
||||
$stats = get_option('jio_daily_stats_' . $today, ['visitors' => 0, 'pageviews' => 0]);
|
||||
|
||||
if (!is_array($stats)) {
|
||||
return ['visitors' => 0, 'pageviews' => 0];
|
||||
@@ -126,7 +126,7 @@ class StatsTracker {
|
||||
* 获取指定日期统计
|
||||
*/
|
||||
public static function get_daily_stats(string $date): array {
|
||||
$stats = get_option('aksrt_daily_stats_' . $date, ['visitors' => 0, 'pageviews' => 0]);
|
||||
$stats = get_option('jio_daily_stats_' . $date, ['visitors' => 0, 'pageviews' => 0]);
|
||||
|
||||
if (!is_array($stats)) {
|
||||
return ['visitors' => 0, 'pageviews' => 0];
|
||||
@@ -158,7 +158,7 @@ class StatsTracker {
|
||||
public static function get_total_views(): int {
|
||||
global $wpdb;
|
||||
$total = $wpdb->get_var(
|
||||
"SELECT SUM(CAST(meta_value AS UNSIGNED)) FROM {$wpdb->postmeta} WHERE meta_key = 'aksrt_post_views'"
|
||||
"SELECT SUM(CAST(meta_value AS UNSIGNED)) FROM {$wpdb->postmeta} WHERE meta_key = 'jio_post_views'"
|
||||
);
|
||||
return max(0, (int) $total);
|
||||
}
|
||||
|
||||
+18
-18
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -25,7 +25,7 @@ class Templates {
|
||||
add_filter('theme_page_templates', [$this, 'register_page_templates']);
|
||||
add_filter('template_include', [$this, 'load_page_template']);
|
||||
add_filter('page_template_hierarchy', [$this, 'template_hierarchy']);
|
||||
add_filter('aksrt_page_template_hierarchy', [$this, 'template_hierarchy']);
|
||||
add_filter('jio_page_template_hierarchy', [$this, 'template_hierarchy']);
|
||||
|
||||
// 短代码注册统一在 Shortcodes(registry);本类只提供 archive/profile 渲染实现。
|
||||
}
|
||||
@@ -35,16 +35,16 @@ class Templates {
|
||||
*/
|
||||
private function page_template_map(): array {
|
||||
return [
|
||||
'templates/pages/page-sign.php' => __('AKSRT - 登录/注册', 'aksrt'),
|
||||
'templates/pages/page-profile.php' => __('AKSRT - 个人中心', 'aksrt'),
|
||||
'templates/pages/page-user-home.php' => __('AKSRT - 用户主页', 'aksrt'),
|
||||
'templates/pages/page-archives.php' => __('AKSRT - 文章归档', 'aksrt'),
|
||||
'templates/pages/page-categories.php' => __('AKSRT - 分类汇总', 'aksrt'),
|
||||
'templates/pages/page-newposts.php' => __('AKSRT - 最新文章', 'aksrt'),
|
||||
'templates/pages/page-sign.php' => __('Jio - 登录/注册', 'jio'),
|
||||
'templates/pages/page-profile.php' => __('Jio - 个人中心', 'jio'),
|
||||
'templates/pages/page-user-home.php' => __('Jio - 用户主页', 'jio'),
|
||||
'templates/pages/page-archives.php' => __('Jio - 文章归档', 'jio'),
|
||||
'templates/pages/page-categories.php' => __('Jio - 分类汇总', 'jio'),
|
||||
'templates/pages/page-newposts.php' => __('Jio - 最新文章', 'jio'),
|
||||
// 注意:page-newposts = 最新文章列表;投稿页是 page-submit(写文章/投稿)
|
||||
'templates/pages/page-submit.php' => __('AKSRT - 写文章/投稿', 'aksrt'),
|
||||
'templates/pages/page-posts-navs.php' => __('AKSRT - 文章导航', 'aksrt'),
|
||||
'templates/pages/page-friends.php' => __('AKSRT - 友情链接', 'aksrt'),
|
||||
'templates/pages/page-submit.php' => __('Jio - 写文章/投稿', 'jio'),
|
||||
'templates/pages/page-posts-navs.php' => __('Jio - 文章导航', 'jio'),
|
||||
'templates/pages/page-friends.php' => __('Jio - 友情链接', 'jio'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -70,15 +70,15 @@ class Templates {
|
||||
}
|
||||
|
||||
$page_template_meta = get_post_meta($post->ID, '_wp_page_template', true);
|
||||
$resolved_template = function_exists('aksrt_resolve_page_template_file')
|
||||
? aksrt_resolve_page_template_file(
|
||||
$resolved_template = function_exists('jio_resolve_page_template_file')
|
||||
? jio_resolve_page_template_file(
|
||||
is_string($page_template_meta) ? $page_template_meta : '',
|
||||
(string) $post->post_name
|
||||
)
|
||||
: '';
|
||||
|
||||
if ($resolved_template !== '' && function_exists('aksrt_locate_template_file')) {
|
||||
$resolved_path = aksrt_locate_template_file($resolved_template);
|
||||
if ($resolved_template !== '' && function_exists('jio_locate_template_file')) {
|
||||
$resolved_path = jio_locate_template_file($resolved_template);
|
||||
if ($resolved_path) {
|
||||
return $resolved_path;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ class Templates {
|
||||
}
|
||||
|
||||
public function render_archive_shortcode(array $attrs = [], string $content = ''): string {
|
||||
$template = AKSRT_DIR . '/templates/shortcodes/archive.php';
|
||||
$template = JIO_DIR . '/templates/shortcodes/archive.php';
|
||||
if (!file_exists($template)) {
|
||||
return '';
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class Templates {
|
||||
}
|
||||
|
||||
public function render_profile_shortcode(array $attrs = [], string $content = ''): string {
|
||||
$template = AKSRT_DIR . '/templates/shortcodes/profile.php';
|
||||
$template = JIO_DIR . '/templates/shortcodes/profile.php';
|
||||
if (!file_exists($template)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
+32
-32
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -60,9 +60,9 @@ class TermMeta {
|
||||
*/
|
||||
public static function resolve_archive_settings(\WP_Term $term): array {
|
||||
$taxonomy = $term->taxonomy === 'post_tag' ? 'post_tag' : 'category';
|
||||
$global = $taxonomy === 'post_tag' && class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::get_tag_page_settings()
|
||||
: (class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_category_page_settings() : [
|
||||
$global = $taxonomy === 'post_tag' && class_exists('\Jio\Settings\Settings')
|
||||
? \Jio\Settings\Settings::get_tag_page_settings()
|
||||
: (class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::get_category_page_settings() : [
|
||||
'header_style' => 'cover',
|
||||
'cover_enabled' => true,
|
||||
'desc_enabled' => true,
|
||||
@@ -96,7 +96,7 @@ class TermMeta {
|
||||
|
||||
$cover_url = isset($saved['cover_url']) ? esc_url_raw((string) $saved['cover_url']) : '';
|
||||
if ($cover_url === '' && !empty($global['cover_enabled'])) {
|
||||
$cover_id = (int) get_term_meta($term->term_id, 'aksrt_category_cover_id', true);
|
||||
$cover_id = (int) get_term_meta($term->term_id, 'jio_category_cover_id', true);
|
||||
$cover_url = $cover_id > 0 ? (string) wp_get_attachment_url($cover_id) : '';
|
||||
if ($cover_url === '') {
|
||||
$cover_url = esc_url_raw((string) ($global['default_cover'] ?? ''));
|
||||
@@ -111,8 +111,8 @@ class TermMeta {
|
||||
// 高级筛选(参考主题 zib-category.php 语义):cat 页按 cat_custom_filter 全量覆盖
|
||||
// 筛选项目,未匹配或 tag 页回退默认配置,custom_filter_show 决定自定义筛选显示。
|
||||
$page = $taxonomy === 'post_tag' ? 'tag' : 'cat';
|
||||
$custom_filter = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::get_archive_custom_filter_config((int) $term->term_id, $page)
|
||||
$custom_filter = class_exists('\Jio\Settings\Settings')
|
||||
? \Jio\Settings\Settings::get_archive_custom_filter_config((int) $term->term_id, $page)
|
||||
: ['custom_enabled' => false, 'custom_filters' => 'all', 'overrides' => []];
|
||||
$overrides = is_array($custom_filter['overrides'] ?? null) ? $custom_filter['overrides'] : [];
|
||||
|
||||
@@ -136,7 +136,7 @@ class TermMeta {
|
||||
}
|
||||
$orderby = sanitize_key((string) ($orderby_option['lists'][0] ?? $global['orderby'] ?? 'date'));
|
||||
|
||||
$filter_all = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_filter_settings() : [];
|
||||
$filter_all = class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::get_post_filter_settings() : [];
|
||||
|
||||
return [
|
||||
'taxonomy' => $taxonomy,
|
||||
@@ -217,7 +217,7 @@ class TermMeta {
|
||||
continue;
|
||||
}
|
||||
$meta_query[] = [
|
||||
'key' => '_aksrt_cf_' . $dim_key,
|
||||
'key' => '_jio_cf_' . $dim_key,
|
||||
'value' => '"' . sanitize_key(wp_unslash((string) $_GET[$dim_key])) . '"',
|
||||
'compare' => 'LIKE',
|
||||
];
|
||||
@@ -228,14 +228,14 @@ class TermMeta {
|
||||
}
|
||||
|
||||
$orderby = isset($_GET['orderby']) ? sanitize_key(wp_unslash((string) $_GET['orderby'])) : 'date';
|
||||
$allowed = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::homepage_allowed_sorts()
|
||||
$allowed = class_exists('\Jio\Settings\Settings')
|
||||
? \Jio\Settings\Settings::homepage_allowed_sorts()
|
||||
: ['modified', 'date', 'views', 'like', 'comment_count', 'favorite', 'rand'];
|
||||
if (!in_array($orderby, $allowed, true)) {
|
||||
$orderby = 'date';
|
||||
}
|
||||
if (function_exists('aksrt_homepage_apply_named_sort_args')) {
|
||||
foreach (aksrt_homepage_apply_named_sort_args([], $orderby) as $key => $value) {
|
||||
if (function_exists('jio_homepage_apply_named_sort_args')) {
|
||||
foreach (jio_homepage_apply_named_sort_args([], $orderby) as $key => $value) {
|
||||
$query->set($key, $value);
|
||||
}
|
||||
}
|
||||
@@ -247,9 +247,9 @@ class TermMeta {
|
||||
public function render_add_fields(string $taxonomy): void {
|
||||
?>
|
||||
<div class="form-field">
|
||||
<label for="aksrt_term_cover_url"><?php esc_html_e('封面图 URL', 'aksrt'); ?></label>
|
||||
<input type="url" name="aksrt_term_meta[cover_url]" id="aksrt_term_cover_url" value="" placeholder="https://...">
|
||||
<p class="description"><?php esc_html_e('分类/标签页顶部封面图,留空则不显示。', 'aksrt'); ?></p>
|
||||
<label for="jio_term_cover_url"><?php esc_html_e('封面图 URL', 'jio'); ?></label>
|
||||
<input type="url" name="jio_term_meta[cover_url]" id="jio_term_cover_url" value="" placeholder="https://...">
|
||||
<p class="description"><?php esc_html_e('分类/标签页顶部封面图,留空则不显示。', 'jio'); ?></p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
@@ -261,33 +261,33 @@ class TermMeta {
|
||||
$meta = self::get_meta($term->term_id);
|
||||
?>
|
||||
<tr class="form-field">
|
||||
<th scope="row"><label for="aksrt_term_cover_url"><?php esc_html_e('封面图 URL', 'aksrt'); ?></label></th>
|
||||
<th scope="row"><label for="jio_term_cover_url"><?php esc_html_e('封面图 URL', 'jio'); ?></label></th>
|
||||
<td>
|
||||
<input type="url" name="aksrt_term_meta[cover_url]" id="aksrt_term_cover_url" value="<?php echo esc_url($meta['cover_url']); ?>" class="regular-text" placeholder="https://...">
|
||||
<p class="description"><?php esc_html_e('分类/标签页顶部封面图,留空则不显示。', 'aksrt'); ?></p>
|
||||
<input type="url" name="jio_term_meta[cover_url]" id="jio_term_cover_url" value="<?php echo esc_url($meta['cover_url']); ?>" class="regular-text" placeholder="https://...">
|
||||
<p class="description"><?php esc_html_e('分类/标签页顶部封面图,留空则不显示。', 'jio'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="form-field">
|
||||
<th scope="row"><label for="aksrt_term_desc"><?php esc_html_e('自定义简介', 'aksrt'); ?></label></th>
|
||||
<th scope="row"><label for="jio_term_desc"><?php esc_html_e('自定义简介', 'jio'); ?></label></th>
|
||||
<td>
|
||||
<textarea name="aksrt_term_meta[description]" id="aksrt_term_desc" rows="3" class="large-text"><?php echo esc_textarea($meta['description']); ?></textarea>
|
||||
<p class="description"><?php esc_html_e('覆盖默认的分类/标签描述。', 'aksrt'); ?></p>
|
||||
<textarea name="jio_term_meta[description]" id="jio_term_desc" rows="3" class="large-text"><?php echo esc_textarea($meta['description']); ?></textarea>
|
||||
<p class="description"><?php esc_html_e('覆盖默认的分类/标签描述。', 'jio'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="form-field">
|
||||
<th scope="row"><?php esc_html_e('显示设置', 'aksrt'); ?></th>
|
||||
<th scope="row"><?php esc_html_e('显示设置', 'jio'); ?></th>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" name="aksrt_term_meta[show_header]" value="1" <?php checked(!empty($meta['show_header'])); ?>>
|
||||
<?php esc_html_e('显示页面头部(标题、描述)', 'aksrt'); ?>
|
||||
<input type="checkbox" name="jio_term_meta[show_header]" value="1" <?php checked(!empty($meta['show_header'])); ?>>
|
||||
<?php esc_html_e('显示页面头部(标题、描述)', 'jio'); ?>
|
||||
</label><br>
|
||||
<label>
|
||||
<input type="checkbox" name="aksrt_term_meta[show_sidebar]" value="1" <?php checked($meta['show_sidebar'] === '1'); ?>>
|
||||
<?php esc_html_e('强制显示侧栏', 'aksrt'); ?>
|
||||
<input type="checkbox" name="jio_term_meta[show_sidebar]" value="1" <?php checked($meta['show_sidebar'] === '1'); ?>>
|
||||
<?php esc_html_e('强制显示侧栏', 'jio'); ?>
|
||||
</label><br>
|
||||
<label>
|
||||
<input type="checkbox" name="aksrt_term_meta[show_featured]" value="1" <?php checked(!empty($meta['show_featured'])); ?>>
|
||||
<?php esc_html_e('显示推荐文章位', 'aksrt'); ?>
|
||||
<input type="checkbox" name="jio_term_meta[show_featured]" value="1" <?php checked(!empty($meta['show_featured'])); ?>>
|
||||
<?php esc_html_e('显示推荐文章位', 'jio'); ?>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -298,14 +298,14 @@ class TermMeta {
|
||||
* Save term meta from form submission.
|
||||
*/
|
||||
public function save_term_meta(int $term_id): void {
|
||||
if (!isset($_POST['aksrt_term_meta']) || !is_array($_POST['aksrt_term_meta'])) {
|
||||
if (!isset($_POST['jio_term_meta']) || !is_array($_POST['jio_term_meta'])) {
|
||||
return;
|
||||
}
|
||||
if (!current_user_can('manage_categories')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$raw = $_POST['aksrt_term_meta'];
|
||||
$raw = $_POST['jio_term_meta'];
|
||||
$sanitized = [
|
||||
'cover_url' => isset($raw['cover_url']) ? esc_url_raw($raw['cover_url']) : '',
|
||||
'description' => isset($raw['description']) ? sanitize_textarea_field($raw['description']) : '',
|
||||
|
||||
+25
-20
@@ -1,16 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
namespace Jio\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
class UpdateChecker {
|
||||
|
||||
private static $instance = null;
|
||||
private const OPTION_KEY = 'aksrt_update_check';
|
||||
private const OPTION_KEY = 'jio_update_check';
|
||||
private const CHECK_INTERVAL = DAY_IN_SECONDS * 1; // Check daily
|
||||
|
||||
private function __construct() {}
|
||||
@@ -36,14 +36,16 @@ class UpdateChecker {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get update endpoint URL
|
||||
* Get update endpoint URL.
|
||||
*
|
||||
* No built-in default: the endpoint comes from the 「更新端点」 setting
|
||||
* (tools/update). Empty setting means update checks are disabled.
|
||||
*/
|
||||
private function get_endpoint(): string {
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
$endpoint = \AKSRT\Settings\Settings::get_value('update_endpoint', '');
|
||||
if (!empty($endpoint)) return $endpoint;
|
||||
if (class_exists('\Jio\Settings\Settings')) {
|
||||
return trim((string) \Jio\Settings\Settings::get_value('update_endpoint', ''));
|
||||
}
|
||||
return 'https://api.aksrt.com/version.json';
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,6 +67,9 @@ class UpdateChecker {
|
||||
*/
|
||||
public function do_check(): void {
|
||||
$endpoint = $this->get_endpoint();
|
||||
if ($endpoint === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$response = wp_remote_get($endpoint, [
|
||||
'timeout' => 5,
|
||||
@@ -118,18 +123,18 @@ class UpdateChecker {
|
||||
$changelog = $stored['changelog'] ?? '';
|
||||
|
||||
// User dismissed this version?
|
||||
$dismissed = get_user_meta(get_current_user_id(), 'aksrt_dismissed_update', true);
|
||||
$dismissed = get_user_meta(get_current_user_id(), 'jio_dismissed_update', true);
|
||||
if ($dismissed === $remote) return;
|
||||
|
||||
$dismiss_url = wp_nonce_url(
|
||||
add_query_arg('aksrt_dismiss_update', $remote, admin_url()),
|
||||
'aksrt_dismiss_update_' . $remote
|
||||
add_query_arg('jio_dismiss_update', $remote, admin_url()),
|
||||
'jio_dismiss_update_' . $remote
|
||||
);
|
||||
|
||||
echo '<div class="notice notice-info is-dismissible">';
|
||||
echo '<p><strong>' . esc_html__('AKSRT 主题更新', 'aksrt') . '</strong></p>';
|
||||
echo '<p><strong>' . esc_html__('Jio 主题更新', 'jio') . '</strong></p>';
|
||||
echo '<p>' . sprintf(
|
||||
esc_html__('新版本 %s 可用(当前版本 %s)。', 'aksrt'),
|
||||
esc_html__('新版本 %s 可用(当前版本 %s)。', 'jio'),
|
||||
'<strong>' . esc_html($remote) . '</strong>',
|
||||
esc_html($current)
|
||||
) . '</p>';
|
||||
@@ -141,10 +146,10 @@ class UpdateChecker {
|
||||
echo '<p>';
|
||||
if (!empty($download_url)) {
|
||||
echo '<a href="' . esc_url($download_url) . '" class="button button-primary" target="_blank">'
|
||||
. esc_html__('下载更新', 'aksrt') . '</a> ';
|
||||
. esc_html__('下载更新', 'jio') . '</a> ';
|
||||
}
|
||||
echo '<a href="' . esc_url($dismiss_url) . '" class="button">'
|
||||
. esc_html__('忽略此版本', 'aksrt') . '</a>';
|
||||
. esc_html__('忽略此版本', 'jio') . '</a>';
|
||||
echo '</p>';
|
||||
echo '</div>';
|
||||
}
|
||||
@@ -153,12 +158,12 @@ class UpdateChecker {
|
||||
* Handle dismiss action
|
||||
*/
|
||||
public static function handle_dismiss(): void {
|
||||
if (!isset($_GET['aksrt_dismiss_update'])) return;
|
||||
$version = sanitize_text_field($_GET['aksrt_dismiss_update']);
|
||||
if (!wp_verify_nonce($_GET['_wp_nonce'] ?? '', 'aksrt_dismiss_update_' . $version)) return;
|
||||
if (!isset($_GET['jio_dismiss_update'])) return;
|
||||
$version = sanitize_text_field($_GET['jio_dismiss_update']);
|
||||
if (!wp_verify_nonce($_GET['_wp_nonce'] ?? '', 'jio_dismiss_update_' . $version)) return;
|
||||
|
||||
update_user_meta(get_current_user_id(), 'aksrt_dismissed_update', $version);
|
||||
wp_safe_redirect(remove_query_arg(['aksrt_dismiss_update', '_wp_nonce']));
|
||||
update_user_meta(get_current_user_id(), 'jio_dismissed_update', $version);
|
||||
wp_safe_redirect(remove_query_arg(['jio_dismiss_update', '_wp_nonce']));
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user