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

	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 and localize with meter data.
		if ( did_action( 'wp_enqueue_scripts' ) ) {

			wp_enqueue_script( 'password-strength-meter' );
			llms()->assets->enqueue_inline(
				'llms-pw-strength-settings',
				'window.LLMS.PasswordStrength = window.LLMS.PasswordStrength || {};window.LLMS.PasswordStrength.get_settings = function() { return JSON.parse( \'' . wp_json_encode( $meter_settings ) . '\' ); };',
				'footer',
				15
			);

		}

	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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