: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// Validate action so as to default to the login screen.
if ( ! in_array( $action, $default_actions, true ) && false === has_filter( 'login_form_' . $action ) ) {
header( 'Content-Type: ' . get_bloginfo( 'html_type' ) . '; charset=' . get_bloginfo( 'charset' ) );
if ( defined( 'RELOCATE' ) && RELOCATE ) { // Move flag is set.
if ( isset( $_SERVER['PATH_INFO'] ) && ( $_SERVER['PATH_INFO'] !== $_SERVER['PHP_SELF'] ) ) {
$_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] );
$url = dirname( set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] ) );
if ( get_option( 'siteurl' ) !== $url ) {
update_option( 'siteurl', $url );
// Set a cookie now to see if they are supported by the browser.
$secure = ( 'https' === parse_url( wp_login_url(), PHP_URL_SCHEME ) );
setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure );
if ( SITECOOKIEPATH !== COOKIEPATH ) {
setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure );
if ( isset( $_GET['wp_lang'] ) ) {
setcookie( 'wp_lang', sanitize_text_field( $_GET['wp_lang'] ), 0, COOKIEPATH, COOKIE_DOMAIN, $secure );
* Fires when the login form is initialized.
do_action( 'login_init' );
* Fires before a specified login form action.
* The dynamic portion of the hook name, `$action`, refers to the action
* that brought the visitor to the login form.
* Possible hook names include:
* - `login_form_checkemail`
* - `login_form_confirm_admin_email`
* - `login_form_confirmaction`
* - `login_form_entered_recovery_mode`
* - `login_form_lostpassword`
* - `login_form_postpass`
* - `login_form_register`
* - `login_form_resetpass`
* - `login_form_retrievepassword`
do_action( "login_form_{$action}" );
$http_post = ( 'POST' === $_SERVER['REQUEST_METHOD'] );
$interim_login = isset( $_REQUEST['interim-login'] );
* Filters the separator used between login form navigation links.
* @param string $login_link_separator The separator used between login form navigation links.
$login_link_separator = apply_filters( 'login_link_separator', ' | ' );
case 'confirm_admin_email':
* Note that `is_user_logged_in()` will return false immediately after logging in
* as the current user is not set, see wp-includes/pluggable.php.
* However this action runs on a redirect after logging in.
if ( ! is_user_logged_in() ) {
wp_safe_redirect( wp_login_url() );
if ( ! empty( $_REQUEST['redirect_to'] ) ) {
$redirect_to = $_REQUEST['redirect_to'];
$redirect_to = admin_url();
if ( current_user_can( 'manage_options' ) ) {
$admin_email = get_option( 'admin_email' );
wp_safe_redirect( $redirect_to );
* Filters the interval for dismissing the admin email confirmation screen.
* If `0` (zero) is returned, the "Remind me later" link will not be displayed.
* @param int $interval Interval time (in seconds). Default is 3 days.
$remind_interval = (int) apply_filters( 'admin_email_remind_interval', 3 * DAY_IN_SECONDS );
if ( ! empty( $_GET['remind_me_later'] ) ) {
if ( ! wp_verify_nonce( $_GET['remind_me_later'], 'remind_me_later_nonce' ) ) {
wp_safe_redirect( wp_login_url() );
if ( $remind_interval > 0 ) {
update_option( 'admin_email_lifespan', time() + $remind_interval );
$redirect_to = add_query_arg( 'admin_email_remind_later', 1, $redirect_to );
wp_safe_redirect( $redirect_to );
if ( ! empty( $_POST['correct-admin-email'] ) ) {
if ( ! check_admin_referer( 'confirm_admin_email', 'confirm_admin_email_nonce' ) ) {
wp_safe_redirect( wp_login_url() );
* Filters the interval for redirecting the user to the admin email confirmation screen.
* If `0` (zero) is returned, the user will not be redirected.
* @param int $interval Interval time (in seconds). Default is 6 months.
$admin_email_check_interval = (int) apply_filters( 'admin_email_check_interval', 6 * MONTH_IN_SECONDS );
if ( $admin_email_check_interval > 0 ) {
update_option( 'admin_email_lifespan', time() + $admin_email_check_interval );
wp_safe_redirect( $redirect_to );
login_header( __( 'Confirm your administration email' ), '', $errors );
* Fires before the admin email confirm form.
* @param WP_Error $errors A `WP_Error` object containing any errors generated by using invalid
* credentials. Note that the error object may not contain any errors.
do_action( 'admin_email_confirm', $errors );
<form class="admin-email-confirm-form" name="admin-email-confirm-form" action="<?php echo esc_url( site_url( 'wp-login.php?action=confirm_admin_email', 'login_post' ) ); ?>" method="post">
* Fires inside the admin-email-confirm-form form tags, before the hidden fields.
do_action( 'admin_email_confirm_form' );
wp_nonce_field( 'confirm_admin_email', 'confirm_admin_email_nonce' );
<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
<h1 class="admin-email__heading">
<?php _e( 'Administration email verification' ); ?>
<p class="admin-email__details">
<?php _e( 'Please verify that the <strong>administration email</strong> for this website is still correct.' ); ?>
/* translators: URL to the WordPress help section about admin email. */
$admin_email_help_url = __( 'https://wordpress.org/documentation/article/settings-general-screen/#email-address' );
$accessibility_text = sprintf(
'<span class="screen-reader-text"> %s</span>',
/* translators: Hidden accessibility text. */
__( '(opens in a new tab)' )
'<a href="%s" rel="noopener" target="_blank">%s%s</a>',
esc_url( $admin_email_help_url ),
__( 'Why is this important?' ),
<p class="admin-email__details">
/* translators: %s: Admin email address. */
__( 'Current administration email: %s' ),
'<strong>' . esc_html( $admin_email ) . '</strong>'
<p class="admin-email__details">
<?php _e( 'This email may be different from your personal email address.' ); ?>
<div class="admin-email__actions">
<div class="admin-email__actions-primary">
$change_link = admin_url( 'options-general.php' );
$change_link = add_query_arg( 'highlight', 'confirm_admin_email', $change_link );
<a class="button button-large" href="<?php echo esc_url( $change_link ); ?>"><?php _e( 'Update' ); ?></a>
<input type="submit" name="correct-admin-email" id="correct-admin-email" class="button button-primary button-large" value="<?php esc_attr_e( 'The email is correct' ); ?>" />
<?php if ( $remind_interval > 0 ) : ?>
<div class="admin-email__actions-secondary">
$remind_me_link = wp_login_url( $redirect_to );
$remind_me_link = add_query_arg(
'action' => 'confirm_admin_email',
'remind_me_later' => wp_create_nonce( 'remind_me_later_nonce' ),
<a href="<?php echo esc_url( $remind_me_link ); ?>"><?php _e( 'Remind me later' ); ?></a>
if ( ! isset( $_POST['post_password'] ) || ! is_string( $_POST['post_password'] ) ) {
wp_safe_redirect( wp_get_referer() );
require_once ABSPATH . WPINC . '/class-phpass.php';
$hasher = new PasswordHash( 8, true );
* Filters the life span of the post password cookie.
* By default, the cookie expires 10 days from creation. To turn this
* into a session cookie, return 0.
* @param int $expires The expiry time, as passed to setcookie().
$expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS );
$referer = wp_get_referer();
$secure = ( 'https' === parse_url( $referer, PHP_URL_SCHEME ) );
setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure );
wp_safe_redirect( wp_get_referer() );
check_admin_referer( 'log-out' );
$user = wp_get_current_user();
if ( ! empty( $_REQUEST['redirect_to'] ) && is_string( $_REQUEST['redirect_to'] ) ) {
$redirect_to = $_REQUEST['redirect_to'];
$requested_redirect_to = $redirect_to;
$redirect_to = add_query_arg(
'wp_lang' => get_user_locale( $user ),
$requested_redirect_to = '';
* Filters the log out redirect URL.
* @param string $redirect_to The redirect destination URL.
* @param string $requested_redirect_to The requested redirect destination URL passed as a parameter.
* @param WP_User $user The WP_User object for the user that's logging out.
$redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user );
wp_safe_redirect( $redirect_to );
$errors = retrieve_password();
if ( ! is_wp_error( $errors ) ) {
$redirect_to = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm';
wp_safe_redirect( $redirect_to );
if ( isset( $_GET['error'] ) ) {
if ( 'invalidkey' === $_GET['error'] ) {
$errors->add( 'invalidkey', __( '<strong>Error:</strong> Your password reset link appears to be invalid. Please request a new link below.' ) );
} elseif ( 'expiredkey' === $_GET['error'] ) {
$errors->add( 'expiredkey', __( '<strong>Error:</strong> Your password reset link has expired. Please request a new link below.' ) );
$lostpassword_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
* Filters the URL redirected to after submitting the lostpassword/retrievepassword form.
* @param string $lostpassword_redirect The redirect destination URL.
$redirect_to = apply_filters( 'lostpassword_redirect', $lostpassword_redirect );
* Fires before the lost password form.
* @since 5.1.0 Added the `$errors` parameter.
* @param WP_Error $errors A `WP_Error` object containing any errors generated by using invalid
* credentials. Note that the error object may not contain any errors.
do_action( 'lost_password', $errors );
__( 'Please enter your username or email address. You will receive an email message with instructions on how to reset your password.' ),
'additional_classes' => array( 'message' ),
if ( isset( $_POST['user_login'] ) && is_string( $_POST['user_login'] ) ) {
$user_login = wp_unslash( $_POST['user_login'] );
<form name="lostpasswordform" id="lostpasswordform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=lostpassword', 'login_post' ) ); ?>" method="post">
<label for="user_login"><?php _e( 'Username or Email Address' ); ?></label>
<input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" autocapitalize="off" autocomplete="username" required="required" />
* Fires inside the lostpassword form tags, before the hidden fields.
do_action( 'lostpassword_form' );
<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
<input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Get New Password' ); ?>" />
<a class="wp-login-log-in" href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a>
if ( get_option( 'users_can_register' ) ) {
$registration_url = sprintf( '<a class="wp-login-register" href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
echo esc_html( $login_link_separator );
/** This filter is documented in wp-includes/general-template.php */
echo apply_filters( 'register', $registration_url );
login_footer( 'user_login' );
list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) );
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
if ( isset( $_GET['key'] ) && isset( $_GET['login'] ) ) {
$value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) );
setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) );
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
$user = check_password_reset_key( $rp_key, $rp_login );
if ( isset( $_POST['pass1'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) {
if ( ! $user || is_wp_error( $user ) ) {
setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
if ( $user && $user->get_error_code() === 'expired_key' ) {
wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) );
wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) );
$errors = new WP_Error();
// Check if password is one or all empty spaces.
if ( ! empty( $_POST['pass1'] ) ) {
$_POST['pass1'] = trim( $_POST['pass1'] );
if ( empty( $_POST['pass1'] ) ) {
$errors->add( 'password_reset_empty_space', __( 'The password cannot be a space or all spaces.' ) );
// Check if password fields do not match.
if ( ! empty( $_POST['pass1'] ) && trim( $_POST['pass2'] ) !== $_POST['pass1'] ) {
$errors->add( 'password_reset_mismatch', __( '<strong>Error:</strong> The passwords do not match.' ) );
* Fires before the password reset procedure is validated.
* @param WP_Error $errors WP Error object.
* @param WP_User|WP_Error $user WP_User object if the login and reset key match. WP_Error object otherwise.
do_action( 'validate_password_reset', $errors, $user );
if ( ( ! $errors->has_errors() ) && isset( $_POST['pass1'] ) && ! empty( $_POST['pass1'] ) ) {
reset_password( $user, $_POST['pass1'] );
setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
__( 'Your password has been reset.' ) . ' <a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log in' ) . '</a>',