LLMS_Form_Field::prepare_password_strength_meter()

Additional preparation for the password strength meter.


Return Return

(void)


Top ↑

Source Source

File: includes/forms/class-llms-form-field.php

785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
protected function prepare_password_strength_meter() {
 
    $meter_settings = array(
        'blocklist'    => array(),
        'min_strength' => ! empty( $this->settings['min_strength'] ) ? $this->settings['min_strength'] : 'strong',
        'min_length'   => ! empty( $this->settings['min_length'] ) ? max( 6, $this->settings['min_length'] ) : 6,
    );
 
    // Backwards compat functionality ends up outputting a minlength attribute on the <div> and we don't want that.
    unset( $this->settings['min_length'] );
 
    /**
     * Modify password strength meter settings.
     *
     * @since 5.0.0
     *
     * @param array $meter_settings {
     *     Hash of meter configuration options.
     *
     *     @type string[] $blocklist    A list of strings that are penalized when used in the password. See "user_inputs" at https://github.com/dropbox/zxcvbn#usage.
     *     @type string   $min_strength The minimum acceptable password strength. Accepts "strong", "medium", or "weak". Default: "strong".
     *     @type int      $min_length   The minimum acceptable password length. Must be >= 6. Default: 6.
     * }
     */
    $meter_settings = apply_filters( 'llms_password_strength_meter_settings', $meter_settings, $this->settings, $this );
 
    // If scripts have been enqueued, add password strength meter script.
    if ( did_action( 'wp_enqueue_scripts' ) ) {
        return $this->enqueue_strength_meter( $meter_settings );
    }
    // Otherwise add it whe `wp_enqueue_scripts` is fired.
    add_action(
        'wp_enqueue_scripts',
        function() use ( $meter_settings ) {
            $this->enqueue_strength_meter( $meter_settings );
        }
    );
 
}


Top ↑

Changelog Changelog

Changelog
Version Description
5.10.0 Make sure to enqueue the strength meter js, whether or not wp_enqueue_scripts hook has been fired yet.
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.