Make WordPress Core


Ignore:
Timestamp:
09/17/2023 03:31:32 PM (3 years ago)
Author:
joedolson
Message:

Administration: Use wp_admin_notice() more in wp-admin/.

Add additional usage of wp_admin_notice() in wp-admin/ on .error and miscellaneous usages previously overlooked.

Follow up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597], [56599].

Props costdev, joedolson.
See #57791.

File:
1 edited

Legend:

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

    r56589 r56600  
    340340                                <?php if ( 1 === $plugins_to_delete ) : ?>
    341341                                        <h1><?php _e( 'Delete Plugin' ); ?></h1>
    342                                         <?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
    343                                                 <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'This plugin may be active on other sites in the network.' ); ?></p></div>
    344                                         <?php endif; ?>
     342                                        <?php
     343                                        if ( $have_non_network_plugins && is_network_admin() ) :
     344                                                $maybe_active_plugin = '<strong>' . __( 'Caution:' ) . '</strong> ' . __( 'This plugin may be active on other sites in the network.' );
     345                                                wp_admin_notice(
     346                                                        $maybe_active_plugin,
     347                                                        array(
     348                                                                'additional_classes' => array( 'error' ),
     349                                                        )
     350                                                );
     351                                        endif;
     352                                        ?>
    345353                                        <p><?php _e( 'You are about to remove the following plugin:' ); ?></p>
    346354                                <?php else : ?>
    347355                                        <h1><?php _e( 'Delete Plugins' ); ?></h1>
    348                                         <?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
    349                                                 <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'These plugins may be active on other sites in the network.' ); ?></p></div>
    350                                         <?php endif; ?>
     356                                        <?php
     357                                        if ( $have_non_network_plugins && is_network_admin() ) :
     358                                                $maybe_active_plugins = '<strong>' . __( 'Caution:' ) . '</strong> ' . __( 'These plugins may be active on other sites in the network.' );
     359                                                wp_admin_notice(
     360                                                        $maybe_active_plugins,
     361                                                        array(
     362                                                                'additional_classes' => array( 'error' ),
     363                                                        )
     364                                                );
     365                                        endif;
     366                                        ?>
    351367                                        <p><?php _e( 'You are about to remove the following plugins:' ); ?></p>
    352368                                <?php endif; ?>
     
    608624if ( ! empty( $invalid ) ) {
    609625        foreach ( $invalid as $plugin_file => $error ) {
    610                 echo '<div id="message" class="error"><p>';
    611                 printf(
     626                $deactivated_message = sprintf(
    612627                        /* translators: 1: Plugin file, 2: Error message. */
    613628                        __( 'The plugin %1$s has been deactivated due to an error: %2$s' ),
     
    615630                        esc_html( $error->get_error_message() )
    616631                );
    617                 echo '</p></div>';
     632                wp_admin_notice(
     633                        $deactivated_message,
     634                        array(
     635                                'id'                 => 'message',
     636                                'additional_classes' => array( 'error' ),
     637                        )
     638                );
    618639        }
    619640}
Note: See TracChangeset for help on using the changeset viewer.