Index: plugins.php
===================================================================
--- plugins.php	(revision 6603)
+++ plugins.php	(working copy)
@@ -27,6 +27,29 @@
 		check_admin_referer('reactivate-all');
 		reactivate_all_plugins('plugins.php?errors=true');
 		wp_redirect('plugins.php?reactivate-all=true'); // overrides the ?error=true one above
+	} elseif ( 'uninstall' == $_GET['action'] ) {
+		check_admin_referer('uninstall-plugin_' . $_GET['plugin']);
+		$current = get_option('active_plugins');
+		$plugin = trim($_GET['plugin']);
+		if ( validate_file($plugin) )
+			wp_die(__('Invalid plugin.'));
+		if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )
+			wp_die(__('Plugin file does not exist.'));	
+		if ( !in_array($plugin, $current ) && is_plugin_uninstallable( $plugin ) ) {	
+			$plugin_assets = get_plugin_assets( $plugin );
+			//check for a callback function
+			if ( $plugin_assets['callback'] != NULL ) {
+				//include the plugin file
+				include_once( ABSPATH . PLUGINDIR . '/' . $plugin );
+				//create and call the action
+				add_action( 'uninstall_plugin_' . $plugin , $plugin_assets['callback'] );
+				do_action( 'uninstall_plugin_' . $plugin );
+			}
+			if ( !delete_plugin_assets( $plugin ) ) {
+				wp_redirect('plugins.php?uninstalled=false');
+			}
+		}
+		wp_redirect('plugins.php?uninstalled=true');
 	}
 
 	exit;
@@ -59,6 +82,12 @@
 	<div id="message" class="updated fade"><p><?php _e('All plugins <strong>deactivated</strong>.'); ?></p></div>
 <?php elseif (isset($_GET['reactivate-all'])) : ?>
 	<div id="message" class="updated fade"><p><?php _e('All plugins <strong>reactivated</strong>.'); ?></p></div>
+<?php elseif (isset($_GET['uninstalled']) && $_GET['uninstalled'] == 'true') : ?>
+<div id="message" class="updated fade"><p><?php _e('Plugin <strong>uninstalled</strong>.'); ?></p></div>
+<?php elseif (isset($_GET['uninstalled']) && $_GET['uninstalled'] != 'true') : ?>
+<div id="message" class="updated fade">
+<p><?php _e('The plugin could not be completely uninstalled. Some database tables, options or files may still exist.'); ?></p>
+</div>
 <?php endif; ?>
 
 <div class="wrap">
@@ -128,6 +157,19 @@
 		<td>$edit</td>";
 		echo"
 	</tr>";
+	
+	if ( is_plugin_uninstallable( $plugin_file ) && (empty( $current_plugins ) || !in_array($plugin_file, $current_plugins) ) ) {
+		$plugin_data = get_plugin_data( ABSPATH . PLUGINDIR . '/' . $plugin_file );
+		$toggle = "<a href='" . wp_nonce_url("plugins.php?action=uninstall&amp;plugin=$plugin_file", 'uninstall-plugin_' . $plugin_file) . "' title='".__('Uninstall this plugin')."' class='delete'><strong>".__("Uninstall all the options and settings (including database tables ) relating to ").$plugin_data['Name']."</strong></a>";
+			?>
+			<tr>
+			<td colspan="5" style="border-top:1px solid #ccc; border-bottom:1px solid #ccc; background-color:#F9B7E0"><?php echo $toggle; ?></td>
+			</tr>
+			<?php
+			}		
+	
+	
+	
 	do_action( 'after_plugin_row', $plugin_file );
 	}
 ?>
