false, 'password_confirm_label' => __('Confirm Password', 'wp-ultimo'), ); } // end defaults; /** * List of keys of the default fields we want to display on the builder. * * @since 2.0.0 * @return array */ public function default_fields() { return array( 'name', 'placeholder', 'tooltip', ); } // end default_fields; /** * If you want to force a particular attribute to a value, declare it here. * * @since 2.0.0 * @return array */ public function force_attributes() { return array( 'id' => 'password', 'required' => true, ); } // end force_attributes; /** * Returns the list of additional fields specific to this type. * * @since 2.0.0 * @return array */ public function get_fields() { return array( 'password_strength_meter' => array( 'type' => 'toggle', 'title' => __('Display Password Strength Meter', 'wp-ultimo'), 'desc' => __('Adds a password strength meter below the password field. Enabling this option also enforces passwords to be strong.', 'wp-ultimo'), 'value' => 1, ), 'password_confirm_field' => array( 'type' => 'toggle', 'title' => __('Display Password Confirm Field', 'wp-ultimo'), 'desc' => __('Adds a "Confirm your Password" field below the default password field to reduce the chance or making a mistake.', 'wp-ultimo'), 'value' => 1, ), ); } // end get_fields; /** * Returns the field/element actual field array to be used on the checkout form. * * @since 2.0.0 * * @param array $attributes Attributes saved on the editor form. * @return array An array of fields, not the field itself. */ public function to_fields_array($attributes) { /* * Logged in user, bail. */ if (is_user_logged_in()) { return array(); } // end if; $checkout_fields = array(); $checkout_fields['password'] = array( 'type' => 'password', 'id' => 'password', 'name' => $attributes['name'], 'placeholder' => $attributes['placeholder'], 'tooltip' => $attributes['tooltip'], 'meter' => $attributes['password_strength_meter'], 'required' => true, 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), 'classes' => wu_get_isset($attributes, 'element_classes', ''), 'html_attr' => array( 'autocomplete' => 'new-password', ), 'wrapper_html_attr' => array( 'style' => $this->calculate_style_attr(), ), ); if ($attributes['password_confirm_field']) { $checkout_fields['password_conf'] = array( 'type' => 'password', 'id' => 'password_conf', 'name' => $attributes['password_confirm_label'], 'placeholder' => '', 'tooltip' => '', 'meter' => false, 'required' => true, 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), 'classes' => wu_get_isset($attributes, 'element_classes', ''), 'html_attr' => array( 'autocomplete' => 'new-password', ), 'wrapper_html_attr' => array( 'style' => $this->calculate_style_attr(), ), ); } // end if; return $checkout_fields; } // end to_fields_array; } // end class Signup_Field_Password;