/** * Display a custom message on the lost password login screen. * * @filter login_message * * @param string $message * * @return string */ public function lost_password_message($message) { $action = filter_input(INPUT_GET, 'action', FILTER_SANITIZE_STRING); $status = filter_input(INPUT_GET, 'expass', FILTER_SANITIZE_STRING); if ('lostpassword' !== $action || 'expired' !== $status) { return $message; } $limit = Expire_Passwords::get_limit(); return sprintf('<p id="login_error">%s</p><br><p>%s</p>', sprintf(_n('Your password must be reset every day.', 'Your password must be reset every %d days.', $limit, 'expire-passwords'), $limit), esc_html__('Please enter your username or e-mail below and a password reset link will be sent to you.', 'expire-passwords')); }
/** * Add content to the custom column in the Users list table. * * @action manage_users_custom_column * * @param string $value * @param string $column_name * @param int $user_id * * @return string */ public function render_users_column($value, $column_name, $user_id) { if ('expass' !== $column_name) { return $value; } if (!Expire_Passwords::has_expirable_role($user_id) || false === ($reset = Expire_Passwords::get_user_meta($user_id))) { return '—'; } $time_diff = sprintf(__('%1$s ago', 'expire-passwords'), human_time_diff($reset, time())); $class = Expire_Passwords::is_expired($user_id) ? 'expass-is-expired' : 'expass-not-expired'; return sprintf('<span class="%s">%s</span>', esc_attr($class), esc_html($time_diff)); }
/** * Set property values and fire hooks. * * @action init */ public function init() { /** * Filter the default age limit for passwords (in days) * when the limit settings field is not set or empty. * * @return int */ self::$default_limit = absint(apply_filters('expass_default_limit', 90)); add_action('user_register', array(__CLASS__, 'save_user_meta')); new Expire_Passwords_Login_Screen(); if (!is_user_logged_in()) { return; } new Expire_Passwords_List_Table(); new Expire_Passwords_Settings(); add_action('password_reset', array(__CLASS__, 'save_user_meta')); }