I'm new in Wordpress and I have a function that drop the tables of my plugin on DB.
<?php
if (! defined('WP_UNINSTALL_PLUGIN')) {
exit;
}
// Uninstallation actions here
global $wpdb;
$table_names = [
$wpdb->prefix . "questions",
$wpdb->prefix . "difficulties",
$wpdb->prefix . "modalities",
$wpdb->prefix . "fields",
$wpdb->prefix . "themes",
$wpdb->prefix . "subjects",
$wpdb->prefix . "disciplines",
$wpdb->prefix . "training_areas",
$wpdb->prefix . "levels",
$wpdb->prefix . "roles",
$wpdb->prefix . "banks",
];
foreach ($table_names as $table_name) {
$wpdb->query("DROP TABLE IF EXISTS $table_name");
}
But when I delete the plugin on admin, it shows this error:
It does drop all the tables, but how I make to stop this error?