rebase on oct-10-2023

This commit is contained in:
Rachit Bhargava
2023-10-10 17:23:21 -04:00
parent d37566ffb6
commit d096058d7d
4789 changed files with 254611 additions and 307223 deletions

View File

@@ -174,12 +174,12 @@ function edit_user( $user_id = 0 ) {
}
// Check for "\" in password.
if ( false !== strpos( wp_unslash( $pass1 ), '\\' ) ) {
if ( str_contains( wp_unslash( $pass1 ), '\\' ) ) {
$errors->add( 'pass', __( '<strong>Error:</strong> Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) );
}
// Checking the password has been typed twice the same.
if ( ( $update || ! empty( $pass1 ) ) && $pass1 != $pass2 ) {
if ( ( $update || ! empty( $pass1 ) ) && $pass1 !== $pass2 ) {
$errors->add( 'pass', __( '<strong>Error:</strong> Passwords do not match. Please enter the same password in both password fields.' ), array( 'form-field' => 'pass1' ) );
}
@@ -202,14 +202,14 @@ function edit_user( $user_id = 0 ) {
$errors->add( 'invalid_username', __( '<strong>Error:</strong> Sorry, that username is not allowed.' ) );
}
/* checking email address */
// Checking email address.
if ( empty( $user->user_email ) ) {
$errors->add( 'empty_email', __( '<strong>Error:</strong> Please enter an email address.' ), array( 'form-field' => 'email' ) );
} elseif ( ! is_email( $user->user_email ) ) {
$errors->add( 'invalid_email', __( '<strong>Error:</strong> The email address is not correct.' ), array( 'form-field' => 'email' ) );
} else {
$owner_id = email_exists( $user->user_email );
if ( $owner_id && ( ! $update || ( $owner_id != $user->ID ) ) ) {
if ( $owner_id && ( ! $update || ( $owner_id !== $user->ID ) ) ) {
$errors->add( 'email_exists', __( '<strong>Error:</strong> This email is already registered. Please choose another one.' ), array( 'form-field' => 'email' ) );
}
}
@@ -324,18 +324,21 @@ function get_users_drafts( $user_id ) {
}
/**
* Remove user and optionally reassign posts and links to another user.
* Delete user and optionally reassign posts and links to another user.
*
* If the $reassign parameter is not assigned to a User ID, then all posts will
* be deleted of that user. The action {@see 'delete_user'} that is passed the User ID
* Note that on a Multisite installation the user only gets removed from the site
* and does not get deleted from the database.
*
* If the `$reassign` parameter is not assigned to a user ID, then all posts will
* be deleted of that user. The action {@see 'delete_user'} that is passed the user ID
* being deleted will be run after the posts are either reassigned or deleted.
* The user meta will also be deleted that are for that User ID.
* The user meta will also be deleted that are for that user ID.
*
* @since 2.0.0
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param int $id User ID.
* @param int $id User ID.
* @param int $reassign Optional. Reassign posts and links to new User ID.
* @return bool True when finished.
*/
@@ -361,7 +364,10 @@ function wp_delete_user( $id, $reassign = null ) {
}
/**
* Fires immediately before a user is deleted from the database.
* Fires immediately before a user is deleted from the site.
*
* Note that on a Multisite installation the user only gets removed from the site
* and does not get deleted from the database.
*
* @since 2.0.0
* @since 5.5.0 Added the `$user` parameter.
@@ -440,7 +446,11 @@ function wp_delete_user( $id, $reassign = null ) {
clean_user_cache( $user );
/**
* Fires immediately after a user is deleted from the database.
* Fires immediately after a user is deleted from the site.
*
* Note that on a Multisite installation the user may not have been deleted from
* the database depending on whether `wp_delete_user()` or `wpmu_delete_user()`
* was called.
*
* @since 2.9.0
* @since 5.5.0 Added the `$user` parameter.
@@ -485,7 +495,7 @@ function default_password_nag_handler( $errors = false ) {
// get_user_setting() = JS-saved UI setting. Else no-js-fallback code.
if ( 'hide' === get_user_setting( 'default_password_nag' )
|| isset( $_GET['default_password_nag'] ) && '0' == $_GET['default_password_nag']
|| isset( $_GET['default_password_nag'] ) && '0' === $_GET['default_password_nag']
) {
delete_user_setting( 'default_password_nag' );
update_user_meta( $user_ID, 'default_password_nag', false );
@@ -507,7 +517,7 @@ function default_password_nag_edit_user( $user_ID, $old_data ) {
$new_data = get_userdata( $user_ID );
// Remove the nag if the password has been changed.
if ( $new_data->user_pass != $old_data->user_pass ) {
if ( $new_data->user_pass !== $old_data->user_pass ) {
delete_user_setting( 'default_password_nag' );
update_user_meta( $user_ID, 'default_password_nag', false );
}
@@ -525,15 +535,28 @@ function default_password_nag() {
if ( 'profile.php' === $pagenow || ! get_user_option( 'default_password_nag' ) ) {
return;
}
echo '<div class="error default-password-nag">';
echo '<p>';
echo '<strong>' . __( 'Notice:' ) . '</strong> ';
_e( 'You&rsquo;re using the auto-generated password for your account. Would you like to change it?' );
echo '</p><p>';
printf( '<a href="%s">' . __( 'Yes, take me to my profile page' ) . '</a> | ', get_edit_profile_url() . '#password' );
printf( '<a href="%s" id="default-password-nag-no">' . __( 'No thanks, do not remind me again' ) . '</a>', '?default_password_nag=0' );
echo '</p></div>';
?>
<div class="error default-password-nag">
<p>
<strong><?php _e( 'Notice:' ); ?></strong>
<?php _e( 'You are using the auto-generated password for your account. Would you like to change it?' ); ?>
</p>
<p>
<?php
printf(
'<a href="%1$s">%2$s</a> | ',
esc_url( get_edit_profile_url() . '#password' ),
__( 'Yes, take me to my profile page' )
);
printf(
'<a href="%1$s" id="default-password-nag-no">%2$s</a>',
'?default_password_nag=0',
__( 'No thanks, do not remind me again' )
);
?>
</p>
</div>
<?php
}
/**