我是Wordpress的新手,我有一个函数可以将我插件的表放到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");
}
但当我删除admin上的插件时,它显示了以下错误:
它确实删除了所有的表,但是我如何阻止这个错误呢?