As explained in my comment in the Question, the error is certainly in how the DROP TABLE
is being performed. But answering to How does uninstalling WordPress plugins work?:
If we do a register_uninstall_hook
in our plugin, the callback is stored in the option uninstall_plugins
in /wp-includes/plugin.php
.
$uninstallable_plugins[plugin_basename($file)] = $callback;
update_option('uninstall_plugins', $uninstallable_plugins);
In the PHPDoc for the function register_uninstall_hook
we have this:
This file (uninstall.php) will be called, if it exists, during the uninstall process bypassing the uninstall hook.
And the bypass happens in /wp-admin/includes/plugin.php
:
define('WP_UNINSTALL_PLUGIN', $file);
include WP_PLUGIN_DIR . "https://wordpress.stackexchange.com/" . dirname($file) . '/uninstall.php';
return true;
So, whatever you have in the uninstall hook or file, it should work by its own. If it does, it will work when the uninstall happens.