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
+10
-10
@@ -39,7 +39,7 @@ class Earn {
|
||||
}
|
||||
|
||||
public function on_user_register(int $user_id): void {
|
||||
if (!class_exists('PointsFree')) {
|
||||
if (!class_exists('AKSRT\\Credits\\PointsFree')) {
|
||||
return;
|
||||
}
|
||||
PointsFree::grant($user_id, 'sign_up', 0, ['type' => 'user', 'id' => $user_id]);
|
||||
@@ -54,7 +54,7 @@ class Earn {
|
||||
public function on_wp_login($user_login, $user = null): void {
|
||||
unset($user_login);
|
||||
$user_id = $user instanceof \WP_User ? (int) $user->ID : 0;
|
||||
if ($user_id <= 0 || !class_exists('PointsFree')) {
|
||||
if ($user_id <= 0 || !class_exists('AKSRT\\Credits\\PointsFree')) {
|
||||
return;
|
||||
}
|
||||
$today = (new \DateTimeImmutable('today', wp_timezone()))->format('Y-m-d');
|
||||
@@ -81,7 +81,7 @@ class Earn {
|
||||
return;
|
||||
}
|
||||
$user_id = (int) $post->post_author;
|
||||
if ($user_id <= 0 || !class_exists('PointsFree')) {
|
||||
if ($user_id <= 0 || !class_exists('AKSRT\\Credits\\PointsFree')) {
|
||||
return;
|
||||
}
|
||||
if (get_post_meta($post->ID, 'aksrt_credit_post_rewarded', true)) {
|
||||
@@ -118,7 +118,7 @@ class Earn {
|
||||
|
||||
private function reward_comment(\WP_Comment $comment): void {
|
||||
$user_id = (int) $comment->user_id;
|
||||
if ($user_id <= 0 || !class_exists('PointsFree')) {
|
||||
if ($user_id <= 0 || !class_exists('AKSRT\\Credits\\PointsFree')) {
|
||||
return;
|
||||
}
|
||||
if (get_comment_meta($comment->comment_ID, 'aksrt_credit_rewarded', true)) {
|
||||
@@ -150,7 +150,7 @@ class Earn {
|
||||
* @param bool $active
|
||||
*/
|
||||
public function on_post_liked(int $post_id, int $actor_id, bool $active): void {
|
||||
if (!$active || $post_id <= 0 || !class_exists('PointsFree')) {
|
||||
if (!$active || $post_id <= 0 || !class_exists('AKSRT\\Credits\\PointsFree')) {
|
||||
return;
|
||||
}
|
||||
$post = get_post($post_id);
|
||||
@@ -165,7 +165,7 @@ class Earn {
|
||||
}
|
||||
|
||||
public function on_post_favorited(int $post_id, int $actor_id, bool $active): void {
|
||||
if (!$active || $post_id <= 0 || !class_exists('PointsFree')) {
|
||||
if (!$active || $post_id <= 0 || !class_exists('AKSRT\\Credits\\PointsFree')) {
|
||||
return;
|
||||
}
|
||||
$post = get_post($post_id);
|
||||
@@ -180,7 +180,7 @@ class Earn {
|
||||
}
|
||||
|
||||
public function on_comment_liked(int $comment_id, int $actor_id, bool $active): void {
|
||||
if (!$active || $comment_id <= 0 || !class_exists('PointsFree')) {
|
||||
if (!$active || $comment_id <= 0 || !class_exists('AKSRT\\Credits\\PointsFree')) {
|
||||
return;
|
||||
}
|
||||
$comment = get_comment($comment_id);
|
||||
@@ -195,14 +195,14 @@ class Earn {
|
||||
}
|
||||
|
||||
public function on_user_followed(int $follower_id, int $following_id): void {
|
||||
if ($following_id <= 0 || $follower_id === $following_id || !class_exists('PointsFree')) {
|
||||
if ($following_id <= 0 || $follower_id === $following_id || !class_exists('AKSRT\\Credits\\PointsFree')) {
|
||||
return;
|
||||
}
|
||||
PointsFree::grant($following_id, 'followed', 0, ['type' => 'user', 'id' => $follower_id]);
|
||||
}
|
||||
|
||||
public function on_forum_topic_created(int $user_id, int $post_id): void {
|
||||
if ($user_id <= 0 || !class_exists('PointsFree')) {
|
||||
if ($user_id <= 0 || !class_exists('AKSRT\\Credits\\PointsFree')) {
|
||||
return;
|
||||
}
|
||||
PointsFree::grant($user_id, 'bbs_posts_new', 0, ['type' => 'post', 'id' => $post_id]);
|
||||
@@ -222,7 +222,7 @@ class Earn {
|
||||
return;
|
||||
}
|
||||
$user_id = (int) $comment->user_id;
|
||||
if ($user_id <= 0 || !class_exists('PointsFree')) {
|
||||
if ($user_id <= 0 || !class_exists('AKSRT\\Credits\\PointsFree')) {
|
||||
return;
|
||||
}
|
||||
if (get_comment_meta($comment_id, 'aksrt_credit_forum_reply', true)) {
|
||||
|
||||
Reference in new issue
Block a user