Make WordPress Core

Changeset 9315


Ignore:
Timestamp:
10/24/2008 05:47:55 AM (16 years ago)
Author:
ryan
Message:

use activate_plugin for error scraping, pass full WP_Error object to wp_die(), whitespace cleanups. Props DD32. fixes #7671

File:
1 edited

Legend:

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

    r9272 r9315  
    2929            $result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin);
    3030            if ( is_wp_error( $result ) )
    31                 wp_die( $result->get_error_message() );
     31                wp_die($result);
    3232            $recent = (array)get_option('recently_activated');
    33             if( isset($recent[ $plugin ]) ){
     33            if ( isset($recent[ $plugin ]) ) {
    3434                unset($recent[ $plugin ]);
    3535                update_option('recently_activated', $recent);
     
    4444            $recent = (array)get_option('recently_activated');
    4545            foreach( (array)$_POST['checked'] as $plugin => $time) {
    46                 if( isset($recent[ $plugin ]) )
     46                if ( isset($recent[ $plugin ]) )
    4747                    unset($recent[ $plugin ]);
    4848            }
     
    6060            error_reporting( E_ALL ^ E_NOTICE );
    6161            @ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
    62             include(WP_PLUGIN_DIR . '/' . $plugin);
     62            $result = activate_plugin($plugin, false);
     63            if ( is_wp_error( $result ) )
     64                wp_die($result);
    6365            exit;
    6466            break;
     
    7476            deactivate_plugins($_POST['checked']);
    7577            $deactivated = array();
    76             foreach( (array)$_POST['checked'] as $plugin )
     78            foreach ( (array)$_POST['checked'] as $plugin )
    7779                $deactivated[ $plugin ] = time();
    7880            update_option('recently_activated', $deactivated + (array)get_option('recently_activated'));
     
    8183            break;
    8284        case 'delete-selected':
    83             if( ! current_user_can('delete_plugins') )
     85            if ( ! current_user_can('delete_plugins') )
    8486                wp_die(__('You do not have sufficient permissions to delete plugins for this blog.'));
    8587
     
    9294            $parent_file = 'plugins.php';
    9395
    94             if( ! isset($_REQUEST['verify-delete']) ) {
     96            if ( ! isset($_REQUEST['verify-delete']) ) {
    9597                wp_enqueue_script('jquery');
    9698                require_once('admin-header.php');
     
    100102                <?php
    101103                    $files_to_delete = $plugin_info = array();
    102                     foreach( (array) $plugins as $plugin ) {
    103                         if( '.' == dirname($plugin) ) {
     104                    foreach ( (array) $plugins as $plugin ) {
     105                        if ( '.' == dirname($plugin) ) {
    104106                            $files_to_delete[] = WP_PLUGIN_DIR . '/' . $plugin;
    105107                            if( $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin) )
     
    121123                    <ul>
    122124                        <?php
    123                         foreach( $plugin_info as $plugin )
     125                        foreach ( $plugin_info as $plugin )
    124126                            echo '<li>', sprintf(__('%s by %s'), $plugin['Name'], $plugin['Author']), '</li>';
    125127                        ?>
     
    131133                    <input type="hidden" name="delete-selected" value="1" />
    132134                    <?php
    133                         foreach( (array)$plugins as $plugin )
     135                        foreach ( (array)$plugins as $plugin )
    134136                            echo '<input type="hidden" name="checked[]" value="' . attribute_escape($plugin) . '" />';
    135137                    ?>
     
    145147                    <ul>
    146148                    <?php
    147                         foreach( (array)$files_to_delete as $file )
     149                        foreach ( (array)$files_to_delete as $file )
    148150                            echo '<li>' . str_replace(WP_PLUGIN_DIR, '', $file) . '</li>';
    149151                    ?>
     
    173175
    174176$invalid = validate_active_plugins();
    175 if( !empty($invalid) )
    176     foreach($invalid as $plugin_file => $error)
     177if ( !empty($invalid) )
     178    foreach ( $invalid as $plugin_file => $error )
    177179        echo '<div id="message" class="error"><p>' . sprintf(__('The plugin <code>%s</code> has been <strong>deactivated</strong> due to an error: %s'), wp_specialchars($plugin_file), $error->get_error_message()) . '</p></div>';
    178180?>
     
    216218
    217219//Clean out any plugins which were deactivated over a week ago.
    218 foreach( $recently_activated as $key => $time )
    219     if( $time + (7*24*60*60) < time() ) //1 week
     220foreach ( $recently_activated as $key => $time )
     221    if ( $time + (7*24*60*60) < time() ) //1 week
    220222        unset($recently_activated[ $key ]);
    221 if( $recently_activated != get_option('recently_activated') ) //If array changed, update it.
     223if ( $recently_activated != get_option('recently_activated') ) //If array changed, update it.
    222224    update_option('recently_activated', $recently_activated);
    223225
    224 foreach( (array)$all_plugins as $plugin_file => $plugin_data) {
     226foreach ( (array)$all_plugins as $plugin_file => $plugin_data) {
    225227
    226228    //Translate, Apply Markup, Sanitize HTML
     
    273275<?php
    274276
    275     if( empty($plugins) ) {
     277    if ( empty($plugins) ) {
    276278        echo '<tr>
    277279            <td colspan="6">' . __('No plugins to show') . '</td>
    278280        </tr>';
    279281    }
    280     foreach( (array)$plugins as $plugin_file => $plugin_data) {
     282    foreach ( (array)$plugins as $plugin_file => $plugin_data) {
    281283        $action_links = array();
    282284
    283         if( 'active' == $context )
     285        if ( 'active' == $context )
    284286            $action_links[] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;plugin=' . $plugin_file, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '" class="delete">' . __('Deactivate') . '</a>';
    285287        else //Inactive or Recently deactivated
Note: See TracChangeset for help on using the changeset viewer.