WordPress.org

Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/plugins.php

    r4664 r5239  
    1212            wp_die(__('Plugin file does not exist.'));
    1313        if (!in_array($plugin, $current)) {
     14            wp_redirect('plugins.php?error=true'); // we'll override this later if the plugin can be included without fatal error
     15            ob_start();
     16            @include(ABSPATH . PLUGINDIR . '/' . $plugin);
    1417            $current[] = $plugin;
    1518            sort($current);
    1619            update_option('active_plugins', $current);
    17             include(ABSPATH . PLUGINDIR . '/' . $plugin);
    1820            do_action('activate_' . $plugin);
     21            ob_end_clean();
    1922        }
    20         wp_redirect('plugins.php?activate=true');
     23        wp_redirect('plugins.php?activate=true'); // overrides the ?error=true one above
    2124    } else if ('deactivate' == $_GET['action']) {
    2225        check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
     
    2629        do_action('deactivate_' . trim( $_GET['plugin'] ));
    2730        wp_redirect('plugins.php?deactivate=true');
     31    } elseif ($_GET['action'] == 'deactivate-all') {
     32        check_admin_referer('deactivate-all');
     33        $current = get_option('active_plugins');
     34       
     35        foreach ($current as $plugin) {
     36            array_splice($current, array_search($plugin, $current), 1);
     37            do_action('deactivate_' . $plugin);
     38        }
     39       
     40        update_option('active_plugins', array());
     41        wp_redirect('plugins.php?deactivate-all=true');
    2842    }
    2943    exit;
     
    5973?>
    6074
    61 <?php if (isset($_GET['activate'])) : ?>
    62 <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p>
    63 </div>
    64 <?php endif; ?>
    65 <?php if (isset($_GET['deactivate'])) : ?>
    66 <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p>
    67 </div>
     75<?php if ( isset($_GET['error']) ) : ?>
     76    <div id="message" class="updated fade"><p><?php _e('Plugin could not be activated because it triggered a <strong>fatal error</strong>.') ?></p></div>
     77<?php elseif ( isset($_GET['activate']) ) : ?>
     78    <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
     79<?php elseif ( isset($_GET['deactivate']) ) : ?>
     80    <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div>
     81<?php elseif (isset($_GET['deactivate-all'])) : ?>
     82    <div id="message" class="updated fade"><p><?php _e('All plugins <strong>deactivated</strong>.'); ?></p></div>
    6883<?php endif; ?>
    6984
     
    117132        if ( $style != '' )
    118133            $style = 'class="' . $style . '"';
    119         if ( is_writable(ABSPATH . 'wp-content/plugins/' . $plugin_file) )
     134        if ( is_writable(ABSPATH . PLUGINDIR . '/' . $plugin_file) )
    120135            $edit = "<a href='plugin-editor.php?file=$plugin_file' title='".__('Open this file in the Plugin Editor')."' class='edit'>".__('Edit')."</a>";
    121136        else
     
    136151?>
    137152
     153<tr>
     154    <td colspan="3">&nbsp;</td>
     155    <td colspan="2" style="width:12em;"><a href="<?php echo wp_nonce_url('plugins.php?action=deactivate-all', 'deactivate-all'); ?>" class="delete"><?php _e('Deactivate All Plugins'); ?></a></td>
     156</tr>
     157
    138158</table>
    139159<?php
Note: See TracChangeset for help on using the changeset viewer.