Questions tagged «deactivated-plugin»

6
删除插件时从数据库中删除表
我创建了一个插件,并想添加一个函数,以在用户删除我的插件时从数据库中删除我的表。我创建了一个函数,当用户停用我的插件时,该函数将从数据库中删除表,但我不希望这样做。这是代码: // Delete table when deactivate function my_plugin_remove_database() { global $wpdb; $table_name = "NestoNovo"; $sql = "DROP TABLE IF EXISTS $table_name;"; $wpdb->query($sql); delete_option("my_plugin_db_version"); } register_deactivation_hook( __FILE__, 'my_plugin_remove_database' ); 如您所见,该功能在停用插件时会删除表,但是在删除插件时我需要这样做。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.