Make WordPress Core

Changeset 56571

Timestamp:
09/14/2023 01:11:29 AM (11 months ago)
Author:
joedolson
Message:

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

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

Props costdev, joedolson.
See #57791.

Location:
trunk/src/wp-admin/includes
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-custom-background.php

    r55881 r56571  
    240240<h1><?php _e( 'Custom Background' ); ?></h1>
    241241
    242         <?php if ( current_user_can( 'customize' ) ) { ?>
    243 <div class="notice notice-info hide-if-no-customize">
    244     <p>
    245             <?php
    246             printf(
     242        <?php
     243        if ( current_user_can( 'customize' ) ) {
     244            $message = sprintf(
    247245                /* translators: %s: URL to background image configuration in Customizer. */
    248246                __( 'You can now manage and live-preview Custom Backgrounds in the <a href="%s">Customizer</a>.' ),
    249247                admin_url( 'customize.php?autofocus[control]=background_image' )
    250248            );
    251             ?>
    252     </p>
    253 </div>
    254         <?php } ?>
    255 
    256         <?php if ( ! empty( $this->updated ) ) { ?>
     249            wp_admin_notice(
     250                $message,
     251                array(
     252                    'type'               => 'info',
     253                    'additional_classes' => array( 'hide-if-no-customize' ),
     254                )
     255            );
     256        }
     257
     258        if ( ! empty( $this->updated ) ) {
     259            ?>
    257260<div id="message" class="updated">
    258261    <p>
  • trunk/src/wp-admin/includes/class-custom-image-header.php

    r55988 r56571  
    510510<h1><?php _e( 'Custom Header' ); ?></h1>
    511511
    512         <?php if ( current_user_can( 'customize' ) ) { ?>
    513 <div class="notice notice-info hide-if-no-customize">
    514     <p>
    515             <?php
    516             printf(
     512        <?php
     513        if ( current_user_can( 'customize' ) ) {
     514            $message = sprintf(
    517515                /* translators: %s: URL to header image configuration in Customizer. */
    518516                __( 'You can now manage and live-preview Custom Header in the <a href="%s">Customizer</a>.' ),
    519517                admin_url( 'customize.php?autofocus[control]=header_image' )
    520518            );
    521             ?>
    522     </p>
    523 </div>
    524         <?php } ?>
     519            wp_admin_notice(
     520                $message,
     521                array(
     522                    'type'               => 'info',
     523                    'additional_classes' => array( 'hide-if-no-customize' ),
     524                )
     525            );
     526        }
     527        ?>
    525528
    526529        <?php if ( ! empty( $this->updated ) ) { ?>
  • trunk/src/wp-admin/includes/class-wp-plugin-install-list-table.php

    r56397 r56571  
    687687            <?php
    688688            if ( ! $compatible_php || ! $compatible_wp ) {
    689                 echo '<div class="notice inline notice-error notice-alt"><p>';
     689                ';
    690690                if ( ! $compatible_php && ! $compatible_wp ) {
    691                     _e( 'This plugin does not work with your versions of WordPress and PHP.' );
     691                    ( 'This plugin does not work with your versions of WordPress and PHP.' );
    692692                    if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
    693                         printf(
     693                        printf(
    694694                            /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
    695695                            ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
     
    697697                            esc_url( wp_get_update_php_url() )
    698698                        );
    699                         wp_update_php_annotation( '</p><p><em>', '</em>' );
     699                        );
    700700                    } elseif ( current_user_can( 'update_core' ) ) {
    701                         printf(
     701                        printf(
    702702                            /* translators: %s: URL to WordPress Updates screen. */
    703703                            ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     
    705705                        );
    706706                    } elseif ( current_user_can( 'update_php' ) ) {
    707                         printf(
     707                        printf(
    708708                            /* translators: %s: URL to Update PHP page. */
    709709                            ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
    710710                            esc_url( wp_get_update_php_url() )
    711711                        );
    712                         wp_update_php_annotation( '</p><p><em>', '</em>' );
     712                        );
    713713                    }
    714714                } elseif ( ! $compatible_wp ) {
    715                     _e( 'This plugin does not work with your version of WordPress.' );
     715                    ( 'This plugin does not work with your version of WordPress.' );
    716716                    if ( current_user_can( 'update_core' ) ) {
    717                         printf(
     717                        printf(
    718718                            /* translators: %s: URL to WordPress Updates screen. */
    719719                            ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     
    722722                    }
    723723                } elseif ( ! $compatible_php ) {
    724                     _e( 'This plugin does not work with your version of PHP.' );
     724                    ( 'This plugin does not work with your version of PHP.' );
    725725                    if ( current_user_can( 'update_php' ) ) {
    726                         printf(
     726                        printf(
    727727                            /* translators: %s: URL to Update PHP page. */
    728728                            ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
    729729                            esc_url( wp_get_update_php_url() )
    730730                        );
    731                         wp_update_php_annotation( '</p><p><em>', '</em>' );
     731                        );
    732732                    }
    733733                }
    734                 echo '</p></div>';
     734
     735                wp_admin_notice(
     736                    $incompatible_notice_message,
     737                    array(
     738                        'type'               => 'error',
     739                        'additional_classes' => array( 'notice-alt', 'inline' ),
     740                    )
     741                );
    735742            }
    736743            ?>
  • trunk/src/wp-admin/includes/class-wp-plugins-list-table.php

    r56549 r56571  
    12441244                    echo apply_filters( 'plugin_auto_update_setting_html', $html, $plugin_file, $plugin_data );
    12451245
    1246                     echo '<div class="notice notice-error notice-alt inline hidden"><p></p></div>';
     1246                    wp_admin_notice(
     1247                        '',
     1248                        array(
     1249                            'type'               => 'error',
     1250                            'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ),
     1251                        )
     1252                    );
     1253
    12471254                    echo '</td>';
    12481255
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r56549 r56571  
    20772077                <?php endif; ?>
    20782078
    2079                 <div class="notice notice-error notice-alt inline hidden">
    2080                     <p class="error"></p>
    2081                 </div>
     2079                <?php
     2080                wp_admin_notice(
     2081                    '<p class="error"></p>',
     2082                    array(
     2083                        'type'               => 'error',
     2084                        'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ),
     2085                        'paragraph_wrap'     => false,
     2086                    )
     2087                );
     2088                ?>
    20822089            </div>
    20832090        </div> <!-- end of .inline-edit-wrapper -->
  • trunk/src/wp-admin/includes/class-wp-privacy-policy-content.php

    r56499 r56571  
    353353            );
    354354        } else {
    355             ?>
    356             <div class="notice notice-warning inline wp-pp-notice">
    357                 <p>
    358                 <?php
    359                 echo $message;
    360                 printf(
    361                     ' <a href="%s" target="_blank">%s <span class="screen-reader-text">%s</span></a>',
    362                     $url,
    363                     $label,
    364                     /* translators: Hidden accessibility text. */
    365                     __( '(opens in a new tab)' )
    366                 );
    367                 ?>
    368                 </p>
    369             </div>
    370             <?php
     355            $message .= sprintf(
     356                ' <a href="%s" target="_blank">%s <span class="screen-reader-text">%s</span></a>',
     357                $url,
     358                $label,
     359                /* translators: Hidden accessibility text. */
     360                __( '(opens in a new tab)' )
     361            );
     362            wp_admin_notice(
     363                $message,
     364                array(
     365                    'type'               => 'warning',
     366                    'additional_classes' => array( 'inline', 'wp-pp-notice' ),
     367                )
     368            );
    371369        }
    372370    }
     
    395393
    396394                /* translators: %s: Date of plugin deactivation. */
    397                 $removed = __( 'You deactivated this plugin on %s and may no longer need this policy.' );
    398                 $removed = '<div class="notice notice-info inline"><p>' . sprintf( $removed, $date ) . '</p></div>';
     395                $removed = sprintf( __( 'You deactivated this plugin on %s and may no longer need this policy.' ), $date );
     396                $removed = wp_get_admin_notice(
     397                    $removed,
     398                    array(
     399                        'type'               => 'info',
     400                        'additional_classes' => array( 'inline' ),
     401                    )
     402                );
    399403            } elseif ( ! empty( $section['updated'] ) ) {
    400404                $badge_class = ' blue';
  • trunk/src/wp-admin/includes/class-wp-terms-list-table.php

    r56549 r56571  
    712712                <input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" />
    713713
    714                 <div class="notice notice-error notice-alt inline hidden">
    715                     <p class="error"></p>
    716                 </div>
     714                <?php
     715                wp_admin_notice(
     716                    '<p class="error"></p>',
     717                    array(
     718                        'type'               => 'error',
     719                        'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ),
     720                        'paragraph_wrap'     => false,
     721                    )
     722                );
     723                ?>
    717724            </div>
    718725            </div>
  • trunk/src/wp-admin/includes/meta-boxes.php

    r56420 r56571  
    312312
    313313        if ( 'draft' === $post->post_status && get_post_meta( $post_id, '_customize_changeset_uuid', true ) ) :
    314             ?>
    315             <div class="notice notice-info notice-alt inline">
    316                 <p>
    317                     <?php
    318                     printf(
    319                         /* translators: %s: URL to the Customizer. */
    320                         __( 'This draft comes from your <a href="%s">unpublished customization changes</a>. You can edit, but there is no need to publish now. It will be published automatically with those changes.' ),
    321                         esc_url(
    322                             add_query_arg(
    323                                 'changeset_uuid',
    324                                 rawurlencode( get_post_meta( $post_id, '_customize_changeset_uuid', true ) ),
    325                                 admin_url( 'customize.php' )
    326                             )
    327                         )
    328                     );
    329                     ?>
    330                 </p>
    331             </div>
    332             <?php
     314            $message = sprintf(
     315                /* translators: %s: URL to the Customizer. */
     316                __( 'This draft comes from your <a href="%s">unpublished customization changes</a>. You can edit, but there is no need to publish now. It will be published automatically with those changes.' ),
     317                esc_url(
     318                    add_query_arg(
     319                        'changeset_uuid',
     320                        rawurlencode( get_post_meta( $post_id, '_customize_changeset_uuid', true ) ),
     321                        admin_url( 'customize.php' )
     322                    )
     323                )
     324            );
     325            wp_admin_notice(
     326                $message,
     327                array(
     328                    'type'               => 'info',
     329                    'additional_classes' => array( 'notice-alt', 'inline' ),
     330                )
     331            );
    333332        endif;
    334333
  • trunk/src/wp-admin/includes/plugin-install.php

    r56446 r56571  
    818818
    819819    if ( ! $compatible_php ) {
    820         echo '<div class="notice notice-error notice-alt"><p>';
    821         _e( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>.' );
     820        $compatible_php_notice_message  = '<p>';
     821        $compatible_php_notice_message .= __( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>.' );
     822
    822823        if ( current_user_can( 'update_php' ) ) {
    823             printf(
     824            printf(
    824825                /* translators: %s: URL to Update PHP page. */
    825826                ' ' . __( '<a href="%s" target="_blank">Click here to learn more about updating PHP</a>.' ),
    826827                esc_url( wp_get_update_php_url() )
    827             );
    828 
    829             wp_update_php_annotation( '</p><p><em>', '</em>' );
     828            ) . wp_update_php_annotation( '</p><p><em>', '</em>', false );
    830829        } else {
    831             echo '</p>';
    832         }
    833         echo '</div>';
     830            $compatible_php_notice_message .= '</p>';
     831        }
     832
     833        wp_admin_notice(
     834            $compatible_php_notice_message,
     835            array(
     836                'type'               => 'error',
     837                'additional_classes' => array( 'notice-alt' ),
     838                'paragraph_wrap'     => false,
     839            )
     840        );
    834841    }
    835842
    836843    if ( ! $tested_wp ) {
    837         echo '<div class="notice notice-warning notice-alt"><p>';
    838         _e( '<strong>Warning:</strong> This plugin <strong>has not been tested</strong> with your current version of WordPress.' );
    839         echo '</p></div>';
     844        wp_admin_notice(
     845            __( '<strong>Warning:</strong> This plugin <strong>has not been tested</strong> with your current version of WordPress.' ),
     846            array(
     847                'type'               => 'warning',
     848                'additional_classes' => array( 'notice-alt' ),
     849            )
     850        );
    840851    } elseif ( ! $compatible_wp ) {
    841         echo '<div class="notice notice-error notice-alt"><p>';
    842         _e( '<strong>Error:</strong> This plugin <strong>requires a newer version of WordPress</strong>.' );
     852        $compatible_wp_notice_message = __( '<strong>Error:</strong> This plugin <strong>requires a newer version of WordPress</strong>.' );
    843853        if ( current_user_can( 'update_core' ) ) {
    844             printf(
     854            printf(
    845855                /* translators: %s: URL to WordPress Updates screen. */
    846856                ' ' . __( '<a href="%s" target="_parent">Click here to update WordPress</a>.' ),
     
    848858            );
    849859        }
    850         echo '</p></div>';
     860
     861        wp_admin_notice(
     862            $compatible_wp_notice_message,
     863            array(
     864                'type'               => 'error',
     865                'additional_classes' => array( 'notice-alt' ),
     866            )
     867        );
    851868    }
    852869
  • trunk/src/wp-admin/includes/plugin.php

    r56414 r56571  
    24982498    }
    24992499
    2500     printf(
    2501         '<div class="notice notice-error"><p><strong>%s</strong><br>%s</p><p><a href="%s">%s</a></p></div>',
     2500    printf(
     2501        '<>',
    25022502        __( 'One or more plugins failed to load properly.' ),
    25032503        __( 'You can find more details and make changes on the Plugins screen.' ),
    25042504        esc_url( admin_url( 'plugins.php?plugin_status=paused' ) ),
    25052505        __( 'Go to the Plugins screen' )
     2506
     2507
     2508
     2509
    25062510    );
    25072511}
     
    25722576        }
    25732577
    2574         printf(
    2575             '<div class="notice notice-warning"><p><strong>%s</strong><br>%s</p><p><a href="%s">%s</a></p></div>',
     2578        printf(
     2579            '<>',
    25762580            sprintf(
    25772581                /* translators: %s: Name of deactivated plugin. */
     
    25832587            __( 'Go to the Plugins screen' )
    25842588        );
     2589
    25852590    }
    25862591
  • trunk/src/wp-admin/includes/template.php

    r56549 r56571  
    513513            <span class="waiting spinner"></span>
    514514        </p>
    515         <div class="notice notice-error notice-alt inline hidden">
    516             <p class="error"></p>
    517         </div>
     515        <?php
     516        wp_admin_notice(
     517            '<p class="error"></p>',
     518            array(
     519                'type'               => 'error',
     520                'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ),
     521                'paragraph_wrap'     => false,
     522            )
     523        );
     524        ?>
    518525    </div>
    519526
     
    27772784 */
    27782785function _wp_posts_page_notice() {
    2779     printf(
    2780         '<div class="notice notice-warning inline"><p>%s</p></div>',
    2781         __( 'You are currently editing the page that shows your latest posts.' )
     2786    wp_admin_notice(
     2787        __( 'You are currently editing the page that shows your latest posts.' ),
     2788        array(
     2789            'type'               => 'warning',
     2790            'additional_classes' => array( 'inline' ),
     2791        )
    27822792    );
    27832793}
  • trunk/src/wp-admin/includes/theme.php

    r56552 r56571  
    12251225    }
    12261226
    1227     printf(
    1228         '<div class="notice notice-error"><p><strong>%s</strong><br>%s</p><p><a href="%s">%s</a></p></div>',
     1227    printf(
     1228        '<>',
    12291229        __( 'One or more themes failed to load properly.' ),
    12301230        __( 'You can find more details and make changes on the Themes screen.' ),
     
    12321232        __( 'Go to the Themes screen' )
    12331233    );
     1234
     1235
     1236
     1237
     1238
     1239
     1240
    12341241}
  • trunk/src/wp-admin/includes/update.php

    r55874 r56571  
    10501050    $url = wp_nonce_url( $url, WP_Recovery_Mode::EXIT_ACTION );
    10511051
    1052     ?>
    1053     <div class="notice notice-info">
    1054         <p>
    1055             <?php
    1056             printf(
    1057                 /* translators: %s: Recovery Mode exit link. */
    1058                 __( 'You are in recovery mode. This means there may be an error with a theme or plugin. To exit recovery mode, log out or use the Exit button. <a href="%s">Exit Recovery Mode</a>' ),
    1059                 esc_url( $url )
    1060             );
    1061             ?>
    1062         </p>
    1063     </div>
    1064     <?php
     1052    $message = sprintf(
     1053        /* translators: %s: Recovery Mode exit link. */
     1054        __( 'You are in recovery mode. This means there may be an error with a theme or plugin. To exit recovery mode, log out or use the Exit button. <a href="%s">Exit Recovery Mode</a>' ),
     1055        esc_url( $url )
     1056    );
     1057    wp_admin_notice( $message, array( 'type' => 'info' ) );
    10651058}
    10661059
Note: See TracChangeset for help on using the changeset viewer.