如果停用插件,则不会删除数据库表。只有当我删除插件时,它才会被删除。这是我的代码:
<?php
register_deactivation_hook( __FILE__, \'my_plugin_remove_database\' );
function my_plugin_remove_database() {
global $wpdb;
$table_name = $wpdb->prefix . \'sandbox\';
$sql = "DROP TABLE IF EXISTS $table_name";
$wpdb->query($sql);
delete_option("my_plugin_db_version");
} ?>