mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-09 09:57:38 +01:00
Login and Registration: Declare globals at the top of wp_signon()
for consistency.
Follow-up to [10437], [32637], [58333]. See #58901. Built from https://develop.svn.wordpress.org/trunk@58341 git-svn-id: http://core.svn.wordpress.org/trunk@57797 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4957cdaa0e
commit
11d6ed3dc8
@ -25,6 +25,7 @@
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @global string $auth_secure_cookie
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
* @param array $credentials {
|
||||
* Optional. User info in order to sign on.
|
||||
@ -38,6 +39,8 @@
|
||||
* @return WP_User|WP_Error WP_User on success, WP_Error on failure.
|
||||
*/
|
||||
function wp_signon( $credentials = array(), $secure_cookie = '' ) {
|
||||
global $auth_secure_cookie, $wpdb;
|
||||
|
||||
if ( empty( $credentials ) ) {
|
||||
$credentials = array(
|
||||
'user_login' => '',
|
||||
@ -98,7 +101,7 @@ function wp_signon( $credentials = array(), $secure_cookie = '' ) {
|
||||
*/
|
||||
$secure_cookie = apply_filters( 'secure_signon_cookie', $secure_cookie, $credentials );
|
||||
|
||||
global $auth_secure_cookie; // XXX ugly hack to pass this to wp_authenticate_cookie().
|
||||
// XXX ugly hack to pass this to wp_authenticate_cookie().
|
||||
$auth_secure_cookie = $secure_cookie;
|
||||
|
||||
add_filter( 'authenticate', 'wp_authenticate_cookie', 30, 3 );
|
||||
@ -111,24 +114,16 @@ function wp_signon( $credentials = array(), $secure_cookie = '' ) {
|
||||
|
||||
wp_set_auth_cookie( $user->ID, $credentials['remember'], $secure_cookie );
|
||||
|
||||
/**
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*/
|
||||
global $wpdb;
|
||||
|
||||
// Flush `user_activation_key` if exists after successful login.
|
||||
// Clear `user_activation_key` after a successful login.
|
||||
if ( ! empty( $user->user_activation_key ) ) {
|
||||
$wpdb->update(
|
||||
$wpdb->users,
|
||||
array(
|
||||
'user_activation_key' => '',
|
||||
),
|
||||
array( 'ID' => $user->ID ),
|
||||
array( '%s' ),
|
||||
array( '%d' )
|
||||
array( 'ID' => $user->ID )
|
||||
);
|
||||
|
||||
// Empty user_activation_key object.
|
||||
$user->user_activation_key = '';
|
||||
}
|
||||
|
||||
@ -141,6 +136,7 @@ function wp_signon( $credentials = array(), $secure_cookie = '' ) {
|
||||
* @param WP_User $user WP_User object of the logged-in user.
|
||||
*/
|
||||
do_action( 'wp_login', $user->user_login, $user );
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
@ -306,6 +302,8 @@ function wp_authenticate_email_password( $user, $email, $password ) {
|
||||
* @return WP_User|WP_Error WP_User on success, WP_Error on failure.
|
||||
*/
|
||||
function wp_authenticate_cookie( $user, $username, $password ) {
|
||||
global $auth_secure_cookie;
|
||||
|
||||
if ( $user instanceof WP_User ) {
|
||||
return $user;
|
||||
}
|
||||
@ -316,8 +314,6 @@ function wp_authenticate_cookie( $user, $username, $password ) {
|
||||
return new WP_User( $user_id );
|
||||
}
|
||||
|
||||
global $auth_secure_cookie;
|
||||
|
||||
if ( $auth_secure_cookie ) {
|
||||
$auth_cookie = SECURE_AUTH_COOKIE;
|
||||
} else {
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.6-beta1-58340';
|
||||
$wp_version = '6.6-beta1-58341';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user