我一直在寻找冲突的方式为您的插件编写一个uninstall.php文件。我知道如何delete_options,我只是不确定我的uninstall.php的开头是否正确。我发现有两篇文章说要采取不同的做法:
法典:
//if uninstall not called from WordPress exit
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
exit ();
delete_option('example');和替代源(wptuts):
if(defined('WP_UNINSTALL_PLUGIN') ){
//delete options, tables or anything else
}那么哪种方法是正确的呢?我倾向于使用wptuts的方式,但这只是因为这对我来说似乎更有意义。谢谢各位
发布于 2013-08-30 18:57:17
这也是一样的。
IF exists DO something
==
IF not exists DO nothing应该缩进或写入exit(),如
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
// not defined, abort
exit ();
}
// it was defined, now delete
delete_option('example');https://stackoverflow.com/questions/18539462
复制相似问题