/** * Returns and/or create the single instance of this class. * * @return Charitable_User_Management * @access public * @since 1.4.0 */ public static function get_instance() { if (is_null(self::$instance)) { self::$instance = new Charitable_User_Management(); } return self::$instance; }
* add_filter( 'charitable_disable_wp_login', '__return_true' ); * * @see Charitable_User_Management::redirect_to_charitable_login() */ add_action('login_form_login', array(Charitable_User_Management::get_instance(), 'maybe_redirect_to_charitable_login')); /** * If hiding all access to wp-login.php using the charitable_disable_wp_login * filter, capture login error messages and display them on the Charitable * login page * * @see Charitable_User_Management::maybe_redirect_at_authenticate() */ add_filter('authenticate', array(Charitable_User_Management::get_instance(), 'maybe_redirect_at_authenticate'), 101, 2); /** * If hiding all access to wp-login.php using the charitable_disable_wp_login * filter, redirect user to custom forgot password page if they try to directly * access /wp-login.php?action=lostpassword * * @see Charitable_User_Management::maybe_redirect_to_custom_lostpassword() */ add_action('login_form_lostpassword', array(Charitable_User_Management::get_instance(), 'maybe_redirect_to_custom_lostpassword')); /** * If hiding all access to wp-login.php using the charitable_disable_wp_login * filter, redirect user to custom reset password page if they try to directly * access /wp-login.php?action=rp or /wp-login.php?action=resetpass * * @see Charitable_User_Management::maybe_redirect_to_custom_password_reset_page() */ add_action('login_form_rp', array(Charitable_User_Management::get_instance(), 'maybe_redirect_to_custom_password_reset_page')); add_action('login_form_resetpass', array(Charitable_User_Management::get_instance(), 'maybe_redirect_to_custom_password_reset_page'));
/** * Get the reset key and login from the cookie. * * @return void * @access protected * @since 1.4.0 */ protected function parse_reset_key() { $this->key = null; $this->login = null; if (!isset($_COOKIE['wp-resetpass-' . COOKIEHASH])) { return; } $cookie = $_COOKIE['wp-resetpass-' . COOKIEHASH]; if (!strpos($cookie, ':')) { return; } $cookie_parts = explode(':', wp_unslash($cookie), 2); list($login, $key) = array_map('sanitize_text_field', $cookie_parts); $user = check_password_reset_key($key, $login); if (is_wp_error($user)) { charitable_get_notices()->add_errors_from_wp_error($user); Charitable_User_Management::get_instance()->set_reset_cookie(); return; } /* Reset key / login is correct, display reset password form with hidden key / login values */ $this->key = $key; $this->login = $login; }