__('I agree with the terms of use.', 'wp-ultimo'), ]; } /** * 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 []; } /** * 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 [ 'id' => 'terms_of_use', 'name' => __('Terms of Use', 'wp-ultimo'), ]; } /** * Returns the list of additional fields specific to this type. * * @since 2.0.0 * @return array */ public function get_fields() { return [ 'tou_name' => [ 'order' => 10, 'type' => 'text', 'title' => __('Terms Checkbox Label', 'wp-ultimo'), 'placeholder' => __('e.g. I agree with the terms of use.', 'wp-ultimo'), ], 'tou_url' => [ 'order' => 20, 'type' => 'url', 'title' => __('Link to the Terms Page', 'wp-ultimo'), 'desc' => __('Enter the link to the terms of use content.', 'wp-ultimo'), 'placeholder' => __('e.g. https://yoursite.com/terms', 'wp-ultimo'), ], ]; } /** * 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 = []; $tou_link = sprintf('%s', $attributes['tou_url'], __('Read here', 'wp-ultimo')); $checkout_fields['terms_of_use'] = [ 'type' => 'checkbox', 'id' => 'terms_of_use', 'name' => $attributes['tou_name'] . ' - ', 'desc' => $tou_link, 'wrapper_classes' => $attributes['element_classes'], 'required' => true, ]; return $checkout_fields; } }