Merge pull request 'fix(ns): root-qualify WP_* classes after PSR-4 move' (#198) from fix/ns-root-wp-classes into main
Reviewed-on: CYL/wordpress-theme-aksrt#198
This commit is contained in:
@@ -124,7 +124,7 @@ class CommentController extends ControllerBase {
|
||||
$args['search'] = $search;
|
||||
}
|
||||
|
||||
$query = new WP_Comment_Query($args);
|
||||
$query = new \WP_Comment_Query($args);
|
||||
|
||||
// Batch prefetch to avoid N+1 queries
|
||||
$user_ids = array_unique(array_filter(array_map(fn($c) => (int) $c->user_id, $query->comments)));
|
||||
@@ -151,7 +151,7 @@ class CommentController extends ControllerBase {
|
||||
$count_args = $args;
|
||||
unset($count_args['number'], $count_args['offset'], $count_args['orderby'], $count_args['order']);
|
||||
$count_args['count'] = true;
|
||||
$total = (int) (new WP_Comment_Query($count_args))->get_comments('count');
|
||||
$total = (int) (new \WP_Comment_Query($count_args))->get_comments('count');
|
||||
|
||||
return $this->success([
|
||||
'data' => $comments,
|
||||
@@ -341,7 +341,7 @@ class CommentController extends ControllerBase {
|
||||
'hierarchical' => 'threaded',
|
||||
];
|
||||
|
||||
$query = new WP_Comment_Query($args);
|
||||
$query = new \WP_Comment_Query($args);
|
||||
|
||||
// Batch prefetch users
|
||||
$user_ids = array_unique(array_filter(array_map(fn($c) => (int) $c->user_id, $query->comments)));
|
||||
@@ -374,7 +374,7 @@ class CommentController extends ControllerBase {
|
||||
/**
|
||||
* Format comment for admin views.
|
||||
*/
|
||||
private function format_comment(WP_Comment $comment, array $users_map = [], array $posts_map = []): array {
|
||||
private function format_comment(\WP_Comment $comment, array $users_map = [], array $posts_map = []): array {
|
||||
$uid = (int) $comment->user_id;
|
||||
$pid = (int) $comment->comment_post_ID;
|
||||
$user = $users_map[$uid] ?? ($uid ? get_userdata($uid) : null);
|
||||
@@ -398,7 +398,7 @@ class CommentController extends ControllerBase {
|
||||
/**
|
||||
* Format comment for public views (no email/IP).
|
||||
*/
|
||||
private function format_comment_public(WP_Comment $comment, array $users_map = []): array {
|
||||
private function format_comment_public(\WP_Comment $comment, array $users_map = []): array {
|
||||
$uid = (int) $comment->user_id;
|
||||
$user = $users_map[$uid] ?? ($uid ? get_userdata($uid) : null);
|
||||
return [
|
||||
|
||||
@@ -331,7 +331,7 @@ trait UserControllerReportOperations {
|
||||
}
|
||||
} elseif ($target_type === 'comment') {
|
||||
$comment = get_comment($target_id);
|
||||
if ($comment instanceof WP_Comment) {
|
||||
if ($comment instanceof \WP_Comment) {
|
||||
$summary['display_name'] = (string) $comment->comment_author;
|
||||
$summary['excerpt'] = wp_trim_words(wp_strip_all_tags((string) $comment->comment_content), 24);
|
||||
$summary['status'] = $comment->comment_approved === '1' ? 'approved' : (string) $comment->comment_approved;
|
||||
|
||||
@@ -261,7 +261,7 @@ class Moderation {
|
||||
*/
|
||||
public function after_post(int $comment_id, $comment_approved, array $commentdata = []): void {
|
||||
$comment = get_comment($comment_id);
|
||||
if (!$comment instanceof WP_Comment) {
|
||||
if (!$comment instanceof \WP_Comment) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ trait ModerationPart1 {
|
||||
}
|
||||
}
|
||||
|
||||
private function resolve_result_from_runtime_or_default(array $commentdata, WP_Comment $comment): array {
|
||||
private function resolve_result_from_runtime_or_default(array $commentdata, \WP_Comment $comment): array {
|
||||
$fp_data = $this->comment_fingerprint($commentdata);
|
||||
if ($fp_data !== '' && isset($this->moderation_result_map[$fp_data])) {
|
||||
return $this->moderation_result_map[$fp_data];
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -109,7 +109,7 @@ class CommentService {
|
||||
/**
|
||||
* Render forum comments HTML for AJAX and initial load.
|
||||
*
|
||||
* @param WP_Comment[] $comments Comments (parents + children mixed).
|
||||
* @param \WP_Comment[] $comments Comments (parents + children mixed).
|
||||
* @param int $topic_id Topic post ID.
|
||||
* @param int $adopted_id Adopted comment ID (0 if none).
|
||||
*/
|
||||
@@ -366,7 +366,7 @@ class CommentService {
|
||||
* @param bool $author_only Only show post-author replies.
|
||||
* @param int $page Page number.
|
||||
* @param int $per_page Items per page.
|
||||
* @return array{comments:WP_Comment[],total:int,max_pages:int,page:int,adopted_id:int}
|
||||
* @return array{comments:\WP_Comment[],total:int,max_pages:int,page:int,adopted_id:int}
|
||||
*/
|
||||
public function get_forum_comments(int $topic_id, string $sort = 'newest', bool $author_only = false, int $page = 1, int $per_page = 30): array {
|
||||
$post = get_post($topic_id);
|
||||
|
||||
@@ -124,7 +124,7 @@ trait CategoryIntegrationGroups {
|
||||
/**
|
||||
* Customizer 注册(可选)
|
||||
*/
|
||||
public function customizer(WP_Customize_Manager $wp_customize): void {
|
||||
public function customizer(\WP_Customize_Manager $wp_customize): void {
|
||||
$wp_customize->add_setting('blogname', ['default' => get_bloginfo('name'), 'type' => 'option']);
|
||||
|
||||
$wp_customize->add_setting('aksrt_logo', [
|
||||
@@ -132,7 +132,7 @@ trait CategoryIntegrationGroups {
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
'transport' => 'postMessage',
|
||||
]);
|
||||
$wp_customize->add_control(new WP_Customize_Image_Control(
|
||||
$wp_customize->add_control(new \WP_Customize_Image_Control(
|
||||
$wp_customize,
|
||||
'aksrt_logo',
|
||||
['label' => __('Logo', 'aksrt'), 'section' => 'title_tagline']
|
||||
@@ -143,7 +143,7 @@ trait CategoryIntegrationGroups {
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
'transport' => 'postMessage',
|
||||
]);
|
||||
$wp_customize->add_control(new WP_Customize_Upload_Control(
|
||||
$wp_customize->add_control(new \WP_Customize_Upload_Control(
|
||||
$wp_customize,
|
||||
'aksrt_favicon',
|
||||
['label' => __('Favicon', 'aksrt'), 'section' => 'title_tagline']
|
||||
|
||||
Reference in New Issue
Block a user