WordPress.org

Make WordPress Core

Ticket #9991: plugins.patch

File plugins.patch, 4.7 KB (added by scribu, 6 years ago)

Put all plugin notices in the function plugin_notices()

  • home/cristi/svn/wp/wp-admin/plugins.php

     
    214214add_contextual_help('plugins', $help); 
    215215 
    216216$title = __('Manage Plugins'); 
    217 require_once('admin-header.php'); 
    218217 
    219 $invalid = validate_active_plugins(); 
    220 if ( !empty($invalid) ) 
    221         foreach ( $invalid as $plugin_file => $error ) 
    222                 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>'; 
    223 ?> 
     218function plugin_notices() { 
     219        global $plugin; 
    224220 
    225 <?php if ( isset($_GET['error']) ) : ?> 
    226         <div id="message" class="updated fade"><p><?php _e('Plugin could not be activated because it triggered a <strong>fatal error</strong>.') ?></p> 
    227         <?php 
    228                 if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?> 
    229         <iframe style="border:0" width="100%" height="70px" src="<?php echo admin_url('plugins.php?action=error_scrape&amp;plugin=' . esc_attr($plugin) . '&amp;_wpnonce=' . esc_attr($_GET['_error_nonce'])); ?>"></iframe> 
    230         <?php 
    231                 } 
     221        $invalid = validate_active_plugins(); 
     222        if ( !empty($invalid) ) 
     223                foreach ( $invalid as $plugin_file => $error ) 
     224                        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>'; 
    232225        ?> 
    233         </div> 
    234 <?php elseif ( isset($_GET['deleted']) ) : 
    235                 $delete_result = get_transient('plugins_delete_result_'.$user_ID); 
    236                 delete_transient('plugins_delete_result'); //Delete it once we're done. 
    237226 
    238                 if ( is_wp_error($delete_result) ) : ?> 
    239                 <div id="message" class="updated fade"><p><?php printf( __('Plugin could not be deleted due to an error: %s'), $delete_result->get_error_message() ); ?></p></div> 
    240                 <?php else : ?> 
    241                 <div id="message" class="updated fade"><p><?php _e('The selected plugins have been <strong>deleted</strong>.'); ?></p></div> 
    242                 <?php endif; ?> 
    243 <?php elseif ( isset($_GET['activate']) ) : ?> 
    244         <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div> 
    245 <?php elseif (isset($_GET['activate-multi'])) : ?> 
    246         <div id="message" class="updated fade"><p><?php _e('Selected plugins <strong>activated</strong>.'); ?></p></div> 
    247 <?php elseif ( isset($_GET['deactivate']) ) : ?> 
    248         <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div> 
    249 <?php elseif (isset($_GET['deactivate-multi'])) : ?> 
    250         <div id="message" class="updated fade"><p><?php _e('Selected plugins <strong>deactivated</strong>.'); ?></p></div> 
    251 <?php endif; ?> 
     227        <?php if ( isset($_GET['error']) ) : ?> 
     228                <div id="message" class="updated fade"><p><?php _e('Plugin could not be activated because it triggered a <strong>fatal error</strong>.') ?></p> 
     229                <?php 
     230                        if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?> 
     231                <iframe style="border:0" width="100%" height="70px" src="<?php echo admin_url('plugins.php?action=error_scrape&amp;plugin=' . esc_attr($plugin) . '&amp;_wpnonce=' . esc_attr($_GET['_error_nonce'])); ?>"></iframe> 
     232                <?php 
     233                        } 
     234                ?> 
     235                </div> 
     236        <?php elseif ( isset($_GET['deleted']) ) : 
     237                        $delete_result = get_transient('plugins_delete_result_'.$user_ID); 
     238                        delete_transient('plugins_delete_result'); //Delete it once we're done. 
    252239 
     240                        if ( is_wp_error($delete_result) ) : ?> 
     241                        <div id="message" class="updated fade"><p><?php printf( __('Plugin could not be deleted due to an error: %s'), $delete_result->get_error_message() ); ?></p></div> 
     242                        <?php else : ?> 
     243                        <div id="message" class="updated fade"><p><?php _e('The selected plugins have been <strong>deleted</strong>.'); ?></p></div> 
     244                        <?php endif; ?> 
     245        <?php elseif ( isset($_GET['activate']) ) : ?> 
     246                <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div> 
     247        <?php elseif (isset($_GET['activate-multi'])) : ?> 
     248                <div id="message" class="updated fade"><p><?php _e('Selected plugins <strong>activated</strong>.'); ?></p></div> 
     249        <?php elseif ( isset($_GET['deactivate']) ) : ?> 
     250                <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div> 
     251        <?php elseif (isset($_GET['deactivate-multi'])) : ?> 
     252                <div id="message" class="updated fade"><p><?php _e('Selected plugins <strong>deactivated</strong>.'); ?></p></div> 
     253        <?php endif; 
     254} 
     255 
     256add_action('admin_notices', 'plugin_notices'); 
     257 
     258require_once('admin-header.php'); 
     259?> 
     260 
    253261<div class="wrap"> 
    254262<?php screen_icon(); ?> 
    255263<h2><?php echo esc_html( $title ); ?></h2>