Ticket #12089: 12089.diff
File 12089.diff, 3.3 KB (added by , 15 years ago) |
---|
-
includes/plugin.php
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 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 ) { 364 368 $current[$plugin] = time(); -
plugins.php
50 50 check_admin_referer('activate-plugin_' . $plugin); 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'); 57 64 if ( isset($recent[ $plugin ]) ) { … … 157 164 check_admin_referer('deactivate-plugin_' . $plugin); 158 165 deactivate_plugins($plugin); 159 166 update_option('recently_activated', array($plugin => time()) + (array)get_option('recently_activated')); 160 wp_redirect("plugins.php?deactivate=true&plugin_status=$status&paged=$page"); 167 if (headers_sent()) 168 echo "<meta http-equiv='refresh' content='0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page' />"; 169 else 170 wp_redirect("plugins.php?deactivate=true&plugin_status=$status&paged=$page"); 161 171 exit; 162 172 break; 163 173 case 'deactivate-selected': … … 302 312 echo '<div id="message" class="error"><p>' . sprintf(__('The plugin <code>%s</code> has been <strong>deactivated</strong> due to an error: %s'), esc_html($plugin_file), $error->get_error_message()) . '</p></div>'; 303 313 ?> 304 314 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> 315 <?php if ( isset($_GET['error']) ) : 316 317 if (isset($_GET['charsout'])) 318 $errmsg = sprintf(__('Plugin could not be activated because it generated %d bytes of <strong>unexpected output</strong>.'), $_GET['charsout']); 319 else 320 $errmsg = __('Plugin could not be activated because it triggered a <strong>fatal error</strong>.'); 321 322 ?> 323 <div id="message" class="updated"><p><?php echo $errmsg; ?></p> 307 324 <?php 308 325 if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?> 309 326 <iframe style="border:0" width="100%" height="70px" src="<?php echo admin_url('plugins.php?action=error_scrape&plugin=' . esc_attr($plugin) . '&_wpnonce=' . esc_attr($_GET['_error_nonce'])); ?>"></iframe>