wp/wp-admin/user-new.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
--- a/wp/wp-admin/user-new.php	Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-admin/user-new.php	Fri Sep 05 18:40:08 2025 +0200
@@ -34,7 +34,7 @@
 
 	$user_details = null;
 	$user_email   = wp_unslash( $_REQUEST['email'] );
-	if ( false !== strpos( $user_email, '@' ) ) {
+	if ( str_contains( $user_email, '@' ) ) {
 		$user_details = get_user_by( 'email', $user_email );
 	} else {
 		if ( current_user_can( 'manage_network_users' ) ) {
@@ -110,7 +110,7 @@
 			 */
 			do_action( 'invite_user', $user_id, $role, $newuser_key );
 
-			$switched_locale = switch_to_locale( get_user_locale( $user_details ) );
+			$switched_locale = switch_to_user_locale( $user_id );
 
 			if ( '' !== get_option( 'blogname' ) ) {
 				$site_title = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
@@ -298,8 +298,8 @@
 
 get_current_screen()->set_help_sidebar(
 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
-	'<p>' . __( '<a href="https://wordpress.org/support/article/users-add-new-screen/">Documentation on Adding New Users</a>' ) . '</p>' .
-	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
+	'<p>' . __( '<a href="https://wordpress.org/documentation/article/users-add-new-screen/">Documentation on Adding New Users</a>' ) . '</p>' .
+	'<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
 );
 
 wp_enqueue_script( 'wp-ajax-response' );
@@ -381,35 +381,50 @@
 ?>
 </h1>
 
-<?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
-	<div class="error">
-		<ul>
-		<?php
-		foreach ( $errors->get_error_messages() as $err ) {
-			echo "<li>$err</li>\n";
-		}
-		?>
-		</ul>
-	</div>
-	<?php
+<?php
+if ( isset( $errors ) && is_wp_error( $errors ) ) :
+	$error_message = '';
+	foreach ( $errors->get_error_messages() as $err ) {
+		$error_message .= "<li>$err</li>\n";
+	}
+	wp_admin_notice(
+		'<ul>' . $error_message . '</ul>',
+		array(
+			'additional_classes' => array( 'error' ),
+			'paragraph_wrap'     => false,
+		)
+	);
 endif;
 
 if ( ! empty( $messages ) ) {
 	foreach ( $messages as $msg ) {
-		echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>';
+		wp_admin_notice(
+			$msg,
+			array(
+				'id'                 => 'message',
+				'additional_classes' => array( 'updated' ),
+				'dismissible'        => true,
+			)
+		);
 	}
 }
 ?>
 
-<?php if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) : ?>
-	<div class="error">
-		<?php
-		foreach ( $add_user_errors->get_error_messages() as $message ) {
-			echo "<p>$message</p>";
-		}
-		?>
-	</div>
-<?php endif; ?>
+<?php
+if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) :
+	$error_message = '';
+	foreach ( $add_user_errors->get_error_messages() as $message ) {
+		$error_message .= "<p>$message</p>\n";
+	}
+	wp_admin_notice(
+		$error_message,
+		array(
+			'additional_classes' => array( 'error' ),
+			'paragraph_wrap'     => false,
+		)
+	);
+endif;
+?>
 <div id="ajax-response"></div>
 
 <?php
@@ -442,8 +457,8 @@
 
 <table class="form-table" role="presentation">
 	<tr class="form-field form-required">
-		<th scope="row"><label for="adduser-email"><?php echo $label; ?></label></th>
-		<td><input name="email" type="<?php echo $type; ?>" id="adduser-email" class="wp-suggest-user" value="" /></td>
+		<th scope="row"><label for="adduser-email"><?php echo esc_html( $label ); ?></label></th>
+		<td><input name="email" type="<?php echo esc_attr( $type ); ?>" id="adduser-email" class="wp-suggest-user" value="" /></td>
 	</tr>
 	<tr class="form-field">
 		<th scope="row"><label for="adduser-role"><?php _e( 'Role' ); ?></label></th>
@@ -457,7 +472,7 @@
 		<th scope="row"><?php _e( 'Skip Confirmation Email' ); ?></th>
 		<td>
 			<input type="checkbox" name="noconfirmation" id="adduser-noconfirmation" value="1" />
-			<label for="adduser-noconfirmation"><?php _e( 'Add the user without sending an email that requires their confirmation.' ); ?></label>
+			<label for="adduser-noconfirmation"><?php _e( 'Add the user without sending an email that requires their confirmation' ); ?></label>
 		</td>
 	</tr>
 	<?php } ?>
@@ -566,25 +581,25 @@
 			</label>
 		</th>
 		<td>
-			<input class="hidden" value=" " /><!-- #24364 workaround -->
+			<input type="hidden" value=" " /><!-- #24364 workaround -->
 			<button type="button" class="button wp-generate-pw hide-if-no-js"><?php _e( 'Generate password' ); ?></button>
 			<div class="wp-pwd">
 				<?php $initial_password = wp_generate_password( 24 ); ?>
-				<span class="password-input-wrapper">
-					<input type="password" name="pass1" id="pass1" class="regular-text" autocomplete="new-password" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result" />
-				</span>
+				<div class="password-input-wrapper">
+					<input type="password" name="pass1" id="pass1" class="regular-text" autocomplete="new-password" spellcheck="false" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result" />
+					<div style="display:none" id="pass-strength-result" aria-live="polite"></div>
+				</div>
 				<button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
 					<span class="dashicons dashicons-hidden" aria-hidden="true"></span>
 					<span class="text"><?php _e( 'Hide' ); ?></span>
 				</button>
-				<div style="display:none" id="pass-strength-result" aria-live="polite"></div>
 			</div>
 		</td>
 	</tr>
 	<tr class="form-field form-required user-pass2-wrap hide-if-js">
 		<th scope="row"><label for="pass2"><?php _e( 'Repeat Password' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
 		<td>
-		<input name="pass2" type="password" id="pass2" autocomplete="new-password" aria-describedby="pass2-desc" />
+		<input type="password" name="pass2" id="pass2" autocomplete="new-password" spellcheck="false" aria-describedby="pass2-desc" />
 		<p class="description" id="pass2-desc"><?php _e( 'Type the password again.' ); ?></p>
 		</td>
 	</tr>
@@ -601,7 +616,7 @@
 		<th scope="row"><?php _e( 'Send User Notification' ); ?></th>
 		<td>
 			<input type="checkbox" name="send_user_notification" id="send_user_notification" value="1" <?php checked( $new_user_send_notification ); ?> />
-			<label for="send_user_notification"><?php _e( 'Send the new user an email about their account.' ); ?></label>
+			<label for="send_user_notification"><?php _e( 'Send the new user an email about their account' ); ?></label>
 		</td>
 	</tr>
 	<?php } // End if ! is_multisite(). ?>
@@ -624,7 +639,7 @@
 		<th scope="row"><?php _e( 'Skip Confirmation Email' ); ?></th>
 		<td>
 			<input type="checkbox" name="noconfirmation" id="noconfirmation" value="1" <?php checked( $new_user_ignore_pass ); ?> />
-			<label for="noconfirmation"><?php _e( 'Add the user without sending an email that requires their confirmation.' ); ?></label>
+			<label for="noconfirmation"><?php _e( 'Add the user without sending an email that requires their confirmation' ); ?></label>
 		</td>
 	</tr>
 	<?php } ?>