WC_Shortcode_My_Account::lost_password
Lost password page handling.
Метод класса: WC_Shortcode_My_Account{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$result = WC_Shortcode_My_Account::lost_password();
Код WC_Shortcode_My_Account::lost_password() WC Shortcode My Account::lost password WC 11.3.0
public static function lost_password() {
/**
* After sending the reset link, don't show the form again.
*/
if ( ! empty( $_GET['reset-link-sent'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only UI selector; login and path are normalized downstream.
wc_get_template( 'myaccount/lost-password-confirmation.php' );
return;
/**
* Process reset key / login from email confirmation link
*/
} elseif ( ! empty( $_GET['show-reset-form'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only UI selector; login and path are normalized downstream.
/*
* Three sources can carry reset credentials onto this page, in this order of precedence:
* WordPress's own wp-resetpass-* cookie, a single-use bridge handle in the URL (used when
* the cookie is SameSite=Strict and so does not survive the click from the email client),
* and the signed token re-posted by the form when password validation rejects a submission.
*/
$reset_cookie = isset( $_COOKIE[ 'wp-resetpass-' . COOKIEHASH ] ) ? wp_unslash( $_COOKIE[ 'wp-resetpass-' . COOKIEHASH ] ) : ''; // @codingStandardsIgnoreLine
$has_reset_cookie = is_string( $reset_cookie ) && 0 < strpos( $reset_cookie, ':' );
$bridge_handle = isset( $_GET['reset-token'] ) ? wc_clean( wp_unslash( $_GET['reset-token'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$has_bridge_handle = is_string( $bridge_handle ) && '' !== $bridge_handle;
$form_args = false;
if ( $has_reset_cookie ) {
list( $rp_id, $rp_key ) = array_map( 'wc_clean', explode( ':', $reset_cookie, 2 ) );
$userdata = get_userdata( absint( $rp_id ) );
$rp_login = $userdata ? $userdata->user_login : '';
// Reset key / login is correct, display reset password form with hidden key / login values.
if ( is_string( $rp_key ) && check_password_reset_key( $rp_key, $rp_login ) instanceof WP_User ) {
$form_args = array(
'key' => $rp_key,
'login' => $rp_login,
);
}
}
if ( $form_args ) {
// The cookie won, but a handle is single-use either way so it cannot be replayed.
self::discard_password_reset_bridge_token( $bridge_handle );
} else {
$form_args = self::consume_password_reset_bridge_token( $bridge_handle );
if ( ! $form_args ) {
$form_args = self::get_posted_password_reset_bridge_credentials();
}
}
if ( $form_args ) {
wc_get_template( 'myaccount/form-reset-password.php', $form_args );
return;
}
if ( $has_reset_cookie || $has_bridge_handle ) {
self::add_password_reset_key_error_notice();
}
}
// Show lost password form by default.
wc_get_template(
'myaccount/form-lost-password.php',
array(
'form' => 'lost_password',
)
);
}