array( 'type' => 'toggle', 'title' => __('Default State', 'wp-ultimo'), 'desc' => __('Use the toggle to the set the default state of the checkbox.', 'wp-ultimo'), 'value' => 0, 'order' => 12, ), ); } // 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) { $checkout_fields = array(); $checkout_fields[$attributes['id']] = array( 'type' => 'checkbox', 'id' => $attributes['id'], 'name' => $attributes['name'], 'tooltip' => $attributes['tooltip'], 'required' => $attributes['required'], 'wrapper_classes' => $attributes['element_classes'], ); if ($attributes['default_state']) { $checkout_fields[$attributes['id']]['html_attr']['checked'] = 'checked'; } // end if; $value = $this->get_value(); if ($value !== '' && (bool) $value === true) { $checkout_fields[$attributes['id']]['html_attr']['checked'] = 'checked'; } // end if; return $checkout_fields; } // end to_fields_array; } // end class Signup_Field_Checkbox;