Make WordPress Core

Changeset 56570

Timestamp:
09/14/2023 12:52:45 AM (11 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.

Location:
trunk/src
Files:
20 edited

Legend:

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

    r55917 r56570  
    155155        // Only show the dashboard notice if it's been less than a minute since the message was postponed.
    156156        if ( $time_passed < MINUTE_IN_SECONDS ) :
    157             ?>
    158         <div class="notice notice-success is-dismissible">
    159             <p>
    160                 <?php
    161                 printf(
    162                     /* translators: %s: Human-readable time interval. */
    163                     __( 'The admin email verification page will reappear after %s.' ),
    164                     human_time_diff( time() + $remind_interval )
    165                 );
    166                 ?>
    167             </p>
    168         </div>
    169         <?php endif; ?>
    170     <?php endif; ?>
     157            $message = sprintf(
     158                /* translators: %s: Human-readable time interval. */
     159                __( 'The admin email verification page will reappear after %s.' ),
     160                human_time_diff( time() + $remind_interval )
     161            );
     162            wp_admin_notice(
     163                $message,
     164                array(
     165                    'type'        => 'success',
     166                    'dismissible' => true,
     167                )
     168            );
     169        endif;
     170    endif;
     171    ?>
    171172
    172173<?php
  • trunk/src/wp-admin/authorize-application.php

    r53827 r56570  
    138138    <h1><?php echo esc_html( $title ); ?></h1>
    139139
    140     <?php if ( is_wp_error( $error ) ) : ?>
    141         <div class="notice notice-error"><p><?php echo $error->get_error_message(); ?></p></div>
    142     <?php endif; ?>
     140    <?php
     141    if ( is_wp_error( $error ) ) {
     142        wp_admin_notice(
     143            $error->get_error_message(),
     144            array(
     145                'type' => 'error',
     146            )
     147        );
     148    }
     149    ?>
    143150
    144151    <div class="card auth-app-card">
     
    195202        ?>
    196203
    197         <?php if ( $new_password ) : ?>
    198             <div class="notice notice-success notice-alt below-h2">
    199                 <p class="application-password-display">
    200                     <label for="new-application-password-value">
    201                         <?php
    202                         printf(
    203                             /* translators: %s: Application name. */
    204                             esc_html__( 'Your new password for %s is:' ),
    205                             '<strong>' . esc_html( $app_name ) . '</strong>'
    206                         );
    207                         ?>
    208                     </label>
    209                     <input id="new-application-password-value" type="text" class="code" readonly="readonly" value="<?php esc_attr( WP_Application_Passwords::chunk_password( $new_password ) ); ?>" />
    210                 </p>
    211                 <p><?php _e( 'Be sure to save this in a safe location. You will not be able to retrieve it.' ); ?></p>
    212             </div>
    213 
    214             <?php
     204        <?php
     205        if ( $new_password ) :
     206            $message = '<p class="application-password-display">
     207                <label for="new-application-password-value">' . sprintf(
     208                /* translators: %s: Application name. */
     209                esc_html__( 'Your new password for %s is:' ),
     210                '<strong>' . esc_html( $app_name ) . '</strong>'
     211            ) . '
     212                </label>
     213                <input id="new-application-password-value" type="text" class="code" readonly="readonly" value="' . esc_attr( WP_Application_Passwords::chunk_password( $new_password ) ) . '" />
     214            </p>
     215            <p>' . __( 'Be sure to save this in a safe location. You will not be able to retrieve it.' ) . '</p>';
     216            $args = array(
     217                'type'               => 'success',
     218                'additional_classes' => array( 'notice-alt', 'below-h2' ),
     219                'paragraph_wrap'     => false,
     220            );
     221            wp_admin_notice( $message, $args );
     222
    215223            /**
    216224             * Fires in the Authorize Application Password new password section in the no-JS version.
     
    227235             */
    228236            do_action( 'wp_authorize_application_password_form_approved_no_js', $new_password, $request, $user );
     237
    229238            ?>
    230         <?php else : ?>
    231239            <form action="<?php echo esc_url( admin_url( 'authorize-application.php' ) ); ?>" method="post" class="form-wrap">
    232240                <?php wp_nonce_field( 'authorize_application_password' ); ?>
  • trunk/src/wp-admin/comment.php

    r55988 r56570  
    162162            }
    163163            if ( $message ) {
    164                 echo '<div id="message" class="notice notice-info"><p>' . $message . '</p></div>';
     164                wp_admin_notice(
     165                    $message,
     166                    array(
     167                        'type' => 'info',
     168                        'id'   => 'message',
     169                    )
     170                );
    165171            }
    166172        }
     173
     174
     175
     176
     177
     178
     179
    167180        ?>
    168 <div id="message" class="notice notice-warning"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php echo $caution_msg; ?></p></div>
    169181
    170182<table class="form-table comment-ays">
  • trunk/src/wp-admin/edit-form-advanced.php

    r55414 r56570  
    441441<hr class="wp-header-end">
    442442
    443 <?php if ( $notice ) : ?>
    444 <div id="notice" class="notice notice-warning"><p id="has-newer-autosave"><?php echo $notice; ?></p></div>
    445 <?php endif; ?>
    446 <?php if ( $message ) : ?>
    447 <div id="message" class="updated notice notice-success is-dismissible"><p><?php echo $message; ?></p></div>
    448 <?php endif; ?>
     443<?php
     444if ( $notice ) :
     445    wp_admin_notice(
     446        '<p id="has-newer-autosave">' . $notice . '</p>',
     447        array(
     448            'type'           => 'warning',
     449            'id'             => 'notice',
     450            'paragraph_wrap' => false,
     451        )
     452    );
     453endif;
     454if ( $message ) :
     455    wp_admin_notice(
     456        $message,
     457        array(
     458            'type'               => 'success',
     459            'dismissible'        => true,
     460            'id'                 => 'message',
     461            'additional_classes' => array( 'updated' ),
     462        )
     463    );
     464endif;
     465?>
    449466<div id="lost-connection-notice" class="error hidden">
    450467    <p><span class="spinner"></span> <?php _e( '<strong>Connection lost.</strong> Saving has been disabled until you are reconnected.' ); ?>
  • trunk/src/wp-admin/edit-form-blocks.php

    r56559 r56570  
    320320    <div class="wrap hide-if-js block-editor-no-js">
    321321        <h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>
    322         <div class="notice notice-error">
    323             <p>
    324                 <?php
    325                     $message = sprintf(
    326                         /* translators: %s: A link to install the Classic Editor plugin. */
    327                         __( 'The block editor requires JavaScript. Please enable JavaScript in your browser settings, or try the <a href="%s">Classic Editor plugin</a>.' ),
    328                         esc_url( wp_nonce_url( self_admin_url( 'plugin-install.php?tab=favorites&user=wordpressdotorg&save=0' ), 'save_wporg_username_' . get_current_user_id() ) )
    329                     );
    330 
    331                     /**
    332                      * Filters the message displayed in the block editor interface when JavaScript is
    333                      * not enabled in the browser.
    334                      *
    335                      * @since 5.0.3
    336                      *
    337                      * @param string  $message The message being displayed.
    338                      * @param WP_Post $post    The post being edited.
    339                      */
    340                     echo apply_filters( 'block_editor_no_javascript_message', $message, $post );
    341                     ?>
    342             </p>
    343         </div>
     322        <?php
     323        $message = sprintf(
     324            /* translators: %s: A link to install the Classic Editor plugin. */
     325            __( 'The block editor requires JavaScript. Please enable JavaScript in your browser settings, or try the <a href="%s">Classic Editor plugin</a>.' ),
     326            esc_url( wp_nonce_url( self_admin_url( 'plugin-install.php?tab=favorites&user=wordpressdotorg&save=0' ), 'save_wporg_username_' . get_current_user_id() ) )
     327        );
     328
     329        /**
     330         * Filters the message displayed in the block editor interface when JavaScript is
     331         * not enabled in the browser.
     332         *
     333         * @since 5.0.3
     334         *
     335         * @param string  $message The message being displayed.
     336         * @param WP_Post $post    The post being edited.
     337         */
     338        $message = apply_filters( 'block_editor_no_javascript_message', $message, $post );
     339        wp_admin_notice(
     340            $message,
     341            array(
     342                'type' => 'error',
     343            )
     344        );
     345        ?>
    344346    </div>
    345347</div>
  • trunk/src/wp-admin/edit-tag-form.php

    r54240 r56570  
    8080
    8181if ( $message ) {
    82     ?>
    83 <div id="message" class="notice notice-<?php echo $class; ?>">
    84     <p><strong><?php echo $message; ?></strong></p>
    85     <?php if ( $wp_http_referer ) { ?>
    86     <p><a href="<?php echo esc_url( wp_validate_redirect( sanitize_url( $wp_http_referer ), admin_url( 'term.php?taxonomy=' . $taxonomy ) ) ); ?>">
    87         <?php echo esc_html( $tax->labels->back_to_items ); ?>
    88     </a></p>
    89     <?php } ?>
    90 </div>
    91     <?php
     82    $message = '<p><strong>' . $message . '</strong></p>';
     83    if ( $wp_http_referer ) {
     84        $message .= '<p><a href="' . esc_url( wp_validate_redirect( sanitize_url( $wp_http_referer ), admin_url( 'term.php?taxonomy=' . $taxonomy ) ) ) . '">' . esc_html( $tax->labels->back_to_items ) . '</a></p>';
     85    }
     86    wp_admin_notice(
     87        $message,
     88        array(
     89            'type'           => $class,
     90            'id'             => 'message',
     91            'paragraph_wrap' => false,
     92        )
     93    );
    9294}
    9395?>
  • trunk/src/wp-admin/options-privacy.php

    r56559 r56570  
    178178<hr class="wp-header-end">
    179179
    180 <div class="notice notice-error hide-if-js">
    181     <p><?php _e( 'The Privacy Settings require JavaScript.' ); ?></p>
    182 </div>
     180<?php
     181wp_admin_notice(
     182    __( 'The Privacy Settings require JavaScript.' ),
     183    array(
     184        'type'               => 'error',
     185        'additional_classes' => array( 'hide-if-js' ),
     186    )
     187);
     188?>
    183189
    184190<div class="privacy-settings-body hide-if-no-js">
  • trunk/src/wp-admin/options-reading.php

    r55412 r56570  
    145145</label></li>
    146146</ul>
    147     <?php if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) === get_option( 'page_on_front' ) ) : ?>
    148     <div id="front-page-warning" class="notice notice-warning inline"><p><?php _e( '<strong>Warning:</strong> these pages should not be the same!' ); ?></p></div>
    149     <?php endif; ?>
    150     <?php if ( get_option( 'wp_page_for_privacy_policy' ) === get_option( 'page_for_posts' ) || get_option( 'wp_page_for_privacy_policy' ) === get_option( 'page_on_front' ) ) : ?>
    151     <div id="privacy-policy-page-warning" class="notice notice-warning inline"><p><?php _e( '<strong>Warning:</strong> these pages should not be the same as your Privacy Policy page!' ); ?></p></div>
    152     <?php endif; ?>
     147    <?php
     148    if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) === get_option( 'page_on_front' ) ) :
     149        wp_admin_notice(
     150            __( '<strong>Warning:</strong> these pages should not be the same!' ),
     151            array(
     152                'type'               => 'warning',
     153                'id'                 => 'front-page-warning',
     154                'additional_classes' => array( 'inline' ),
     155            )
     156        );
     157    endif;
     158    if ( get_option( 'wp_page_for_privacy_policy' ) === get_option( 'page_for_posts' ) || get_option( 'wp_page_for_privacy_policy' ) === get_option( 'page_on_front' ) ) :
     159        wp_admin_notice(
     160            __( '<strong>Warning:</strong> these pages should not be the same as your Privacy Policy page!' ),
     161            array(
     162                'type'               => 'warning',
     163                'id'                 => 'privacy-policy-page-warning',
     164                'additional_classes' => array( 'inline' ),
     165            )
     166        );
     167    endif;
     168    ?>
    153169</fieldset></td>
    154170</tr>
  • trunk/src/wp-admin/options.php

    r55988 r56570  
    360360    <h1><?php esc_html_e( 'All Settings' ); ?></h1>
    361361
    362     <div class="notice notice-warning">
    363         <p><strong><?php _e( 'Warning:' ); ?></strong> <?php _e( 'This page allows direct access to your site settings. You can break things here. Please be cautious!' ); ?></p>
    364     </div>
    365 
     362    <?php
     363    wp_admin_notice(
     364        '<strong>' . __( 'Warning:' ) . '</strong> ' . __( 'This page allows direct access to your site settings. You can break things here. Please be cautious!' ),
     365        array(
     366            'type' => 'warning',
     367        )
     368    );
     369    ?>
    366370    <form name="form" action="options.php" method="post" id="all-options">
    367371        <?php wp_nonce_field( 'options-options' ); ?>
  • 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">
  • trunk/src/wp-admin/privacy-policy-guide.php

    r56559 r56570  
    6161<hr class="wp-header-end">
    6262
    63 <div class="notice notice-error hide-if-js">
    64     <p><?php _e( 'The Privacy Settings require JavaScript.' ); ?></p>
    65 </div>
     63<?php
     64wp_admin_notice(
     65    __( 'The Privacy Settings require JavaScript.' ),
     66    array(
     67        'type'               => 'error',
     68        'additional_classes' => array( 'hide-if-js' ),
     69    )
     70);
     71?>
    6672
    6773<div class="privacy-settings-body hide-if-no-js">
  • trunk/src/wp-admin/site-editor.php

    r56559 r56570  
    161161    <div class="wrap hide-if-js site-editor-no-js">
    162162        <h1 class="wp-heading-inline"><?php _e( 'Edit site' ); ?></h1>
    163         <div class="notice notice-error">
    164             <p>
    165                 <?php
    166                     /**
    167                      * Filters the message displayed in the site editor interface when JavaScript is
    168                      * not enabled in the browser.
    169                      *
    170                      * @since 6.3.0
    171                      *
    172                      * @param string  $message The message being displayed.
    173                      * @param WP_Post $post    The post being edited.
    174                      */
    175                     echo apply_filters( 'site_editor_no_javascript_message', __( 'The site editor requires JavaScript. Please enable JavaScript in your browser settings.' ), $post );
    176                 ?>
    177             </p>
    178         </div>
     163        <?php
     164        /**
     165         * Filters the message displayed in the site editor interface when JavaScript is
     166         * not enabled in the browser.
     167         *
     168         * @since 6.3.0
     169         *
     170         * @param string  $message The message being displayed.
     171         * @param WP_Post $post    The post being edited.
     172         */
     173        $message = apply_filters( 'site_editor_no_javascript_message', __( 'The site editor requires JavaScript. Please enable JavaScript in your browser settings.' ), $post );
     174        wp_admin_notice(
     175            $message,
     176            array(
     177                'type'               => 'error',
     178                'additional_classes' => array( 'hide-if-js' ),
     179            )
     180        );
     181        ?>
    179182    </div>
    180183</div>
  • trunk/src/wp-admin/site-health-info.php

    r51970 r56570  
    1919
    2020$health_check_site_status = WP_Site_Health::get_instance();
     21
     22
     23
     24
     25
     26
     27
     28
    2129?>
    22 
    23 <div class="notice notice-error hide-if-js">
    24     <p><?php _e( 'The Site Health check requires JavaScript.' ); ?></p>
    25 </div>
    2630
    2731<div class="health-check-body health-check-debug-tab hide-if-no-js">
  • trunk/src/wp-admin/site-health.php

    r55917 r56570  
    106106    if ( isset( $_GET['https_updated'] ) ) {
    107107        if ( $_GET['https_updated'] ) {
    108             ?>
    109             <div id="message" class="notice notice-success is-dismissible"><p><?php _e( 'Site URLs switched to HTTPS.' ); ?></p></div>
    110             <?php
     108            wp_admin_notice(
     109                __( 'Site URLs switched to HTTPS.' ),
     110                array(
     111                    'type'        => 'success',
     112                    'id'          => 'message',
     113                    'dismissible' => true,
     114                )
     115            );
    111116        } else {
    112             ?>
    113             <div id="message" class="notice notice-error is-dismissible"><p><?php _e( 'Site URLs could not be switched to HTTPS.' ); ?></p></div>
    114             <?php
     117            wp_admin_notice(
     118                __( 'Site URLs could not be switched to HTTPS.' ),
     119                array(
     120                    'type'        => 'error',
     121                    'id'          => 'message',
     122                    'dismissible' => true,
     123                )
     124            );
    115125        }
    116126    }
     
    213223    return;
    214224} else {
     225
     226
     227
     228
     229
     230
     231
    215232    ?>
    216 
    217 <div class="notice notice-error hide-if-js">
    218     <p><?php _e( 'The Site Health check requires JavaScript.' ); ?></p>
    219 </div>
    220233
    221234<div class="health-check-body health-check-status-tab hide-if-no-js">
  • trunk/src/wp-admin/theme-editor.php

    r56014 r56570  
    190190<h1><?php echo esc_html( $title ); ?></h1>
    191191
    192 <?php if ( isset( $_GET['a'] ) ) : ?>
    193     <div id="message" class="updated notice is-dismissible">
    194         <p><?php _e( 'File edited successfully.' ); ?></p>
    195     </div>
    196 <?php elseif ( is_wp_error( $edit_error ) ) : ?>
    197     <div id="message" class="notice notice-error">
    198         <p><?php _e( 'There was an error while trying to update the file. You may need to fix something and try updating again.' ); ?></p>
    199         <pre><?php echo esc_html( $edit_error->get_error_message() ? $edit_error->get_error_message() : $edit_error->get_error_code() ); ?></pre>
    200     </div>
    201 <?php endif; ?>
    202 
    203 <?php if ( preg_match( '/\.css$/', $file ) && ! wp_is_block_theme() && current_user_can( 'customize' ) ) : ?>
    204     <div id="message" class="notice-info notice">
    205         <p><strong><?php _e( 'Did you know?' ); ?></strong></p>
    206         <p>
    207             <?php
    208             printf(
    209                 /* translators: %s: Link to Custom CSS section in the Customizer. */
    210                 __( 'There is no need to change your CSS here &mdash; you can edit and live preview CSS changes in the <a href="%s">built-in CSS editor</a>.' ),
    211                 esc_url( add_query_arg( 'autofocus[section]', 'custom_css', admin_url( 'customize.php' ) ) )
    212             );
    213             ?>
    214         </p>
    215     </div>
    216 <?php endif; ?>
     192<?php
     193if ( isset( $_GET['a'] ) ) {
     194    wp_admin_notice(
     195        __( 'File edited successfully.' ),
     196        array(
     197            'id'                 => 'message',
     198            'is-dismissible'     => true,
     199            'additional_classes' => array( 'updated' ),
     200        )
     201    );
     202} elseif ( is_wp_error( $edit_error ) ) {
     203    $error_code = esc_html( $edit_error->get_error_message() ? $edit_error->get_error_message() : $edit_error->get_error_code() );
     204    $message    = '<p>' . __( 'There was an error while trying to update the file. You may need to fix something and try updating again.' ) . '</p>
     205    <pre>' . $error_code . '</pre>';
     206    wp_admin_notice(
     207        $message,
     208        array(
     209            'type' => 'error',
     210            'id'   => 'message',
     211        )
     212    );
     213}
     214
     215if ( preg_match( '/\.css$/', $file ) && ! wp_is_block_theme() && current_user_can( 'customize' ) ) {
     216    $message = '<p><strong>' . __( 'Did you know?' ) . '</strong></p><p>' . sprintf(
     217        /* translators: %s: Link to Custom CSS section in the Customizer. */
     218        __( 'There is no need to change your CSS here &mdash; you can edit and live preview CSS changes in the <a href="%s">built-in CSS editor</a>.' ),
     219        esc_url( add_query_arg( 'autofocus[section]', 'custom_css', admin_url( 'customize.php' ) ) )
     220    ) . '</p>';
     221    wp_admin_notice(
     222        $message,
     223        array(
     224            'type' => 'info',
     225            'id'   => 'message',
     226        )
     227    );
     228}
     229?>
    217230
    218231<div class="fileedit-sub">
     
    305318        <div>
    306319            <div class="editor-notices">
    307                 <?php if ( is_child_theme() && $theme->get_stylesheet() === get_template() ) : ?>
    308                     <div class="notice notice-warning inline">
    309                         <p>
    310                             <?php if ( is_writable( $file ) ) : ?>
    311                                 <strong><?php _e( 'Caution:' ); ?></strong>
    312                             <?php endif; ?>
    313                             <?php _e( 'This is a file in your current parent theme.' ); ?>
    314                         </p>
    315                     </div>
    316                 <?php endif; ?>
     320                <?php
     321                if ( is_child_theme() && $theme->get_stylesheet() === get_template() ) :
     322                    $message  = ( is_writable( $file ) ) ? '<strong>' . __( 'Caution:' ) . '</strong> ' : '';
     323                    $message .= __( 'This is a file in your current parent theme.' );
     324                    wp_admin_notice(
     325                        $message,
     326                        array(
     327                            'type'               => 'warning',
     328                            'additional_classes' => array( 'inline' ),
     329                        )
     330                    );
     331                endif;
     332                ?>
    317333            </div>
    318             <?php if ( is_writable( $file ) ) : ?>
     334            <?php
     335            if ( is_writable( $file ) ) {
     336                ?>
    319337                <p class="submit">
    320338                    <?php submit_button( __( 'Update File' ), 'primary', 'submit', false ); ?>
    321339                    <span class="spinner"></span>
    322340                </p>
    323             <?php else : ?>
     341                <?php
     342            } else {
     343                ?>
    324344                <p>
    325345                    <?php
     
    331351                    ?>
    332352                </p>
    333             <?php endif; ?>
     353                <?php
     354            }
     355            ?>
    334356        </div>
    335357
     
    343365<?php
    344366$dismissed_pointers = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
    345 if ( ! in_array( 'theme_editor_notice', $dismissed_pointers, true ) ) :
     367if ( ! in_array( 'theme_editor_notice', $dismissed_pointers, true ) )
    346368    // Get a back URL.
    347369    $referer = wp_get_referer();
     
    389411    </div>
    390412    <?php
    391 endif; // Editor warning notice.
     413 // Editor warning notice.
    392414
    393415require_once ABSPATH . 'wp-admin/admin-footer.php';
  • trunk/src/wp-admin/theme-install.php

    r55412 r56570  
    319319
    320320    <# if ( data.installed ) { #>
    321         <div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div>
     321        <?php
     322        wp_admin_notice(
     323            _x( 'Installed', 'theme' ),
     324            array(
     325                'type'               => 'success',
     326                'additional_classes' => array( 'notice-alt' ),
     327            )
     328        );
     329        ?>
    322330    <# } #>
    323331
  • trunk/src/wp-admin/themes.php

    r56515 r56570  
    470470    <?php
    471471    if ( ! $theme['compatibleWP'] || ! $theme['compatiblePHP'] ) {
    472         echo '<div class="notice inline notice-error notice-alt"><p>';
     472        ';
    473473        if ( ! $theme['compatibleWP'] && ! $theme['compatiblePHP'] ) {
    474             _e( 'This theme does not work with your versions of WordPress and PHP.' );
     474            ( 'This theme does not work with your versions of WordPress and PHP.' );
    475475            if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
    476                 printf(
     476                printf(
    477477                    /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
    478478                    ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
     
    480480                    esc_url( wp_get_update_php_url() )
    481481                );
    482                 wp_update_php_annotation( '</p><p><em>', '</em>' );
     482                );
    483483            } elseif ( current_user_can( 'update_core' ) ) {
    484                 printf(
     484                printf(
    485485                    /* translators: %s: URL to WordPress Updates screen. */
    486486                    ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     
    488488                );
    489489            } elseif ( current_user_can( 'update_php' ) ) {
    490                 printf(
     490                printf(
    491491                    /* translators: %s: URL to Update PHP page. */
    492492                    ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
    493493                    esc_url( wp_get_update_php_url() )
    494494                );
    495                 wp_update_php_annotation( '</p><p><em>', '</em>' );
     495                );
    496496            }
    497497        } elseif ( ! $theme['compatibleWP'] ) {
    498             _e( 'This theme does not work with your version of WordPress.' );
     498            ( 'This theme does not work with your version of WordPress.' );
    499499            if ( current_user_can( 'update_core' ) ) {
    500                 printf(
     500                printf(
    501501                    /* translators: %s: URL to WordPress Updates screen. */
    502502                    ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     
    505505            }
    506506        } elseif ( ! $theme['compatiblePHP'] ) {
    507             _e( 'This theme does not work with your version of PHP.' );
     507            ( 'This theme does not work with your version of PHP.' );
    508508            if ( current_user_can( 'update_php' ) ) {
    509                 printf(
     509                printf(
    510510                    /* translators: %s: URL to Update PHP page. */
    511511                    ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
    512512                    esc_url( wp_get_update_php_url() )
    513513                );
    514                 wp_update_php_annotation( '</p><p><em>', '</em>' );
     514                );
    515515            }
    516516        }
    517         echo '</p></div>';
     517
     518        wp_admin_notice(
     519            $message,
     520            array(
     521                'type'               => 'error',
     522                'additional_classes' => array( 'inline', 'notice-alt' ),
     523            )
     524        );
    518525    }
    519526    ?>
     
    693700 */
    694701function wp_theme_auto_update_setting_template() {
     702
     703
     704
     705
     706
     707
     708
    695709    $template = '
    696710        <div class="theme-autoupdate">
     
    718732                <br />' . wp_get_auto_update_message() . '</span>
    719733            <# } #>
    720             <div class="notice notice-error notice-alt inline hidden"><p></p></div>
     734           
    721735        </div>
    722736    ';
  • trunk/src/wp-admin/update-core.php

    r56548 r56570  
    256256        echo '</h2>';
    257257
    258         echo '<div class="notice notice-warning inline"><p>';
    259         printf(
     258        $message = sprintf(
    260259            /* translators: 1: Documentation on WordPress backups, 2: Documentation on updating WordPress. */
    261260            __( '<strong>Important:</strong> Before updating, please <a href="%1$s">back up your database and files</a>. For help with updates, visit the <a href="%2$s">Updating WordPress</a> documentation page.' ),
     
    263262            __( 'https://wordpress.org/documentation/article/updating-wordpress/' )
    264263        );
    265         echo '</p></div>';
     264        wp_admin_notice(
     265            $message,
     266            array(
     267                'type'               => 'warning',
     268                'additional_classes' => array( 'inline' ),
     269            )
     270        );
    266271    } elseif ( $is_development_version ) {
    267272        echo '<h2 class="response">' . __( 'You are using a development version of WordPress.' ) . '</h2>';
     
    303308        if ( 'enabled' === $_GET['core-major-auto-updates-saved'] ) {
    304309            $notice_text = __( 'Automatic updates for all WordPress versions have been enabled. Thank you!' );
    305             echo '<div class="notice notice-success is-dismissible"><p>' . $notice_text . '</p></div>';
     310            wp_admin_notice(
     311                $notice_text,
     312                array(
     313                    'type'        => 'success',
     314                    'dismissible' => true,
     315                )
     316            );
    306317        } elseif ( 'disabled' === $_GET['core-major-auto-updates-saved'] ) {
    307318            $notice_text = __( 'WordPress will only receive automatic security and maintenance releases from now on.' );
    308             echo '<div class="notice notice-success is-dismissible"><p>' . $notice_text . '</p></div>';
     319            wp_admin_notice(
     320                $notice_text,
     321                array(
     322                    'type'        => 'success',
     323                    'dismissible' => true,
     324                )
     325            );
    309326        }
    310327    }
  • trunk/src/wp-admin/user-edit.php

    r56515 r56570  
    201201        ?>
    202202
    203         <?php if ( ! IS_PROFILE_PAGE && is_super_admin( $profile_user->ID ) && current_user_can( 'manage_network_options' ) ) : ?>
    204             <div class="notice notice-info"><p><strong><?php _e( 'Important:' ); ?></strong> <?php _e( 'This user has super admin privileges.' ); ?></p></div>
    205         <?php endif; ?>
    206 
    207         <?php if ( isset( $_GET['updated'] ) ) : ?>
    208             <div id="message" class="updated notice is-dismissible">
    209                 <?php if ( IS_PROFILE_PAGE ) : ?>
    210                     <p><strong><?php _e( 'Profile updated.' ); ?></strong></p>
    211                 <?php else : ?>
    212                     <p><strong><?php _e( 'User updated.' ); ?></strong></p>
    213                 <?php endif; ?>
    214                 <?php if ( $wp_http_referer && ! str_contains( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?>
    215                     <p><a href="<?php echo esc_url( wp_validate_redirect( sanitize_url( $wp_http_referer ), self_admin_url( 'users.php' ) ) ); ?>"><?php _e( '&larr; Go to Users' ); ?></a></p>
    216                 <?php endif; ?>
    217             </div>
    218         <?php endif; ?>
    219 
    220         <?php if ( isset( $_GET['error'] ) ) : ?>
    221             <div class="notice notice-error">
    222             <?php if ( 'new-email' === $_GET['error'] ) : ?>
    223                 <p><?php _e( 'Error while saving the new email address. Please try again.' ); ?></p>
    224             <?php endif; ?>
    225             </div>
    226         <?php endif; ?>
    227 
    228         <?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
     203        <?php
     204        if ( ! IS_PROFILE_PAGE && is_super_admin( $profile_user->ID ) && current_user_can( 'manage_network_options' ) ) :
     205            $message = '<strong>' . __( 'Important:' ) . '</strong> ' . __( 'This user has super admin privileges.' );
     206            wp_admin_notice(
     207                $message,
     208                array(
     209                    'type' => 'info',
     210                )
     211            );
     212        endif;
     213
     214        if ( isset( $_GET['updated'] ) ) :
     215            if ( IS_PROFILE_PAGE ) :
     216                $message = '<strong>' . __( 'Profile updated.' ) . '</strong>';
     217            else :
     218                $message = '<strong>' . __( 'User updated.' ) . '</strong>';
     219            endif;
     220            if ( $wp_http_referer && ! str_contains( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) :
     221                $message .= '<a href="' . esc_url( wp_validate_redirect( sanitize_url( $wp_http_referer ), self_admin_url( 'users.php' ) ) ) . '">' . __( '&larr; Go to Users' ) . '</a>';
     222            endif;
     223            wp_admin_notice(
     224                $message,
     225                array(
     226                    'id'                 => 'message',
     227                    'dismissible'        => true,
     228                    'additional_classes' => array( 'updated' ),
     229                )
     230            );
     231        endif;
     232
     233        if ( isset( $_GET['error'] ) ) :
     234            $message = '';
     235            if ( 'new-email' === $_GET['error'] ) :
     236                $message = __( 'Error while saving the new email address. Please try again.' );
     237            endif;
     238            wp_admin_notice(
     239                $message,
     240                array(
     241                    'type' => 'error',
     242                )
     243            );
     244        endif;
     245
     246        if ( isset( $errors ) && is_wp_error( $errors ) ) {
     247            ?>
    229248            <div class="error">
    230249                <p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p>
    231250            </div>
    232         <?php endif; ?>
     251            <?php
     252        }
     253        ?>
    233254
    234255        <div class="wrap" id="profile-page">
     
    803824                                        <button type="button" name="do_new_application_password" id="do_new_application_password" class="button button-secondary"><?php _e( 'Add New Application Password' ); ?></button>
    804825                                    </div>
    805                                 <?php else : ?>
    806                                     <div class="notice notice-error inline">
    807                                         <p><?php _e( 'Your website appears to use Basic Authentication, which is not currently compatible with Application Passwords.' ); ?></p>
    808                                     </div>
    809                                 <?php endif; ?>
     826                                    <?php
     827                                else :
     828                                    wp_admin_notice(
     829                                        __( 'Your website appears to use Basic Authentication, which is not currently compatible with Application Passwords.' ),
     830                                        array(
     831                                            'type'               => 'error',
     832                                            'additional_classes' => array( 'inline' ),
     833                                        )
     834                                    );
     835                                endif;
     836                                ?>
    810837
    811838                                <div class="application-passwords-list-table-wrapper">
  • trunk/src/wp-includes/functions.php

    r56559 r56570  
    83198319 * @since 5.1.0
    83208320 * @since 5.2.0 Added the `$before` and `$after` parameters.
     8321
    83218322 *
    83228323 * @param string $before Markup to output before the annotation. Default `<p class="description">`.
    83238324 * @param string $after  Markup to output after the annotation. Default `</p>`.
    8324  */
    8325 function wp_update_php_annotation( $before = '<p class="description">', $after = '</p>' ) {
     8325 * @param bool   $echo   Markup should echo if true. Default `true`.
     8326 *
     8327 * @return string|void
     8328 */
     8329function wp_update_php_annotation( $before = '<p class="description">', $after = '</p>', $echo = true ) {
    83268330    $annotation = wp_get_update_php_annotation();
    83278331
    83288332    if ( $annotation ) {
    8329         echo $before . $annotation . $after;
     8333        if ( $echo ) {
     8334            echo $before . $annotation . $after;
     8335        } else {
     8336            return $before . $annotation . $after;
     8337        }
    83308338    }
    83318339}
Note: See TracChangeset for help on using the changeset viewer.