Created
January 23, 2018 21:41
-
-
Save shreyans94/dad92a9d587a883a32efd998bb594f0b to your computer and use it in GitHub Desktop.
Edit Woocommerce/Wordpress Password Strength and its Text (From strength 3 to 1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wc_ninja_remove_password_strength() { | |
if ( wp_script_is( 'wc-password-strength-meter', 'enqueued' ) ) { | |
wp_dequeue_script( 'wc-password-strength-meter' ); | |
} | |
} | |
add_action( 'wp_print_scripts', 'wc_ninja_remove_password_strength', 100 ); | |
add_filter( 'woocommerce_min_password_strength', create_function( '', 'return 1;' ) ); | |
add_action( 'wp_enqueue_scripts', 'my_strength_meter_localize_script' ); | |
function my_strength_meter_localize_script() { | |
wp_localize_script( 'password-strength-meter', 'pwsL10n', array( | |
'empty' => __( 'But... it\'s empty!', '.' ), | |
'short' => __( 'Password Too Short!', 'theme-domain' ), | |
'bad' => __( 'You Can Make it Stronger' ), | |
'good' => __( 'Good Password Strength!', 'theme-domain' ), | |
'strong' => __( 'Now, that\'s a strong password!', 'theme-domain' ), | |
'mismatch' => __( 'Passwords are completely different, come on!', 'theme-domain' ) | |
) ); | |
} | |
add_filter( 'wc_password_strength_meter_params', 'my_strength_meter_custom_strings' ); | |
function my_strength_meter_custom_strings( $data ) { | |
$data_new = array( | |
'i18n_password_error' => esc_attr__( 'Enter a Longer Password.', 'theme-domain' ), | |
'i18n_password_hint' => esc_attr__( 'To make it stronger, use upper and lower case letters, numbers, and symbols like ! " ? $ % ^ & ). ', 'theme-domain' ) | |
); | |
return array_merge( $data, $data_new ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment