fix(ns): class_exists() must use FQCN after PSR-4

Bare class_exists('Balance') looks up global Balance, always false
under AKSRT\* namespaces → REST 403 on balance exchange and friends.
Rewrite string checks to AKSRT\{Domain}\{Class}.
This commit is contained in:
kate522 committed 2026-07-17 15:40:20 +08:00
1 parent d55d1c6b62
commit 68d2e78d77
40 files changed
+105 -105

No files matched your search

+6 -6
View File
@@ -489,7 +489,7 @@ class PostMetaBox {
* Content-pay sales summary for posts list (zibll 销售数据 column parity).
*/
private function render_sales_column(int $post_id): void {
if (!function_exists('aksrt_get_pay_meta') || !class_exists('DomainModel')) {
if (!function_exists('aksrt_get_pay_meta') || !class_exists('AKSRT\\Core\\DomainModel')) {
echo '—';
return;
}
@@ -549,7 +549,7 @@ class PostMetaBox {
* Dropdown filter for content pay_type on edit.php?post_type=post.
*/
public function render_pay_type_filter(string $post_type): void {
if ($post_type !== 'post' || !class_exists('DomainModel')) {
if ($post_type !== 'post' || !class_exists('AKSRT\\Core\\DomainModel')) {
return;
}
$current = isset($_GET['aksrt_pay_type']) ? sanitize_key((string) wp_unslash($_GET['aksrt_pay_type'])) : '';
@@ -582,7 +582,7 @@ class PostMetaBox {
return;
}
$pay_type = sanitize_key((string) wp_unslash($_GET['aksrt_pay_type']));
if ($pay_type === '' || !class_exists('DomainModel')) {
if ($pay_type === '' || !class_exists('AKSRT\\Core\\DomainModel')) {
return;
}
$pay_type = DomainModel::normalize_pay_type($pay_type);
@@ -663,7 +663,7 @@ class PostMetaBox {
<select name="aksrt_bulk_pay_type" class="aksrt-bulk-pay-type">
<option value="-1"><?php esc_html_e('— 不更改 —', 'aksrt'); ?></option>
<?php
$pay_labels = class_exists('DomainModel') ? DomainModel::pay_type_labels() : [];
$pay_labels = class_exists('AKSRT\\Core\\DomainModel') ? DomainModel::pay_type_labels() : [];
foreach ($pay_labels as $k => $lab) :
?>
<option value="<?php echo esc_attr($k); ?>"><?php echo esc_html($lab); ?></option>
@@ -701,7 +701,7 @@ class PostMetaBox {
* Only non-sentinel fields are written; omit to keep existing.
*/
private function save_bulk_pay_fields(int $post_id): void {
if (!class_exists('DomainModel') || !function_exists('aksrt_get_pay_meta')) {
if (!class_exists('AKSRT\\Core\\DomainModel') || !function_exists('aksrt_get_pay_meta')) {
return;
}
if (!current_user_can('edit_post', $post_id)) {
@@ -746,7 +746,7 @@ class PostMetaBox {
update_post_meta($post_id, DomainModel::PAY_META_KEY, $meta);
update_post_meta($post_id, DomainModel::PAY_TYPE_KEY, (string) ($meta['pay_type'] ?? DomainModel::PAY_TYPE_NO));
update_post_meta($post_id, DomainModel::PAY_PRICE_KEY, (float) ($meta['price'] ?? 0));
if (class_exists('DomainModel') && method_exists('DomainModel', 'is_resource_pay_type')) {
if (class_exists('AKSRT\\Core\\DomainModel') && method_exists('AKSRT\\Core\\DomainModel', 'is_resource_pay_type')) {
update_post_meta(
$post_id,
DomainModel::RESOURCE_MARKER_KEY,
+1 -1
View File
@@ -486,7 +486,7 @@ class ResourceMetaBox {
$gallery = $this->parse_json_array($_POST['aksrt_pay_gallery'] ?? '');
// 清洗下载源
if ($downloads !== null && class_exists('Setup') && method_exists('Setup', 'sanitize_downloads_meta')) {
if ($downloads !== null && class_exists('AKSRT\\Core\\Setup') && method_exists('AKSRT\\Core\\Setup', 'sanitize_downloads_meta')) {
$downloads = Setup::sanitize_downloads_meta($downloads);
}
+2 -2
View File
@@ -260,7 +260,7 @@ class Shortcodes {
* [aksrt_archive] 文章归档
*/
public function render_archive(array $atts = [], string $content = ''): string {
if (!class_exists('Templates')) {
if (!class_exists('AKSRT\\Core\\Templates')) {
return '';
}
return Templates::get_instance()->render_archive_shortcode($atts, $content);
@@ -270,7 +270,7 @@ class Shortcodes {
* [aksrt_profile] 个人资料卡
*/
public function render_profile(array $atts = [], string $content = ''): string {
if (!class_exists('Templates')) {
if (!class_exists('AKSRT\\Core\\Templates')) {
return '';
}
return Templates::get_instance()->render_profile_shortcode($atts, $content);