fix(ns): root-qualify WP_* classes after PSR-4 move
Bare WP_REST_Server etc. resolve under AKSRT\* namespaces; prefix with \ for Balance REST and other type hints / constructors.
This commit is contained in:
1 parent
d3107a449b
commit
1e21911b03
9 files changed
+27
-27
No files matched your search
@@ -14,14 +14,14 @@ trait BalanceServiceRest {
|
||||
public function register_routes(): void {
|
||||
register_rest_route('aksrt/v1', '/pay/balance/charge', [
|
||||
[
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'methods' => \WP_REST_Server::READABLE,
|
||||
'callback' => [$this, 'rest_charge_options'],
|
||||
'permission_callback' => static function () {
|
||||
return is_user_logged_in();
|
||||
},
|
||||
],
|
||||
[
|
||||
'methods' => WP_REST_Server::CREATABLE,
|
||||
'methods' => \WP_REST_Server::CREATABLE,
|
||||
'callback' => [$this, 'rest_charge_create'],
|
||||
'permission_callback' => static function () {
|
||||
return is_user_logged_in();
|
||||
@@ -31,7 +31,7 @@ trait BalanceServiceRest {
|
||||
|
||||
register_rest_route('aksrt/v1', '/pay/transfer', [
|
||||
[
|
||||
'methods' => WP_REST_Server::CREATABLE,
|
||||
'methods' => \WP_REST_Server::CREATABLE,
|
||||
'callback' => [$this, 'rest_transfer'],
|
||||
'permission_callback' => static function () {
|
||||
return is_user_logged_in();
|
||||
@@ -41,7 +41,7 @@ trait BalanceServiceRest {
|
||||
|
||||
register_rest_route('aksrt/v1', '/pay/transfer/search', [
|
||||
[
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'methods' => \WP_REST_Server::READABLE,
|
||||
'callback' => [$this, 'rest_transfer_search'],
|
||||
'permission_callback' => static function () {
|
||||
return is_user_logged_in();
|
||||
@@ -51,7 +51,7 @@ trait BalanceServiceRest {
|
||||
|
||||
register_rest_route('aksrt/v1', '/pay/balance/exchange', [
|
||||
[
|
||||
'methods' => WP_REST_Server::CREATABLE,
|
||||
'methods' => \WP_REST_Server::CREATABLE,
|
||||
'callback' => [$this, 'rest_exchange_from_credits'],
|
||||
'permission_callback' => static function () {
|
||||
return is_user_logged_in();
|
||||
@@ -61,14 +61,14 @@ trait BalanceServiceRest {
|
||||
|
||||
register_rest_route('aksrt/v1', '/pay/points/buy', [
|
||||
[
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'methods' => \WP_REST_Server::READABLE,
|
||||
'callback' => [$this, 'rest_points_buy_options'],
|
||||
'permission_callback' => static function () {
|
||||
return is_user_logged_in();
|
||||
},
|
||||
],
|
||||
[
|
||||
'methods' => WP_REST_Server::CREATABLE,
|
||||
'methods' => \WP_REST_Server::CREATABLE,
|
||||
'callback' => [$this, 'rest_points_buy_create'],
|
||||
'permission_callback' => static function () {
|
||||
return is_user_logged_in();
|
||||
@@ -78,7 +78,7 @@ trait BalanceServiceRest {
|
||||
|
||||
register_rest_route('aksrt/v1', '/pay/balance/withdraw', [
|
||||
[
|
||||
'methods' => WP_REST_Server::CREATABLE,
|
||||
'methods' => \WP_REST_Server::CREATABLE,
|
||||
'callback' => [$this, 'rest_balance_withdraw'],
|
||||
'permission_callback' => static function () {
|
||||
return is_user_logged_in();
|
||||
@@ -261,7 +261,7 @@ trait BalanceServiceRest {
|
||||
return rest_ensure_response(['success' => true, 'data' => ['users' => []]]);
|
||||
}
|
||||
$exclude = [get_current_user_id()];
|
||||
$q = new WP_User_Query([
|
||||
$q = new \WP_User_Query([
|
||||
'search' => '*' . $s . '*',
|
||||
'search_columns' => ['user_login', 'user_nicename', 'display_name', 'user_email'],
|
||||
'exclude' => $exclude,
|
||||
|
||||
@@ -263,7 +263,7 @@ class Credits {
|
||||
$q['search'] = '*' . esc_attr((string) $args['search']) . '*';
|
||||
$q['search_columns'] = ['user_login', 'user_email', 'display_name', 'user_nicename'];
|
||||
}
|
||||
$user_query = new WP_User_Query($q);
|
||||
$user_query = new \WP_User_Query($q);
|
||||
$users = $user_query->get_results();
|
||||
$items = [];
|
||||
foreach ($users as $u) {
|
||||
|
||||
@@ -101,8 +101,8 @@ class Earn {
|
||||
if ($on_approved) {
|
||||
return;
|
||||
}
|
||||
$comment = $comment instanceof WP_Comment ? $comment : get_comment($comment_id);
|
||||
if (!($comment instanceof WP_Comment) || (int) $comment->comment_approved !== 1) {
|
||||
$comment = $comment instanceof \WP_Comment ? $comment : get_comment($comment_id);
|
||||
if (!($comment instanceof \WP_Comment) || (int) $comment->comment_approved !== 1) {
|
||||
return;
|
||||
}
|
||||
$this->reward_comment($comment);
|
||||
@@ -110,13 +110,13 @@ class Earn {
|
||||
|
||||
public function on_comment_transition($new_status, $old_status, $comment): void {
|
||||
unset($old_status);
|
||||
if ($new_status !== 'approved' || !($comment instanceof WP_Comment)) {
|
||||
if ($new_status !== 'approved' || !($comment instanceof \WP_Comment)) {
|
||||
return;
|
||||
}
|
||||
$this->reward_comment($comment);
|
||||
}
|
||||
|
||||
private function reward_comment(WP_Comment $comment): void {
|
||||
private function reward_comment(\WP_Comment $comment): void {
|
||||
$user_id = (int) $comment->user_id;
|
||||
if ($user_id <= 0 || !class_exists('PointsFree')) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user