Skip to content

Commit 41a9086

Browse files
committed
fix: gamipress fetching utilities query issue
1 parent f755485 commit 41a9086

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

includes/Actions/GamiPress/GamiPressController.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static function fetchAllRankType()
6868
global $wpdb;
6969

7070
return $wpdb->get_results(
71-
"SELECT ID, post_name, post_title, post_type FROM wp_posts where post_type like 'rank_type' AND post_status = 'publish'"
71+
$wpdb->prepare("SELECT ID, post_name, post_title, post_type FROM %1s where post_type like 'rank-type' AND post_status = 'publish'", $wpdb->posts)
7272
);
7373
}
7474

@@ -78,7 +78,7 @@ public static function fetchAllRankBYType($query_params)
7878

7979
global $wpdb;
8080
$ranks = $wpdb->get_results(
81-
$wpdb->prepare("SELECT ID, post_name, post_title, post_type FROM wp_posts where post_type like %s AND post_status = 'publish'", $selectRankType)
81+
$wpdb->prepare("SELECT ID, post_name, post_title, post_type FROM %1s where post_type like %s AND post_status = 'publish'", $wpdb->posts, $selectRankType)
8282
);
8383

8484
wp_send_json_success($ranks);
@@ -89,7 +89,7 @@ public static function fetchAllAchievementType()
8989
global $wpdb;
9090

9191
return $wpdb->get_results(
92-
$wpdb->prepare("SELECT ID, post_name, post_title, post_type FROM %1s WHERE post_type LIKE %2s AND post_status = 'publish' ORDER BY post_title ASC", $wpdb->posts, 'achievement-type')
92+
$wpdb->prepare("SELECT ID, post_name, post_title, post_type FROM %1s WHERE post_type LIKE 'achievement-type' AND post_status = 'publish' ORDER BY post_title ASC", $wpdb->posts)
9393
);
9494
}
9595

@@ -99,17 +99,19 @@ public static function fetchAllAchievementBYType($query_params)
9999

100100
global $wpdb;
101101
$awards = $wpdb->get_results(
102-
$wpdb->prepare("SELECT ID, post_name, post_title, post_type FROM wp_posts where post_type like %s AND post_status = 'publish'", $selectAchievementType)
102+
$wpdb->prepare("SELECT ID, post_name, post_title, post_type FROM %1s where post_type like %s AND post_status = 'publish'", $wpdb->posts, $selectAchievementType)
103103
);
104+
104105
array_unshift($awards, ['ID' => 'Any', 'post_name' => 'any_achievement', 'post_title' => 'Any Achievement']);
106+
105107
wp_send_json_success($awards);
106108
}
107109

108110
public static function fetchAllPointType()
109111
{
110112
global $wpdb;
111113
$points = $wpdb->get_results(
112-
$wpdb->prepare("SELECT ID, post_name, post_title, post_type FROM %1s WHERE post_type LIKE %2s AND post_status = 'publish' ORDER BY post_title ASC", $wpdb->posts, 'points-type')
114+
$wpdb->prepare("SELECT ID, post_name, post_title, post_type FROM %1s WHERE post_type LIKE 'points-type' AND post_status = 'publish' ORDER BY post_title ASC", $wpdb->posts)
113115
);
114116
wp_send_json_success($points);
115117
}

0 commit comments

Comments
 (0)