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:
1 parent
d55d1c6b62
commit
68d2e78d77
40 files changed
+105
-105
No files matched your search
@@ -89,7 +89,7 @@ class Forum {
|
||||
private function draft_service(): DraftService {
|
||||
if (!$this->draft_svc) {
|
||||
// Draft service is loaded by bootstrap before this class.
|
||||
if (!class_exists('DraftService', false)) {
|
||||
if (!class_exists('AKSRT\\Forum\\DraftService', false)) {
|
||||
require_once __DIR__ . '/class-aksrt-forum-draft-service.php';
|
||||
}
|
||||
$this->draft_svc = new DraftService($this);
|
||||
|
||||
@@ -572,7 +572,7 @@ class PlateFollowPay {
|
||||
}
|
||||
|
||||
private function is_follow_pay_enabled(int $plate_id): bool {
|
||||
if (class_exists('Forum') && method_exists('Forum', 'is_plate_follow_pay_enabled')) {
|
||||
if (class_exists('AKSRT\\Forum\\Forum') && method_exists('AKSRT\\Forum\\Forum', 'is_plate_follow_pay_enabled')) {
|
||||
return (bool) Forum::get_instance()->is_plate_follow_pay_enabled($plate_id);
|
||||
}
|
||||
return (int) get_post_meta($plate_id, '_aksrt_follow_pay', true) === 1;
|
||||
@@ -582,7 +582,7 @@ class PlateFollowPay {
|
||||
* @return array{amount:float,modo:string,is_vip_price:bool,is_free:bool,label:string,base:float,vip_level:int}
|
||||
*/
|
||||
private function resolve_price(int $plate_id, int $user_id): array {
|
||||
if (class_exists('Forum') && method_exists('Forum', 'resolve_plate_follow_pay_price')) {
|
||||
if (class_exists('AKSRT\\Forum\\Forum') && method_exists('AKSRT\\Forum\\Forum', 'resolve_plate_follow_pay_price')) {
|
||||
return Forum::get_instance()->resolve_plate_follow_pay_price($plate_id, $user_id);
|
||||
}
|
||||
return [
|
||||
@@ -604,7 +604,7 @@ class PlateFollowPay {
|
||||
return function_exists('aksrt_guest_has_plate_follow_access')
|
||||
&& aksrt_guest_has_plate_follow_access($plate_id);
|
||||
}
|
||||
if (class_exists('Forum') && method_exists('Forum', 'is_user_following_plate')) {
|
||||
if (class_exists('AKSRT\\Forum\\Forum') && method_exists('AKSRT\\Forum\\Forum', 'is_user_following_plate')) {
|
||||
return (bool) Forum::get_instance()->is_user_following_plate($user_id, $plate_id);
|
||||
}
|
||||
$follow_list = get_user_meta($user_id, 'aksrt_follow_plate', true);
|
||||
@@ -615,7 +615,7 @@ class PlateFollowPay {
|
||||
}
|
||||
|
||||
private function mark_followed(int $user_id, int $plate_id): void {
|
||||
if (class_exists('Forum') && method_exists('Forum', 'mark_plate_followed')) {
|
||||
if (class_exists('AKSRT\\Forum\\Forum') && method_exists('AKSRT\\Forum\\Forum', 'mark_plate_followed')) {
|
||||
Forum::get_instance()->mark_plate_followed($user_id, $plate_id);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class PlateMetaBox {
|
||||
$roles_map = [];
|
||||
$applications = [];
|
||||
|
||||
if (class_exists('Forum')) {
|
||||
if (class_exists('AKSRT\\Forum\\Forum')) {
|
||||
$forum = Forum::get_instance();
|
||||
$moderator_ids = $forum->get_plate_moderators($plate_id);
|
||||
$roles_map = $forum->get_moderator_roles($plate_id);
|
||||
@@ -292,7 +292,7 @@ class PlateMetaBox {
|
||||
if ($status === 'pending') {
|
||||
return true;
|
||||
}
|
||||
return class_exists('Forum') && $status === Forum::APPLICATION_PENDING;
|
||||
return class_exists('AKSRT\\Forum\\Forum') && $status === Forum::APPLICATION_PENDING;
|
||||
}));
|
||||
if (!$pending) {
|
||||
echo '<p class="description">' . esc_html__('暂无待处理申请。', 'aksrt') . '</p>';
|
||||
@@ -495,7 +495,7 @@ class PlateMetaBox {
|
||||
$desired[$add_id] = $add_role;
|
||||
}
|
||||
|
||||
if (class_exists('Forum')) {
|
||||
if (class_exists('AKSRT\\Forum\\Forum')) {
|
||||
$forum = Forum::get_instance();
|
||||
$current = $forum->get_plate_moderators($post_id);
|
||||
foreach ($current as $uid) {
|
||||
@@ -527,7 +527,7 @@ class PlateMetaBox {
|
||||
$actions = isset($_POST['aksrt_plate_app']) && is_array($_POST['aksrt_plate_app'])
|
||||
? wp_unslash($_POST['aksrt_plate_app'])
|
||||
: [];
|
||||
if (!$actions || !class_exists('Forum')) {
|
||||
if (!$actions || !class_exists('AKSRT\\Forum\\Forum')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -576,7 +576,7 @@ class TopicPay {
|
||||
* @return array{amount:float,is_vip_price:bool,is_free:bool,label:string,base:float,vip_set:bool,vip_level:int}
|
||||
*/
|
||||
private function resolve_price(int $topic_id, int $user_id): array {
|
||||
if (class_exists('Forum')) {
|
||||
if (class_exists('AKSRT\\Forum\\Forum')) {
|
||||
return Forum::get_instance()->resolve_topic_pay_price($topic_id, $user_id);
|
||||
}
|
||||
return [
|
||||
@@ -594,7 +594,7 @@ class TopicPay {
|
||||
if ($user_id <= 0) {
|
||||
return function_exists('aksrt_guest_has_paid_access') && aksrt_guest_has_paid_access($topic_id);
|
||||
}
|
||||
if (class_exists('Forum')) {
|
||||
if (class_exists('AKSRT\\Forum\\Forum')) {
|
||||
return Forum::get_instance()->has_user_paid_topic($user_id, $topic_id);
|
||||
}
|
||||
if (class_exists('\AKSRT\Payment\Order')) {
|
||||
@@ -608,7 +608,7 @@ class TopicPay {
|
||||
}
|
||||
|
||||
private function mark_unlocked(int $user_id, int $topic_id): void {
|
||||
if (class_exists('Forum') && method_exists('Forum', 'mark_topic_unlocked')) {
|
||||
if (class_exists('AKSRT\\Forum\\Forum') && method_exists('AKSRT\\Forum\\Forum', 'mark_topic_unlocked')) {
|
||||
Forum::get_instance()->mark_topic_unlocked($user_id, $topic_id);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user