Make WordPress Core


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

    r56515 r56570  
    470470    <?php
    471471    if ( ! $theme['compatibleWP'] || ! $theme['compatiblePHP'] ) {
    472         echo '<div class="notice inline notice-error notice-alt"><p>';
     472        $message = '';
    473473        if ( ! $theme['compatibleWP'] && ! $theme['compatiblePHP'] ) {
    474             _e( 'This theme does not work with your versions of WordPress and PHP.' );
     474            $message = __( '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                $message .= sprintf(
    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                $message .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
    483483            } elseif ( current_user_can( 'update_core' ) ) {
    484                 printf(
     484                $message .= sprintf(
    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                $message .= sprintf(
    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                $message .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
    496496            }
    497497        } elseif ( ! $theme['compatibleWP'] ) {
    498             _e( 'This theme does not work with your version of WordPress.' );
     498            $message .= __( 'This theme does not work with your version of WordPress.' );
    499499            if ( current_user_can( 'update_core' ) ) {
    500                 printf(
     500                $message .= sprintf(
    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            $message .= __( 'This theme does not work with your version of PHP.' );
    508508            if ( current_user_can( 'update_php' ) ) {
    509                 printf(
     509                $message .= sprintf(
    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                $message .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
    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    $notice   = wp_get_admin_notice(
     703        '',
     704        array(
     705            'type'               => 'error',
     706            'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ),
     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            ' . $notice . '
    721735        </div>
    722736    ';
Note: See TracChangeset for help on using the changeset viewer.