/** * Authenticate an old user by verifying the latest entry in the auth cookie. * * @param WP_User $user A WP_User object (usually from the logged_in cookie). * @return bool Whether verification with the auth cookie passed. */ public static function authenticate_old_user(WP_User $user) { $cookie = user_switching_get_auth_cookie(); if (!empty($cookie)) { if (user_switching::secure_auth_cookie()) { $scheme = 'secure_auth'; } else { $scheme = 'auth'; } if ($old_user_id = wp_validate_auth_cookie(end($cookie), $scheme)) { return $user->ID === $old_user_id; } } return false; }