Make WordPress Core

Ticket #5625: wp-admin_plugins.php.diff

File wp-admin_plugins.php.diff, 2.9 KB (added by arickmann, 17 years ago)

Plugins page from wp-admin/plugins.php

  • plugins.php

     
    2727                check_admin_referer('reactivate-all');
    2828                reactivate_all_plugins('plugins.php?errors=true');
    2929                wp_redirect('plugins.php?reactivate-all=true'); // overrides the ?error=true one above
     30        } elseif ( 'uninstall' == $_GET['action'] ) {
     31                check_admin_referer('uninstall-plugin_' . $_GET['plugin']);
     32                $current = get_option('active_plugins');
     33                $plugin = trim($_GET['plugin']);
     34                if ( validate_file($plugin) )
     35                        wp_die(__('Invalid plugin.'));
     36                if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )
     37                        wp_die(__('Plugin file does not exist.'));     
     38                if ( !in_array($plugin, $current ) && is_plugin_uninstallable( $plugin ) ) {   
     39                        $plugin_assets = get_plugin_assets( $plugin );
     40                        //check for a callback function
     41                        if ( $plugin_assets['callback'] != NULL ) {
     42                                //include the plugin file
     43                                include_once( ABSPATH . PLUGINDIR . '/' . $plugin );
     44                                //create and call the action
     45                                add_action( 'uninstall_plugin_' . $plugin , $plugin_assets['callback'] );
     46                                do_action( 'uninstall_plugin_' . $plugin );
     47                        }
     48                        if ( !delete_plugin_assets( $plugin ) ) {
     49                                wp_redirect('plugins.php?uninstalled=false');
     50                        }
     51                }
     52                wp_redirect('plugins.php?uninstalled=true');
    3053        }
    3154
    3255        exit;
     
    5982        <div id="message" class="updated fade"><p><?php _e('All plugins <strong>deactivated</strong>.'); ?></p></div>
    6083<?php elseif (isset($_GET['reactivate-all'])) : ?>
    6184        <div id="message" class="updated fade"><p><?php _e('All plugins <strong>reactivated</strong>.'); ?></p></div>
     85<?php elseif (isset($_GET['uninstalled']) && $_GET['uninstalled'] == 'true') : ?>
     86<div id="message" class="updated fade"><p><?php _e('Plugin <strong>uninstalled</strong>.'); ?></p></div>
     87<?php elseif (isset($_GET['uninstalled']) && $_GET['uninstalled'] != 'true') : ?>
     88<div id="message" class="updated fade">
     89<p><?php _e('The plugin could not be completely uninstalled. Some database tables, options or files may still exist.'); ?></p>
     90</div>
    6291<?php endif; ?>
    6392
    6493<div class="wrap">
     
    128157                <td>$edit</td>";
    129158                echo"
    130159        </tr>";
     160       
     161        if ( is_plugin_uninstallable( $plugin_file ) && (empty( $current_plugins ) || !in_array($plugin_file, $current_plugins) ) ) {
     162                $plugin_data = get_plugin_data( ABSPATH . PLUGINDIR . '/' . $plugin_file );
     163                $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>";
     164                        ?>
     165                        <tr>
     166                        <td colspan="5" style="border-top:1px solid #ccc; border-bottom:1px solid #ccc; background-color:#F9B7E0"><?php echo $toggle; ?></td>
     167                        </tr>
     168                        <?php
     169                        }               
     170       
     171       
     172       
    131173        do_action( 'after_plugin_row', $plugin_file );
    132174        }
    133175?>