WordPress.org

Ready to get started?Download WordPress

Forums

Uninstall.php for my plugin (2 posts)

  1. Evan Herman
    Member
    Posted 11 months 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:

    Codex:

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

    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
    Member
    Posted 11 months 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.

Reply

You must log in to post.

About this Topic