WordPress不会删除表格上的插件取消激活
问题描述:
所以我做了这个功能,当我的自定义插件被停用并且它不工作时,删除一个表格。哪里不对?它正在进入功能并且表名是正确的。WordPress不会删除表格上的插件取消激活
function my_plugin_remove_database() {
global $wpdb;
$table_name = $wpdb->prefix . 'makes';
$sql = "DROP TABLE IF EXISTS $table_name";
$wpdb->query($sql);
}
register_deactivation_hook(__FILE__, 'my_plugin_remove_database');
答
function pluginUninstall() {
global $wpdb;
$table = $wpdb->prefix."park";
//Delete any options thats stored also?
//delete_option('wp_yourplugin_version');
$wpdb->query("DROP TABLE IF EXISTS $table");
}//end pluginUninstall function
//hook into WordPress when its being deactivated:
register_deactivation_hook(__FILE__, 'pluginUninstall');`enter code here`