Plugin Uninstall and Deactivate via Options Menu

You just need to obtain the basename of any plugin to deactivate it.

if( $uninstall == true ) {
    delete_option( 'CHANGETHIS' );
    deactivate_plugins( plugin_basename( __FILE__ ) );
}

Generally they look like mypluginfolder/mypluginmasterfile.php

Give that a shot.


There are a variety of ways to getting it to work.

If you want a button on the options page to call that, you could just POST to the options page and check to see if the uninstall button was clicked.

Something like:

$uninstall = isset( $_POST[ 'uninstall' ] ) ? true : false;