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.
Built from https://develop.svn.wordpress.org/trunk@56570


git-svn-id: http://core.svn.wordpress.org/trunk@56082 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
joedolson 2023-09-14 00:54:19 +00:00
parent 178e6722fe
commit 0f4010bd49
21 changed files with 435 additions and 226 deletions

View File

@ -137,9 +137,16 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
<div class="wrap">
<h1><?php echo esc_html( $title ); ?></h1>
<?php if ( is_wp_error( $error ) ) : ?>
<div class="notice notice-error"><p><?php echo $error->get_error_message(); ?></p></div>
<?php endif; ?>
<?php
if ( is_wp_error( $error ) ) {
wp_admin_notice(
$error->get_error_message(),
array(
'type' => 'error',
)
);
}
?>
<div class="card auth-app-card">
<h2 class="title"><?php _e( 'An application would like to connect to your account.' ); ?></h2>
@ -194,24 +201,25 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
}
?>
<?php if ( $new_password ) : ?>
<div class="notice notice-success notice-alt below-h2">
<p class="application-password-display">
<label for="new-application-password-value">
<?php
printf(
/* translators: %s: Application name. */
esc_html__( 'Your new password for %s is:' ),
'<strong>' . esc_html( $app_name ) . '</strong>'
);
?>
</label>
<input id="new-application-password-value" type="text" class="code" readonly="readonly" value="<?php esc_attr( WP_Application_Passwords::chunk_password( $new_password ) ); ?>" />
</p>
<p><?php _e( 'Be sure to save this in a safe location. You will not be able to retrieve it.' ); ?></p>
</div>
<?php
if ( $new_password ) :
$message = '<p class="application-password-display">
<label for="new-application-password-value">' . sprintf(
/* translators: %s: Application name. */
esc_html__( 'Your new password for %s is:' ),
'<strong>' . esc_html( $app_name ) . '</strong>'
) . '
</label>
<input id="new-application-password-value" type="text" class="code" readonly="readonly" value="' . esc_attr( WP_Application_Passwords::chunk_password( $new_password ) ) . '" />
</p>
<p>' . __( 'Be sure to save this in a safe location. You will not be able to retrieve it.' ) . '</p>';
$args = array(
'type' => 'success',
'additional_classes' => array( 'notice-alt', 'below-h2' ),
'paragraph_wrap' => false,
);
wp_admin_notice( $message, $args );
<?php
/**
* Fires in the Authorize Application Password new password section in the no-JS version.
*
@ -226,8 +234,8 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
* @param WP_User $user The user authorizing the application.
*/
do_action( 'wp_authorize_application_password_form_approved_no_js', $new_password, $request, $user );
else :
?>
<?php else : ?>
<form action="<?php echo esc_url( admin_url( 'authorize-application.php' ) ); ?>" method="post" class="form-wrap">
<?php wp_nonce_field( 'authorize_application_password' ); ?>
<input type="hidden" name="action" value="authorize_application_password" />

View File

@ -161,11 +161,23 @@ switch ( $action ) {
break;
}
if ( $message ) {
echo '<div id="message" class="notice notice-info"><p>' . $message . '</p></div>';
wp_admin_notice(
$message,
array(
'type' => 'info',
'id' => 'message',
)
);
}
}
wp_admin_notice(
'<strong>' . __( 'Caution:' ) . '</strong> ' . $caution_msg,
array(
'type' => 'warning',
'id' => 'message',
)
);
?>
<div id="message" class="notice notice-warning"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php echo $caution_msg; ?></p></div>
<table class="form-table comment-ays">
<tr>

View File

@ -440,12 +440,29 @@ if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create
<hr class="wp-header-end">
<?php if ( $notice ) : ?>
<div id="notice" class="notice notice-warning"><p id="has-newer-autosave"><?php echo $notice; ?></p></div>
<?php endif; ?>
<?php if ( $message ) : ?>
<div id="message" class="updated notice notice-success is-dismissible"><p><?php echo $message; ?></p></div>
<?php endif; ?>
<?php
if ( $notice ) :
wp_admin_notice(
'<p id="has-newer-autosave">' . $notice . '</p>',
array(
'type' => 'warning',
'id' => 'notice',
'paragraph_wrap' => false,
)
);
endif;
if ( $message ) :
wp_admin_notice(
$message,
array(
'type' => 'success',
'dismissible' => true,
'id' => 'message',
'additional_classes' => array( 'updated' ),
)
);
endif;
?>
<div id="lost-connection-notice" class="error hidden">
<p><span class="spinner"></span> <?php _e( '<strong>Connection lost.</strong> Saving has been disabled until you are reconnected.' ); ?>
<span class="hide-if-no-sessionstorage"><?php _e( 'This post is being backed up in your browser, just in case.' ); ?></span>

View File

@ -319,27 +319,29 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
<?php // JavaScript is disabled. ?>
<div class="wrap hide-if-js block-editor-no-js">
<h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>
<div class="notice notice-error">
<p>
<?php
$message = sprintf(
/* translators: %s: A link to install the Classic Editor plugin. */
__( 'The block editor requires JavaScript. Please enable JavaScript in your browser settings, or try the <a href="%s">Classic Editor plugin</a>.' ),
esc_url( wp_nonce_url( self_admin_url( 'plugin-install.php?tab=favorites&user=wordpressdotorg&save=0' ), 'save_wporg_username_' . get_current_user_id() ) )
);
<?php
$message = sprintf(
/* translators: %s: A link to install the Classic Editor plugin. */
__( 'The block editor requires JavaScript. Please enable JavaScript in your browser settings, or try the <a href="%s">Classic Editor plugin</a>.' ),
esc_url( wp_nonce_url( self_admin_url( 'plugin-install.php?tab=favorites&user=wordpressdotorg&save=0' ), 'save_wporg_username_' . get_current_user_id() ) )
);
/**
* Filters the message displayed in the block editor interface when JavaScript is
* not enabled in the browser.
*
* @since 5.0.3
*
* @param string $message The message being displayed.
* @param WP_Post $post The post being edited.
*/
echo apply_filters( 'block_editor_no_javascript_message', $message, $post );
?>
</p>
</div>
/**
* Filters the message displayed in the block editor interface when JavaScript is
* not enabled in the browser.
*
* @since 5.0.3
*
* @param string $message The message being displayed.
* @param WP_Post $post The post being edited.
*/
$message = apply_filters( 'block_editor_no_javascript_message', $message, $post );
wp_admin_notice(
$message,
array(
'type' => 'error',
)
);
?>
</div>
</div>

View File

@ -79,16 +79,18 @@ do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy ); ?>
$class = ( isset( $msg ) && 5 === $msg ) ? 'error' : 'success';
if ( $message ) {
?>
<div id="message" class="notice notice-<?php echo $class; ?>">
<p><strong><?php echo $message; ?></strong></p>
<?php if ( $wp_http_referer ) { ?>
<p><a href="<?php echo esc_url( wp_validate_redirect( sanitize_url( $wp_http_referer ), admin_url( 'term.php?taxonomy=' . $taxonomy ) ) ); ?>">
<?php echo esc_html( $tax->labels->back_to_items ); ?>
</a></p>
<?php } ?>
</div>
<?php
$message = '<p><strong>' . $message . '</strong></p>';
if ( $wp_http_referer ) {
$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>';
}
wp_admin_notice(
$message,
array(
'type' => $class,
'id' => 'message',
'paragraph_wrap' => false,
)
);
}
?>

View File

@ -154,20 +154,21 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
// Only show the dashboard notice if it's been less than a minute since the message was postponed.
if ( $time_passed < MINUTE_IN_SECONDS ) :
?>
<div class="notice notice-success is-dismissible">
<p>
<?php
printf(
/* translators: %s: Human-readable time interval. */
__( 'The admin email verification page will reappear after %s.' ),
human_time_diff( time() + $remind_interval )
);
?>
</p>
</div>
<?php endif; ?>
<?php endif; ?>
$message = sprintf(
/* translators: %s: Human-readable time interval. */
__( 'The admin email verification page will reappear after %s.' ),
human_time_diff( time() + $remind_interval )
);
wp_admin_notice(
$message,
array(
'type' => 'success',
'dismissible' => true,
)
);
endif;
endif;
?>
<?php
if ( has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) :

View File

@ -177,9 +177,15 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
<hr class="wp-header-end">
<div class="notice notice-error hide-if-js">
<p><?php _e( 'The Privacy Settings require JavaScript.' ); ?></p>
</div>
<?php
wp_admin_notice(
__( 'The Privacy Settings require JavaScript.' ),
array(
'type' => 'error',
'additional_classes' => array( 'hide-if-js' ),
)
);
?>
<div class="privacy-settings-body hide-if-no-js">
<h2><?php _e( 'Privacy Settings' ); ?></h2>

View File

@ -144,12 +144,28 @@ else :
?>
</label></li>
</ul>
<?php if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) === get_option( 'page_on_front' ) ) : ?>
<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>
<?php endif; ?>
<?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' ) ) : ?>
<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>
<?php endif; ?>
<?php
if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) === get_option( 'page_on_front' ) ) :
wp_admin_notice(
__( '<strong>Warning:</strong> these pages should not be the same!' ),
array(
'type' => 'warning',
'id' => 'front-page-warning',
'additional_classes' => array( 'inline' ),
)
);
endif;
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' ) ) :
wp_admin_notice(
__( '<strong>Warning:</strong> these pages should not be the same as your Privacy Policy page!' ),
array(
'type' => 'warning',
'id' => 'privacy-policy-page-warning',
'additional_classes' => array( 'inline' ),
)
);
endif;
?>
</fieldset></td>
</tr>
<?php endif; ?>

View File

@ -359,10 +359,14 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
<div class="wrap">
<h1><?php esc_html_e( 'All Settings' ); ?></h1>
<div class="notice notice-warning">
<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>
</div>
<?php
wp_admin_notice(
'<strong>' . __( 'Warning:' ) . '</strong> ' . __( 'This page allows direct access to your site settings. You can break things here. Please be cautious!' ),
array(
'type' => 'warning',
)
);
?>
<form name="form" action="options.php" method="post" id="all-options">
<?php wp_nonce_field( 'options-options' ); ?>
<input type="hidden" name="action" value="update" />

View File

@ -182,16 +182,29 @@ $content = esc_textarea( $content );
<div class="wrap">
<h1><?php echo esc_html( $title ); ?></h1>
<?php if ( isset( $_GET['a'] ) ) : ?>
<div id="message" class="updated notice is-dismissible">
<p><?php _e( 'File edited successfully.' ); ?></p>
</div>
<?php elseif ( is_wp_error( $edit_error ) ) : ?>
<div id="message" class="notice notice-error">
<p><?php _e( 'There was an error while trying to update the file. You may need to fix something and try updating again.' ); ?></p>
<pre><?php echo esc_html( $edit_error->get_error_message() ? $edit_error->get_error_message() : $edit_error->get_error_code() ); ?></pre>
</div>
<?php endif; ?>
<?php
if ( isset( $_GET['a'] ) ) :
wp_admin_notice(
__( 'File edited successfully.' ),
array(
'additional_classes' => array( 'updated', 'is-dismissible' ),
'id' => 'message',
)
);
elseif ( is_wp_error( $edit_error ) ) :
$error = esc_html( $edit_error->get_error_message() ? $edit_error->get_error_message() : $edit_error->get_error_code() );
$message = '<p>' . __( 'There was an error while trying to update the file. You may need to fix something and try updating again.' ) . '</p>
<pre>' . $error . '</pre>';
wp_admin_notice(
$message,
array(
'type' => 'error',
'id' => 'message',
'paragraph_wrap' => false,
)
);
endif;
?>
<div class="fileedit-sub">
<div class="alignleft">
@ -280,11 +293,17 @@ $content = esc_textarea( $content );
<?php if ( is_writable( $real_file ) ) : ?>
<div class="editor-notices">
<?php if ( in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) ) { ?>
<div class="notice notice-warning inline active-plugin-edit-warning">
<p><?php _e( '<strong>Warning:</strong> Making changes to active plugins is not recommended.' ); ?></p>
</div>
<?php } ?>
<?php
if ( in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) ) {
wp_admin_notice(
__( '<strong>Warning:</strong> Making changes to active plugins is not recommended.' ),
array(
'type' => 'warning',
'additional_classes' => array( 'inline', 'active-plugin-edit-warning' ),
)
);
}
?>
</div>
<p class="submit">
<?php submit_button( __( 'Update File' ), 'primary', 'submit', false ); ?>

View File

@ -60,9 +60,15 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
<hr class="wp-header-end">
<div class="notice notice-error hide-if-js">
<p><?php _e( 'The Privacy Settings require JavaScript.' ); ?></p>
</div>
<?php
wp_admin_notice(
__( 'The Privacy Settings require JavaScript.' ),
array(
'type' => 'error',
'additional_classes' => array( 'hide-if-js' ),
)
);
?>
<div class="privacy-settings-body hide-if-no-js">
<h2><?php _e( 'Privacy Policy Guide' ); ?></h2>

View File

@ -160,22 +160,25 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
<?php // JavaScript is disabled. ?>
<div class="wrap hide-if-js site-editor-no-js">
<h1 class="wp-heading-inline"><?php _e( 'Edit site' ); ?></h1>
<div class="notice notice-error">
<p>
<?php
/**
* Filters the message displayed in the site editor interface when JavaScript is
* not enabled in the browser.
*
* @since 6.3.0
*
* @param string $message The message being displayed.
* @param WP_Post $post The post being edited.
*/
echo apply_filters( 'site_editor_no_javascript_message', __( 'The site editor requires JavaScript. Please enable JavaScript in your browser settings.' ), $post );
?>
</p>
</div>
<?php
/**
* Filters the message displayed in the site editor interface when JavaScript is
* not enabled in the browser.
*
* @since 6.3.0
*
* @param string $message The message being displayed.
* @param WP_Post $post The post being edited.
*/
$message = apply_filters( 'site_editor_no_javascript_message', __( 'The site editor requires JavaScript. Please enable JavaScript in your browser settings.' ), $post );
wp_admin_notice(
$message,
array(
'type' => 'error',
'additional_classes' => array( 'hide-if-js' ),
)
);
?>
</div>
</div>

View File

@ -18,11 +18,15 @@ if ( ! class_exists( 'WP_Site_Health' ) ) {
}
$health_check_site_status = WP_Site_Health::get_instance();
?>
<div class="notice notice-error hide-if-js">
<p><?php _e( 'The Site Health check requires JavaScript.' ); ?></p>
</div>
wp_admin_notice(
__( 'The Site Health check requires JavaScript.' ),
array(
'type' => 'error',
'additional_classes' => array( 'hide-if-js' ),
)
);
?>
<div class="health-check-body health-check-debug-tab hide-if-no-js">
<?php

View File

@ -105,13 +105,23 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
<?php
if ( isset( $_GET['https_updated'] ) ) {
if ( $_GET['https_updated'] ) {
?>
<div id="message" class="notice notice-success is-dismissible"><p><?php _e( 'Site URLs switched to HTTPS.' ); ?></p></div>
<?php
wp_admin_notice(
__( 'Site URLs switched to HTTPS.' ),
array(
'type' => 'success',
'id' => 'message',
'dismissible' => true,
)
);
} else {
?>
<div id="message" class="notice notice-error is-dismissible"><p><?php _e( 'Site URLs could not be switched to HTTPS.' ); ?></p></div>
<?php
wp_admin_notice(
__( 'Site URLs could not be switched to HTTPS.' ),
array(
'type' => 'error',
'id' => 'message',
'dismissible' => true,
)
);
}
}
?>
@ -212,12 +222,15 @@ if ( isset( $_GET['tab'] ) && ! empty( $_GET['tab'] ) ) {
require_once ABSPATH . 'wp-admin/admin-footer.php';
return;
} else {
wp_admin_notice(
__( 'The Site Health check requires JavaScript.' ),
array(
'type' => 'error',
'additional_classes' => array( 'hide-if-js' ),
)
);
?>
<div class="notice notice-error hide-if-js">
<p><?php _e( 'The Site Health check requires JavaScript.' ); ?></p>
</div>
<div class="health-check-body health-check-status-tab hide-if-no-js">
<div class="site-status-all-clear hide">
<p class="icon">

View File

@ -189,31 +189,44 @@ if ( $file_description !== $file_show ) {
<div class="wrap">
<h1><?php echo esc_html( $title ); ?></h1>
<?php if ( isset( $_GET['a'] ) ) : ?>
<div id="message" class="updated notice is-dismissible">
<p><?php _e( 'File edited successfully.' ); ?></p>
</div>
<?php elseif ( is_wp_error( $edit_error ) ) : ?>
<div id="message" class="notice notice-error">
<p><?php _e( 'There was an error while trying to update the file. You may need to fix something and try updating again.' ); ?></p>
<pre><?php echo esc_html( $edit_error->get_error_message() ? $edit_error->get_error_message() : $edit_error->get_error_code() ); ?></pre>
</div>
<?php endif; ?>
<?php
if ( isset( $_GET['a'] ) ) {
wp_admin_notice(
__( 'File edited successfully.' ),
array(
'id' => 'message',
'is-dismissible' => true,
'additional_classes' => array( 'updated' ),
)
);
} elseif ( is_wp_error( $edit_error ) ) {
$error_code = esc_html( $edit_error->get_error_message() ? $edit_error->get_error_message() : $edit_error->get_error_code() );
$message = '<p>' . __( 'There was an error while trying to update the file. You may need to fix something and try updating again.' ) . '</p>
<pre>' . $error_code . '</pre>';
wp_admin_notice(
$message,
array(
'type' => 'error',
'id' => 'message',
)
);
}
<?php if ( preg_match( '/\.css$/', $file ) && ! wp_is_block_theme() && current_user_can( 'customize' ) ) : ?>
<div id="message" class="notice-info notice">
<p><strong><?php _e( 'Did you know?' ); ?></strong></p>
<p>
<?php
printf(
/* translators: %s: Link to Custom CSS section in the Customizer. */
__( '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>.' ),
esc_url( add_query_arg( 'autofocus[section]', 'custom_css', admin_url( 'customize.php' ) ) )
);
?>
</p>
</div>
<?php endif; ?>
if ( preg_match( '/\.css$/', $file ) && ! wp_is_block_theme() && current_user_can( 'customize' ) ) {
$message = '<p><strong>' . __( 'Did you know?' ) . '</strong></p><p>' . sprintf(
/* translators: %s: Link to Custom CSS section in the Customizer. */
__( '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>.' ),
esc_url( add_query_arg( 'autofocus[section]', 'custom_css', admin_url( 'customize.php' ) ) )
) . '</p>';
wp_admin_notice(
$message,
array(
'type' => 'info',
'id' => 'message',
)
);
}
?>
<div class="fileedit-sub">
<div class="alignleft">
@ -304,23 +317,30 @@ else :
<div>
<div class="editor-notices">
<?php if ( is_child_theme() && $theme->get_stylesheet() === get_template() ) : ?>
<div class="notice notice-warning inline">
<p>
<?php if ( is_writable( $file ) ) : ?>
<strong><?php _e( 'Caution:' ); ?></strong>
<?php endif; ?>
<?php _e( 'This is a file in your current parent theme.' ); ?>
</p>
</div>
<?php endif; ?>
<?php
if ( is_child_theme() && $theme->get_stylesheet() === get_template() ) :
$message = ( is_writable( $file ) ) ? '<strong>' . __( 'Caution:' ) . '</strong> ' : '';
$message .= __( 'This is a file in your current parent theme.' );
wp_admin_notice(
$message,
array(
'type' => 'warning',
'additional_classes' => array( 'inline' ),
)
);
endif;
?>
</div>
<?php if ( is_writable( $file ) ) : ?>
<?php
if ( is_writable( $file ) ) {
?>
<p class="submit">
<?php submit_button( __( 'Update File' ), 'primary', 'submit', false ); ?>
<span class="spinner"></span>
</p>
<?php else : ?>
<?php
} else {
?>
<p>
<?php
printf(
@ -330,7 +350,9 @@ else :
);
?>
</p>
<?php endif; ?>
<?php
}
?>
</div>
<?php wp_print_file_editor_templates(); ?>
@ -342,7 +364,7 @@ endif; // End if $error.
</div>
<?php
$dismissed_pointers = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
if ( ! in_array( 'theme_editor_notice', $dismissed_pointers, true ) ) :
if ( ! in_array( 'theme_editor_notice', $dismissed_pointers, true ) ) {
// Get a back URL.
$referer = wp_get_referer();
@ -388,6 +410,6 @@ if ( ! in_array( 'theme_editor_notice', $dismissed_pointers, true ) ) :
</div>
</div>
<?php
endif; // Editor warning notice.
} // Editor warning notice.
require_once ABSPATH . 'wp-admin/admin-footer.php';

View File

@ -318,7 +318,15 @@ if ( $tab ) {
<# } #>
<# if ( data.installed ) { #>
<div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div>
<?php
wp_admin_notice(
_x( 'Installed', 'theme' ),
array(
'type' => 'success',
'additional_classes' => array( 'notice-alt' ),
)
);
?>
<# } #>
<# if ( ! data.compatible_wp || ! data.compatible_php ) { #>

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>
';

View File

@ -255,14 +255,19 @@ function core_upgrade_preamble() {
_e( 'An updated version of WordPress is available.' );
echo '</h2>';
echo '<div class="notice notice-warning inline"><p>';
printf(
$message = sprintf(
/* translators: 1: Documentation on WordPress backups, 2: Documentation on updating WordPress. */
__( '<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.' ),
__( 'https://wordpress.org/documentation/article/wordpress-backups/' ),
__( 'https://wordpress.org/documentation/article/updating-wordpress/' )
);
echo '</p></div>';
wp_admin_notice(
$message,
array(
'type' => 'warning',
'additional_classes' => array( 'inline' ),
)
);
} elseif ( $is_development_version ) {
echo '<h2 class="response">' . __( 'You are using a development version of WordPress.' ) . '</h2>';
} else {
@ -302,10 +307,22 @@ function core_auto_updates_settings() {
if ( isset( $_GET['core-major-auto-updates-saved'] ) ) {
if ( 'enabled' === $_GET['core-major-auto-updates-saved'] ) {
$notice_text = __( 'Automatic updates for all WordPress versions have been enabled. Thank you!' );
echo '<div class="notice notice-success is-dismissible"><p>' . $notice_text . '</p></div>';
wp_admin_notice(
$notice_text,
array(
'type' => 'success',
'dismissible' => true,
)
);
} elseif ( 'disabled' === $_GET['core-major-auto-updates-saved'] ) {
$notice_text = __( 'WordPress will only receive automatic security and maintenance releases from now on.' );
echo '<div class="notice notice-success is-dismissible"><p>' . $notice_text . '</p></div>';
wp_admin_notice(
$notice_text,
array(
'type' => 'success',
'dismissible' => true,
)
);
}
}

View File

@ -200,36 +200,57 @@ switch ( $action ) {
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
<?php if ( ! IS_PROFILE_PAGE && is_super_admin( $profile_user->ID ) && current_user_can( 'manage_network_options' ) ) : ?>
<div class="notice notice-info"><p><strong><?php _e( 'Important:' ); ?></strong> <?php _e( 'This user has super admin privileges.' ); ?></p></div>
<?php endif; ?>
<?php
if ( ! IS_PROFILE_PAGE && is_super_admin( $profile_user->ID ) && current_user_can( 'manage_network_options' ) ) :
$message = '<strong>' . __( 'Important:' ) . '</strong> ' . __( 'This user has super admin privileges.' );
wp_admin_notice(
$message,
array(
'type' => 'info',
)
);
endif;
<?php if ( isset( $_GET['updated'] ) ) : ?>
<div id="message" class="updated notice is-dismissible">
<?php if ( IS_PROFILE_PAGE ) : ?>
<p><strong><?php _e( 'Profile updated.' ); ?></strong></p>
<?php else : ?>
<p><strong><?php _e( 'User updated.' ); ?></strong></p>
<?php endif; ?>
<?php if ( $wp_http_referer && ! str_contains( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?>
<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>
<?php endif; ?>
</div>
<?php endif; ?>
if ( isset( $_GET['updated'] ) ) :
if ( IS_PROFILE_PAGE ) :
$message = '<strong>' . __( 'Profile updated.' ) . '</strong>';
else :
$message = '<strong>' . __( 'User updated.' ) . '</strong>';
endif;
if ( $wp_http_referer && ! str_contains( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) :
$message .= '<a href="' . esc_url( wp_validate_redirect( sanitize_url( $wp_http_referer ), self_admin_url( 'users.php' ) ) ) . '">' . __( '&larr; Go to Users' ) . '</a>';
endif;
wp_admin_notice(
$message,
array(
'id' => 'message',
'dismissible' => true,
'additional_classes' => array( 'updated' ),
)
);
endif;
<?php if ( isset( $_GET['error'] ) ) : ?>
<div class="notice notice-error">
<?php if ( 'new-email' === $_GET['error'] ) : ?>
<p><?php _e( 'Error while saving the new email address. Please try again.' ); ?></p>
<?php endif; ?>
</div>
<?php endif; ?>
if ( isset( $_GET['error'] ) ) :
$message = '';
if ( 'new-email' === $_GET['error'] ) :
$message = __( 'Error while saving the new email address. Please try again.' );
endif;
wp_admin_notice(
$message,
array(
'type' => 'error',
)
);
endif;
<?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
if ( isset( $errors ) && is_wp_error( $errors ) ) {
?>
<div class="error">
<p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p>
</div>
<?php endif; ?>
<?php
}
?>
<div class="wrap" id="profile-page">
<h1 class="wp-heading-inline">
@ -802,11 +823,17 @@ switch ( $action ) {
<button type="button" name="do_new_application_password" id="do_new_application_password" class="button button-secondary"><?php _e( 'Add New Application Password' ); ?></button>
</div>
<?php else : ?>
<div class="notice notice-error inline">
<p><?php _e( 'Your website appears to use Basic Authentication, which is not currently compatible with Application Passwords.' ); ?></p>
</div>
<?php endif; ?>
<?php
else :
wp_admin_notice(
__( 'Your website appears to use Basic Authentication, which is not currently compatible with Application Passwords.' ),
array(
'type' => 'error',
'additional_classes' => array( 'inline' ),
)
);
endif;
?>
<div class="application-passwords-list-table-wrapper">
<?php

View File

@ -8318,15 +8318,23 @@ function wp_get_default_update_php_url() {
*
* @since 5.1.0
* @since 5.2.0 Added the `$before` and `$after` parameters.
* @since 6.4.0 Added the `$echo` parameter.
*
* @param string $before Markup to output before the annotation. Default `<p class="description">`.
* @param string $after Markup to output after the annotation. Default `</p>`.
* @param bool $echo Markup should echo if true. Default `true`.
*
* @return string|void
*/
function wp_update_php_annotation( $before = '<p class="description">', $after = '</p>' ) {
function wp_update_php_annotation( $before = '<p class="description">', $after = '</p>', $echo = true ) {
$annotation = wp_get_update_php_annotation();
if ( $annotation ) {
echo $before . $annotation . $after;
if ( $echo ) {
echo $before . $annotation . $after;
} else {
return $before . $annotation . $after;
}
}
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.4-alpha-56569';
$wp_version = '6.4-alpha-56570';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.