Make WordPress Core


Ignore:
Timestamp:
09/14/2023 02:13:42 AM (10 months ago)
Author:
joedolson
Message:

Administration: Use wp_admin_notice() for .updated.

Add usages of wp_admin_notice() and wp_get_admin_notice() on .updated 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/themes.php

    r56570 r56573  
    261261<?php
    262262if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) {
    263     ?>
    264     <div id="message1" class="updated notice is-dismissible"><p><?php _e( 'The active theme is broken. Reverting to the default theme.' ); ?></p></div>
    265     <?php
     263    wp_admin_notice(
     264        __( 'The active theme is broken. Reverting to the default theme.' ),
     265        array(
     266            'id'                 => 'message1',
     267            'additional_classes' => array( 'updated' ),
     268            'dismissible'        => true,
     269        )
     270    );
    266271} elseif ( isset( $_GET['activated'] ) ) {
    267272    if ( isset( $_GET['previewed'] ) ) {
    268         ?>
    269         <div id="message2" class="updated notice is-dismissible"><p><?php _e( 'Settings saved and theme activated.' ); ?> <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php _e( 'Visit site' ); ?></a></p></div>
    270         <?php
     273        wp_admin_notice(
     274            __( 'Settings saved and theme activated.' ) . '<a href="' . esc_url( home_url( '/' ) ) . '">' . __( 'Visit site' ) . '</a>',
     275            array(
     276                'id'                 => 'message2',
     277                'additional_classes' => array( 'updated' ),
     278                'dismissible'        => true,
     279            )
     280        );
    271281    } else {
    272         ?>
    273         <div id="message2" class="updated notice is-dismissible"><p><?php _e( 'New theme activated.' ); ?> <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php _e( 'Visit site' ); ?></a></p></div>
    274         <?php
     282        wp_admin_notice(
     283            __( 'New theme activated.' ) . '<a href="' . esc_url( home_url( '/' ) ) . '">' . __( 'Visit site' ) . '</a>',
     284            array(
     285                'id'                 => 'message2',
     286                'additional_classes' => array( 'updated' ),
     287                'dismissible'        => true,
     288            )
     289        );
    275290    }
    276291} elseif ( isset( $_GET['deleted'] ) ) {
    277     ?>
    278     <div id="message3" class="updated notice is-dismissible"><p><?php _e( 'Theme deleted.' ); ?></p></div>
    279     <?php
     292    wp_admin_notice(
     293        __( 'Theme deleted.' ),
     294        array(
     295            'id'                 => 'message3',
     296            'additional_classes' => array( 'updated' ),
     297            'dismissible'        => true,
     298        )
     299    );
    280300} elseif ( isset( $_GET['delete-active-child'] ) ) {
    281     ?>
    282     <div id="message4" class="error"><p><?php _e( 'You cannot delete a theme while it has an active child theme.' ); ?></p></div>
    283     <?php
     301    wp_admin_notice(
     302        __( 'You cannot delete a theme while it has an active child theme.' ),
     303        array(
     304            'id'                 => 'message4',
     305            'additional_classes' => array( 'error' ),
     306        )
     307    );
    284308} elseif ( isset( $_GET['resumed'] ) ) {
    285     ?>
    286     <div id="message5" class="updated notice is-dismissible"><p><?php _e( 'Theme resumed.' ); ?></p></div>
    287     <?php
     309    wp_admin_notice(
     310        __( 'Theme resumed.' ),
     311        array(
     312            'id'                 => 'message5',
     313            'additional_classes' => array( 'updated' ),
     314            'dismissible'        => true,
     315        )
     316    );
    288317} elseif ( isset( $_GET['error'] ) && 'resuming' === $_GET['error'] ) {
    289     ?>
    290     <div id="message6" class="error"><p><?php _e( 'Theme could not be resumed because it triggered a <strong>fatal error</strong>.' ); ?></p></div>
    291     <?php
     318    wp_admin_notice(
     319        __( 'Theme could not be resumed because it triggered a <strong>fatal error</strong>.' ),
     320        array(
     321            'id'                 => 'message6',
     322            'additional_classes' => array( 'error' ),
     323        )
     324    );
    292325} elseif ( isset( $_GET['enabled-auto-update'] ) ) {
    293     ?>
    294     <div id="message7" class="updated notice is-dismissible"><p><?php _e( 'Theme will be auto-updated.' ); ?></p></div>
    295     <?php
     326    wp_admin_notice(
     327        __( 'Theme will be auto-updated.' ),
     328        array(
     329            'id'                 => 'message7',
     330            'additional_classes' => array( 'updated' ),
     331            'dismissible'        => true,
     332        )
     333    );
    296334} elseif ( isset( $_GET['disabled-auto-update'] ) ) {
    297     ?>
    298     <div id="message8" class="updated notice is-dismissible"><p><?php _e( 'Theme will no longer be auto-updated.' ); ?></p></div>
    299     <?php
     335    wp_admin_notice(
     336        __( 'Theme will no longer be auto-updated.' ),
     337        array(
     338            'id'                 => 'message8',
     339            'additional_classes' => array( 'updated' ),
     340            'dismissible'        => true,
     341        )
     342    );
    300343}
    301344
Note: See TracChangeset for help on using the changeset viewer.