false,
'back_button_label' => __('← Go Back', '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(
'id',
'name',
);
} // 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();
} // 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(
'enable_go_back_button' => array(
'type' => 'toggle',
'title' => __('Add "Go Back" button', 'wp-ultimo'),
'desc' => __('Enable this option to add a "Go Back" button. Useful for multi-step checkout forms.', 'wp-ultimo'),
'tooltip' => '',
'value' => 0,
'html_attr' => array(
'v-model' => 'enable_go_back_button',
),
),
'back_button_label' => array(
'type' => 'text',
'title' => __('"Go Back" Button Label', 'wp-ultimo'),
'desc' => __('Value to be used as the "Go Back" label.', 'wp-ultimo'),
'placeholder' => __('e.g. ← Go Back', 'wp-ultimo'),
'value' => __('← Go Back', 'wp-ultimo'),
'wrapper_html_attr' => array(
'v-cloak' => '1',
'v-show' => 'enable_go_back_button',
),
),
);
} // 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) {
$uniqid = uniqid();
$fields = array();
$fields[$attributes['id'] . '_errors'] = array(
'type' => 'html',
'wrapper_classes' => 'wu_submit_button_errors wu-clear-both',
'content' => '',
'wrapper_html_attr' => array(
'v-if' => 'get_errors()',
),
);
$fields[$attributes['id'] . '_group'] = array(
'type' => 'group',
'raw' => true,
'default' => array(),
'wrapper_classes' => '',
'fields' => array(),
);
$button_wrapper_classes = 'wu_submit_button';
if ($attributes['enable_go_back_button']) {
$steps = \WP_Ultimo\Checkout\Checkout::get_instance()->steps;
$is_first_step = isset($steps[0]) && $steps[0]['id'] === $attributes['step'];
if (!$is_first_step) {
$fields[$attributes['id'] . '_group']['fields'][$attributes['id'] . '_go_back'] = array(
'type' => 'html',
'wrapper_classes' => 'md:wu-w-1/2 wu-box-border wu-float-left wu--mt-4',
'id' => $attributes['id'] . '_go_back',
'content' => sprintf('%s', $attributes['back_button_label']),
);
$button_wrapper_classes .= ' md:wu-w-1/2 wu-box-border wu-float-left wu-text-right';
} // end if;
} // end if;
$fields[$attributes['id'] . '_group']['fields'][$attributes['id']] = array(
'type' => 'submit',
'wrapper_classes' => trim($button_wrapper_classes . ' ' . wu_get_isset($attributes, 'wrapper_element_classes', '')),
'classes' => trim('button button-primary btn-primary' . ' ' . wu_get_isset($attributes, 'element_classes', '')),
'id' => $attributes['id'],
'name' => $attributes['name'],
);
if ($attributes['enable_go_back_button']) {
$fields[$attributes['id'] . '_clear'] = array(
'type' => 'clear',
);
} // end if;
return $fields;
} // end to_fields_array;
} // end class Signup_Field_Submit_Button;