Make WordPress Core

Changeset 5753


Ignore:
Timestamp:
06/25/2007 06:57:54 PM (18 years ago)
Author:
markjaquith
Message:

Display fatal errors that prevent plugins from being activated. fixes #4508

File:
1 edited

Legend:

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

    r5700 r5753  
    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
     14            wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), 'plugins.php?error=true&plugin=' . $plugin)); // we'll override this later if the plugin can be included without fatal error
    1515            ob_start();
    1616            @include(ABSPATH . PLUGINDIR . '/' . $plugin);
     
    2222        }
    2323        wp_redirect('plugins.php?activate=true'); // overrides the ?error=true one above
    24     } else if ('deactivate' == $_GET['action']) {
     24    } elseif ('error_scrape' == $_GET['action']) {
     25        $plugin = trim($_GET['plugin']);
     26        check_admin_referer('plugin-activation-error_' . $plugin);
     27        if ( validate_file($plugin) )
     28            wp_die(__('Invalid plugin.'));
     29        if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )
     30            wp_die(__('Plugin file does not exist.'));
     31        include(ABSPATH . PLUGINDIR . '/' . $plugin);
     32    } elseif ('deactivate' == $_GET['action']) {
    2533        check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
    2634        $current = get_option('active_plugins');
     
    7482
    7583<?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>
     84    <div id="message" class="updated fade"><p><?php _e('Plugin could not be activated because it triggered a <strong>fatal error</strong>.') ?></p>
     85    <?php
     86        $plugin = trim($_GET['plugin']);
     87        if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) && 1 == strtolower(ini_get('display_errors'))) { ?>
     88    <iframe style="border:0" width="100%" height="70px" src="<?php bloginfo('wpurl'); ?>/wp-admin/plugins.php?action=error_scrape&amp;plugin=<?php echo attribute_escape($plugin); ?>&amp;_wpnonce=<?php echo attribute_escape($_GET['_error_nonce']); ?>"></iframe>
     89    <?php
     90        }
     91    ?>
     92    </div>
    7793<?php elseif ( isset($_GET['activate']) ) : ?>
    7894    <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
Note: See TracChangeset for help on using the changeset viewer.