这将为您提供在插件激活期间注册unistall挂钩的选项。
function myplugin_activation_callback(){
register_uninstall_hook( __FILE__, \'myplugin_uninstall_callback\' );
}
register_activation_hook( __FILE__, \'myplugin_activation_callback\' );
function myplugin_uninstall_callback(){
//Perform your uninstall operations here
delete_option(\'test_option\');
}
然而,最简单的方法是使用
uninstall.php
使用以下代码归档:
if (!defined(\'WP_UNINSTALL_PLUGIN\')) {
die;
}
//Perform your uninstall operations here
delete_option(\'test_option\');
不建议同时使用两者。