Make WordPress Core


Ignore:
Timestamp:
09/14/2023 12:52:45 AM (15 months ago)
Author:
joedolson
Message:

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

Add usages of wp_admin_notice() and wp_get_admin_notice() on .notice-[type] in the root level of /wp-admin/. Ongoing task to implement new function across core.

Props costdev, joedolson.
See #57791.

File:
1 edited

Legend:

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

    r56014 r56570  
    183183<h1><?php echo esc_html( $title ); ?></h1>
    184184
    185 <?php if ( isset( $_GET['a'] ) ) : ?>
    186     <div id="message" class="updated notice is-dismissible">
    187         <p><?php _e( 'File edited successfully.' ); ?></p>
    188     </div>
    189 <?php elseif ( is_wp_error( $edit_error ) ) : ?>
    190     <div id="message" class="notice notice-error">
    191         <p><?php _e( 'There was an error while trying to update the file. You may need to fix something and try updating again.' ); ?></p>
    192         <pre><?php echo esc_html( $edit_error->get_error_message() ? $edit_error->get_error_message() : $edit_error->get_error_code() ); ?></pre>
    193     </div>
    194 <?php endif; ?>
     185<?php
     186if ( isset( $_GET['a'] ) ) :
     187    wp_admin_notice(
     188        __( 'File edited successfully.' ),
     189        array(
     190            'additional_classes' => array( 'updated', 'is-dismissible' ),
     191            'id'                 => 'message',
     192        )
     193    );
     194elseif ( is_wp_error( $edit_error ) ) :
     195    $error   = esc_html( $edit_error->get_error_message() ? $edit_error->get_error_message() : $edit_error->get_error_code() );
     196    $message = '<p>' . __( 'There was an error while trying to update the file. You may need to fix something and try updating again.' ) . '</p>
     197    <pre>' . $error . '</pre>';
     198    wp_admin_notice(
     199        $message,
     200        array(
     201            'type'           => 'error',
     202            'id'             => 'message',
     203            'paragraph_wrap' => false,
     204        )
     205    );
     206endif;
     207?>
    195208
    196209<div class="fileedit-sub">
     
    281294    <?php if ( is_writable( $real_file ) ) : ?>
    282295        <div class="editor-notices">
    283         <?php if ( in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) ) { ?>
    284             <div class="notice notice-warning inline active-plugin-edit-warning">
    285                 <p><?php _e( '<strong>Warning:</strong> Making changes to active plugins is not recommended.' ); ?></p>
    286             </div>
    287         <?php } ?>
     296        <?php
     297        if ( in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) ) {
     298            wp_admin_notice(
     299                __( '<strong>Warning:</strong> Making changes to active plugins is not recommended.' ),
     300                array(
     301                    'type'               => 'warning',
     302                    'additional_classes' => array( 'inline', 'active-plugin-edit-warning' ),
     303                )
     304            );
     305        }
     306        ?>
    288307        </div>
    289308        <p class="submit">
Note: See TracChangeset for help on using the changeset viewer.