I'm updating a WordPress plugin and using Plugin Check to detect errors. I'm getting the following error:
ERROR WordPress.DB.PreparedSQL.NotPrepared Use placeholders and $wpdb->prepare(); found $query
But my query already uses $wpdb->prepare()
. Here’s my code:
<?php
$query = 'SELECT * FROM ' . $wpdb->base_prefix . "picks WHERE pick_result <> '' AND tipster_id = %d";
if (!empty($where)) {
$query .= ' ' . esc_sql($where);
}
if (!empty($order)) {
$query .= ' ' . esc_sql($order);
}
if (!empty($limits)) {
$query .= ' ' . esc_sql($limits);
}
$tipster_picks = $wpdb->get_results($wpdb->prepare($query, $tipster), ARRAY_A);
Does anyone know why Plugin Check is flagging this as an error? Is there something wrong with how I'm handling $where
, $order
, or $limits
?
Thanks in advance!