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.

git-svn-id: https://develop.svn.wordpress.org/trunk@56570 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Joe Dolson
2023-09-14 00:52:45 +00:00
parent 96a7954ee6
commit 3cefc7c7ff
20 changed files with 434 additions and 225 deletions
+28 -14
View File
@@ -469,52 +469,59 @@ foreach ( $themes as $theme ) :
<?php
if ( ! $theme['compatibleWP'] || ! $theme['compatiblePHP'] ) {
echo '<div class="notice inline notice-error notice-alt"><p>';
$message = '';
if ( ! $theme['compatibleWP'] && ! $theme['compatiblePHP'] ) {
_e( 'This theme does not work with your versions of WordPress and PHP.' );
$message = __( 'This theme does not work with your versions of WordPress and PHP.' );
if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
printf(
$message .= sprintf(
/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
self_admin_url( 'update-core.php' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
$message .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
} elseif ( current_user_can( 'update_core' ) ) {
printf(
$message .= sprintf(
/* translators: %s: URL to WordPress Updates screen. */
' ' . __( '<a href="%s">Please update WordPress</a>.' ),
self_admin_url( 'update-core.php' )
);
} elseif ( current_user_can( 'update_php' ) ) {
printf(
$message .= sprintf(
/* translators: %s: URL to Update PHP page. */
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
$message .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
}
} elseif ( ! $theme['compatibleWP'] ) {
_e( 'This theme does not work with your version of WordPress.' );
$message .= __( 'This theme does not work with your version of WordPress.' );
if ( current_user_can( 'update_core' ) ) {
printf(
$message .= sprintf(
/* translators: %s: URL to WordPress Updates screen. */
' ' . __( '<a href="%s">Please update WordPress</a>.' ),
self_admin_url( 'update-core.php' )
);
}
} elseif ( ! $theme['compatiblePHP'] ) {
_e( 'This theme does not work with your version of PHP.' );
$message .= __( 'This theme does not work with your version of PHP.' );
if ( current_user_can( 'update_php' ) ) {
printf(
$message .= sprintf(
/* translators: %s: URL to Update PHP page. */
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
$message .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
}
}
echo '</p></div>';
wp_admin_notice(
$message,
array(
'type' => 'error',
'additional_classes' => array( 'inline', 'notice-alt' ),
)
);
}
?>
@@ -692,6 +699,13 @@ if ( ! is_multisite() && $broken_themes ) {
* @return string The template for displaying the auto-update setting link.
*/
function wp_theme_auto_update_setting_template() {
$notice = wp_get_admin_notice(
'',
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ),
)
);
$template = '
<div class="theme-autoupdate">
<# if ( data.autoupdate.supported ) { #>
@@ -717,7 +731,7 @@ function wp_theme_auto_update_setting_template() {
<# } #>
<br />' . wp_get_auto_update_message() . '</span>
<# } #>
<div class="notice notice-error notice-alt inline hidden"><p></p></div>
' . $notice . '
</div>
';