Use PHP 7.4 featers and PHP 8 polyfills

This commit is contained in:
David Stone
2025-02-08 13:57:32 -07:00
parent 8bea6067cd
commit b41dc2b2eb
550 changed files with 15270 additions and 14627 deletions

View File

@ -144,7 +144,7 @@ abstract class Base_Signup_Field {
*/
public function get_field_as_type_option() {
return array(
return [
'title' => $this->get_title(),
'desc' => $this->get_description(),
'tooltip' => $this->get_tooltip(),
@ -154,8 +154,8 @@ abstract class Base_Signup_Field {
'default_fields' => $this->default_fields(),
'force_attributes' => $this->force_attributes(),
'all_attributes' => $this->get_all_attributes(),
'fields' => array($this, 'get_editor_fields'),
);
'fields' => [$this, 'get_editor_fields'],
];
}
/**
@ -180,10 +180,10 @@ abstract class Base_Signup_Field {
*/
public function get_tabs() {
return array(
return [
'content',
'style',
);
];
}
/**
@ -219,7 +219,7 @@ abstract class Base_Signup_Field {
*/
public function calculate_style_attr() {
$styles = array();
$styles = [];
$width = (int) wu_get_isset($this->attributes, 'width');
@ -244,7 +244,7 @@ abstract class Base_Signup_Field {
* @param array $attributes Array containing settings for the field.
* @return void
*/
public function set_attributes($attributes) {
public function set_attributes($attributes): void {
$this->attributes = $attributes;
}
@ -257,7 +257,7 @@ abstract class Base_Signup_Field {
*/
public function force_attributes() {
return array();
return [];
}
/**
@ -268,7 +268,7 @@ abstract class Base_Signup_Field {
*/
public function defaults() {
return array();
return [];
}
/**
@ -279,14 +279,14 @@ abstract class Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
'id',
'name',
'placeholder',
'tooltip',
'default',
'required',
);
];
}
/**
@ -297,7 +297,7 @@ abstract class Base_Signup_Field {
* @param array $attributes The list of attributes of the field.
* @return array
*/
public function get_editor_fields($attributes = array()) {
public function get_editor_fields($attributes = []) {
$final_field_list = $this->get_fields();
@ -305,28 +305,28 @@ abstract class Base_Signup_Field {
* Checks if this is a site field
*/
if ($this->is_site_field()) {
$final_field_list[ '_site_notice_field_' . uniqid() ] = array(
$final_field_list[ '_site_notice_field_' . uniqid() ] = [
'type' => 'note',
'classes' => 'wu--mt-px',
'desc' => sprintf('<div class="wu-p-4 wu--m-4 wu-bg-blue-100 wu-text-blue-600 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid">%s</div>', __('This is a site-related field. For that reason, this field will not show up when no plans are present on the shopping cart.', 'wp-ultimo')),
'order' => 98.5,
);
];
}
/*
* Checks if this is a user field
*/
if ($this->is_user_field()) {
$final_field_list[ '_user_notice_field_' . uniqid() ] = array(
$final_field_list[ '_user_notice_field_' . uniqid() ] = [
'type' => 'note',
'classes' => 'wu--mt-px',
'desc' => sprintf('<div class="wu-p-4 wu--m-4 wu-bg-blue-100 wu-text-blue-600 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid">%s</div>', __('This is a customer-related field. For that reason, this field will not show up when the user is logged and already has a customer on file.', 'wp-ultimo')),
'order' => 98.5,
);
];
}
foreach ($final_field_list as $key => &$field) {
$field['html_attr'] = wu_get_isset($field, 'html_attr', array());
$field['html_attr'] = wu_get_isset($field, 'html_attr', []);
$value = wu_get_isset($attributes, $key, null);
@ -382,11 +382,11 @@ abstract class Base_Signup_Field {
$tab = wu_get_isset($field, 'tab', 'content');
$field['wrapper_html_attr'] = array_merge(
wu_get_isset($field, 'wrapper_html_attr', array()),
array(
wu_get_isset($field, 'wrapper_html_attr', []),
[
'v-cloak' => 1,
'v-show' => sprintf('require("type", "%s") && require("tab", "%s")', $this->get_type(), $tab) . ($show_reqs ? " && $show_reqs" : ''),
)
]
);
}
@ -401,14 +401,14 @@ abstract class Base_Signup_Field {
*/
public function get_all_attributes() {
$styles = array(
$styles = [
'wrapper_element_classes',
'element_classes',
'element_id',
'from_request',
'width',
'logged',
);
];
$field_keys = array_keys($this->get_fields());
@ -436,34 +436,34 @@ abstract class Base_Signup_Field {
*/
public static function fields_list() {
$fields = array();
$fields = [];
$fields['id'] = array(
$fields['id'] = [
'type' => 'text',
'title' => __('Field ID', 'wp-ultimo'),
'placeholder' => __('e.g. info-name', 'wp-ultimo'),
'tooltip' => __('Only alpha-numeric and hyphens allowed.', 'wp-ultimo'),
'desc' => __('The ID of the field. This is used to reference the field.', 'wp-ultimo'),
'value' => wu_request('id', ''),
'html_attr' => array(
'html_attr' => [
'v-on:input' => 'id = $event.target.value.toLowerCase().replace(/[^a-z0-9-_]+/g, "")',
'v-bind:value' => 'id',
),
);
],
];
$fields['name'] = array(
$fields['name'] = [
'type' => 'text',
'title' => __('Field Label', 'wp-ultimo'),
'placeholder' => __('e.g. Your Name', 'wp-ultimo'),
'desc' => __('This is what your customer see as the field title.', 'wp-ultimo'),
'tooltip' => __('Leave blank to hide the field label. You can also set a placeholder value and tip in the "Additional Settings" tab.', 'wp-ultimo'),
'value' => '',
'html_attr' => array(
'html_attr' => [
'v-model' => 'name',
),
);
],
];
$fields['placeholder'] = array(
$fields['placeholder'] = [
'type' => 'text',
'title' => __('Field Placeholder', 'wp-ultimo'),
'placeholder' => __('e.g. Placeholder value', 'wp-ultimo'),
@ -471,12 +471,12 @@ abstract class Base_Signup_Field {
'tooltip' => '',
'value' => '',
'tab' => 'advanced',
'html_attr' => array(
'html_attr' => [
'v-model' => 'placeholder',
),
);
],
];
$fields['tooltip'] = array(
$fields['tooltip'] = [
'type' => 'textarea',
'title' => __('Field Tooltip', 'wp-ultimo'),
'placeholder' => __('e.g. This field is great, be sure to fill it.', 'wp-ultimo'),
@ -485,60 +485,60 @@ abstract class Base_Signup_Field {
'tooltip' => '',
'value' => '',
'tab' => 'advanced',
'html_attr' => array(
'html_attr' => [
'v-model' => 'tooltip',
'rows' => 4,
),
);
],
];
$fields['default_value'] = array(
$fields['default_value'] = [
'type' => 'text',
'title' => __('Default Value', 'wp-ultimo'),
'placeholder' => __('e.g. None', 'wp-ultimo'),
'value' => '',
'html_attr' => array(
'html_attr' => [
'v-model' => 'default_value',
),
);
],
];
$fields['note'] = array(
$fields['note'] = [
'type' => 'textarea',
'title' => __('Content', 'wp-ultimo'),
'placeholder' => '',
'tooltip' => '',
'value' => '',
'html_attr' => array(
'html_attr' => [
'v-model' => 'content',
),
);
],
];
$fields['limits'] = array(
$fields['limits'] = [
'type' => 'group',
'title' => __('Field Length', 'wp-ultimo'),
'tooltip' => '',
'fields' => array(
'min' => array(
'fields' => [
'min' => [
'type' => 'number',
'value' => '',
'placeholder' => __('Min', 'wp-ultimo'),
'wrapper_classes' => 'wu-w-1/2',
'html_attr' => array(
'html_attr' => [
'v-model' => 'min',
),
),
'max' => array(
],
],
'max' => [
'type' => 'number',
'value' => '',
'placeholder' => __('Max', 'wp-ultimo'),
'wrapper_classes' => 'wu-ml-2 wu-w-1/2',
'html_attr' => array(
'html_attr' => [
'v-model' => 'max',
),
),
),
);
],
],
],
];
$fields['save_as'] = array(
$fields['save_as'] = [
'type' => 'select',
'title' => __('Save As', 'wp-ultimo'),
'desc' => __('Select how you want to save this piece of meta data. You can attach it to the customer or the site as site meta or as site option.', 'wp-ultimo'),
@ -546,28 +546,28 @@ abstract class Base_Signup_Field {
'tooltip' => '',
'value' => 'customer_meta',
'order' => 99.5,
'options' => array(
'options' => [
'customer_meta' => __('Customer Meta', 'wp-ultimo'),
'user_meta' => __('User Meta', 'wp-ultimo'),
'site_meta' => __('Site Meta', 'wp-ultimo'),
'site_option' => __('Site Option', 'wp-ultimo'),
'nothing' => __('Do not save', 'wp-ultimo'),
),
'html_attr' => array(
],
'html_attr' => [
'v-model' => 'save_as',
),
);
],
];
$fields['required'] = array(
$fields['required'] = [
'type' => 'toggle',
'title' => __('Required', 'wp-ultimo'),
'desc' => __('Mark this field as required. The checkout will not proceed unless this field is filled.', 'wp-ultimo'),
'value' => 0,
'order' => 98,
'html_attr' => array(
'html_attr' => [
'v-model' => 'required',
),
);
],
];
return $fields;
}

View File

@ -122,9 +122,9 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'zip_and_country' => true,
);
];
}
/**
@ -135,9 +135,9 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
'name',
);
];
}
/**
@ -148,10 +148,10 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
*/
public function force_attributes() {
return array(
return [
'id' => 'billing_address',
'required' => true,
);
];
}
/**
@ -162,14 +162,14 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
*/
public function get_fields() {
return array(
'zip_and_country' => array(
return [
'zip_and_country' => [
'type' => 'toggle',
'title' => __('Display only ZIP and Country?', 'wp-ultimo'),
'desc' => __('Checking this option will only add the ZIP and country fields, instead of all the normal billing address fields.', 'wp-ultimo'),
'value' => true,
),
);
],
];
}
/**
@ -197,7 +197,7 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
$field['type'] = 'select';
$field['options_template'] = $option_template;
$field['options'] = array();
$field['options'] = [];
$field['required'] = true;
$field['wrapper_html_attr']['v-if'] = "{$data_key_name}.length";
$field['html_attr']['required'] = 'required';
@ -234,16 +234,16 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
}
if (isset($fields['billing_country'])) {
$fields['billing_country']['html_attr'] = array(
$fields['billing_country']['html_attr'] = [
'v-model' => 'country',
);
];
}
if ( ! $zip_only) {
if (isset($fields['billing_state'])) {
$fields['billing_state']['html_attr'] = array(
$fields['billing_state']['html_attr'] = [
'v-model.lazy' => 'state',
);
];
/**
* Format the state field accordingly.
@ -254,9 +254,9 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
}
if (isset($fields['billing_city'])) {
$fields['billing_city']['html_attr'] = array(
$fields['billing_city']['html_attr'] = [
'v-model.lazy' => 'city',
);
];
/**
* Format the city field accordingly.

View File

@ -122,9 +122,9 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'',
);
];
}
/**
@ -135,13 +135,13 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
'id',
'name',
'tooltip',
'save_as',
'required',
);
];
}
/**
@ -152,7 +152,7 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
*/
public function force_attributes() {
return array();
return [];
}
/**
@ -163,15 +163,15 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
*/
public function get_fields() {
return array(
'default_state' => array(
return [
'default_state' => [
'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,
),
);
],
];
}
/**
@ -184,16 +184,16 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
*/
public function to_fields_array($attributes) {
$checkout_fields = array();
$checkout_fields = [];
$checkout_fields[ $attributes['id'] ] = array(
$checkout_fields[ $attributes['id'] ] = [
'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';

View File

@ -108,9 +108,9 @@ class Signup_Field_Color extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'',
);
];
}
/**
@ -121,14 +121,14 @@ class Signup_Field_Color extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
'id',
'name',
'placeholder',
'tooltip',
'required',
'save_as',
);
];
}
/**
@ -139,7 +139,7 @@ class Signup_Field_Color extends Base_Signup_Field {
*/
public function force_attributes() {
return array();
return [];
}
/**
@ -150,14 +150,14 @@ class Signup_Field_Color extends Base_Signup_Field {
*/
public function get_fields() {
return array(
'default_value' => array(
return [
'default_value' => [
'type' => 'color-picker',
'order' => 12,
'title' => __('Default Color', 'wp-ultimo'),
'desc' => __('Set the default value for this color field.', 'wp-ultimo'),
),
);
],
];
}
/**
@ -170,8 +170,8 @@ class Signup_Field_Color extends Base_Signup_Field {
*/
public function to_fields_array($attributes) {
return array(
$attributes['id'] => array(
return [
$attributes['id'] => [
'type' => 'color',
'id' => $attributes['id'],
'name' => $attributes['name'],
@ -182,10 +182,10 @@ class Signup_Field_Color extends Base_Signup_Field {
'wrapper_classes' => $attributes['element_classes'],
'classes' => 'wu-rounded',
'value' => $this->get_value(),
'html_attr' => array(
'html_attr' => [
'style' => 'width: 50px !important',
),
),
);
],
],
];
}
}

View File

@ -108,10 +108,10 @@ class Signup_Field_Discount_Code extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'placeholder' => '',
'default' => '',
);
];
}
/**
@ -122,11 +122,11 @@ class Signup_Field_Discount_Code extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
'name',
'placeholder',
'tooltip',
);
];
}
/**
@ -137,9 +137,9 @@ class Signup_Field_Discount_Code extends Base_Signup_Field {
*/
public function force_attributes() {
return array(
return [
'id' => 'discount_code',
);
];
}
/**
@ -150,7 +150,7 @@ class Signup_Field_Discount_Code extends Base_Signup_Field {
*/
public function get_fields() {
return array();
return [];
}
/**
@ -163,19 +163,19 @@ class Signup_Field_Discount_Code extends Base_Signup_Field {
*/
public function to_fields_array($attributes) {
$checkout_fields = array();
$checkout_fields = [];
$checkout_fields['discount_code_checkbox'] = array(
$checkout_fields['discount_code_checkbox'] = [
'id' => 'discount_code',
'type' => 'toggle',
'name' => __('Have a coupon code?', 'wp-ultimo'),
'class' => 'wu-w-auto',
'html_attr' => array(
'html_attr' => [
'v-model' => 'toggle_discount_code',
),
);
],
];
$checkout_fields['discount_code'] = array(
$checkout_fields['discount_code'] = [
'type' => 'text',
'id' => 'discount_code',
'name' => $attributes['name'],
@ -184,16 +184,16 @@ class Signup_Field_Discount_Code extends Base_Signup_Field {
'default' => $attributes['default'],
'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''),
'classes' => wu_get_isset($attributes, 'element_classes', ''),
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-show' => 'toggle_discount_code',
'style' => $this->calculate_style_attr(),
),
'html_attr' => array(
],
'html_attr' => [
'v-model.lazy' => 'discount_code',
'v-init:discount_code' => "'{$this->get_value()}'",
'v-init:toggle_discount_code' => ! empty($this->get_value()),
),
);
],
];
return $checkout_fields;
}

View File

@ -115,9 +115,9 @@ class Signup_Field_Email extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'display_notices' => true,
);
];
}
/**
@ -128,11 +128,11 @@ class Signup_Field_Email extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
'name',
'placeholder',
'tooltip',
);
];
}
/**
@ -143,10 +143,10 @@ class Signup_Field_Email extends Base_Signup_Field {
*/
public function force_attributes() {
return array(
return [
'id' => 'email_address',
'required' => true,
);
];
}
/**
@ -157,18 +157,18 @@ class Signup_Field_Email extends Base_Signup_Field {
*/
public function get_fields() {
return array(
'display_notices' => array(
return [
'display_notices' => [
'type' => 'toggle',
'title' => __('Display Notices', 'wp-ultimo'),
'desc' => __('When the customer is already logged in, a box with the customer\'s username and a link to logout is displayed instead of the email field. Disable this option if you do not want that box to show up.', 'wp-ultimo'),
'tooltip' => '',
'value' => 1,
'html_attr' => array(
'html_attr' => [
'v-model' => 'display_notices',
),
),
);
],
],
];
}
/**
@ -181,34 +181,34 @@ class Signup_Field_Email extends Base_Signup_Field {
*/
public function to_fields_array($attributes) {
$checkout_fields = array();
$checkout_fields = [];
if (is_user_logged_in()) {
if ($attributes['display_notices']) {
$checkout_fields['login_note'] = array(
$checkout_fields['login_note'] = [
'type' => 'note',
'title' => __('Not you?', 'wp-ultimo'),
'desc' => array($this, 'render_not_you_customer_message'),
'desc' => [$this, 'render_not_you_customer_message'],
'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''),
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'style' => $this->calculate_style_attr(),
),
);
],
];
}
} else {
if ($attributes['display_notices']) {
$checkout_fields['login_note'] = array(
$checkout_fields['login_note'] = [
'type' => 'note',
'title' => __('Existing customer?', 'wp-ultimo'),
'desc' => array($this, 'render_existing_customer_message'),
'desc' => [$this, 'render_existing_customer_message'],
'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''),
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'style' => $this->calculate_style_attr(),
),
);
],
];
}
$checkout_fields['email_address'] = array(
$checkout_fields['email_address'] = [
'type' => 'text',
'id' => 'email_address',
'name' => $attributes['name'],
@ -218,10 +218,10 @@ class Signup_Field_Email extends Base_Signup_Field {
'required' => true,
'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''),
'classes' => wu_get_isset($attributes, 'element_classes', ''),
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'style' => $this->calculate_style_attr(),
),
);
],
];
}
return $checkout_fields;

View File

@ -108,9 +108,9 @@ class Signup_Field_Hidden extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'from_request' => true,
);
];
}
/**
@ -121,10 +121,10 @@ class Signup_Field_Hidden extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
'id',
'save_as',
);
];
}
/**
@ -135,7 +135,7 @@ class Signup_Field_Hidden extends Base_Signup_Field {
*/
public function force_attributes() {
return array();
return [];
}
/**
@ -146,8 +146,8 @@ class Signup_Field_Hidden extends Base_Signup_Field {
*/
public function get_fields() {
return array(
'fixed_value' => array(
return [
'fixed_value' => [
'order' => 12,
'type' => 'text',
'title' => __('Pre-filled Value', 'wp-ultimo'),
@ -155,8 +155,8 @@ class Signup_Field_Hidden extends Base_Signup_Field {
'placeholder' => __('e.g. blue', 'wp-ultimo'),
'tooltip' => '',
'value' => '',
),
);
],
];
}
/**
@ -186,13 +186,13 @@ class Signup_Field_Hidden extends Base_Signup_Field {
*/
public function to_fields_array($attributes) {
return array(
$attributes['id'] => array(
return [
$attributes['id'] => [
'type' => 'hidden',
'id' => $attributes['id'],
'wrapper_classes' => $attributes['element_classes'],
'value' => $this->get_value(),
),
);
],
];
}
}

View File

@ -109,10 +109,10 @@ class Signup_Field_Order_Bump extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'order_bump_template' => 'simple',
'display_product_description' => 0,
);
];
}
/**
@ -123,10 +123,10 @@ class Signup_Field_Order_Bump extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
// 'id',
'name',
);
];
}
/**
@ -137,9 +137,9 @@ class Signup_Field_Order_Bump extends Base_Signup_Field {
*/
public function force_attributes() {
return array(
return [
'order_bump_template' => 'simple',
);
];
}
/**
@ -163,37 +163,37 @@ class Signup_Field_Order_Bump extends Base_Signup_Field {
*/
public function get_fields() {
$editor_fields = array(
'product' => array(
$editor_fields = [
'product' => [
'type' => 'model',
'title' => __('Product', 'wp-ultimo'),
'placeholder' => __('e.g. Premium', 'wp-ultimo'),
'desc' => __('Select the product that will be presented to the customer as an add-on option.', 'wp-ultimo'),
'tooltip' => '',
'order' => 12,
'html_attr' => array(
'html_attr' => [
'data-model' => 'product',
'data-value-field' => 'id',
'data-label-field' => 'name',
'data-search-field' => 'name',
'data-max-items' => 1,
),
),
'display_product_description' => array(
],
],
'display_product_description' => [
'order' => 13,
'type' => 'toggle',
'title' => __('Display Product Description', 'wp-ultimo'),
'desc' => __('Toggle to display the product description as well, if one is available.', 'wp-ultimo'),
'value' => 0,
),
'display_product_image' => array(
],
'display_product_image' => [
'order' => 14,
'type' => 'toggle',
'title' => __('Display Product Image', 'wp-ultimo'),
'desc' => __('Toggle to display the product image as well, if one is available.', 'wp-ultimo'),
'value' => 1,
),
);
],
];
// $editor_fields['order_bump_template'] = array(
// 'type' => 'group',
@ -240,7 +240,7 @@ class Signup_Field_Order_Bump extends Base_Signup_Field {
$product = is_numeric($product_id) ? wu_get_product($product_id) : wu_get_product_by_slug($product_id);
if ( ! $product) {
return array();
return [];
}
$attributes['product'] = $product;
@ -249,12 +249,12 @@ class Signup_Field_Order_Bump extends Base_Signup_Field {
$content = $template_class ? $template_class->render_container($attributes) : __('Template does not exist.', 'wp-ultimo');
return array(
$attributes['id'] => array(
return [
$attributes['id'] => [
'type' => 'note',
'desc' => $content,
'wrapper_classes' => $attributes['element_classes'],
),
);
],
];
}
}

View File

@ -104,10 +104,10 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'order_summary_template' => 'clean',
'table_columns' => 'simple',
);
];
}
/**
@ -118,9 +118,9 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
'name',
);
];
}
/**
@ -131,9 +131,9 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
*/
public function force_attributes() {
return array(
return [
'id' => 'order_summary',
);
];
}
/**
@ -157,34 +157,34 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
*/
public function get_fields() {
$editor_fields = array();
$editor_fields = [];
$editor_fields['table_columns'] = array(
$editor_fields['table_columns'] = [
'type' => 'select',
'title' => __('Table Columns', 'wp-ultimo'),
'desc' => __('"Simplified" will condense all discount and tax info into separate rows to keep the table with only two columns. "Display All" adds a discounts and taxes column to each product row.', 'wp-ultimo'),
'options' => array(
'options' => [
'simple' => __('Simplified', 'wp-ultimo'),
'full' => __('Display All', 'wp-ultimo'),
),
);
],
];
$editor_fields['order_summary_template'] = array(
$editor_fields['order_summary_template'] = [
'type' => 'group',
'desc' => Field_Templates_Manager::get_instance()->render_preview_block('order_summary'),
'fields' => array(
'order_summary_template' => array(
'fields' => [
'order_summary_template' => [
'type' => 'select',
'title' => __('Layout', 'wp-ultimo'),
'placeholder' => __('Select your Layout', 'wp-ultimo'),
'options' => array($this, 'get_templates'),
'options' => [$this, 'get_templates'],
'wrapper_classes' => 'wu-flex-grow',
'html_attr' => array(
'html_attr' => [
'v-model' => 'order_summary_template',
),
),
),
);
],
],
],
];
// @todo: re-add developer notes.
// $editor_fields['_dev_note_develop_your_own_template_order_summary'] = array(
@ -208,7 +208,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
*/
public function to_fields_array($attributes) {
$checkout_fields = array();
$checkout_fields = [];
/*
* Backwards compatibility with previous betas
@ -221,15 +221,15 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
$content = $template_class ? $template_class->render_container($attributes) : __('Template does not exist.', 'wp-ultimo');
$checkout_fields[ $attributes['id'] ] = array(
$checkout_fields[ $attributes['id'] ] = [
'type' => 'note',
'desc' => $content,
'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''),
'classes' => wu_get_isset($attributes, 'element_classes', ''),
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'style' => $this->calculate_style_attr(),
),
);
],
];
return $checkout_fields;
}

View File

@ -122,10 +122,10 @@ class Signup_Field_Password extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'password_confirm_field' => false,
'password_confirm_label' => __('Confirm Password', 'wp-ultimo'),
);
];
}
/**
@ -136,11 +136,11 @@ class Signup_Field_Password extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
'name',
'placeholder',
'tooltip',
);
];
}
/**
@ -151,10 +151,10 @@ class Signup_Field_Password extends Base_Signup_Field {
*/
public function force_attributes() {
return array(
return [
'id' => 'password',
'required' => true,
);
];
}
/**
@ -165,20 +165,20 @@ class Signup_Field_Password extends Base_Signup_Field {
*/
public function get_fields() {
return array(
'password_strength_meter' => array(
return [
'password_strength_meter' => [
'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(
],
'password_confirm_field' => [
'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,
),
);
],
];
}
/**
@ -194,12 +194,12 @@ class Signup_Field_Password extends Base_Signup_Field {
* Logged in user, bail.
*/
if (is_user_logged_in()) {
return array();
return [];
}
$checkout_fields = array();
$checkout_fields = [];
$checkout_fields['password'] = array(
$checkout_fields['password'] = [
'type' => 'password',
'id' => 'password',
'name' => $attributes['name'],
@ -209,16 +209,16 @@ class Signup_Field_Password extends Base_Signup_Field {
'required' => true,
'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''),
'classes' => wu_get_isset($attributes, 'element_classes', ''),
'html_attr' => array(
'html_attr' => [
'autocomplete' => 'new-password',
),
'wrapper_html_attr' => array(
],
'wrapper_html_attr' => [
'style' => $this->calculate_style_attr(),
),
);
],
];
if ($attributes['password_confirm_field']) {
$checkout_fields['password_conf'] = array(
$checkout_fields['password_conf'] = [
'type' => 'password',
'id' => 'password_conf',
'name' => $attributes['password_confirm_label'],
@ -228,13 +228,13 @@ class Signup_Field_Password extends Base_Signup_Field {
'required' => true,
'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''),
'classes' => wu_get_isset($attributes, 'element_classes', ''),
'html_attr' => array(
'html_attr' => [
'autocomplete' => 'new-password',
),
'wrapper_html_attr' => array(
],
'wrapper_html_attr' => [
'style' => $this->calculate_style_attr(),
),
);
],
];
}
return $checkout_fields;

View File

@ -109,9 +109,9 @@ class Signup_Field_Payment extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'',
);
];
}
/**
@ -122,9 +122,9 @@ class Signup_Field_Payment extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
'name',
);
];
}
/**
@ -135,9 +135,9 @@ class Signup_Field_Payment extends Base_Signup_Field {
*/
public function force_attributes() {
return array(
return [
'id' => 'payment',
);
];
}
/**
@ -148,7 +148,7 @@ class Signup_Field_Payment extends Base_Signup_Field {
*/
public function get_fields() {
return array();
return [];
}
/**
@ -161,24 +161,24 @@ class Signup_Field_Payment extends Base_Signup_Field {
*/
public function to_fields_array($attributes) {
$fields = array(
'payment_template' => array(
$fields = [
'payment_template' => [
'type' => 'text',
'id' => 'payment_template',
'name' => '',
'classes' => 'wu-hidden',
),
'payment' => array(
],
'payment' => [
'type' => 'payment-methods',
'id' => 'payment',
'name' => $attributes['name'],
'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''),
'classes' => wu_get_isset($attributes, 'element_classes', ''),
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'style' => $this->calculate_style_attr(),
),
),
);
],
],
];
/*
* Checks if we need to add the
@ -187,22 +187,22 @@ class Signup_Field_Payment extends Base_Signup_Field {
if ( ! wu_get_setting('force_auto_renew', 1)) {
$auto_renewable_gateways = Gateway_Manager::get_instance()->get_auto_renewable_gateways();
$fields['auto_renew'] = array(
$fields['auto_renew'] = [
'type' => 'toggle',
'id' => 'auto_renew',
'name' => __('Auto-renew', 'wp-ultimo'),
'tooltip' => '',
'value' => '1',
'html_attr' => array(
'html_attr' => [
'v-model' => 'auto_renew',
'true-value' => '1',
'false-value' => '0',
),
'wrapper_html_attr' => array(
],
'wrapper_html_attr' => [
'v-cloak' => 1,
'v-show' => sprintf('%s.includes(gateway) && order.should_collect_payment && order.has_recurring', json_encode($auto_renewable_gateways)),
),
);
],
];
}
return $fields;

View File

@ -104,9 +104,9 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'period_selection_template' => 'clean',
);
];
}
/**
@ -117,9 +117,9 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
// 'name',
);
];
}
/**
@ -130,11 +130,11 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
*/
public function force_attributes() {
return array(
return [
'id' => 'period_selection',
'name' => __('Plan Duration Switch', 'wp-ultimo'),
'required' => true,
);
];
}
/**
@ -158,119 +158,119 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
*/
public function get_fields() {
$editor_fields = array();
$editor_fields = [];
$editor_fields['period_selection_template'] = array(
$editor_fields['period_selection_template'] = [
'type' => 'group',
'order' => 98.4,
'desc' => Field_Templates_Manager::get_instance()->render_preview_block('period_selection'),
'fields' => array(
'period_selection_template' => array(
'fields' => [
'period_selection_template' => [
'type' => 'select',
'title' => __('Period Selector Template', 'wp-ultimo'),
'placeholder' => __('Select your Template', 'wp-ultimo'),
'options' => array($this, 'get_template_options'),
'options' => [$this, 'get_template_options'],
'wrapper_classes' => 'wu-flex-grow',
'html_attr' => array(
'html_attr' => [
'v-model' => 'period_selection_template',
),
),
),
);
],
],
],
];
$editor_fields['period_options_header'] = array(
$editor_fields['period_options_header'] = [
'type' => 'small-header',
'title' => __('Options', 'wp-ultimo'),
'desc' => __('Add different options below. These need to match your product price variations.', 'wp-ultimo'),
'order' => 90,
);
];
$editor_fields['period_options_empty'] = array(
$editor_fields['period_options_empty'] = [
'type' => 'note',
'desc' => __('Add the first option using the button below.', 'wp-ultimo'),
'classes' => 'wu-text-gray-600 wu-text-xs wu-text-center wu-w-full',
'wrapper_classes' => 'wu-bg-gray-100 wu-items-end',
'order' => 90.5,
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-if' => 'period_options.length === 0',
'v-cloak' => '1',
),
);
],
];
$editor_fields['period_options'] = array(
$editor_fields['period_options'] = [
'type' => 'group',
'tooltip' => '',
'order' => 91,
'wrapper_classes' => 'wu-relative wu-bg-gray-100 wu-pb-2',
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-if' => 'period_options.length',
'v-for' => '(period_option, index) in period_options',
'v-cloak' => '1',
),
'fields' => array(
'period_options_remove' => array(
],
'fields' => [
'period_options_remove' => [
'type' => 'note',
'desc' => sprintf('<a title="%s" class="wu-no-underline wu-inline-block wu-text-gray-600 wu-mt-2 wu-mr-2" href="#" @click.prevent="() => period_options.splice(index, 1)"><span class="dashicons-wu-squared-cross"></span></a>', __('Remove', 'wp-ultimo')),
'wrapper_classes' => 'wu-absolute wu-top-0 wu-right-0',
),
'period_options_duration' => array(
],
'period_options_duration' => [
'type' => 'number',
'title' => __('Duration', 'wp-ultimo'),
'placeholder' => '',
'wrapper_classes' => 'wu-w-2/12',
'min' => 1,
'html_attr' => array(
'html_attr' => [
'v-model' => 'period_option.duration',
'steps' => 1,
'v-bind:name' => '"period_options[" + index + "][duration]"',
),
),
'period_options_duration_unit' => array(
],
],
'period_options_duration_unit' => [
'type' => 'select',
'title' => '&nbsp',
'placeholder' => '',
'wrapper_classes' => 'wu-w-5/12 wu-mx-2',
'html_attr' => array(
'html_attr' => [
'v-model' => 'period_option.duration_unit',
'v-bind:name' => '"period_options[" + index + "][duration_unit]"',
),
'options' => array(
],
'options' => [
'day' => __('Days', 'wp-ultimo'),
'week' => __('Weeks', 'wp-ultimo'),
'month' => __('Months', 'wp-ultimo'),
'year' => __('Years', 'wp-ultimo'),
),
),
'period_options_label' => array(
],
],
'period_options_label' => [
'type' => 'text',
'title' => __('Label', 'wp-ultimo'),
'placeholder' => __('e.g. Monthly', 'wp-ultimo'),
'wrapper_classes' => 'wu-w-5/12',
'html_attr' => array(
'html_attr' => [
'v-model' => 'period_option.label',
'v-bind:name' => '"period_options[" + index + "][label]"',
),
),
),
);
],
],
],
];
$editor_fields['repeat'] = array(
$editor_fields['repeat'] = [
'order' => 92,
'type' => 'submit',
'title' => __('+ Add option', 'wp-ultimo'),
'classes' => 'wu-uppercase wu-text-2xs wu-text-blue-700 wu-border-none wu-bg-transparent wu-font-bold wu-text-right wu-w-full wu-cursor-pointer',
'wrapper_classes' => 'wu-bg-gray-100 wu-items-end',
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-cloak' => '1',
),
'html_attr' => array(
],
'html_attr' => [
'v-on:click.prevent' => '() => period_options.push({
duration: 1,
duration_unit: "month",
label: "",
})',
),
);
],
];
return $editor_fields;
}
@ -286,39 +286,39 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
public function to_fields_array($attributes) {
if (wu_get_isset($attributes, 'period_selection_template') === 'legacy') {
wp_register_script('wu-legacy-signup', wu_get_asset('legacy-signup.js', 'js'), array('wu-functions'), wu_get_version());
wp_register_script('wu-legacy-signup', wu_get_asset('legacy-signup.js', 'js'), ['wu-functions'], wu_get_version());
wp_enqueue_script('wu-legacy-signup');
wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), array('dashicons'), wu_get_version());
wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), ['dashicons'], wu_get_version());
}
$template_class = Field_Templates_Manager::get_instance()->get_template_class('period_selection', $attributes['period_selection_template']);
$content = $template_class ? $template_class->render_container($attributes) : __('Template does not exist.', 'wp-ultimo');
$checkout_fields = array();
$checkout_fields = [];
$checkout_fields[ $attributes['id'] ] = array(
$checkout_fields[ $attributes['id'] ] = [
'type' => 'note',
'id' => $attributes['id'],
'wrapper_classes' => $attributes['element_classes'],
'desc' => $content,
);
];
$checkout_fields['duration'] = array(
$checkout_fields['duration'] = [
'type' => 'hidden',
'html_attr' => array(
'html_attr' => [
'v-model' => 'duration',
),
);
],
];
$checkout_fields['duration_unit'] = array(
$checkout_fields['duration_unit'] = [
'type' => 'hidden',
'html_attr' => array(
'html_attr' => [
'v-model' => 'duration_unit',
),
);
],
];
return $checkout_fields;
}

View File

@ -104,12 +104,12 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'pricing_table_products' => implode(',', array_keys(wu_get_plans_as_options())),
'pricing_table_template' => 'list',
'force_different_durations' => false,
'hide_pricing_table_when_pre_selected' => false,
);
];
}
/**
@ -120,9 +120,9 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
// 'name',
);
];
}
/**
@ -133,11 +133,11 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
*/
public function force_attributes() {
return array(
return [
'id' => 'pricing_table',
'name' => __('Plan Selection', 'wp-ultimo'),
'required' => true,
);
];
}
/**
@ -161,66 +161,66 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
*/
public function get_fields() {
$editor_fields = array();
$editor_fields = [];
$editor_fields['pricing_table_products'] = array(
$editor_fields['pricing_table_products'] = [
'type' => 'model',
'title' => __('Products', 'wp-ultimo'),
'placeholder' => __('e.g. Premium', 'wp-ultimo'),
'desc' => __('Be sure to add the products in the order you want them to show up.', 'wp-ultimo'),
'tooltip' => '',
'order' => 20,
'html_attr' => array(
'html_attr' => [
'data-model' => 'product',
'data-value-field' => 'id',
'data-label-field' => 'name',
'data-search-field' => 'name',
'data-include' => implode(',', array_keys(wu_get_plans_as_options())),
'data-max-items' => 999,
),
);
],
];
$editor_fields['force_different_durations'] = array(
$editor_fields['force_different_durations'] = [
'type' => 'toggle',
'title' => __('Force Different Durations', 'wp-ultimo'),
'desc' => __('Check this option to force the display of plans with different recurring durations.', 'wp-ultimo'),
'tooltip' => '',
'value' => 0,
'order' => 22,
'html_attr' => array(
'html_attr' => [
'v-model' => 'force_different_durations',
),
);
],
];
$editor_fields['hide_pricing_table_when_pre_selected'] = array(
$editor_fields['hide_pricing_table_when_pre_selected'] = [
'type' => 'toggle',
'title' => __('Hide when Pre-Selected', 'wp-ultimo'),
'desc' => __('Prevent customers from seeing this field when a plan was already selected via the URL.', 'wp-ultimo'),
'tooltip' => __('If the pricing table field is the only field in the current step, the step will be skipped.', 'wp-ultimo'),
'value' => 0,
'order' => 24,
'html_attr' => array(
'html_attr' => [
'v-model' => 'hide_pricing_table_when_pre_selected',
),
);
],
];
$editor_fields['pricing_table_template'] = array(
$editor_fields['pricing_table_template'] = [
'type' => 'group',
'desc' => Field_Templates_Manager::get_instance()->render_preview_block('pricing_table'),
'order' => 26,
'fields' => array(
'pricing_table_template' => array(
'fields' => [
'pricing_table_template' => [
'type' => 'select',
'title' => __('Pricing Table Template', 'wp-ultimo'),
'placeholder' => __('Select your Template', 'wp-ultimo'),
'options' => array($this, 'get_pricing_table_templates'),
'options' => [$this, 'get_pricing_table_templates'],
'wrapper_classes' => 'wu-flex-grow',
'html_attr' => array(
'html_attr' => [
'v-model' => 'pricing_table_template',
),
),
),
);
],
],
],
];
// @todo: re-add developer notes.
// $editor_fields['_dev_note_develop_your_own_template_2'] = array(
@ -245,7 +245,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
public function to_fields_array($attributes) {
if (wu_get_isset($attributes, 'pricing_table_template') === 'legacy') {
wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), array('dashicons'), wu_get_version());
wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), ['dashicons'], wu_get_version());
wp_add_inline_style('legacy-shortcodes', \WP_Ultimo\Checkout\Legacy_Checkout::get_instance()->get_legacy_dynamic_styles());
}
@ -263,32 +263,32 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
* Hide when pre-selected.
*/
if (wu_should_hide_form_field($attributes)) {
return array();
return [];
}
$template_attributes = array(
$template_attributes = [
'products' => $products,
'name' => $attributes['name'],
'force_different_durations' => $attributes['force_different_durations'],
'classes' => wu_get_isset($attributes, 'element_classes', ''),
);
];
$template_class = Field_Templates_Manager::get_instance()->get_template_class('pricing_table', $attributes['pricing_table_template']);
$content = $template_class ? $template_class->render_container($template_attributes) : __('Template does not exist.', 'wp-ultimo');
$checkout_fields = array();
$checkout_fields = [];
$checkout_fields[ $attributes['id'] ] = array(
$checkout_fields[ $attributes['id'] ] = [
'type' => 'note',
'id' => $attributes['id'],
'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''),
'classes' => wu_get_isset($attributes, 'element_classes', ''),
'desc' => $content,
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'style' => $this->calculate_style_attr(),
),
);
],
];
return $checkout_fields;
}

View File

@ -103,9 +103,9 @@ class Signup_Field_Products extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'',
);
];
}
/**
@ -116,7 +116,7 @@ class Signup_Field_Products extends Base_Signup_Field {
*/
public function default_fields() {
return array();
return [];
}
/**
@ -127,10 +127,10 @@ class Signup_Field_Products extends Base_Signup_Field {
*/
public function force_attributes() {
return array(
return [
'name' => __('Pre-selected Products', 'wp-ultimo'),
'id' => 'products',
);
];
}
/**
@ -141,22 +141,22 @@ class Signup_Field_Products extends Base_Signup_Field {
*/
public function get_fields() {
return array(
'products' => array(
return [
'products' => [
'type' => 'model',
'title' => __('Products', 'wp-ultimo'),
'placeholder' => __('Products', 'wp-ultimo'),
'desc' => __('Use this field to pre-select products. This is useful when you have a signup page for specific offering/bundles and do not want your customers to be able to choose plans and other products manually.', 'wp-ultimo'),
'tooltip' => '',
'html_attr' => array(
'html_attr' => [
'data-model' => 'product',
'data-value-field' => 'id',
'data-label-field' => 'name',
'data-search-field' => 'name',
'data-max-items' => 10,
),
),
);
],
],
];
}
/**
@ -169,18 +169,18 @@ class Signup_Field_Products extends Base_Signup_Field {
*/
public function to_fields_array($attributes) {
$checkout_fields = array();
$checkout_fields = [];
$products = explode(',', (string) $attributes['products']);
foreach ($products as $product_id) {
$checkout_fields[ "products[{$product_id}]" ] = array(
$checkout_fields[ "products[{$product_id}]" ] = [
'type' => 'hidden',
'value' => $product_id,
'html_attr' => array(
'html_attr' => [
'v-bind:name' => "'products[]'",
),
);
],
];
}
$this->insert_products_in_form($products);

View File

@ -108,9 +108,9 @@ class Signup_Field_Select extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'',
);
];
}
/**
@ -121,7 +121,7 @@ class Signup_Field_Select extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
'id',
'name',
'placeholder',
@ -129,7 +129,7 @@ class Signup_Field_Select extends Base_Signup_Field {
'tooltip',
'required',
'save_as',
);
];
}
/**
@ -140,7 +140,7 @@ class Signup_Field_Select extends Base_Signup_Field {
*/
public function force_attributes() {
return array();
return [];
}
/**
@ -151,81 +151,81 @@ class Signup_Field_Select extends Base_Signup_Field {
*/
public function get_fields() {
$editor_fields = array();
$editor_fields = [];
$editor_fields['options_header'] = array(
$editor_fields['options_header'] = [
'order' => 12,
'type' => 'small-header',
'title' => __('Options', 'wp-ultimo'),
'desc' => __('Add different options below. The first option is used as the default.', 'wp-ultimo'),
);
];
$editor_fields['options_empty'] = array(
$editor_fields['options_empty'] = [
'type' => 'note',
'desc' => __('Add the first option using the button below.', 'wp-ultimo'),
'classes' => 'wu-text-gray-600 wu-text-xs wu-text-center wu-w-full',
'wrapper_classes' => 'wu-bg-gray-100 wu-items-end',
'order' => 13,
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-if' => 'options.length === 0',
'v-cloak' => '1',
),
);
],
];
$editor_fields['options'] = array(
$editor_fields['options'] = [
'order' => 14,
'type' => 'group',
'tooltip' => '',
'wrapper_classes' => 'wu-relative wu-bg-gray-100',
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-if' => 'options.length',
'v-for' => '(option, index) in options',
'v-cloak' => '1',
),
'fields' => array(
'options_remove' => array(
],
'fields' => [
'options_remove' => [
'type' => 'note',
'desc' => sprintf('<a title="%s" class="wu-no-underline wu-inline-block wu-text-gray-600 wu-mt-2 wu-mr-2" href="#" @click.prevent="() => options.splice(index, 1)"><span class="dashicons-wu-squared-cross"></span></a>', __('Remove', 'wp-ultimo')),
'wrapper_classes' => 'wu-absolute wu-top-0 wu-right-0',
),
'options_key' => array(
],
'options_key' => [
'type' => 'text',
'title' => __('Option Value', 'wp-ultimo'),
'placeholder' => __('e.g. option1', 'wp-ultimo'),
'wrapper_classes' => 'wu-w-1/2 wu-mr-2',
'html_attr' => array(
'html_attr' => [
'v-model' => 'option.key',
'steps' => 1,
'v-bind:name' => '"options[" + index + "][key]"',
),
),
'options_label' => array(
],
],
'options_label' => [
'type' => 'text',
'title' => __('Label', 'wp-ultimo'),
'placeholder' => __('e.g. Option 1', 'wp-ultimo'),
'wrapper_classes' => 'wu-w-1/2 wu-ml-2',
'html_attr' => array(
'html_attr' => [
'v-model' => 'option.label',
'v-bind:name' => '"options[" + index + "][label]"',
),
),
),
);
],
],
],
];
$editor_fields['repeat_select_option'] = array(
$editor_fields['repeat_select_option'] = [
'order' => 16,
'type' => 'submit',
'title' => __('+ Add option', 'wp-ultimo'),
'classes' => 'wu-uppercase wu-text-2xs wu-text-blue-700 wu-border-none wu-bg-transparent wu-font-bold wu-text-right wu-w-full wu-cursor-pointer',
'wrapper_classes' => 'wu-bg-gray-100 wu-items-end',
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-cloak' => '1',
),
'html_attr' => array(
],
'html_attr' => [
'type' => 'button',
'v-on:click.prevent' => '() => options.push({})',
),
);
],
];
return $editor_fields;
}
@ -240,14 +240,14 @@ class Signup_Field_Select extends Base_Signup_Field {
*/
public function to_fields_array($attributes) {
$options = array();
$options = [];
foreach ($attributes['options'] as $_option) {
$options[ $_option['key'] ] = $_option['label'];
}
return array(
$attributes['id'] => array(
return [
$attributes['id'] => [
'type' => 'select',
'id' => $attributes['id'],
'name' => $attributes['name'],
@ -258,7 +258,7 @@ class Signup_Field_Select extends Base_Signup_Field {
'wrapper_classes' => $attributes['element_classes'],
'options' => $options,
'value' => $this->get_value(),
),
);
],
];
}
}

View File

@ -103,9 +103,9 @@ class Signup_Field_Shortcode extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'',
);
];
}
/**
@ -116,10 +116,10 @@ class Signup_Field_Shortcode extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
// 'id',
// 'name',
);
];
}
/**
@ -130,9 +130,9 @@ class Signup_Field_Shortcode extends Base_Signup_Field {
*/
public function force_attributes() {
return array(
return [
'name' => __('Shortcode', 'wp-ultimo'),
);
];
}
/**
@ -143,14 +143,14 @@ class Signup_Field_Shortcode extends Base_Signup_Field {
*/
public function get_fields() {
return array(
'shortcode_code' => array(
return [
'shortcode_code' => [
'type' => 'text',
'title' => __('Shortcode', 'wp-ultimo'),
'placeholder' => __('e.g. [shortcode]', 'wp-ultimo'),
'desc' => __('Please, enter the full shortcode, including [].', 'wp-ultimo'),
),
);
],
];
}
/**
@ -163,16 +163,16 @@ class Signup_Field_Shortcode extends Base_Signup_Field {
*/
public function to_fields_array($attributes) {
return array(
$attributes['id'] => array(
return [
$attributes['id'] => [
'type' => 'note',
'desc' => fn() => do_shortcode($attributes['shortcode_code']),
'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''),
'classes' => wu_get_isset($attributes, 'element_classes', ''),
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'style' => $this->calculate_style_attr(),
),
),
);
],
],
];
}
}

View File

@ -119,9 +119,9 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'auto_generate_site_title' => false,
);
];
}
/**
@ -132,11 +132,11 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
'name',
'placeholder',
'tooltip',
);
];
}
/**
@ -147,10 +147,10 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
*/
public function force_attributes() {
return array(
return [
'id' => 'site_title',
'required' => true,
);
];
}
/**
@ -161,18 +161,18 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
*/
public function get_fields() {
return array(
'auto_generate_site_title' => array(
return [
'auto_generate_site_title' => [
'type' => 'toggle',
'title' => __('Auto-generate?', 'wp-ultimo'),
'desc' => __('Check this option to auto-generate this field based on the username of the customer.', 'wp-ultimo'),
'tooltip' => '',
'value' => 0,
'html_attr' => array(
'html_attr' => [
'v-model' => 'auto_generate_site_title',
),
),
);
],
],
];
}
/**
@ -188,24 +188,24 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
* If we should auto-generate, add as hidden.
*/
if (isset($attributes['auto_generate_site_title']) && $attributes['auto_generate_site_title']) {
return array(
'auto_generate_site_title' => array(
return [
'auto_generate_site_title' => [
'type' => 'hidden',
'id' => 'auto_generate_site_title',
'value' => 'username',
),
'site_title' => array(
],
'site_title' => [
'type' => 'hidden',
'id' => 'site_title',
'html_attr' => array(
'html_attr' => [
'v-bind:value' => 'username',
),
),
);
],
],
];
}
return array(
'site_title' => array(
return [
'site_title' => [
'type' => 'text',
'id' => 'site_title',
'required' => true,
@ -215,10 +215,10 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''),
'classes' => wu_get_isset($attributes, 'element_classes', ''),
'value' => $this->get_value(),
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'style' => $this->calculate_style_attr(),
),
),
);
],
],
];
}
}

View File

@ -114,13 +114,13 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
global $current_site;
return array(
return [
'auto_generate_site_url' => false,
'display_url_preview' => true,
'enable_domain_selection' => false,
'display_field_attachments' => true,
'available_domains' => $current_site->domain . PHP_EOL,
);
];
}
/**
@ -131,11 +131,11 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
'name',
'placeholder',
'tooltip',
);
];
}
/**
@ -146,10 +146,10 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
*/
public function force_attributes() {
return array(
return [
'id' => 'site_url',
'required' => true,
);
];
}
/**
@ -162,19 +162,19 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
global $current_site;
return array(
'auto_generate_site_url' => array(
return [
'auto_generate_site_url' => [
'order' => 12,
'type' => 'toggle',
'title' => __('Auto-generate', 'wp-ultimo'),
'desc' => __('Check this option to auto-generate this field based on the username of the customer.', 'wp-ultimo'),
'tooltip' => '',
'value' => 0,
'html_attr' => array(
'html_attr' => [
'v-model' => 'auto_generate_site_url',
),
),
'display_field_attachments' => array(
],
],
'display_field_attachments' => [
'order' => 18,
'type' => 'toggle',
'title' => __('Display URL field attachments', 'wp-ultimo'),
@ -182,14 +182,14 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
'tooltip' => '',
'value' => 1,
'tab' => 'content',
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-show' => '!auto_generate_site_url',
),
'html_attr' => array(
],
'html_attr' => [
'v-model' => 'display_field_attachments',
),
),
'display_url_preview' => array(
],
],
'display_url_preview' => [
'order' => 19,
'type' => 'toggle',
'title' => __('Display URL preview block', 'wp-ultimo'),
@ -197,14 +197,14 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
'tooltip' => '',
'value' => 1,
'tab' => 'content',
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-show' => '!auto_generate_site_url',
),
'html_attr' => array(
],
'html_attr' => [
'v-model' => 'display_url_preview',
),
),
'enable_domain_selection' => array(
],
],
'enable_domain_selection' => [
'order' => 20,
'type' => 'toggle',
'title' => __('Enable Domain Selection', 'wp-ultimo'),
@ -212,15 +212,15 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
'tooltip' => '',
'value' => 0,
'tab' => 'content',
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-show' => '!auto_generate_site_url',
),
'html_attr' => array(
],
'html_attr' => [
'v-model' => 'enable_domain_selection',
'rows' => 5,
),
),
'available_domains' => array(
],
],
'available_domains' => [
'order' => 30,
'type' => 'textarea',
'title' => __('Available Domains', 'wp-ultimo'),
@ -228,14 +228,14 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
'desc' => __('Enter one domain option per line.', 'wp-ultimo'),
'value' => $current_site->domain . PHP_EOL,
'tab' => 'content',
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-show' => '!auto_generate_site_url && enable_domain_selection',
),
'html_attr' => array(
],
'html_attr' => [
'rows' => 4,
),
),
);
],
],
];
}
/**
@ -246,10 +246,10 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
*/
public function get_url_preview_templates() {
$templates = array(
$templates = [
'legacy/signup/steps/step-domain-url-preview' => __('New URL Preview', 'wp-ultimo'),
// 'legacy/signup/steps/step-domain-url-preview' => __('Legacy Template', 'wp-ultimo'),
);
];
return apply_filters('wu_get_pricing_table_templates', $templates);
}
@ -267,23 +267,23 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
* If we should auto-generate, add as hidden.
*/
if ($attributes['auto_generate_site_url']) {
return array(
'auto_generate_site_url' => array(
return [
'auto_generate_site_url' => [
'type' => 'hidden',
'id' => 'auto_generate_site_url',
'value' => 'username',
),
'site_url' => array(
],
'site_url' => [
'type' => 'hidden',
'id' => 'site_url',
'value' => uniqid(),
),
);
],
];
}
$checkout_fields = array();
$checkout_fields = [];
$checkout_fields['site_url'] = array(
$checkout_fields['site_url'] = [
'type' => 'text',
'id' => 'site_url',
'wrapper_classes' => 'wu-flex-grow wu-my-0',
@ -294,40 +294,40 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
'required' => true,
'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', 'wu-my-1'),
'classes' => wu_get_isset($attributes, 'element_classes', ''),
'html_attr' => array(
'html_attr' => [
'autocomplete' => 'off',
'v-on:input' => 'site_url = $event.target.value.toLowerCase().replace(/[^a-z0-9-]+/g, "")',
'v-bind:value' => 'site_url',
),
);
],
];
if ($attributes['display_field_attachments']) {
$checkout_fields['site_url']['classes'] .= ' xs:wu-rounded-none';
$checkout_fields['site_url']['prefix'] = ' ';
$checkout_fields['site_url']['prefix_html_attr'] = array(
$checkout_fields['site_url']['prefix_html_attr'] = [
'class' => 'wu-flex wu-items-center wu-px-3 wu-mt-1 sm:wu-mb-1 wu-border-box wu-font-mono wu-justify-center sm:wu-border-r-0',
'style' => 'background-color: rgba(0, 0, 0, 0.008); border: 1px solid #eee; margin-right: -1px; font-size: 90%;',
'v-html' => 'is_subdomain ? "https://" : "https://" + site_domain + "/"',
'v-cloak' => 1,
);
];
$checkout_fields['site_url']['suffix'] = ' ';
$checkout_fields['site_url']['suffix_html_attr'] = array(
$checkout_fields['site_url']['suffix_html_attr'] = [
'class' => 'wu-flex wu-items-center wu-px-3 sm:wu-mt-1 wu-mb-1 wu-border-box wu-font-mono wu-justify-center sm:wu-border-l-0',
'style' => 'background-color: rgba(0, 0, 0, 0.008); border: 1px solid #eee; margin-left: -1px; font-size: 90%;',
'v-html' => '"." + site_domain',
'v-cloak' => 1,
'v-show' => 'is_subdomain',
);
];
}
if ($attributes['available_domains'] && $attributes['enable_domain_selection']) {
$options = $this->get_domain_options($attributes['available_domains']);
$checkout_fields['site_domain'] = array(
$checkout_fields['site_domain'] = [
'name' => __('Domain', 'wp-ultimo'),
'options' => $options,
'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''),
@ -337,27 +337,27 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
'id' => 'site_domain',
'type' => 'select',
'classes' => 'input',
'html_attr' => array(
'html_attr' => [
'v-model' => 'site_domain',
),
'wrapper_html_attr' => array(
],
'wrapper_html_attr' => [
'style' => $this->calculate_style_attr(),
),
);
],
];
}
if ($attributes['display_url_preview']) {
$content = wu_get_template_contents('legacy/signup/steps/step-domain-url-preview');
$checkout_fields['site_url_preview'] = array(
$checkout_fields['site_url_preview'] = [
'type' => 'note',
'desc' => $content,
'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''),
'classes' => wu_get_isset($attributes, 'element_classes', ''),
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'style' => $this->calculate_style_attr(),
),
);
],
];
}
return $checkout_fields;

View File

@ -104,9 +104,9 @@ class Signup_Field_Steps extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'steps_template' => 'clean',
);
];
}
/**
@ -117,7 +117,7 @@ class Signup_Field_Steps extends Base_Signup_Field {
*/
public function default_fields() {
return array();
return [];
}
/**
@ -128,9 +128,9 @@ class Signup_Field_Steps extends Base_Signup_Field {
*/
public function force_attributes() {
return array(
return [
'id' => 'steps',
);
];
}
/**
@ -154,23 +154,23 @@ class Signup_Field_Steps extends Base_Signup_Field {
*/
public function get_fields() {
$editor_fields['steps_template'] = array(
$editor_fields['steps_template'] = [
'type' => 'group',
'desc' => Field_Templates_Manager::get_instance()->render_preview_block('steps'),
'order' => 98,
'fields' => array(
'steps_template' => array(
'fields' => [
'steps_template' => [
'type' => 'select',
'title' => __('Layout', 'wp-ultimo'),
'placeholder' => __('Select your Layout', 'wp-ultimo'),
'options' => array($this, 'get_templates'),
'options' => [$this, 'get_templates'],
'wrapper_classes' => 'wu-flex-grow',
'html_attr' => array(
'html_attr' => [
'v-model' => 'steps_template',
),
),
),
);
],
],
],
];
// @todo: re-add developer notes.
// $editor_fields['_dev_note_develop_your_own_template_steps'] = array(
@ -195,7 +195,7 @@ class Signup_Field_Steps extends Base_Signup_Field {
public function to_fields_array($attributes) {
if (wu_get_isset($attributes, 'steps_template') === 'legacy') {
wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), array('dashicons'), wu_get_version());
wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), ['dashicons'], wu_get_version());
wp_add_inline_style('legacy-shortcodes', \WP_Ultimo\Checkout\Legacy_Checkout::get_instance()->get_legacy_dynamic_styles());
}
@ -207,12 +207,12 @@ class Signup_Field_Steps extends Base_Signup_Field {
$content = $template_class ? $template_class->render_container($attributes) : __('Template does not exist.', 'wp-ultimo');
return array(
$attributes['id'] => array(
return [
$attributes['id'] => [
'type' => 'note',
'desc' => $content,
'wrapper_classes' => $attributes['element_classes'],
),
);
],
];
}
}

View File

@ -108,10 +108,10 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'enable_go_back_button' => false,
'back_button_label' => __('&larr; Go Back', 'wp-ultimo'),
);
];
}
/**
@ -122,10 +122,10 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
'id',
'name',
);
];
}
/**
@ -136,7 +136,7 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
*/
public function force_attributes() {
return array();
return [];
}
/**
@ -147,29 +147,29 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
*/
public function get_fields() {
return array(
'enable_go_back_button' => array(
return [
'enable_go_back_button' => [
'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(
'html_attr' => [
'v-model' => 'enable_go_back_button',
),
),
'back_button_label' => array(
],
],
'back_button_label' => [
'type' => 'text',
'title' => __('"Go Back" Button Label', 'wp-ultimo'),
'desc' => __('Value to be used as the "Go Back" label.', 'wp-ultimo'),
'placeholder' => __('e.g. &larr; Go Back', 'wp-ultimo'),
'value' => __('&larr; Go Back', 'wp-ultimo'),
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-cloak' => '1',
'v-show' => 'enable_go_back_button',
),
),
);
],
],
];
}
/**
@ -184,24 +184,24 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
$uniqid = uniqid();
$fields = array();
$fields = [];
$fields[ $attributes['id'] . '_errors' ] = array(
$fields[ $attributes['id'] . '_errors' ] = [
'type' => 'html',
'wrapper_classes' => 'wu_submit_button_errors wu-clear-both',
'content' => '<span v-cloak class="wu-block wu-bg-red-100 wu-p-2 wu-mb-4" v-html="get_errors().join(' . esc_js(json_encode('<br>')) . ')"></span>',
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-if' => 'get_errors()',
),
);
],
];
$fields[ $attributes['id'] . '_group' ] = array(
$fields[ $attributes['id'] . '_group' ] = [
'type' => 'group',
'raw' => true,
'default' => array(),
'default' => [],
'wrapper_classes' => '',
'fields' => array(),
);
'fields' => [],
];
$button_wrapper_classes = 'wu_submit_button';
@ -211,29 +211,29 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
$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(
$fields[ $attributes['id'] . '_group' ]['fields'][ $attributes['id'] . '_go_back' ] = [
'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('<a href="#" class="button wu-go-back" v-on:click.prevent="go_back()">%s</a>', $attributes['back_button_label']),
);
];
$button_wrapper_classes .= ' md:wu-w-1/2 wu-box-border wu-float-left wu-text-right';
}
}
$fields[ $attributes['id'] . '_group' ]['fields'][ $attributes['id'] ] = array(
$fields[ $attributes['id'] . '_group' ]['fields'][ $attributes['id'] ] = [
'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(
$fields[ $attributes['id'] . '_clear' ] = [
'type' => 'clear',
);
];
}
return $fields;

View File

@ -105,13 +105,13 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
*/
public function defaults() {
return array(
'template_selection_sites' => implode(',', wu_get_site_templates(array('fields' => 'ids'))),
return [
'template_selection_sites' => implode(',', wu_get_site_templates(['fields' => 'ids'])),
'template_selection_type' => 'name',
'template_selection_template' => 'clean',
'cols' => 3,
'hide_template_selection_when_pre_selected' => false,
);
];
}
/**
@ -122,9 +122,9 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
// 'name',
);
];
}
/**
@ -135,11 +135,11 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
*/
public function force_attributes() {
return array(
return [
'id' => 'template_selection',
'name' => __('Template Selection', 'wp-ultimo'),
'required' => true,
);
];
}
/**
@ -163,50 +163,50 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
*/
public function get_fields() {
$editor_fields = array();
$editor_fields = [];
$editor_fields['cols'] = array(
$editor_fields['cols'] = [
'type' => 'hidden',
);
];
$editor_fields['template_selection_type'] = array(
$editor_fields['template_selection_type'] = [
'type' => 'select',
'title' => __('Available templates', 'wp-ultimo'),
'desc' => __('How do you want to choose available which templates will be available.', 'wp-ultimo'),
'order' => 20,
'options' => array(
'options' => [
'name' => __('Select by names'),
'categories' => __('Select by categories'),
'all' => __('All templates'),
),
'html_attr' => array(
],
'html_attr' => [
'v-model' => 'template_selection_type',
),
);
],
];
$editor_fields['template_selection_categories'] = array(
$editor_fields['template_selection_categories'] = [
'type' => 'select',
'title' => __('Template Categories', 'wp-ultimo'),
'placeholder' => __('e.g.: Landing Page, Health...', 'wp-ultimo'),
'desc' => __('Customers will be able to filter by categories during signup.', 'wp-ultimo'),
'order' => 21,
'options' => Site::get_all_categories(),
'html_attr' => array(
'html_attr' => [
'data-selectize-categories' => 1,
'multiple' => 1,
),
'wrapper_html_attr' => array(
],
'wrapper_html_attr' => [
'v-show' => 'template_selection_type === "categories"',
),
);
],
];
$editor_fields['template_selection_sites'] = array(
$editor_fields['template_selection_sites'] = [
'type' => 'model',
'title' => __('Template Sites', 'wp-ultimo'),
'placeholder' => __('e.g. Template Site 1, My Agency', 'wp-ultimo'),
'desc' => __('Be sure to add the templates in the order you want them to show up.', 'wp-ultimo'),
'order' => 22,
'html_attr' => array(
'html_attr' => [
'v-model' => 'template_selection_sites',
'data-model' => 'site',
'data-value-field' => 'blog_id',
@ -216,46 +216,46 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
'data-include' => implode(
',',
wu_get_site_templates(
array(
[
'fields' => 'blog_id',
)
]
)
),
),
'wrapper_html_attr' => array(
],
'wrapper_html_attr' => [
'v-show' => 'template_selection_type === \'name\'',
),
);
],
];
$editor_fields['hide_template_selection_when_pre_selected'] = array(
$editor_fields['hide_template_selection_when_pre_selected'] = [
'type' => 'toggle',
'title' => __('Hide when Pre-Selected', 'wp-ultimo'),
'desc' => __('Prevent customers from seeing this field when a template was already selected via the URL.', 'wp-ultimo'),
'tooltip' => __('If the template selection field is the only field in the current step, the step will be skipped.', 'wp-ultimo'),
'value' => 0,
'order' => 23,
'html_attr' => array(
'html_attr' => [
'v-model' => 'hide_template_selection_when_pre_selected',
),
);
],
];
$editor_fields['template_selection_template'] = array(
$editor_fields['template_selection_template'] = [
'type' => 'group',
'order' => 24,
'desc' => Field_Templates_Manager::get_instance()->render_preview_block('template_selection'),
'fields' => array(
'template_selection_template' => array(
'fields' => [
'template_selection_template' => [
'type' => 'select',
'title' => __('Template Selector Template', 'wp-ultimo'),
'placeholder' => __('Select your Template', 'wp-ultimo'),
'options' => array($this, 'get_template_selection_templates'),
'options' => [$this, 'get_template_selection_templates'],
'wrapper_classes' => 'wu-flex-grow',
'html_attr' => array(
'html_attr' => [
'v-model' => 'template_selection_template',
),
),
),
);
],
],
],
];
// @todo: re-add developer notes.
// $editor_fields['_dev_note_develop_your_own_template_1'] = array(
@ -296,14 +296,14 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
*/
public function to_fields_array($attributes) {
$checkout_fields = array();
$checkout_fields = [];
$checkout_fields['template_id'] = array(
$checkout_fields['template_id'] = [
'type' => 'hidden',
'html_attr' => array(
'html_attr' => [
'v-model' => 'template_id',
),
);
],
];
/**
* Hide when pre-selected.
@ -313,22 +313,22 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
}
if (wu_get_isset($attributes, 'template_selection_template') === 'legacy') {
wp_register_script('wu-legacy-signup', wu_get_asset('legacy-signup.js', 'js'), array('wu-functions'), wu_get_version());
wp_register_script('wu-legacy-signup', wu_get_asset('legacy-signup.js', 'js'), ['wu-functions'], wu_get_version());
wp_enqueue_script('wu-legacy-signup');
wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), array('dashicons'), wu_get_version());
wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), ['dashicons'], wu_get_version());
}
$site_list = $this->site_list($attributes);
$customer_sites = array();
$customer_sites = [];
if (wu_get_setting('allow_own_site_as_template')) {
$customer = wu_get_current_customer();
if ($customer) {
$customer_sites = $customer->get_sites(array('fields' => 'ids'));
$customer_sites = $customer->get_sites(['fields' => 'ids']);
$site_list = array_merge(
$customer_sites,
@ -344,23 +344,23 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
// Remove inactive sites
$sites = array_filter($sites, fn($site) => $site->is_active());
$template_attributes = array(
$template_attributes = [
'sites' => $sites,
'name' => $attributes['name'],
'cols' => $attributes['cols'],
'categories' => $attributes['template_selection_categories'] ?? \WP_Ultimo\Models\Site::get_all_categories($sites),
'customer_sites' => $customer_sites,
);
];
$template_class = Field_Templates_Manager::get_instance()->get_template_class('template_selection', $attributes['template_selection_template']);
$content = $template_class ? $template_class->render_container($template_attributes, $this) : __('Template does not exist.', 'wp-ultimo');
$checkout_fields[ $attributes['id'] ] = array(
$checkout_fields[ $attributes['id'] ] = [
'type' => 'note',
'desc' => $content,
'wrapper_classes' => $attributes['element_classes'],
);
];
return $checkout_fields;
}
@ -380,16 +380,16 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
}
if ($selection_type === 'all') {
return wu_get_site_templates(array('fields' => 'blog_id'));
return wu_get_site_templates(['fields' => 'blog_id']);
}
if ($selection_type === 'categories') {
return array_column(
\WP_Ultimo\Models\Site::get_all_by_categories(
$attributes['template_selection_categories'],
array(
'fields' => array('blog_id'),
),
[
'fields' => ['blog_id'],
],
),
'blog_id'
);

View File

@ -122,9 +122,9 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'tou_name' => __('I agree with the terms of use.', 'wp-ultimo'),
);
];
}
/**
@ -135,7 +135,7 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field {
*/
public function default_fields() {
return array();
return [];
}
/**
@ -146,10 +146,10 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field {
*/
public function force_attributes() {
return array(
return [
'id' => 'terms_of_use',
'name' => __('Terms of Use', 'wp-ultimo'),
);
];
}
/**
@ -160,21 +160,21 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field {
*/
public function get_fields() {
return array(
'tou_name' => array(
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' => array(
],
'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'),
),
);
],
];
}
/**
@ -187,18 +187,18 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field {
*/
public function to_fields_array($attributes) {
$checkout_fields = array();
$checkout_fields = [];
$tou_link = sprintf('<a href="%s" target="_blank">%s</a>', $attributes['tou_url'], __('Read here', 'wp-ultimo'));
$checkout_fields['terms_of_use'] = array(
$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;
}

View File

@ -108,9 +108,9 @@ class Signup_Field_Text extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'',
);
];
}
/**
@ -121,7 +121,7 @@ class Signup_Field_Text extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
'id',
'name',
'placeholder',
@ -129,7 +129,7 @@ class Signup_Field_Text extends Base_Signup_Field {
'tooltip',
'required',
'save_as',
);
];
}
/**
@ -140,7 +140,7 @@ class Signup_Field_Text extends Base_Signup_Field {
*/
public function force_attributes() {
return array();
return [];
}
/**
@ -151,7 +151,7 @@ class Signup_Field_Text extends Base_Signup_Field {
*/
public function get_fields() {
return array();
return [];
}
/**
@ -164,8 +164,8 @@ class Signup_Field_Text extends Base_Signup_Field {
*/
public function to_fields_array($attributes) {
$fields = array(
$attributes['id'] => array(
$fields = [
$attributes['id'] => [
'type' => 'text',
'id' => $attributes['id'],
'name' => $attributes['name'],
@ -174,8 +174,8 @@ class Signup_Field_Text extends Base_Signup_Field {
'required' => $attributes['required'],
'wrapper_classes' => $attributes['element_classes'],
'value' => $this->get_value(),
),
);
],
];
return $fields;
}

View File

@ -122,9 +122,9 @@ class Signup_Field_Username extends Base_Signup_Field {
*/
public function defaults() {
return array(
return [
'auto_generate_username' => false,
);
];
}
/**
@ -135,11 +135,11 @@ class Signup_Field_Username extends Base_Signup_Field {
*/
public function default_fields() {
return array(
return [
'name',
'placeholder',
'tooltip',
);
];
}
/**
@ -150,10 +150,10 @@ class Signup_Field_Username extends Base_Signup_Field {
*/
public function force_attributes() {
return array(
return [
'id' => 'username',
'required' => true,
);
];
}
/**
@ -164,18 +164,18 @@ class Signup_Field_Username extends Base_Signup_Field {
*/
public function get_fields() {
return array(
'auto_generate_username' => array(
return [
'auto_generate_username' => [
'type' => 'toggle',
'title' => __('Auto-generate', 'wp-ultimo'),
'desc' => __('Check this option to auto-generate this field based on the email address of the customer.', 'wp-ultimo'),
'tooltip' => '',
'value' => 0,
'html_attr' => array(
'html_attr' => [
'v-model' => 'auto_generate_username',
),
),
);
],
],
];
}
/**
@ -191,26 +191,26 @@ class Signup_Field_Username extends Base_Signup_Field {
* Logged in user, bail.
*/
if (is_user_logged_in()) {
return array();
return [];
}
if (isset($attributes['auto_generate_username']) && $attributes['auto_generate_username']) {
return array(
'auto_generate_username' => array(
return [
'auto_generate_username' => [
'type' => 'hidden',
'id' => 'auto_generate_username',
'value' => 'email',
),
'username' => array(
],
'username' => [
'type' => 'hidden',
'id' => 'username',
'value' => uniqid(),
),
);
],
];
}
return array(
'username' => array(
return [
'username' => [
'type' => 'text',
'id' => 'username',
'name' => $attributes['name'],
@ -220,15 +220,15 @@ class Signup_Field_Username extends Base_Signup_Field {
'classes' => wu_get_isset($attributes, 'element_classes', ''),
'required' => true,
'value' => $this->get_value(),
'html_attr' => array(
'html_attr' => [
'v-model' => 'username',
'v-init:username' => "'{$this->get_value()}'",
'autocomplete' => 'username',
),
'wrapper_html_attr' => array(
],
'wrapper_html_attr' => [
'style' => $this->calculate_style_attr(),
),
),
);
],
],
];
}
}

View File

@ -32,7 +32,7 @@ class Base_Field_Template {
/**
* @var array
*/
protected $attributes = array();
protected $attributes = [];
/**
* Field Template Constructor
@ -41,7 +41,7 @@ class Base_Field_Template {
*
* @param array $attributes The attributes passed to the field.
*/
public function __construct($attributes = array()) {
public function __construct($attributes = []) {
$this->attributes = $attributes;
}

View File

@ -88,7 +88,7 @@ class Simple_Order_Bump_Field_Template extends Base_Field_Template {
*/
public function get_preview(): string {
return wu_get_asset('checkout-forms/clean-template-selection.png');
return wu_get_asset('checkout-forms/clean-template-selection.webp');
}
/**
@ -99,7 +99,7 @@ class Simple_Order_Bump_Field_Template extends Base_Field_Template {
* @param array $attributes The field template attributes.
* @return void
*/
public function output($attributes) {
public function output($attributes): void {
/**
* Loads the actual order-bump template

View File

@ -88,7 +88,7 @@ class Clean_Order_Summary_Field_Template extends Base_Field_Template {
*/
public function get_preview(): string {
return wu_get_asset('checkout-forms/clean-order-summary.png');
return wu_get_asset('checkout-forms/clean-order-summary.webp');
}
/**
@ -99,7 +99,7 @@ class Clean_Order_Summary_Field_Template extends Base_Field_Template {
* @param array $attributes The field template attributes.
* @return void
*/
public function output($attributes) {
public function output($attributes): void {
/**
* Loads the actual order-summary template

View File

@ -90,7 +90,7 @@ class Clean_Period_Selection_Field_Template extends Base_Field_Template {
*/
public function get_preview(): string {
return wu_get_asset('checkout-forms/clean-period-selection.png');
return wu_get_asset('checkout-forms/clean-period-selection.webp');
}
/**
@ -101,7 +101,7 @@ class Clean_Period_Selection_Field_Template extends Base_Field_Template {
* @param array $attributes The field template attributes.
* @return void
*/
public function output($attributes) {
public function output($attributes): void {
wu_get_template('checkout/templates/period-selection/clean', $attributes);
}

View File

@ -90,7 +90,7 @@ class Legacy_Period_Selection_Field_Template extends Base_Field_Template {
*/
public function get_preview(): string {
return wu_get_asset('checkout-forms/legacy-period-selection.png');
return wu_get_asset('checkout-forms/legacy-period-selection.webp');
}
/**
@ -101,7 +101,7 @@ class Legacy_Period_Selection_Field_Template extends Base_Field_Template {
* @param array $attributes The field template attributes.
* @return void
*/
public function output($attributes) {
public function output($attributes): void {
wu_get_template('checkout/templates/period-selection/legacy', $attributes);
}

View File

@ -90,7 +90,7 @@ class Legacy_Pricing_Table_Field_Template extends Base_Field_Template {
*/
public function get_preview(): string {
return wu_get_asset('checkout-forms/legacy-pricing-table.png');
return wu_get_asset('checkout-forms/legacy-pricing-table.webp');
}
/**
@ -101,7 +101,7 @@ class Legacy_Pricing_Table_Field_Template extends Base_Field_Template {
* @param array $attributes The field template attributes.
* @return void
*/
public function output($attributes) {
public function output($attributes): void {
wu_get_template('checkout/templates/pricing-table/legacy', $attributes);
}

View File

@ -68,7 +68,7 @@ class List_Pricing_Table_Field_Template extends Base_Field_Template {
*/
public function get_preview(): string {
return wu_get_asset('checkout-forms/list-pricing-table.png');
return wu_get_asset('checkout-forms/list-pricing-table.webp');
}
/**
@ -79,7 +79,7 @@ class List_Pricing_Table_Field_Template extends Base_Field_Template {
* @param array $attributes The field template attributes.
* @return void
*/
public function output($attributes) {
public function output($attributes): void {
wu_get_template('checkout/templates/pricing-table/list', $attributes);
}

View File

@ -88,7 +88,7 @@ class Clean_Steps_Field_Template extends Base_Field_Template {
*/
public function get_preview(): string {
return wu_get_asset('checkout-forms/clean-steps.png');
return wu_get_asset('checkout-forms/clean-steps.webp');
}
/**
@ -99,7 +99,7 @@ class Clean_Steps_Field_Template extends Base_Field_Template {
* @param array $attributes The field template attributes.
* @return void
*/
public function output($attributes) {
public function output($attributes): void {
wu_get_template('checkout/templates/steps/clean', $attributes);
}

View File

@ -88,7 +88,7 @@ class Legacy_Steps_Field_Template extends Base_Field_Template {
*/
public function get_preview(): string {
return wu_get_asset('checkout-forms/legacy-steps.png');
return wu_get_asset('checkout-forms/legacy-steps.webp');
}
/**
@ -99,7 +99,7 @@ class Legacy_Steps_Field_Template extends Base_Field_Template {
* @param array $attributes The field template attributes.
* @return void
*/
public function output($attributes) {
public function output($attributes): void {
wu_get_template('checkout/templates/steps/legacy', $attributes);
}

View File

@ -88,7 +88,7 @@ class Minimal_Steps_Field_Template extends Base_Field_Template {
*/
public function get_preview(): string {
return wu_get_asset('checkout-forms/minimal-steps.png');
return wu_get_asset('checkout-forms/minimal-steps.webp');
}
/**
@ -99,7 +99,7 @@ class Minimal_Steps_Field_Template extends Base_Field_Template {
* @param array $attributes The field template attributes.
* @return void
*/
public function output($attributes) {
public function output($attributes): void {
wu_get_template('checkout/templates/steps/minimal', $attributes);
}

View File

@ -88,7 +88,7 @@ class Clean_Template_Selection_Field_Template extends Base_Field_Template {
*/
public function get_preview(): string {
return wu_get_asset('checkout-forms/clean-template-selection.png');
return wu_get_asset('checkout-forms/clean-template-selection.webp');
}
/**
@ -99,7 +99,7 @@ class Clean_Template_Selection_Field_Template extends Base_Field_Template {
* @param array $attributes The field template attributes.
* @return void
*/
public function output($attributes) {
public function output($attributes): void {
wu_get_template('checkout/templates/template-selection/clean', $attributes);
}

View File

@ -79,7 +79,7 @@ class Legacy_Template_Selection_Field_Template extends Base_Field_Template {
*/
public function get_preview(): string {
return wu_get_asset('checkout-forms/legacy-template-selection.png');
return wu_get_asset('checkout-forms/legacy-template-selection.webp');
}
/**
@ -90,7 +90,7 @@ class Legacy_Template_Selection_Field_Template extends Base_Field_Template {
* @param array $attributes The field template attributes.
* @return void
*/
public function output($attributes) {
public function output($attributes): void {
wu_get_template('checkout/templates/template-selection/legacy', $attributes);
}

View File

@ -77,7 +77,7 @@ class Minimal_Template_Selection_Field_Template extends Base_Field_Template {
*/
public function get_preview(): string {
return wu_get_asset('checkout-forms/minimal-template-selection.png');
return wu_get_asset('checkout-forms/minimal-template-selection.webp');
}
/**
@ -88,7 +88,7 @@ class Minimal_Template_Selection_Field_Template extends Base_Field_Template {
* @param array $attributes The field template attributes.
* @return void
*/
public function output($attributes) {
public function output($attributes): void {
wu_get_template('checkout/templates/template-selection/minimal', $attributes);
}