Uninstall.php for my plugin (2 posts)

  1. Evan Herman
    Posted 2 years ago #

    I keep finding conflicting ways to write an uninstall.php file for your plugin. I know how to delete_options, I'm just not sure If the beginning of my uninstall.php is correct. I've found two articles that say to do it differently:


    //if uninstall not called from WordPress exit
    if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
    	exit ();

    and alternate source (wptuts):

    if(defined('WP_UNINSTALL_PLUGIN') ){  
      //delete options, tables or anything else  

    So which is the correct way? I'm leaning towards the wptuts way, but only because it seems to make a bit more sense to me.
    Thanks guys

  2. Rod Whiteley
    Posted 2 years ago #

    I prefer the second way if there is not much code. But I prefer the first way if there is a lot of code, because I do not like { and } to be far apart.

Topic Closed

This topic has been closed to new replies.

About this Topic