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

Add additional usage of `wp_admin_notice()` in `wp-admin/` on `.error` and miscellaneous usages previously overlooked. 

Follow up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597], [56599].

Props costdev, joedolson.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56600


git-svn-id: http://core.svn.wordpress.org/trunk@56112 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
joedolson 2023-09-17 15:33:17 +00:00
parent 6cdd74585d
commit 3356f6e33f
16 changed files with 304 additions and 161 deletions

View File

@ -113,8 +113,8 @@ if ( isset( $_REQUEST['post_id'] ) ) {
$id = media_handle_upload( 'async-upload', $post_id ); $id = media_handle_upload( 'async-upload', $post_id );
if ( is_wp_error( $id ) ) { if ( is_wp_error( $id ) ) {
printf( $message = sprintf(
'<div class="error-div error">%s <strong>%s</strong><br />%s</div>', '%s <strong>%s</strong><br />%s',
sprintf( sprintf(
'<button type="button" class="dismiss button-link" onclick="jQuery(this).parents(\'div.media-item\').slideUp(200, function(){jQuery(this).remove();});">%s</button>', '<button type="button" class="dismiss button-link" onclick="jQuery(this).parents(\'div.media-item\').slideUp(200, function(){jQuery(this).remove();});">%s</button>',
__( 'Dismiss' ) __( 'Dismiss' )
@ -126,6 +126,13 @@ if ( is_wp_error( $id ) ) {
), ),
esc_html( $id->get_error_message() ) esc_html( $id->get_error_message() )
); );
wp_admin_notice(
$message,
array(
'additional_classes' => array( 'error-div', 'error' ),
'paragraph_wrap' => false,
)
);
exit; exit;
} }

View File

@ -301,7 +301,13 @@ if ( isset( $_REQUEST['error'] ) ) {
break; break;
} }
if ( $error_msg ) { if ( $error_msg ) {
echo '<div id="moderated" class="error"><p>' . $error_msg . '</p></div>'; wp_admin_notice(
$error_msg,
array(
'id' => 'moderated',
'additional_classes' => array( 'error' ),
)
);
} }
} }

View File

@ -462,12 +462,21 @@ if ( $message ) :
) )
); );
endif; endif;
$connection_lost_message = sprintf(
'<span class="spinner"></span> %1$s <span class="hide-if-no-sessionstorage">%2$s</span>',
__( '<strong>Connection lost.</strong> Saving has been disabled until you are reconnected.' ),
__( 'This post is being backed up in your browser, just in case.' )
);
wp_admin_notice(
$connection_lost_message,
array(
'id' => 'lost-connection-notice',
'additional_classes' => array( 'error', 'hidden' ),
)
);
?> ?>
<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>
</p>
</div>
<form name="post" action="post.php" method="post" id="post" <form name="post" action="post.php" method="post" id="post"
<?php <?php
/** /**

View File

@ -348,9 +348,16 @@ if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
<hr class="wp-header-end"> <hr class="wp-header-end">
<?php if ( $message ) : ?> <?php
<div id="message" class="<?php echo $class; ?> notice is-dismissible"><p><?php echo $message; ?></p></div> if ( $message ) :
<?php wp_admin_notice(
$message,
array(
'id' => 'message',
'additional_classes' => array( $class ),
'dismissible' => true,
)
);
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message', 'error' ), $_SERVER['REQUEST_URI'] ); $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message', 'error' ), $_SERVER['REQUEST_URI'] );
endif; endif;
?> ?>

View File

@ -60,16 +60,21 @@ $parent_file = 'tools.php';
<div class="wrap"> <div class="wrap">
<h1><?php echo esc_html( $title ); ?></h1> <h1><?php echo esc_html( $title ); ?></h1>
<?php if ( ! empty( $_GET['invalid'] ) ) : ?> <?php
<div class="error"> if ( ! empty( $_GET['invalid'] ) ) :
<p><strong><?php _e( 'Error:' ); ?></strong> $importer_not_installed = '<strong>' . __( 'Error:' ) . '</strong> ' . sprintf(
<?php /* translators: %s: Importer slug. */
/* translators: %s: Importer slug. */ __( 'The %s importer is invalid or is not installed.' ),
printf( __( 'The %s importer is invalid or is not installed.' ), '<strong>' . esc_html( $_GET['invalid'] ) . '</strong>' ); '<strong>' . esc_html( $_GET['invalid'] ) . '</strong>'
?> );
</p> wp_admin_notice(
</div> $importer_not_installed,
<?php endif; ?> array(
'additional_classes' => array( 'error' ),
)
);
endif;
?>
<p><?php _e( 'If you have posts or comments in another system, WordPress can import those into this site. To get started, choose a system to import from below:' ); ?></p> <p><?php _e( 'If you have posts or comments in another system, WordPress can import those into this site. To get started, choose a system to import from below:' ); ?></p>
<?php <?php

View File

@ -384,7 +384,14 @@ switch ( $action ) {
$_nav_menu_selected_id = wp_update_nav_menu_object( 0, array( 'menu-name' => $new_menu_title ) ); $_nav_menu_selected_id = wp_update_nav_menu_object( 0, array( 'menu-name' => $new_menu_title ) );
if ( is_wp_error( $_nav_menu_selected_id ) ) { if ( is_wp_error( $_nav_menu_selected_id ) ) {
$messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $_nav_menu_selected_id->get_error_message() . '</p></div>'; $messages[] = wp_get_admin_notice(
$_nav_menu_selected_id->get_error_message(),
array(
'id' => 'message',
'additional_classes' => array( 'error' ),
'dismissible' => true,
)
);
} else { } else {
$_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id ); $_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id );
$nav_menu_selected_id = $_nav_menu_selected_id; $nav_menu_selected_id = $_nav_menu_selected_id;
@ -435,7 +442,14 @@ switch ( $action ) {
exit; exit;
} }
} else { } else {
$messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'Please enter a valid menu name.' ) . '</p></div>'; $messages[] = wp_get_admin_notice(
__( 'Please enter a valid menu name.' ),
array(
'id' => 'message',
'additional_classes' => array( 'error' ),
'dismissible' => true,
)
);
} }
// Update existing menu. // Update existing menu.
@ -457,7 +471,14 @@ switch ( $action ) {
$menu_title = trim( esc_html( $_POST['menu-name'] ) ); $menu_title = trim( esc_html( $_POST['menu-name'] ) );
if ( ! $menu_title ) { if ( ! $menu_title ) {
$messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'Please enter a valid menu name.' ) . '</p></div>'; $messages[] = wp_get_admin_notice(
__( 'Please enter a valid menu name.' ),
array(
'id' => 'message',
'additional_classes' => array( 'error' ),
'dismissible' => true,
)
);
$menu_title = $_menu_object->name; $menu_title = $_menu_object->name;
} }
@ -510,7 +531,14 @@ switch ( $action ) {
// Set menu locations. // Set menu locations.
set_theme_mod( 'nav_menu_locations', $menu_locations ); set_theme_mod( 'nav_menu_locations', $menu_locations );
$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Menu locations updated.' ) . '</p></div>'; $messages[] = wp_get_admin_notice(
__( 'Menu locations updated.' ),
array(
'id' => 'message',
'additional_classes' => array( 'updated' ),
'dismissible' => true,
)
);
} }
break; break;

View File

@ -29,7 +29,15 @@ if ( empty( $plugins ) ) {
?> ?>
<div class="wrap"> <div class="wrap">
<h1><?php echo esc_html( $title ); ?></h1> <h1><?php echo esc_html( $title ); ?></h1>
<div id="message" class="error"><p><?php _e( 'No plugins are currently available.' ); ?></p></div> <?php
wp_admin_notice(
__( 'No plugins are currently available.' ),
array(
'id' => 'message',
'additional_classes' => array( 'error' ),
)
);
?>
</div> </div>
<?php <?php
require_once ABSPATH . 'wp-admin/admin-footer.php'; require_once ABSPATH . 'wp-admin/admin-footer.php';

View File

@ -339,15 +339,31 @@ if ( $action ) {
?> ?>
<?php if ( 1 === $plugins_to_delete ) : ?> <?php if ( 1 === $plugins_to_delete ) : ?>
<h1><?php _e( 'Delete Plugin' ); ?></h1> <h1><?php _e( 'Delete Plugin' ); ?></h1>
<?php if ( $have_non_network_plugins && is_network_admin() ) : ?> <?php
<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'This plugin may be active on other sites in the network.' ); ?></p></div> if ( $have_non_network_plugins && is_network_admin() ) :
<?php endif; ?> $maybe_active_plugin = '<strong>' . __( 'Caution:' ) . '</strong> ' . __( 'This plugin may be active on other sites in the network.' );
wp_admin_notice(
$maybe_active_plugin,
array(
'additional_classes' => array( 'error' ),
)
);
endif;
?>
<p><?php _e( 'You are about to remove the following plugin:' ); ?></p> <p><?php _e( 'You are about to remove the following plugin:' ); ?></p>
<?php else : ?> <?php else : ?>
<h1><?php _e( 'Delete Plugins' ); ?></h1> <h1><?php _e( 'Delete Plugins' ); ?></h1>
<?php if ( $have_non_network_plugins && is_network_admin() ) : ?> <?php
<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'These plugins may be active on other sites in the network.' ); ?></p></div> if ( $have_non_network_plugins && is_network_admin() ) :
<?php endif; ?> $maybe_active_plugins = '<strong>' . __( 'Caution:' ) . '</strong> ' . __( 'These plugins may be active on other sites in the network.' );
wp_admin_notice(
$maybe_active_plugins,
array(
'additional_classes' => array( 'error' ),
)
);
endif;
?>
<p><?php _e( 'You are about to remove the following plugins:' ); ?></p> <p><?php _e( 'You are about to remove the following plugins:' ); ?></p>
<?php endif; ?> <?php endif; ?>
<ul class="ul-disc"> <ul class="ul-disc">
@ -607,14 +623,19 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
$invalid = validate_active_plugins(); $invalid = validate_active_plugins();
if ( ! empty( $invalid ) ) { if ( ! empty( $invalid ) ) {
foreach ( $invalid as $plugin_file => $error ) { foreach ( $invalid as $plugin_file => $error ) {
echo '<div id="message" class="error"><p>'; $deactivated_message = sprintf(
printf(
/* translators: 1: Plugin file, 2: Error message. */ /* translators: 1: Plugin file, 2: Error message. */
__( 'The plugin %1$s has been deactivated due to an error: %2$s' ), __( 'The plugin %1$s has been deactivated due to an error: %2$s' ),
'<code>' . esc_html( $plugin_file ) . '</code>', '<code>' . esc_html( $plugin_file ) . '</code>',
esc_html( $error->get_error_message() ) esc_html( $error->get_error_message() )
); );
echo '</p></div>'; wp_admin_notice(
$deactivated_message,
array(
'id' => 'message',
'additional_classes' => array( 'error' ),
)
);
} }
} }

View File

@ -262,7 +262,12 @@ if ( preg_match( '/\.css$/', $file ) && ! wp_is_block_theme() && current_user_ca
<?php <?php
if ( $theme->errors() ) { if ( $theme->errors() ) {
echo '<div class="error"><p><strong>' . __( 'This theme is broken.' ) . '</strong> ' . $theme->errors()->get_error_message() . '</p></div>'; wp_admin_notice(
'<strong>' . __( 'This theme is broken.' ) . '</strong> ' . $theme->errors()->get_error_message(),
array(
'additional_classes' => array( 'error' ),
)
);
} }
?> ?>
@ -294,7 +299,12 @@ if ( $theme->errors() ) {
<?php <?php
if ( $error ) : if ( $error ) :
echo '<div class="error"><p>' . __( 'File does not exist! Please double check the name and try again.' ) . '</p></div>'; wp_admin_notice(
__( 'File does not exist! Please double check the name and try again.' ),
array(
'additional_classes' => array( 'error' ),
)
);
else : else :
?> ?>
<form name="template" id="template" action="theme-editor.php" method="post"> <form name="template" id="template" action="theme-editor.php" method="post">

View File

@ -183,9 +183,14 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
<hr class="wp-header-end"> <hr class="wp-header-end">
<div class="error hide-if-js"> <?php
<p><?php _e( 'The Theme Installer screen requires JavaScript.' ); ?></p> wp_admin_notice(
</div> __( 'The Theme Installer screen requires JavaScript.' ),
array(
'additional_classes' => array( 'error', 'hide-if-js' ),
)
);
?>
<div class="upload-theme"> <div class="upload-theme">
<?php install_themes_upload(); ?> <?php install_themes_upload(); ?>

View File

@ -345,7 +345,12 @@ if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) {
$current_theme = wp_get_theme(); $current_theme = wp_get_theme();
if ( $current_theme->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) { if ( $current_theme->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) {
echo '<div class="error"><p>' . __( 'Error:' ) . ' ' . $current_theme->errors()->get_error_message() . '</p></div>'; wp_admin_notice(
__( 'Error:' ) . ' ' . $current_theme->errors()->get_error_message(),
array(
'additional_classes' => array( 'error' ),
)
);
} }
$current_theme_actions = array(); $current_theme_actions = array();
@ -438,79 +443,88 @@ foreach ( $themes as $theme ) :
<?php } ?> <?php } ?>
<?php if ( $theme['hasUpdate'] ) : ?> <?php if ( $theme['hasUpdate'] ) : ?>
<?php if ( $theme['updateResponse']['compatibleWP'] && $theme['updateResponse']['compatiblePHP'] ) : ?> <?php
<div class="update-message notice inline notice-warning notice-alt"><p> if ( $theme['updateResponse']['compatibleWP'] && $theme['updateResponse']['compatiblePHP'] ) :
<?php if ( $theme['hasPackage'] ) : ?> if ( $theme['hasPackage'] ) {
<?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?> $new_version_available = __( 'New version available. <button class="button-link" type="button">Update now</button>' );
<?php else : ?> } else {
<?php _e( 'New version available.' ); ?> $new_version_available = __( 'New version available.' );
<?php endif; ?> }
</p></div> wp_admin_notice(
<?php else : ?> $new_version_available,
<div class="update-message notice inline notice-error notice-alt"><p> array(
<?php 'type' => 'warning',
if ( ! $theme['updateResponse']['compatibleWP'] && ! $theme['updateResponse']['compatiblePHP'] ) { 'additional_classes' => array( 'notice-alt', 'inline', 'update-message' ),
printf( )
/* translators: %s: Theme name. */ );
__( 'There is a new version of %s available, but it does not work with your versions of WordPress and PHP.' ), else :
$theme['name'] $theme_update_error = '';
if ( ! $theme['updateResponse']['compatibleWP'] && ! $theme['updateResponse']['compatiblePHP'] ) {
$theme_update_error .= sprintf(
/* translators: %s: Theme name. */
__( 'There is a new version of %s available, but it does not work with your versions of WordPress and PHP.' ),
$theme['name']
);
if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
$theme_update_error .= 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() )
); );
if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) { wp_update_php_annotation( '</p><p><em>', '</em>', false );
printf( } elseif ( current_user_can( 'update_core' ) ) {
/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */ $theme_update_error .= sprintf(
' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ), /* translators: %s: URL to WordPress Updates screen. */
self_admin_url( 'update-core.php' ), ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
esc_url( wp_get_update_php_url() ) self_admin_url( 'update-core.php' )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
} elseif ( current_user_can( 'update_core' ) ) {
printf(
/* 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(
/* 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>' );
}
} elseif ( ! $theme['updateResponse']['compatibleWP'] ) {
printf(
/* translators: %s: Theme name. */
__( 'There is a new version of %s available, but it does not work with your version of WordPress.' ),
$theme['name']
); );
if ( current_user_can( 'update_core' ) ) { } elseif ( current_user_can( 'update_php' ) ) {
printf( $theme_update_error .= sprintf(
/* translators: %s: URL to WordPress Updates screen. */ /* translators: %s: URL to Update PHP page. */
' ' . __( '<a href="%s">Please update WordPress</a>.' ), ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
self_admin_url( 'update-core.php' ) esc_url( wp_get_update_php_url() )
);
}
} elseif ( ! $theme['updateResponse']['compatiblePHP'] ) {
printf(
/* translators: %s: Theme name. */
__( 'There is a new version of %s available, but it does not work with your version of PHP.' ),
$theme['name']
); );
if ( current_user_can( 'update_php' ) ) { wp_update_php_annotation( '</p><p><em>', '</em>', false );
printf(
/* 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>' );
}
} }
?> } elseif ( ! $theme['updateResponse']['compatibleWP'] ) {
</p></div> $theme_update_error .= sprintf(
<?php endif; ?> /* translators: %s: Theme name. */
<?php endif; ?> __( 'There is a new version of %s available, but it does not work with your version of WordPress.' ),
$theme['name']
);
if ( current_user_can( 'update_core' ) ) {
$theme_update_error .= sprintf(
/* translators: %s: URL to WordPress Updates screen. */
' ' . __( '<a href="%s">Please update WordPress</a>.' ),
self_admin_url( 'update-core.php' )
);
}
} elseif ( ! $theme['updateResponse']['compatiblePHP'] ) {
$theme_update_error .= sprintf(
/* translators: %s: Theme name. */
__( 'There is a new version of %s available, but it does not work with your version of PHP.' ),
$theme['name']
);
if ( current_user_can( 'update_php' ) ) {
$theme_update_error .= 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>', false );
}
}
wp_admin_notice(
$theme_update_error,
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'inline', 'update-message' ),
)
);
endif;
endif;
<?php
if ( ! $theme['compatibleWP'] || ! $theme['compatiblePHP'] ) { if ( ! $theme['compatibleWP'] || ! $theme['compatiblePHP'] ) {
$message = ''; $message = '';
if ( ! $theme['compatibleWP'] && ! $theme['compatiblePHP'] ) { if ( ! $theme['compatibleWP'] && ! $theme['compatiblePHP'] ) {
@ -566,9 +580,7 @@ foreach ( $themes as $theme ) :
) )
); );
} }
?>
<?php
/* translators: %s: Theme name. */ /* translators: %s: Theme name. */
$details_aria_label = sprintf( _x( 'View Theme Details for %s', 'theme' ), $theme['name'] ); $details_aria_label = sprintf( _x( 'View Theme Details for %s', 'theme' ), $theme['name'] );
?> ?>
@ -662,7 +674,9 @@ if ( ! is_multisite() && $broken_themes ) {
<td></td> <td></td>
<?php } ?> <?php } ?>
</tr> </tr>
<?php foreach ( $broken_themes as $broken_theme ) : ?> <?php
foreach ( $broken_themes as $broken_theme ) :
?>
<tr> <tr>
<td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : esc_html( $broken_theme->get_stylesheet() ); ?></td> <td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : esc_html( $broken_theme->get_stylesheet() ); ?></td>
<td><?php echo $broken_theme->errors()->get_error_message(); ?></td> <td><?php echo $broken_theme->errors()->get_error_message(); ?></td>
@ -723,7 +737,9 @@ if ( ! is_multisite() && $broken_themes ) {
} }
?> ?>
</tr> </tr>
<?php endforeach; ?> <?php
endforeach;
?>
</table> </table>
</div> </div>

View File

@ -1072,16 +1072,22 @@ if ( 'upgrade-core' === $action ) {
if ( 'themes' === $upgrade_error ) { if ( 'themes' === $upgrade_error ) {
$theme_updates = get_theme_updates(); $theme_updates = get_theme_updates();
if ( ! empty( $theme_updates ) ) { if ( ! empty( $theme_updates ) ) {
echo '<div class="error"><p>'; wp_admin_notice(
_e( 'Please select one or more themes to update.' ); __( 'Please select one or more themes to update.' ),
echo '</p></div>'; array(
'additional_classes' => array( 'error' ),
)
);
} }
} else { } else {
$plugin_updates = get_plugin_updates(); $plugin_updates = get_plugin_updates();
if ( ! empty( $plugin_updates ) ) { if ( ! empty( $plugin_updates ) ) {
echo '<div class="error"><p>'; wp_admin_notice(
_e( 'Please select one or more plugins to update.' ); __( 'Please select one or more plugins to update.' ),
echo '</p></div>'; array(
'additional_classes' => array( 'error' ),
)
);
} }
} }
} }

View File

@ -244,11 +244,12 @@ switch ( $action ) {
endif; endif;
if ( isset( $errors ) && is_wp_error( $errors ) ) { if ( isset( $errors ) && is_wp_error( $errors ) ) {
?> wp_admin_notice(
<div class="error"> implode( "</p>\n<p>", $errors->get_error_messages() ),
<p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p> array(
</div> 'additional_classes' => array( 'error' ),
<?php )
);
} }
?> ?>

View File

@ -381,17 +381,19 @@ if ( current_user_can( 'create_users' ) ) {
?> ?>
</h1> </h1>
<?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?> <?php
<div class="error"> if ( isset( $errors ) && is_wp_error( $errors ) ) :
<ul> $error_message = '';
<?php foreach ( $errors->get_error_messages() as $err ) {
foreach ( $errors->get_error_messages() as $err ) { $error_message .= "<li>$err</li>\n";
echo "<li>$err</li>\n"; }
} wp_admin_notice(
?> '<ul>' . $error_message . '</ul>',
</ul> array(
</div> 'additional_classes' => array( 'error' ),
<?php 'paragraph_wrap' => false,
)
);
endif; endif;
if ( ! empty( $messages ) ) { if ( ! empty( $messages ) ) {
@ -408,15 +410,21 @@ if ( ! empty( $messages ) ) {
} }
?> ?>
<?php if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) : ?> <?php
<div class="error"> if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) :
<?php $error_message = '';
foreach ( $add_user_errors->get_error_messages() as $message ) { foreach ( $add_user_errors->get_error_messages() as $message ) {
echo "<p>$message</p>"; $error_message .= "<p>$message</p>\n";
} }
?> wp_admin_notice(
</div> $error_message,
<?php endif; ?> array(
'additional_classes' => array( 'error' ),
'paragraph_wrap' => false,
)
);
endif;
?>
<div id="ajax-response"></div> <div id="ajax-response"></div>
<?php <?php

View File

@ -339,11 +339,16 @@ switch ( $wp_list_table->current_action() ) {
<div class="wrap"> <div class="wrap">
<h1><?php _e( 'Delete Users' ); ?></h1> <h1><?php _e( 'Delete Users' ); ?></h1>
<?php if ( isset( $_REQUEST['error'] ) ) : ?> <?php
<div class="error"> if ( isset( $_REQUEST['error'] ) ) :
<p><strong><?php _e( 'Error:' ); ?></strong> <?php _e( 'Please select an option.' ); ?></p> wp_admin_notice(
</div> '<strong>' . __( 'Error:' ) . '</strong> ' . __( 'Please select an option.' ),
<?php endif; ?> array(
'additional_classes' => array( 'error' ),
)
);
endif;
?>
<?php if ( 1 === count( $all_user_ids ) ) : ?> <?php if ( 1 === count( $all_user_ids ) ) : ?>
<p><?php _e( 'You have specified this user for deletion:' ); ?></p> <p><?php _e( 'You have specified this user for deletion:' ); ?></p>
@ -742,17 +747,18 @@ switch ( $wp_list_table->current_action() ) {
endif; endif;
?> ?>
<?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?> <?php
<div class="error"> if ( isset( $errors ) && is_wp_error( $errors ) ) :
<ul> $error_message = '';
<?php foreach ( $errors->get_error_messages() as $err ) {
foreach ( $errors->get_error_messages() as $err ) { $error_message .= "<li>$err</li>\n";
echo "<li>$err</li>\n"; }
} wp_admin_notice(
?> '<ul>' . $error_message . '</ul>',
</ul> array(
</div> 'additional_classes' => array( 'error' ),
<?php )
);
endif; endif;
if ( ! empty( $messages ) ) { if ( ! empty( $messages ) ) {

View File

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