Changeset 13167
- Timestamp:
- 02/16/2010 03:44:20 AM (15 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/plugin.php
r13155 r13167 359 359 wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error 360 360 ob_start(); 361 @include(WP_PLUGIN_DIR . '/' . $plugin); 361 include(WP_PLUGIN_DIR . '/' . $plugin); 362 if ( ob_get_length() > 0 ) { 363 $output = ob_get_clean(); 364 return new WP_Error('unexpected_output', __('The plugin generated unexpected output.'), $output); 365 } 362 366 do_action( 'activate_plugin', trim( $plugin) ); 363 367 if ( $network_wide ) { -
trunk/wp-admin/plugins.php
r13155 r13167 51 51 52 52 $result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin, $network_wide); 53 if ( is_wp_error( $result ) ) 54 wp_die($result); 53 if ( is_wp_error( $result ) ) { 54 if ('unexpected_output' == $result->get_error_code()) { 55 $redirect = 'plugins.php?error=true&charsout=' . strlen($result->get_error_data()) . '&plugin=' . $plugin; 56 wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); 57 exit; 58 } else { 59 wp_die($result); 60 } 61 } 55 62 56 63 $recent = (array)get_option('recently_activated'); … … 141 148 wp_die($valid); 142 149 143 if ( defined('E_RECOVERABLE_ERROR') ) 144 error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR); 145 else 146 error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING); 150 if ( ! WP_DEBUG ) { 151 if ( defined('E_RECOVERABLE_ERROR') ) 152 error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR); 153 else 154 error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING); 155 } 147 156 148 157 @ini_set('display_errors', true); //Ensure that Fatal errors are displayed. … … 158 167 deactivate_plugins($plugin); 159 168 update_option('recently_activated', array($plugin => time()) + (array)get_option('recently_activated')); 160 wp_redirect("plugins.php?deactivate=true&plugin_status=$status&paged=$page"); 169 if (headers_sent()) 170 echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page" ) . "' />"; 171 else 172 wp_redirect("plugins.php?deactivate=true&plugin_status=$status&paged=$page"); 161 173 exit; 162 174 break; … … 303 315 ?> 304 316 305 <?php if ( isset($_GET['error']) ) : ?> 306 <div id="message" class="updated"><p><?php _e('Plugin could not be activated because it triggered a <strong>fatal error</strong>.') ?></p> 317 <?php if ( isset($_GET['error']) ) : 318 319 if (isset($_GET['charsout'])) 320 $errmsg = sprintf(__('Plugin could not be activated because it generated %d characters of <strong>unexpected output</strong>.'), $_GET['charsout']); 321 else 322 $errmsg = __('Plugin could not be activated because it triggered a <strong>fatal error</strong>.'); 323 324 ?> 325 <div id="message" class="updated"><p><?php echo $errmsg; ?></p> 307 326 <?php 308 327 if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
Note: See TracChangeset
for help on using the changeset viewer.