function slt_fsp_validate_strong_password($errors, $user_data) { $password_ok = true; $enforce = true; $password = isset($_POST['pass1']) && trim($_POST['pass1']) ? $_POST['pass1'] : false; $role = isset($_POST['role']) ? $_POST['role'] : false; $user_id = isset($user_data->ID) ? $user_data->ID : false; $username = isset($_POST["user_login"]) ? $_POST["user_login"] : $user_data->user_login; // No password set? // Already got a password error? if (false === $password || $errors->get_error_data("pass")) { return $errors; } // Should a strong password be enforced for this user? if ($user_id) { // User ID specified $enforce = slt_fsp_enforce_for_user($user_id); } else { // No ID yet, adding new user - omit check for "weaker" roles if ($role && in_array($role, apply_filters('slt_fsp_weak_roles', array("subscriber", "contributor")))) { $enforce = false; } } // Enforce? if ($enforce) { // Using zxcvbn? if (SLT_FSP_USE_ZXCVBN) { // Check the strength passed from the zxcvbn meter $compare_strong = html_entity_decode(__('strong'), ENT_QUOTES, 'UTF-8'); $compare_good = html_entity_decode(__('good'), ENT_QUOTES, 'UTF-8'); if (!in_array($_POST['slt-fsp-pass-strength-result'], array(null, $compare_strong, $compare_good))) { $password_ok = false; } } else { // Old-style check if (slt_fsp_password_strength($password, $username) < 3) { $password_ok = false; } } } // Error? if (!$password_ok) { $errors->add('pass', apply_filters('slt_fsp_error_message', __('<strong>ERROR</strong>: Please make the password a medium or strong one.', 'slt-force-strong-passwords'))); } return $errors; }
function slt_fsp_validate_strong_password($errors, $user_data) { $password_ok = true; $enforce = true; $password = isset($_POST['pass1']) && trim($_POST['pass1']) ? $_POST['pass1'] : false; $role = isset($_POST['role']) ? $_POST['role'] : false; $user_id = isset($user_data->ID) ? $user_data->ID : false; $username = isset($_POST["user_login"]) ? $_POST["user_login"] : $user_data->user_login; // No password set? // Already got a password error? if (false === $password || $errors->get_error_data("pass")) { return $errors; } // Should a strong password be enforced for this user? if ($user_id) { // User ID specified $enforce = slt_fsp_enforce_for_user($user_id); } else { // No ID yet, adding new user - omit check for "weaker" roles if ($role && in_array($role, apply_filters('slt_fsp_weak_roles', array("subscriber", "contributor")))) { $enforce = false; } } // Enforce? if ($enforce) { // Using zxcvbn? if (SLT_FSP_USE_ZXCVBN) { // Check the strength passed from the zxcvbn meter $compare_strong = html_entity_decode(__('Strong'), ENT_QUOTES, 'UTF-8'); $compare_medium = html_entity_decode(__('Medium'), ENT_QUOTES, 'UTF-8'); $compare_strong_es = html_entity_decode(__('Fuerte'), ENT_QUOTES, 'UTF-8'); $compare_strong_id = html_entity_decode(__('Kuat'), ENT_QUOTES, 'UTF-8'); $compare_strong_sk = html_entity_decode(__('Silné'), ENT_QUOTES, 'UTF-8'); $compare_strong_da = html_entity_decode(__('Stærk'), ENT_QUOTES, 'UTF-8'); $compare_strong_eo = html_entity_decode(__('Forta'), ENT_QUOTES, 'UTF-8'); $compare_strong_de = html_entity_decode(__('Stark'), ENT_QUOTES, 'UTF-8'); $compare_strong_bg = html_entity_decode(__('Устойчива'), ENT_QUOTES, 'UTF-8'); $compare_strong_az = html_entity_decode(__('Güclü'), ENT_QUOTES, 'UTF-8'); $compare_strong_hu = html_entity_decode(__('Erős'), ENT_QUOTES, 'UTF-8'); $compare_strong_hy = html_entity_decode(__('Ապահով'), ENT_QUOTES, 'UTF-8'); $compare_strong_tl = html_entity_decode(__('Malakas'), ENT_QUOTES, 'UTF-8'); $compare_strong_fa = html_entity_decode(__('قوی'), ENT_QUOTES, 'UTF-8'); $compare_strong_pl = html_entity_decode(__('Silne'), ENT_QUOTES, 'UTF-8'); $compare_strong_nb = html_entity_decode(__('Sterk'), ENT_QUOTES, 'UTF-8'); $compare_strong_nn = html_entity_decode(__('Sterkt'), ENT_QUOTES, 'UTF-8'); $compare_strong_sv = html_entity_decode(__('Starkt'), ENT_QUOTES, 'UTF-8'); $compare_strong_it = html_entity_decode(__('Forte'), ENT_QUOTES, 'UTF-8'); $compare_strong_tr = html_entity_decode(__('Güçlü'), ENT_QUOTES, 'UTF-8'); $compare_strong_ca = html_entity_decode(__('Robusta'), ENT_QUOTES, 'UTF-8'); $compare_strong_ps = html_entity_decode(__('قوي'), ENT_QUOTES, 'UTF-8'); $compare_strong_zh = html_entity_decode(__('讚'), ENT_QUOTES, 'UTF-8'); $compare_strong_lt = html_entity_decode(__('Stiprus'), ENT_QUOTES, 'UTF-8'); $compare_strong_el = html_entity_decode(__('Δυνατό'), ENT_QUOTES, 'UTF-8'); $compare_strong_ko = html_entity_decode(__('강함'), ENT_QUOTES, 'UTF-8'); $compare_strong_th = html_entity_decode(__('ใช้ได้'), ENT_QUOTES, 'UTF-8'); $compare_strong_ru = html_entity_decode(__('Надёжный'), ENT_QUOTES, 'UTF-8'); $compare_strong_sr = html_entity_decode(__('Јако'), ENT_QUOTES, 'UTF-8'); $compare_strong_et = html_entity_decode(__('Tugev'), ENT_QUOTES, 'UTF-8'); $compare_strong_fi = html_entity_decode(__('Erinomainen'), ENT_QUOTES, 'UTF-8'); $compare_strong_cy = html_entity_decode(__('Cryf'), ENT_QUOTES, 'UTF-8'); $compare_strong_oc = html_entity_decode(__('Fòrta'), ENT_QUOTES, 'UTF-8'); $compare_strong_he = html_entity_decode(__('סיסמה חזקה'), ENT_QUOTES, 'UTF-8'); $compare_strong_zh = html_entity_decode(__('强'), ENT_QUOTES, 'UTF-8'); $compare_strong_is = html_entity_decode(__('Traust'), ENT_QUOTES, 'UTF-8'); $compare_strong_eu = html_entity_decode(__('Sendoa'), ENT_QUOTES, 'UTF-8'); $compare_strong_sl = html_entity_decode(__('Dobra'), ENT_QUOTES, 'UTF-8'); $compare_strong_ug = html_entity_decode(__('كۈچلۈك'), ENT_QUOTES, 'UTF-8'); $compare_strong_my = html_entity_decode(__('အားကောင်း'), ENT_QUOTES, 'UTF-8'); $compare_strong_hr = html_entity_decode(__('Jako'), ENT_QUOTES, 'UTF-8'); $compare_strong_gd = html_entity_decode(__('Làidir'), ENT_QUOTES, 'UTF-8'); $compare_strong_uk = html_entity_decode(__('Сильний'), ENT_QUOTES, 'UTF-8'); $compare_strong_ja = html_entity_decode(__('強力'), ENT_QUOTES, 'UTF-8'); $compare_strong_ro = html_entity_decode(__('Puternică'), ENT_QUOTES, 'UTF-8'); $compare_strong_sq = html_entity_decode(__('I fortë'), ENT_QUOTES, 'UTF-8'); if (!in_array($_POST['slt-fsp-pass-strength-result'], array(null, $compare_strong, $compare_medium, $compare_strong_es, $compare_strong_id, $compare_strong_sk, $compare_strong_da, $compare_strong_eo, $compare_strong_de, $compare_strong_bg, $compare_strong_az, $compare_strong_hu, $compare_strong_hy, $compare_strong_tl, $compare_strong_fa, $compare_strong_pl, $compare_strong_nb, $compare_strong_nn, $compare_strong_sv, $compare_strong_it, $compare_strong_tr, $compare_strong_ca, $compare_strong_ps, $compare_strong_zh, $compare_strong_lt, $compare_strong_el, $compare_strong_ko, $compare_strong_th, $compare_strong_ru, $compare_strong_sr, $compare_strong_et, $compare_strong_fi, $compare_strong_cy, $compare_strong_oc, $compare_strong_he, $compare_strong_zh, $compare_strong_is, $compare_strong_eu, $compare_strong_sl, $compare_strong_ug, $compare_strong_my, $compare_strong_hr, $compare_strong_gd, $compare_strong_uk, $compare_strong_ja, $compare_strong_ro, $compare_strong_sq))) { $password_ok = false; } } else { // Old-style check if (slt_fsp_password_strength($password, $username) < 3) { $password_ok = false; } } } // Error? if (!$password_ok) { $errors->add('pass', apply_filters('slt_fsp_error_message', __('<strong>ERROR</strong>: Please make the password a medium or strong one.', 'slt-force-strong-passwords'))); } return $errors; }
/** Functionality used by both user profile and reset password validation. */ function slt_fsp_validate_strong_password($errors, $user_data) { $password_ok = true; $enforce = true; $password = isset($_POST['pass1']) && trim($_POST['pass1']) ? sanitize_text_field($_POST['pass1']) : false; $role = isset($_POST['role']) ? sanitize_text_field($_POST['role']) : false; $user_id = isset($user_data->ID) ? sanitize_text_field($user_data->ID) : false; $username = isset($_POST['user_login']) ? sanitize_text_field($_POST['user_login']) : $user_data->user_login; // No password set? // Already got a password error? if (false === $password || is_wp_error($errors) && $errors->get_error_data('pass')) { return $errors; } // Should a strong password be enforced for this user? if ($user_id) { // User ID specified. $enforce = slt_fsp_enforce_for_user($user_id); } else { // No ID yet, adding new user - omit check for "weaker" roles. if ($role && in_array($role, apply_filters('slt_fsp_weak_roles', array('subscriber', 'contributor')))) { $enforce = false; } } // Enforce? if ($enforce) { // Using zxcvbn? if (SLT_FSP_USE_ZXCVBN) { // Check the strength passed from the zxcvbn meter. $compare_strong = html_entity_decode(__('strong'), ENT_QUOTES, 'UTF-8'); $compare_strong_reset = html_entity_decode(__('hide-if-no-js strong'), ENT_QUOTES, 'UTF-8'); if (!in_array($_POST['slt-fsp-pass-strength-result'], array(null, $compare_strong, $compare_strong_reset))) { $password_ok = false; } } else { // Old-style check. if (slt_fsp_password_strength($password, $username) !== 4) { $password_ok = false; } } } // Error? if (!$password_ok && is_wp_error($errors)) { // Is this a WP error object? $errors->add('pass', apply_filters('slt_fsp_error_message', __('<strong>ERROR</strong>: Please make the password a strong one.', 'slt-force-strong-passwords'))); } return $errors; }