So I have a WP plugin that one of my devs built some time ago which has some php like this:
foreach ((array)$docs as $key => $file)
{
if ((int)$file === 0)
{
$results = $wpdb->get_var($wpdb->prepare(
'SELECT id FROM wp_posts WHERE guid = %s',
$file
));
if ((int)$results !== 0)
{
$settings['docs'][$type][] = (int)$results;
}
}
else
{
$settings['docs'][$type][] = (int)$file;
}
}
Problem is that the database prefix has been changed by the Security plugin. I know that I can update wp_posts above with the new prefix such as abcdef_post, but there’s gotta be a more appropriate way of doing this in a plugin. What is proper in this case?