settings = Plugin::get_settings( 'performance' ); add_filter( 'adminease_settings_fields', [ $this, 'adminease_settings_fields' ] ); if( empty( $this->settings['disable_front_password_meter'] ) ) { return; } add_action( 'wp_enqueue_scripts', [ $this, 'dequeue_meter' ], 999 ); add_action( 'wp_footer', [ $this, 'dequeue_meter' ], 1 ); } /** * Adds the switch to the Performance tab. * * @param array $fields The settings fields keyed by tab. * * @return array The modified settings fields. */ public function adminease_settings_fields( array $fields ): array { $fields['performance']['fields'][] = [ 'type' => 'switch', 'id' => 'disable-front-password-meter', 'name' => 'adminease[performance][disable_front_password_meter]', 'value' => $this->settings['disable_front_password_meter'] ?? '', 'label_class' => 'pwp-switch', 'input_class' => 'pwp-field-input', 'label' => __( 'No password strength meter on the front end', 'adminease' ), 'description' => __( 'WooCommerce and some plugins load a large password checker on account and checkout pages. This stops it loading for visitors and saves page weight. The login screen keeps it. Customers will not see the live password strength hint, so turn on "Force strong passwords" to keep weak passwords out.', 'adminease' ), 'conflicts' => [ 'woocommerce/woocommerce.php' => __( 'WooCommerce checks password strength on the account page and checkout. Turning this on removes that check.', 'adminease' ), ], ]; return $fields; } /** * Removes the password strength scripts from the queue. * They are only dequeued, never deregistered, so a plugin that asks for them later * does not hit an unknown handle. * * @return void */ public function dequeue_meter(): void { wp_dequeue_script( 'wc-password-strength-meter' ); wp_dequeue_script( 'password-strength-meter' ); wp_dequeue_script( 'zxcvbn-async' ); } }