Use PHP 7.4 featers and PHP 8 polyfills
This commit is contained in:
@ -179,7 +179,7 @@ class Cart implements \JsonSerializable {
|
||||
* @since 2.0.0
|
||||
* @var \WP_Ultimo\Models\Product[]
|
||||
*/
|
||||
protected $products = array();
|
||||
protected $products = [];
|
||||
|
||||
/**
|
||||
* The cart recurring products.
|
||||
@ -187,7 +187,7 @@ class Cart implements \JsonSerializable {
|
||||
* @since 2.0.0
|
||||
* @var \WP_Ultimo\Models\Product[]
|
||||
*/
|
||||
protected $recurring_products = array();
|
||||
protected $recurring_products = [];
|
||||
|
||||
/**
|
||||
* The cart additional products.
|
||||
@ -195,7 +195,7 @@ class Cart implements \JsonSerializable {
|
||||
* @since 2.0.0
|
||||
* @var \WP_Ultimo\Models\Product[]
|
||||
*/
|
||||
protected $additional_products = array();
|
||||
protected $additional_products = [];
|
||||
|
||||
/**
|
||||
* Line item representation of the products.
|
||||
@ -203,7 +203,7 @@ class Cart implements \JsonSerializable {
|
||||
* @since 2.0.0
|
||||
* @var \WP_Ultimo\Checkout\Line_Item[]
|
||||
*/
|
||||
protected $line_items = array();
|
||||
protected $line_items = [];
|
||||
|
||||
/**
|
||||
* If this cart should auto-renew.
|
||||
@ -227,7 +227,7 @@ class Cart implements \JsonSerializable {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $extra = array();
|
||||
protected $extra = [];
|
||||
|
||||
/**
|
||||
* The cart description.
|
||||
@ -255,7 +255,7 @@ class Cart implements \JsonSerializable {
|
||||
* this helps us to keep things cleaner and secure.
|
||||
*/
|
||||
$args = shortcode_atts(
|
||||
array(
|
||||
[
|
||||
|
||||
/*
|
||||
* Cart Type.
|
||||
@ -265,7 +265,7 @@ class Cart implements \JsonSerializable {
|
||||
/*
|
||||
* The list of products being bought.
|
||||
*/
|
||||
'products' => array(),
|
||||
'products' => [],
|
||||
|
||||
/*
|
||||
* The duration parameters
|
||||
@ -309,7 +309,7 @@ class Cart implements \JsonSerializable {
|
||||
*/
|
||||
'currency' => '',
|
||||
|
||||
),
|
||||
],
|
||||
$args
|
||||
);
|
||||
|
||||
@ -411,7 +411,7 @@ class Cart implements \JsonSerializable {
|
||||
* @param mixed $value The value to set.
|
||||
* @return void
|
||||
*/
|
||||
public function set_param($key, $value) {
|
||||
public function set_param($key, $value): void {
|
||||
|
||||
$this->extra[] = $key;
|
||||
|
||||
@ -504,7 +504,7 @@ class Cart implements \JsonSerializable {
|
||||
|
||||
$desc = wu_get_setting('company_name', __('Subscription', 'wp-ultimo'));
|
||||
|
||||
$products = array();
|
||||
$products = [];
|
||||
|
||||
foreach ($this->get_line_items() as $line_item) {
|
||||
$product = $line_item->get_product();
|
||||
@ -529,7 +529,7 @@ class Cart implements \JsonSerializable {
|
||||
* @param string $descriptor The cart description.
|
||||
* @return void
|
||||
*/
|
||||
public function set_cart_descriptor($descriptor) {
|
||||
public function set_cart_descriptor($descriptor): void {
|
||||
|
||||
$this->cart_descriptor = $descriptor;
|
||||
}
|
||||
@ -568,7 +568,7 @@ class Cart implements \JsonSerializable {
|
||||
/*
|
||||
* Adds the country to calculate taxes.
|
||||
*/
|
||||
$this->country = $this->country ? $this->country : ($this->customer ? $this->customer->get_country() : '');
|
||||
$this->country = ($this->country ?: $this->customer) ? $this->customer->get_country() : '';
|
||||
|
||||
/*
|
||||
* Set the currency in cart
|
||||
@ -676,9 +676,9 @@ class Cart implements \JsonSerializable {
|
||||
*/
|
||||
$allowed_status = apply_filters(
|
||||
'wu_cart_set_payment_allowed_status',
|
||||
array(
|
||||
[
|
||||
'pending',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if ( ! in_array($payment->get_status(), $allowed_status, true)) {
|
||||
@ -768,7 +768,7 @@ class Cart implements \JsonSerializable {
|
||||
/*
|
||||
* Adds the country to calculate taxes.
|
||||
*/
|
||||
$this->country = $this->country ? $this->country : $this->customer->get_country();
|
||||
$this->country = $this->country ?: $this->customer->get_country();
|
||||
|
||||
/*
|
||||
* Set the currency in cart
|
||||
@ -933,8 +933,8 @@ class Cart implements \JsonSerializable {
|
||||
* hev it here to prevent bugs.
|
||||
*/
|
||||
if ( ! $is_plan_change || ($this->get_plan_id() === $membership->get_plan_id() && $this->duration_unit === $membership->get_duration_unit() && $this->duration === $membership->get_duration())) {
|
||||
$this->products = array();
|
||||
$this->line_items = array();
|
||||
$this->products = [];
|
||||
$this->line_items = [];
|
||||
|
||||
$this->errors->add('no_changes', __('This cart proposes no changes to the current membership.', 'wp-ultimo'));
|
||||
|
||||
@ -993,8 +993,8 @@ class Cart implements \JsonSerializable {
|
||||
}
|
||||
|
||||
if ( ! $membership->is_free() && $old_price_per_day < $new_price_per_day && $days_in_old_cycle > $days_in_new_cycle && $membership->get_status() === Membership_Status::ACTIVE) {
|
||||
$this->products = array();
|
||||
$this->line_items = array();
|
||||
$this->products = [];
|
||||
$this->line_items = [];
|
||||
|
||||
$description = sprintf(
|
||||
// translators: %1$s the duration, and %2$s the duration unit (day, week, month, etc)
|
||||
@ -1023,7 +1023,7 @@ class Cart implements \JsonSerializable {
|
||||
if ($membership->is_active() || $membership->get_status() === Membership_Status::TRIALING) {
|
||||
$line_item_params = apply_filters(
|
||||
'wu_checkout_credit_line_item_params',
|
||||
array(
|
||||
[
|
||||
'type' => 'credit',
|
||||
'title' => __('Scheduled Swap Credit', 'wp-ultimo'),
|
||||
'description' => __('Swap scheduled to next billing cycle.', 'wp-ultimo'),
|
||||
@ -1031,7 +1031,7 @@ class Cart implements \JsonSerializable {
|
||||
'taxable' => false,
|
||||
'quantity' => 1,
|
||||
'unit_price' => - $this->get_total(),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$credit_line_item = new Line_Item($line_item_params);
|
||||
@ -1061,28 +1061,28 @@ class Cart implements \JsonSerializable {
|
||||
protected function search_for_same_period_plans($plan_a, $plan_b) {
|
||||
|
||||
if ($plan_a->get_duration_unit() === $plan_b->get_duration_unit() && $plan_a->get_duration() === $plan_b->get_duration()) {
|
||||
return array(
|
||||
return [
|
||||
$plan_a,
|
||||
$plan_b,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$plan_a_variation = $plan_a->get_as_variation($plan_b->get_duration(), $plan_b->get_duration_unit());
|
||||
|
||||
if ($plan_a_variation) {
|
||||
return array(
|
||||
return [
|
||||
$plan_a_variation,
|
||||
$plan_b,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$plan_b_variation = $plan_b->get_as_variation($plan_a->get_duration(), $plan_a->get_duration_unit());
|
||||
|
||||
if ($plan_b_variation) {
|
||||
return array(
|
||||
return [
|
||||
$plan_a,
|
||||
$plan_b_variation,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
if ($this->duration_unit && $this->duration && ($this->duration_unit !== $plan_b->get_duration_unit() || $this->duration !== $plan_b->get_duration())) {
|
||||
@ -1093,19 +1093,19 @@ class Cart implements \JsonSerializable {
|
||||
}
|
||||
|
||||
if ($plan_b->get_duration_unit() === $plan_a_variation->get_duration_unit() && $plan_b->get_duration() === $plan_a_variation->get_duration()) {
|
||||
return array(
|
||||
return [
|
||||
$plan_a_variation,
|
||||
$plan_b,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$plan_b_variation = $plan_b->get_as_variation($this->duration, $this->duration_unit);
|
||||
|
||||
if ($plan_b_variation) {
|
||||
return array(
|
||||
return [
|
||||
$plan_a_variation,
|
||||
$plan_b_variation,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1175,7 +1175,7 @@ class Cart implements \JsonSerializable {
|
||||
|
||||
if ($fee_credit > 0) {
|
||||
$new_line_item = new Line_Item(
|
||||
array(
|
||||
[
|
||||
'product' => $old_plan,
|
||||
'type' => 'fee',
|
||||
'description' => '--',
|
||||
@ -1184,7 +1184,7 @@ class Cart implements \JsonSerializable {
|
||||
'recurring' => false,
|
||||
'unit_price' => $fee_credit,
|
||||
'quantity' => 1,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$new_line_item = $this->apply_taxes_to_item($new_line_item);
|
||||
@ -1217,7 +1217,7 @@ class Cart implements \JsonSerializable {
|
||||
|
||||
$line_item_params = apply_filters(
|
||||
'wu_checkout_credit_line_item_params',
|
||||
array(
|
||||
[
|
||||
'type' => 'credit',
|
||||
'title' => __('Credit', 'wp-ultimo'),
|
||||
'description' => __('Prorated amount based on the previous membership.', 'wp-ultimo'),
|
||||
@ -1225,7 +1225,7 @@ class Cart implements \JsonSerializable {
|
||||
'taxable' => false,
|
||||
'quantity' => 1,
|
||||
'unit_price' => - $credit,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
@ -1467,7 +1467,7 @@ class Cart implements \JsonSerializable {
|
||||
* @param \WP_Ultimo\Checkout\Line_Item $line_item The line item.
|
||||
* @return void
|
||||
*/
|
||||
public function add_line_item($line_item) {
|
||||
public function add_line_item($line_item): void {
|
||||
|
||||
if ( ! is_a($line_item, '\WP_Ultimo\Checkout\Line_Item')) {
|
||||
return;
|
||||
@ -1597,13 +1597,13 @@ class Cart implements \JsonSerializable {
|
||||
|
||||
$line_item_data = apply_filters(
|
||||
'wu_add_product_line_item',
|
||||
array(
|
||||
[
|
||||
'product' => $product,
|
||||
'quantity' => $quantity,
|
||||
'unit_price' => $amount,
|
||||
'duration' => $duration,
|
||||
'duration_unit' => $duration_unit,
|
||||
),
|
||||
],
|
||||
$product,
|
||||
$duration,
|
||||
$duration_unit,
|
||||
@ -1666,7 +1666,7 @@ class Cart implements \JsonSerializable {
|
||||
*/
|
||||
$setup_fee_line_item = apply_filters(
|
||||
'wu_add_product_setup_fee_line_item',
|
||||
array(
|
||||
[
|
||||
'product' => $product,
|
||||
'type' => 'fee',
|
||||
'description' => '--',
|
||||
@ -1675,7 +1675,7 @@ class Cart implements \JsonSerializable {
|
||||
'recurring' => false,
|
||||
'unit_price' => $product->get_setup_fee(),
|
||||
'quantity' => $quantity,
|
||||
),
|
||||
],
|
||||
$product,
|
||||
$this
|
||||
);
|
||||
@ -1697,7 +1697,7 @@ class Cart implements \JsonSerializable {
|
||||
|
||||
$line_items = $this->line_items;
|
||||
|
||||
$tax_brackets = array();
|
||||
$tax_brackets = [];
|
||||
|
||||
foreach ($line_items as $line_item) {
|
||||
$tax_bracket = $line_item->get_tax_rate();
|
||||
@ -1818,18 +1818,18 @@ class Cart implements \JsonSerializable {
|
||||
* @param array $where_clauses Additional where clauses for search.
|
||||
* @return \WP_Ultimo\Checkout\Line_Item[]
|
||||
*/
|
||||
public function get_line_items_by_type($type = 'product', $where_clauses = array()): array {
|
||||
public function get_line_items_by_type($type = 'product', $where_clauses = []): array {
|
||||
|
||||
$where_clauses[] = array('type', $type);
|
||||
$where_clauses[] = ['type', $type];
|
||||
|
||||
// Cast to array recursively
|
||||
$line_items = json_decode(json_encode($this->line_items), true);
|
||||
|
||||
$line_items = Array_Search::find(
|
||||
$line_items,
|
||||
array(
|
||||
[
|
||||
'where' => $where_clauses,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$ids = array_keys($line_items);
|
||||
@ -1958,10 +1958,10 @@ class Cart implements \JsonSerializable {
|
||||
|
||||
$subtotal = 0;
|
||||
|
||||
$exclude_types = array(
|
||||
$exclude_types = [
|
||||
'discount',
|
||||
'credit',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($this->line_items as $line_item) {
|
||||
if (in_array($line_item->get_type(), $exclude_types, true)) {
|
||||
@ -2037,9 +2037,9 @@ class Cart implements \JsonSerializable {
|
||||
$new_line_item = clone $line_item;
|
||||
|
||||
$new_line_item->attributes(
|
||||
array(
|
||||
[
|
||||
'discount_rate' => 0,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$new_line_item->recalculate_totals();
|
||||
@ -2230,21 +2230,21 @@ class Cart implements \JsonSerializable {
|
||||
}
|
||||
|
||||
$line_item->attributes(
|
||||
array(
|
||||
[
|
||||
'discount_rate' => $this->discount_code->get_setup_fee_value(),
|
||||
'discount_type' => $this->discount_code->get_setup_fee_type(),
|
||||
'apply_discount_to_renewals' => false,
|
||||
'discount_label' => strtoupper($this->discount_code->get_code()),
|
||||
)
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$line_item->attributes(
|
||||
array(
|
||||
[
|
||||
'discount_rate' => $this->discount_code->get_value(),
|
||||
'discount_type' => $this->discount_code->get_type(),
|
||||
'apply_discount_to_renewals' => $this->discount_code->should_apply_to_renewals(),
|
||||
'discount_label' => strtoupper($this->discount_code->get_code()),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -2301,13 +2301,13 @@ class Cart implements \JsonSerializable {
|
||||
}
|
||||
|
||||
$line_item->attributes(
|
||||
array(
|
||||
[
|
||||
'tax_rate' => $tax_rate ?? 0,
|
||||
'tax_type' => $tax_type ?? 'percentage',
|
||||
'tax_label' => $tax_label ?? '',
|
||||
'tax_inclusive' => wu_get_setting('inclusive_tax', false),
|
||||
'tax_exempt' => $this->is_tax_exempt(),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$line_item->recalculate_totals();
|
||||
@ -2323,17 +2323,17 @@ class Cart implements \JsonSerializable {
|
||||
*/
|
||||
public function calculate_totals() {
|
||||
|
||||
return (object) array(
|
||||
'recurring' => (object) array(
|
||||
return (object) [
|
||||
'recurring' => (object) [
|
||||
'subtotal' => $this->get_recurring_subtotal(),
|
||||
'total' => $this->get_recurring_total(),
|
||||
),
|
||||
],
|
||||
'subtotal' => $this->get_subtotal(),
|
||||
'total_taxes' => $this->get_total_taxes(),
|
||||
'total_fees' => $this->get_total_fees(),
|
||||
'total_discounts' => $this->get_total_discounts(),
|
||||
'total' => $this->get_total(),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2355,7 +2355,7 @@ class Cart implements \JsonSerializable {
|
||||
*/
|
||||
public function get_extra_params() {
|
||||
|
||||
$extra_params = array();
|
||||
$extra_params = [];
|
||||
|
||||
foreach ($this->extra as $key) {
|
||||
$extra_params[ $key ] = $this->get_param($key);
|
||||
@ -2374,20 +2374,20 @@ class Cart implements \JsonSerializable {
|
||||
|
||||
$totals = $this->calculate_totals();
|
||||
|
||||
$errors = array();
|
||||
$errors = [];
|
||||
|
||||
if ($this->errors->has_errors()) {
|
||||
foreach ($this->errors as $code => $messages) {
|
||||
foreach ($messages as $message) {
|
||||
$errors[] = array(
|
||||
$errors[] = [
|
||||
'code' => $code,
|
||||
'message' => $message,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (object) array(
|
||||
return (object) [
|
||||
|
||||
'errors' => $errors,
|
||||
'url' => $this->get_cart_url(),
|
||||
@ -2407,12 +2407,12 @@ class Cart implements \JsonSerializable {
|
||||
|
||||
'extra' => $this->get_extra_params(),
|
||||
|
||||
'dates' => (object) array(
|
||||
'dates' => (object) [
|
||||
'date_trial_end' => $this->get_billing_start_date(),
|
||||
'date_next_charge' => $this->get_billing_next_charge_date(),
|
||||
),
|
||||
],
|
||||
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2423,23 +2423,23 @@ class Cart implements \JsonSerializable {
|
||||
*/
|
||||
public function to_membership_data() {
|
||||
|
||||
$membership_data = array();
|
||||
$membership_data = [];
|
||||
|
||||
$all_additional_products = $this->get_line_items_by_type(
|
||||
'product',
|
||||
array(
|
||||
array('product_id', '!=', $this->get_plan_id()),
|
||||
)
|
||||
[
|
||||
['product_id', '!=', $this->get_plan_id()],
|
||||
]
|
||||
);
|
||||
|
||||
$addon_list = array();
|
||||
$addon_list = [];
|
||||
|
||||
foreach ($all_additional_products as $line_item) {
|
||||
$addon_list[ $line_item->get_product_id() ] = $line_item->get_quantity();
|
||||
}
|
||||
|
||||
$membership_data = array_merge(
|
||||
array(
|
||||
[
|
||||
'recurring' => $this->has_recurring(),
|
||||
'plan_id' => $this->get_plan() ? $this->get_plan()->get_id() : 0,
|
||||
'initial_amount' => $this->get_total(),
|
||||
@ -2452,7 +2452,7 @@ class Cart implements \JsonSerializable {
|
||||
'billing_cycles' => $this->get_plan() ? $this->get_plan()->get_billing_cycles() : 0,
|
||||
'auto_renew' => false, // @todo: revisit
|
||||
'upgraded_from' => false, // @todo: revisit
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
return $membership_data;
|
||||
@ -2466,10 +2466,10 @@ class Cart implements \JsonSerializable {
|
||||
*/
|
||||
public function to_payment_data() {
|
||||
|
||||
$payment_data = array();
|
||||
$payment_data = [];
|
||||
|
||||
// Creates the pending payment
|
||||
$payment_data = array(
|
||||
$payment_data = [
|
||||
'status' => 'pending',
|
||||
'tax_total' => $this->get_total_taxes(),
|
||||
'fees' => $this->get_total_fees(),
|
||||
@ -2478,7 +2478,7 @@ class Cart implements \JsonSerializable {
|
||||
'discount_code' => $this->get_discount_code() ? $this->get_discount_code()->get_code() : '',
|
||||
'subtotal' => $this->get_subtotal(),
|
||||
'total' => $this->get_total(),
|
||||
);
|
||||
];
|
||||
|
||||
return $payment_data;
|
||||
}
|
||||
@ -2523,7 +2523,7 @@ class Cart implements \JsonSerializable {
|
||||
* @param mixed $currency The currency code.
|
||||
* @return void
|
||||
*/
|
||||
public function set_currency($currency) {
|
||||
public function set_currency($currency): void {
|
||||
|
||||
$this->currency = $currency;
|
||||
}
|
||||
@ -2568,7 +2568,7 @@ class Cart implements \JsonSerializable {
|
||||
* @param \WP_Ultimo\Models\Membership $membership A valid membership object.
|
||||
* @return void
|
||||
*/
|
||||
public function set_membership($membership) {
|
||||
public function set_membership($membership): void {
|
||||
|
||||
$this->membership = $membership;
|
||||
}
|
||||
@ -2580,7 +2580,7 @@ class Cart implements \JsonSerializable {
|
||||
* @param \WP_Ultimo\Models\Customer $customer A valid customer object.
|
||||
* @return void
|
||||
*/
|
||||
public function set_customer($customer) {
|
||||
public function set_customer($customer): void {
|
||||
|
||||
$this->customer = $customer;
|
||||
}
|
||||
@ -2592,7 +2592,7 @@ class Cart implements \JsonSerializable {
|
||||
* @param \WP_Ultimo\Models\Payment $payment A valid payment object.
|
||||
* @return void
|
||||
*/
|
||||
public function set_payment($payment) {
|
||||
public function set_payment($payment): void {
|
||||
|
||||
$this->payment = $payment;
|
||||
}
|
||||
@ -2637,7 +2637,7 @@ class Cart implements \JsonSerializable {
|
||||
* @param string $country The country of the customer.
|
||||
* @return void
|
||||
*/
|
||||
public function set_country($country) {
|
||||
public function set_country($country): void {
|
||||
|
||||
$this->country = $country;
|
||||
}
|
||||
@ -2668,7 +2668,7 @@ class Cart implements \JsonSerializable {
|
||||
|
||||
$all_products = $this->products;
|
||||
|
||||
$products_list = array();
|
||||
$products_list = [];
|
||||
|
||||
foreach ($all_products as $product) {
|
||||
if ($product->get_id() !== $this->plan_id) {
|
||||
@ -2677,9 +2677,9 @@ class Cart implements \JsonSerializable {
|
||||
}
|
||||
|
||||
return add_query_arg(
|
||||
array(
|
||||
[
|
||||
'products' => $products_list,
|
||||
),
|
||||
],
|
||||
$base_url
|
||||
);
|
||||
}
|
||||
|
@ -27,18 +27,18 @@ class Checkout_Pages {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
add_filter('display_post_states', array($this, 'add_wp_ultimo_status_annotation'), 10, 2);
|
||||
add_filter('display_post_states', [$this, 'add_wp_ultimo_status_annotation'], 10, 2);
|
||||
|
||||
add_action('wu_thank_you_site_block', array($this, 'add_verify_email_notice'), 10, 3);
|
||||
add_action('wu_thank_you_site_block', [$this, 'add_verify_email_notice'], 10, 3);
|
||||
|
||||
add_shortcode('wu_confirmation', array($this, 'render_confirmation_page'));
|
||||
add_shortcode('wu_confirmation', [$this, 'render_confirmation_page']);
|
||||
|
||||
add_filter('lostpassword_redirect', array($this, 'filter_lost_password_redirect'));
|
||||
add_filter('lostpassword_redirect', [$this, 'filter_lost_password_redirect']);
|
||||
|
||||
if (is_main_site()) {
|
||||
add_action('before_signup_header', array($this, 'redirect_to_registration_page'));
|
||||
add_action('before_signup_header', [$this, 'redirect_to_registration_page']);
|
||||
|
||||
$use_custom_login = wu_get_setting('enable_custom_login_page', false);
|
||||
|
||||
@ -46,30 +46,30 @@ class Checkout_Pages {
|
||||
return;
|
||||
}
|
||||
|
||||
add_filter('login_url', array($this, 'filter_login_url'), 10, 3);
|
||||
add_filter('login_url', [$this, 'filter_login_url'], 10, 3);
|
||||
|
||||
add_filter('lostpassword_url', array($this, 'filter_login_url'), 10, 3);
|
||||
add_filter('lostpassword_url', [$this, 'filter_login_url'], 10, 3);
|
||||
|
||||
add_filter('retrieve_password_message', array($this, 'replace_reset_password_link'), 10, 4);
|
||||
add_filter('retrieve_password_message', [$this, 'replace_reset_password_link'], 10, 4);
|
||||
|
||||
add_filter('network_site_url', array($this, 'maybe_change_wp_login_on_urls'));
|
||||
add_filter('network_site_url', [$this, 'maybe_change_wp_login_on_urls']);
|
||||
|
||||
add_action('login_init', array($this, 'maybe_obfuscate_login_url'), 9);
|
||||
add_action('login_init', [$this, 'maybe_obfuscate_login_url'], 9);
|
||||
|
||||
add_action('template_redirect', array($this, 'maybe_redirect_to_admin_panel'));
|
||||
add_action('template_redirect', [$this, 'maybe_redirect_to_admin_panel']);
|
||||
|
||||
add_action('after_password_reset', array($this, 'maybe_redirect_to_confirm_screen'));
|
||||
add_action('after_password_reset', [$this, 'maybe_redirect_to_confirm_screen']);
|
||||
|
||||
add_action('lost_password', array($this, 'maybe_handle_password_reset_errors'));
|
||||
add_action('lost_password', [$this, 'maybe_handle_password_reset_errors']);
|
||||
|
||||
add_action('validate_password_reset', array($this, 'maybe_handle_password_reset_errors'));
|
||||
add_action('validate_password_reset', [$this, 'maybe_handle_password_reset_errors']);
|
||||
|
||||
/**
|
||||
* Adds the force elements controls.
|
||||
*/
|
||||
add_action('post_submitbox_misc_actions', array($this, 'render_compat_mode_setting'));
|
||||
add_action('post_submitbox_misc_actions', [$this, 'render_compat_mode_setting']);
|
||||
|
||||
add_action('save_post', array($this, 'handle_compat_mode_setting'));
|
||||
add_action('save_post', [$this, 'handle_compat_mode_setting']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ class Checkout_Pages {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_compat_mode_setting() {
|
||||
public function render_compat_mode_setting(): void {
|
||||
|
||||
$post_id = get_the_ID();
|
||||
|
||||
@ -129,7 +129,7 @@ class Checkout_Pages {
|
||||
* @param int $post_id The id of the post being saved.
|
||||
* @return void
|
||||
*/
|
||||
public function handle_compat_mode_setting($post_id) {
|
||||
public function handle_compat_mode_setting($post_id): void {
|
||||
|
||||
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
|
||||
return;
|
||||
@ -163,7 +163,7 @@ class Checkout_Pages {
|
||||
* Only perform computational-heavy tasks if the URL has
|
||||
* wp-login.php in it to begin with.
|
||||
*/
|
||||
if (strpos($url, 'wp-login.php') === false) {
|
||||
if (! str_contains($url, 'wp-login.php')) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
@ -189,7 +189,7 @@ class Checkout_Pages {
|
||||
*/
|
||||
public function get_error_message($error_code, $username = '') {
|
||||
|
||||
$messages = array(
|
||||
$messages = [
|
||||
'incorrect_password' => sprintf(__('<strong>Error:</strong> The password you entered is incorrect.', 'wp-ultimo')),
|
||||
// From here we are using the same messages as WordPress core.
|
||||
'expired' => __('Your session has expired. Please log in to continue where you left off.'),
|
||||
@ -206,7 +206,7 @@ class Checkout_Pages {
|
||||
'password_reset_mismatch' => __('<strong>Error:</strong> The passwords do not match.'),
|
||||
'invalidkey' => __('<strong>Error:</strong> Your password reset link appears to be invalid. Please request a new link below.'),
|
||||
'expiredkey' => __('<strong>Error:</strong> Your password reset link has expired. Please request a new link below.'),
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Filter the error messages.
|
||||
@ -231,15 +231,15 @@ class Checkout_Pages {
|
||||
* @param \WP_Error $errors The error object.
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_handle_password_reset_errors($errors) {
|
||||
public function maybe_handle_password_reset_errors($errors): void {
|
||||
|
||||
if ($errors->has_errors()) {
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
[
|
||||
'action' => wu_request('action', ''),
|
||||
'user_login' => wu_request('user_login', ''),
|
||||
'error' => $errors->get_error_code(),
|
||||
),
|
||||
],
|
||||
wp_login_url()
|
||||
);
|
||||
|
||||
@ -260,7 +260,7 @@ class Checkout_Pages {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_redirect_to_confirm_screen() {
|
||||
public function maybe_redirect_to_confirm_screen(): void {
|
||||
|
||||
if (wu_request('redirect_to')) {
|
||||
wp_redirect(wu_request('redirect_to'));
|
||||
@ -286,7 +286,7 @@ class Checkout_Pages {
|
||||
return $message;
|
||||
}
|
||||
|
||||
$results = array();
|
||||
$results = [];
|
||||
|
||||
preg_match_all('/.*\/wp-login\.php.*/', $message, $results);
|
||||
|
||||
@ -300,12 +300,12 @@ class Checkout_Pages {
|
||||
$switched_locale = switch_to_locale($locale);
|
||||
|
||||
$new_url = add_query_arg(
|
||||
array(
|
||||
[
|
||||
'action' => 'rp',
|
||||
'key' => $key,
|
||||
'login' => rawurlencode($user_login),
|
||||
'wp_lang' => $locale,
|
||||
),
|
||||
],
|
||||
wp_login_url()
|
||||
);
|
||||
|
||||
@ -327,7 +327,7 @@ class Checkout_Pages {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_redirect_to_admin_panel() {
|
||||
public function maybe_redirect_to_admin_panel(): void {
|
||||
|
||||
global $post;
|
||||
|
||||
@ -356,14 +356,14 @@ class Checkout_Pages {
|
||||
*/
|
||||
$exclusion_list = apply_filters(
|
||||
'wu_maybe_redirect_to_admin_panel_exclusion_list',
|
||||
array(
|
||||
[
|
||||
'preview', // WordPress Preview
|
||||
'ct_builder', // Oxygen Builder
|
||||
'fl_builder', // Beaver Builder
|
||||
'elementor-preview', // Elementor
|
||||
'brizy-edit', // Brizy
|
||||
'brizy-edit-iframe', // Brizy
|
||||
),
|
||||
],
|
||||
$custom_login_page,
|
||||
$post,
|
||||
$this
|
||||
@ -410,7 +410,7 @@ class Checkout_Pages {
|
||||
* @param \WP_Ultimo\Models\Customer $customer the current customer.
|
||||
* @return void
|
||||
*/
|
||||
public function add_verify_email_notice($payment, $membership, $customer) {
|
||||
public function add_verify_email_notice($payment, $membership, $customer): void {
|
||||
|
||||
if ($payment->get_total() == 0 && $customer->get_email_verification() === 'pending') {
|
||||
$html = '<div class="wu-p-4 wu-bg-yellow-200 wu-mb-2 wu-text-yellow-700 wu-rounded">%s</div>';
|
||||
@ -429,7 +429,7 @@ class Checkout_Pages {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_obfuscate_login_url() {
|
||||
public function maybe_obfuscate_login_url(): void {
|
||||
|
||||
$use_custom_login = wu_get_setting('enable_custom_login_page', false);
|
||||
|
||||
@ -484,7 +484,7 @@ class Checkout_Pages {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function redirect_to_registration_page() {
|
||||
public function redirect_to_registration_page(): void {
|
||||
|
||||
$registration_url = $this->get_page_url('register');
|
||||
|
||||
@ -520,7 +520,7 @@ class Checkout_Pages {
|
||||
return $login_url;
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params = [];
|
||||
|
||||
$old_url_params = wp_parse_url($login_url, PHP_URL_QUERY);
|
||||
|
||||
@ -555,13 +555,13 @@ class Checkout_Pages {
|
||||
*/
|
||||
public function get_signup_pages() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'register' => wu_guess_registration_page(),
|
||||
'update' => wu_get_setting('default_update_page', false),
|
||||
'login' => wu_get_setting('default_login_page', false),
|
||||
'block_frontend' => wu_get_setting('default_block_frontend_page', false),
|
||||
'new_site' => wu_get_setting('default_new_site_page', false),
|
||||
);
|
||||
];
|
||||
}
|
||||
/**
|
||||
* Returns the WP_Post object for one of the pages.
|
||||
@ -617,13 +617,13 @@ class Checkout_Pages {
|
||||
return $states;
|
||||
}
|
||||
|
||||
$labels = array(
|
||||
$labels = [
|
||||
'register' => __('WP Multisite WaaS - Register Page', 'wp-ultimo'),
|
||||
'login' => __('WP Multisite WaaS - Login Page', 'wp-ultimo'),
|
||||
'block_frontend' => __('WP Multisite WaaS - Site Blocked Page', 'wp-ultimo'),
|
||||
'update' => __('WP Multisite WaaS - Membership Update Page', 'wp-ultimo'),
|
||||
'new_site' => __('WP Multisite WaaS - New Site Page', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
|
||||
$pages = array_map('absint', $this->get_signup_pages());
|
||||
|
||||
@ -649,10 +649,10 @@ class Checkout_Pages {
|
||||
|
||||
return wu_get_template_contents(
|
||||
'checkout/confirmation',
|
||||
array(
|
||||
[
|
||||
'errors' => Checkout::get_instance()->errors,
|
||||
'membership' => wu_get_membership_by_hash(wu_request('membership')),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -159,44 +159,44 @@ class Checkout {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
/*
|
||||
* Setup and handle checkout
|
||||
*/
|
||||
add_action('wu_setup_checkout', array($this, 'setup_checkout'));
|
||||
add_action('wu_setup_checkout', [$this, 'setup_checkout']);
|
||||
|
||||
add_action('wu_setup_checkout', array($this, 'maybe_process_checkout'), 20);
|
||||
add_action('wu_setup_checkout', [$this, 'maybe_process_checkout'], 20);
|
||||
|
||||
/*
|
||||
* Add the rewrite rules.
|
||||
*/
|
||||
add_action('init', array($this, 'add_rewrite_rules'), 20);
|
||||
add_action('init', [$this, 'add_rewrite_rules'], 20);
|
||||
|
||||
add_filter('wu_request', array($this, 'get_checkout_from_query_vars'), 10, 2);
|
||||
add_filter('wu_request', [$this, 'get_checkout_from_query_vars'], 10, 2);
|
||||
|
||||
/*
|
||||
* Creates the order object to display to the customer
|
||||
*/
|
||||
add_action('wu_ajax_wu_create_order', array($this, 'create_order'));
|
||||
add_action('wu_ajax_wu_create_order', [$this, 'create_order']);
|
||||
|
||||
add_action('wu_ajax_nopriv_wu_create_order', array($this, 'create_order'));
|
||||
add_action('wu_ajax_nopriv_wu_create_order', [$this, 'create_order']);
|
||||
|
||||
/*
|
||||
* Validates form and process preflight.
|
||||
*/
|
||||
add_action('wu_ajax_wu_validate_form', array($this, 'maybe_handle_order_submission'));
|
||||
add_action('wu_ajax_wu_validate_form', [$this, 'maybe_handle_order_submission']);
|
||||
|
||||
add_action('wu_ajax_nopriv_wu_validate_form', array($this, 'maybe_handle_order_submission'));
|
||||
add_action('wu_ajax_nopriv_wu_validate_form', [$this, 'maybe_handle_order_submission']);
|
||||
|
||||
/*
|
||||
* Adds the necessary scripts
|
||||
*/
|
||||
add_action('wu_checkout_scripts', array($this, 'register_scripts'));
|
||||
add_action('wu_checkout_scripts', [$this, 'register_scripts']);
|
||||
|
||||
/*
|
||||
* Errors
|
||||
*/
|
||||
add_action('wu_checkout_errors', array($this, 'maybe_display_checkout_errors'));
|
||||
add_action('wu_checkout_errors', [$this, 'maybe_display_checkout_errors']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -213,7 +213,7 @@ class Checkout {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function add_rewrite_rules() {
|
||||
public function add_rewrite_rules(): void {
|
||||
|
||||
$register = Checkout_Pages::get_instance()->get_signup_page('register');
|
||||
|
||||
@ -297,13 +297,13 @@ class Checkout {
|
||||
|
||||
$cart_arguments = apply_filters(
|
||||
'wu_get_checkout_from_query_vars',
|
||||
array(
|
||||
[
|
||||
'products',
|
||||
'duration',
|
||||
'duration_unit',
|
||||
'template_id',
|
||||
'wu_preselected',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
/**
|
||||
@ -345,7 +345,7 @@ class Checkout {
|
||||
* @param \WP_Ultimo\UI\Checkout_Element $element The checkout element.
|
||||
* @return void
|
||||
*/
|
||||
public function setup_checkout($element = null) {
|
||||
public function setup_checkout($element = null): void {
|
||||
|
||||
if ($this->already_setup) {
|
||||
return;
|
||||
@ -362,7 +362,7 @@ class Checkout {
|
||||
if ( ! $checkout_form_slug && is_a($element, \WP_Ultimo\UI\Checkout_Element::class)) {
|
||||
$pre_loaded_checkout_form_slug = $element->get_pre_loaded_attribute('slug', $checkout_form_slug);
|
||||
|
||||
$checkout_form_slug = $pre_loaded_checkout_form_slug ? $pre_loaded_checkout_form_slug : $checkout_form_slug;
|
||||
$checkout_form_slug = $pre_loaded_checkout_form_slug ?: $checkout_form_slug;
|
||||
}
|
||||
|
||||
$this->checkout_form = wu_get_checkout_form_by_slug($checkout_form_slug);
|
||||
@ -382,7 +382,7 @@ class Checkout {
|
||||
|
||||
$this->step = $this->checkout_form->get_step($this->step_name, true);
|
||||
|
||||
$this->step['fields'] ??= array();
|
||||
$this->step['fields'] ??= [];
|
||||
|
||||
$this->auto_submittable_field = $this->contains_auto_submittable_field($this->step['fields']);
|
||||
|
||||
@ -408,19 +408,19 @@ class Checkout {
|
||||
*/
|
||||
public function contains_auto_submittable_field($fields) {
|
||||
|
||||
$relevant_fields = array();
|
||||
$relevant_fields = [];
|
||||
|
||||
$field_types_to_ignore = array(
|
||||
$field_types_to_ignore = [
|
||||
'hidden',
|
||||
'products',
|
||||
'submit_button',
|
||||
'period_selection',
|
||||
'steps',
|
||||
);
|
||||
];
|
||||
|
||||
// Extra check to prevent error messages from being displayed.
|
||||
if ( ! is_array($fields)) {
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
}
|
||||
|
||||
foreach ($fields as $field) {
|
||||
@ -457,10 +457,10 @@ class Checkout {
|
||||
* while the value should be the parameter we should watch for changes
|
||||
* so we can submit the form when we detect one.
|
||||
*/
|
||||
$auto_submittable_fields = array(
|
||||
$auto_submittable_fields = [
|
||||
'template_selection' => 'template_id',
|
||||
'pricing_table' => 'products',
|
||||
);
|
||||
];
|
||||
|
||||
return apply_filters('wu_checkout_get_auto_submittable_fields', $auto_submittable_fields, $this);
|
||||
}
|
||||
@ -471,7 +471,7 @@ class Checkout {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_handle_order_submission() {
|
||||
public function maybe_handle_order_submission(): void {
|
||||
|
||||
$this->setup_checkout();
|
||||
|
||||
@ -484,7 +484,7 @@ class Checkout {
|
||||
wp_send_json_error($validation);
|
||||
}
|
||||
|
||||
wp_send_json_success(array());
|
||||
wp_send_json_success([]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -498,7 +498,7 @@ class Checkout {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_order_submission() {
|
||||
public function handle_order_submission(): void {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
@ -545,7 +545,7 @@ class Checkout {
|
||||
|
||||
$wpdb->query('COMMIT');
|
||||
|
||||
$this->session->set('signup', array());
|
||||
$this->session->set('signup', []);
|
||||
$this->session->commit();
|
||||
|
||||
wp_send_json_success($results);
|
||||
@ -589,8 +589,8 @@ class Checkout {
|
||||
$cart = new Cart(
|
||||
apply_filters(
|
||||
'wu_cart_parameters',
|
||||
array(
|
||||
'products' => $this->request_or_session('products', array()),
|
||||
[
|
||||
'products' => $this->request_or_session('products', []),
|
||||
'discount_code' => $this->request_or_session('discount_code'),
|
||||
'country' => $this->request_or_session('billing_country'),
|
||||
'state' => $this->request_or_session('billing_state'),
|
||||
@ -601,7 +601,7 @@ class Checkout {
|
||||
'duration' => $this->request_or_session('duration'),
|
||||
'duration_unit' => $this->request_or_session('duration_unit'),
|
||||
'cart_type' => $this->request_or_session('cart_type', 'new'),
|
||||
),
|
||||
],
|
||||
$this
|
||||
)
|
||||
);
|
||||
@ -684,7 +684,7 @@ class Checkout {
|
||||
/*
|
||||
* Handles display names, if needed.
|
||||
*/
|
||||
add_filter('pre_user_display_name', array($this, 'handle_display_name'));
|
||||
add_filter('pre_user_display_name', [$this, 'handle_display_name']);
|
||||
|
||||
/*
|
||||
* If we get to this point, most of the validations are done.
|
||||
@ -834,7 +834,7 @@ class Checkout {
|
||||
$gateway->trigger_payment_processed($this->payment, $this->membership);
|
||||
}
|
||||
|
||||
$success_data = array(
|
||||
$success_data = [
|
||||
'nonce' => wp_create_nonce('wp-ultimo-register-nonce'),
|
||||
'customer' => $this->customer->to_search_results(),
|
||||
'total' => $this->order->get_total(),
|
||||
@ -843,11 +843,11 @@ class Checkout {
|
||||
'payment_id' => $this->payment->get_id(),
|
||||
'cart_type' => $this->order->get_cart_type(),
|
||||
'auto_renew' => $this->order->should_auto_renew(),
|
||||
'gateway' => array(
|
||||
'gateway' => [
|
||||
'slug' => $gateway->get_id(),
|
||||
'data' => array(),
|
||||
),
|
||||
);
|
||||
'data' => [],
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
* Let's the gateway do its thing.
|
||||
@ -862,7 +862,7 @@ class Checkout {
|
||||
/*
|
||||
* Attach the gateway results to the return array.
|
||||
*/
|
||||
$success_data['gateway']['data'] = $result && is_array($result) ? $result : array();
|
||||
$success_data['gateway']['data'] = $result && is_array($result) ? $result : [];
|
||||
|
||||
/*
|
||||
* On error, bail.
|
||||
@ -941,24 +941,24 @@ class Checkout {
|
||||
*
|
||||
* Next step then would be to create one.
|
||||
*/
|
||||
$customer_data = array(
|
||||
$customer_data = [
|
||||
'username' => $username,
|
||||
'email' => $this->request_or_session('email_address'),
|
||||
'password' => $this->request_or_session('password'),
|
||||
'email_verification' => $this->get_customer_email_verification_status(),
|
||||
'signup_form' => $form_slug,
|
||||
'meta' => array(),
|
||||
);
|
||||
'meta' => [],
|
||||
];
|
||||
|
||||
/*
|
||||
* If the user is logged in,
|
||||
* we use the existing email address to create the customer.
|
||||
*/
|
||||
if ($this->is_existing_user()) {
|
||||
$customer_data = array(
|
||||
$customer_data = [
|
||||
'email' => wp_get_current_user()->user_email,
|
||||
'email_verification' => 'verified',
|
||||
);
|
||||
];
|
||||
} elseif (isset($customer_data['email']) && get_user_by('email', $customer_data['email'])) {
|
||||
return new \WP_Error('email_exists', __('The email address you entered is already in use.', 'wp-ultimo'));
|
||||
}
|
||||
@ -993,7 +993,7 @@ class Checkout {
|
||||
* class, so there's no problem in passing
|
||||
* the entire post array in here.
|
||||
*/
|
||||
$session = $this->session->get('signup') ?? array();
|
||||
$session = $this->session->get('signup') ?? [];
|
||||
$billing_address->attributes(array_merge($session, $_POST));
|
||||
|
||||
/*
|
||||
@ -1068,7 +1068,7 @@ class Checkout {
|
||||
if ($checkout_form) {
|
||||
$customer_meta_fields = $checkout_form->get_all_meta_fields('customer_meta');
|
||||
|
||||
$meta_repository = array();
|
||||
$meta_repository = [];
|
||||
|
||||
foreach ($customer_meta_fields as $customer_meta_field) {
|
||||
/*
|
||||
@ -1106,7 +1106,7 @@ class Checkout {
|
||||
|
||||
$user = $customer->get_user();
|
||||
|
||||
$user_meta_repository = array();
|
||||
$user_meta_repository = [];
|
||||
|
||||
foreach ($user_meta_fields as $user_meta_field) {
|
||||
/*
|
||||
@ -1239,7 +1239,7 @@ class Checkout {
|
||||
if ($auto_generate_url === 'username') {
|
||||
$site_url = $this->customer->get_username();
|
||||
|
||||
$site_title = $site_title ? $site_title : $site_url;
|
||||
$site_title = $site_title ?: $site_url;
|
||||
} else {
|
||||
$site_url = strtolower(str_replace(' ', '', preg_replace('/&([a-z])[a-z]+;/i', '$1', htmlentities(trim((string) $site_title)))));
|
||||
}
|
||||
@ -1278,7 +1278,7 @@ class Checkout {
|
||||
* that way we can use it when actually registering
|
||||
* the site on WordPress.
|
||||
*/
|
||||
$transient = array();
|
||||
$transient = [];
|
||||
|
||||
if ($this->checkout_form) {
|
||||
$site_meta_fields = $this->checkout_form->get_all_fields();
|
||||
@ -1289,7 +1289,7 @@ class Checkout {
|
||||
* to make sure plain passwords do not get stored
|
||||
* on the database.
|
||||
*/
|
||||
if (strpos((string) $site_meta_field['id'], 'password') !== false ) {
|
||||
if (str_contains((string) $site_meta_field['id'], 'password') ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1310,7 +1310,7 @@ class Checkout {
|
||||
*/
|
||||
$template_id = apply_filters('wu_checkout_template_id', (int) $this->request_or_session('template_id'), $this->membership, $this);
|
||||
|
||||
$site_data = array(
|
||||
$site_data = [
|
||||
'domain' => $d->domain,
|
||||
'path' => $d->path,
|
||||
'title' => $site_title,
|
||||
@ -1321,7 +1321,7 @@ class Checkout {
|
||||
'signup_options' => $this->get_site_meta_fields($form_slug, 'site_option'),
|
||||
'signup_meta' => $this->get_site_meta_fields($form_slug, 'site_meta'),
|
||||
'type' => Site_Type::CUSTOMER_OWNED,
|
||||
);
|
||||
];
|
||||
|
||||
$pending_site = $this->membership->create_pending_site($site_data);
|
||||
|
||||
@ -1340,12 +1340,12 @@ class Checkout {
|
||||
protected function get_site_meta_fields($form_slug, $meta_type = 'site_meta') {
|
||||
|
||||
if (empty($form_slug) || $form_slug === 'none') {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
$checkout_form = wu_get_checkout_form_by_slug($form_slug);
|
||||
|
||||
$list = array();
|
||||
$list = [];
|
||||
|
||||
if ($checkout_form) {
|
||||
$site_meta_fields = $checkout_form->get_all_meta_fields($meta_type);
|
||||
@ -1389,11 +1389,11 @@ class Checkout {
|
||||
*/
|
||||
$previous_payment = $this->membership->get_last_pending_payment();
|
||||
|
||||
$cancel_types = array(
|
||||
$cancel_types = [
|
||||
'upgrade',
|
||||
'downgrade',
|
||||
'addon',
|
||||
);
|
||||
];
|
||||
|
||||
if ($previous_payment && in_array($this->type, $cancel_types, true)) {
|
||||
$previous_payment->set_status(Payment_Status::CANCELLED);
|
||||
@ -1444,12 +1444,12 @@ class Checkout {
|
||||
*/
|
||||
if ($this->order->has_trial()) {
|
||||
$payment->attributes(
|
||||
array(
|
||||
[
|
||||
'tax_total' => 0,
|
||||
'subtotal' => 0,
|
||||
'refund_total' => 0,
|
||||
'total' => 0,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$payment->save();
|
||||
@ -1464,7 +1464,7 @@ class Checkout {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function validate_form() {
|
||||
public function validate_form(): void {
|
||||
|
||||
$validation = $this->validate();
|
||||
|
||||
@ -1481,7 +1481,7 @@ class Checkout {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function create_order() {
|
||||
public function create_order(): void {
|
||||
|
||||
$this->setup_checkout();
|
||||
|
||||
@ -1493,8 +1493,8 @@ class Checkout {
|
||||
$cart = new Cart(
|
||||
apply_filters(
|
||||
'wu_cart_parameters',
|
||||
array(
|
||||
'products' => $this->request_or_session('products', array()),
|
||||
[
|
||||
'products' => $this->request_or_session('products', []),
|
||||
'discount_code' => $this->request_or_session('discount_code'),
|
||||
'country' => $country,
|
||||
'state' => $state,
|
||||
@ -1505,7 +1505,7 @@ class Checkout {
|
||||
'duration' => $this->request_or_session('duration'),
|
||||
'duration_unit' => $this->request_or_session('duration_unit'),
|
||||
'cart_type' => $this->request_or_session('cart_type', 'new'),
|
||||
),
|
||||
],
|
||||
$this
|
||||
)
|
||||
);
|
||||
@ -1518,15 +1518,15 @@ class Checkout {
|
||||
$country_data = wu_get_country($cart->get_country());
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
[
|
||||
'order' => $cart->done(),
|
||||
'states' => wu_key_map_to_array($country_data->get_states_as_options(), 'code', 'name'),
|
||||
'cities' => wu_key_map_to_array($country_data->get_cities_as_options($state), 'code', 'name'),
|
||||
'labels' => array(
|
||||
'labels' => [
|
||||
'state_field' => $country_data->get_administrative_division_name(null, true),
|
||||
'city_field' => $country_data->get_municipality_name(null, true),
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -1543,11 +1543,11 @@ class Checkout {
|
||||
/*
|
||||
* Localized strings.
|
||||
*/
|
||||
$i18n = array(
|
||||
$i18n = [
|
||||
'loading' => __('Loading...', 'wp-ultimo'),
|
||||
'added_to_order' => __('The item was added!', 'wp-ultimo'),
|
||||
'weak_password' => __('The Password entered is too weak.', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
|
||||
/*
|
||||
* Get the default gateway.
|
||||
@ -1579,14 +1579,14 @@ class Checkout {
|
||||
}
|
||||
}
|
||||
|
||||
$products = array_merge($this->request_or_session('products', array()), wu_request('products', array()));
|
||||
$products = array_merge($this->request_or_session('products', []), wu_request('products', []));
|
||||
|
||||
$geolocation = \WP_Ultimo\Geolocation::geolocate_ip('', true);
|
||||
|
||||
/*
|
||||
* Set the default variables.
|
||||
*/
|
||||
$variables = array(
|
||||
$variables = [
|
||||
'i18n' => $i18n,
|
||||
'ajaxurl' => wu_ajax_url(),
|
||||
'late_ajaxurl' => wu_ajax_url('init'),
|
||||
@ -1603,7 +1603,7 @@ class Checkout {
|
||||
'needs_billing_info' => true,
|
||||
'auto_renew' => true,
|
||||
'products' => array_unique($products),
|
||||
);
|
||||
];
|
||||
|
||||
/*
|
||||
* There's a couple of things we need to determine.
|
||||
@ -1651,7 +1651,7 @@ class Checkout {
|
||||
$variables['membership_id'] = $membership_id;
|
||||
}
|
||||
|
||||
list($plan, $other_products) = wu_segregate_products($variables['products']);
|
||||
[$plan, $other_products] = wu_segregate_products($variables['products']);
|
||||
|
||||
$variables['plan'] = $plan ? $plan->get_id() : 0;
|
||||
|
||||
@ -1700,7 +1700,7 @@ class Checkout {
|
||||
*
|
||||
* First, let's set upm the general rules:
|
||||
*/
|
||||
$rules = array(
|
||||
$rules = [
|
||||
'email_address' => 'required_without:user_id|email|unique:\WP_User,email',
|
||||
'username' => 'required_without:user_id|alpha_dash|min:4|lowercase|unique:\WP_User,login',
|
||||
'password' => 'required_without:user_id|min:6',
|
||||
@ -1713,7 +1713,7 @@ class Checkout {
|
||||
'billing_zip_code' => 'required_with:billing_zip_code',
|
||||
'billing_state' => 'state',
|
||||
'billing_city' => 'city',
|
||||
);
|
||||
];
|
||||
|
||||
/*
|
||||
* Add rules for site when creating a new account.
|
||||
@ -1745,7 +1745,7 @@ class Checkout {
|
||||
$validation_rules = $this->validation_rules();
|
||||
|
||||
if (wu_request('pre-flight') || wu_request('checkout_form') === 'wu-finish-checkout') {
|
||||
$validation_rules = array();
|
||||
$validation_rules = [];
|
||||
|
||||
return $validation_rules;
|
||||
}
|
||||
@ -1764,10 +1764,10 @@ class Checkout {
|
||||
}
|
||||
|
||||
// We'll use this to validate product fields
|
||||
$product_fields = array(
|
||||
$product_fields = [
|
||||
'pricing_table',
|
||||
'products',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Add the additional required fields.
|
||||
@ -1825,9 +1825,9 @@ class Checkout {
|
||||
$rules = $this->get_validation_rules();
|
||||
}
|
||||
|
||||
$base_aliases = array();
|
||||
$base_aliases = [];
|
||||
|
||||
$checkout_form_fields = $this->checkout_form ? $this->checkout_form->get_all_fields() : array();
|
||||
$checkout_form_fields = $this->checkout_form ? $this->checkout_form->get_all_fields() : [];
|
||||
|
||||
// Add current form fields
|
||||
foreach ($checkout_form_fields as $field) {
|
||||
@ -1841,13 +1841,13 @@ class Checkout {
|
||||
|
||||
// Add some hidden or compound fields ids
|
||||
$validation_aliases = array_merge(
|
||||
array(
|
||||
[
|
||||
'password_conf' => __('Password confirmation', 'wp-ultimo'),
|
||||
'template_id' => __('Template ID', 'wp-ultimo'),
|
||||
'valid_password' => __('Valid password', 'wp-ultimo'),
|
||||
'products' => __('Products', 'wp-ultimo'),
|
||||
'gateway' => __('Payment Gateway', 'wp-ultimo'),
|
||||
),
|
||||
],
|
||||
$base_aliases
|
||||
);
|
||||
|
||||
@ -1885,7 +1885,7 @@ class Checkout {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_process_checkout() {
|
||||
public function maybe_process_checkout(): void {
|
||||
/*
|
||||
* Sets up the checkout
|
||||
* environment.
|
||||
@ -1944,10 +1944,10 @@ class Checkout {
|
||||
*/
|
||||
if ($payment) {
|
||||
$redirect_url = add_query_arg(
|
||||
array(
|
||||
[
|
||||
'payment' => $payment->get_hash(),
|
||||
'status' => 'error',
|
||||
),
|
||||
],
|
||||
$redirect_url
|
||||
);
|
||||
}
|
||||
@ -1973,11 +1973,11 @@ class Checkout {
|
||||
* have checkout_ on their name, or start
|
||||
* with a underscore.
|
||||
*/
|
||||
$to_save = array_filter($_POST, fn($item) => strncmp((string) $item, 'checkout_', strlen('checkout_')) !== 0 && strncmp((string) $item, '_', strlen('_')) !== 0, ARRAY_FILTER_USE_KEY);
|
||||
$to_save = array_filter($_POST, fn($item) => ! str_starts_with((string) $item, 'checkout_') && ! str_starts_with((string) $item, '_'), ARRAY_FILTER_USE_KEY);
|
||||
|
||||
if (isset($to_save['pre-flight'])) {
|
||||
unset($to_save['pre-flight']);
|
||||
$this->session->add_values('signup', array('pre_selected' => $to_save));
|
||||
$this->session->add_values('signup', ['pre_selected' => $to_save]);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2119,12 +2119,12 @@ class Checkout {
|
||||
if (has_action('wp_ultimo_registration')) {
|
||||
$_payment = wu_get_payment($payment->get_id());
|
||||
|
||||
$args = array(
|
||||
$args = [
|
||||
0, // Site ID is not yet available at this point
|
||||
$customer->get_user_id(),
|
||||
$this->session->get('signup'),
|
||||
$_payment && $_payment->get_membership() ? new \WU_Plan($_payment->get_membership()->get_plan()) : false,
|
||||
);
|
||||
];
|
||||
|
||||
ob_start();
|
||||
|
||||
@ -2152,10 +2152,10 @@ class Checkout {
|
||||
$redirect_url = apply_filters('wp_ultimo_redirect_url_after_signup', $redirect_url, 0, get_current_user_id(), $_POST);
|
||||
|
||||
$redirect_url = add_query_arg(
|
||||
array(
|
||||
[
|
||||
'payment' => $payment ? $payment->get_hash() : 'none',
|
||||
'status' => 'done',
|
||||
),
|
||||
],
|
||||
$redirect_url
|
||||
);
|
||||
}
|
||||
@ -2174,10 +2174,10 @@ class Checkout {
|
||||
return new \WP_Error(
|
||||
'error',
|
||||
$e->getMessage(),
|
||||
array(
|
||||
[
|
||||
'trace' => $e->getTrace(),
|
||||
'payment' => $payment,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -2254,7 +2254,7 @@ class Checkout {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
$custom_css = apply_filters('wu_checkout_custom_css', '');
|
||||
|
||||
@ -2264,7 +2264,7 @@ class Checkout {
|
||||
|
||||
wp_enqueue_style('wu-admin');
|
||||
|
||||
wp_register_script('wu-checkout', wu_get_asset('checkout.js', 'js'), array('jquery-core', 'wu-vue', 'moment', 'wu-block-ui', 'wu-functions', 'password-strength-meter', 'underscore', 'wp-polyfill', 'wp-hooks', 'wu-cookie-helpers'), wu_get_version(), true);
|
||||
wp_register_script('wu-checkout', wu_get_asset('checkout.js', 'js'), ['jquery-core', 'wu-vue', 'moment', 'wu-block-ui', 'wu-functions', 'password-strength-meter', 'underscore', 'wp-polyfill', 'wp-hooks', 'wu-cookie-helpers'], wu_get_version(), true);
|
||||
|
||||
wp_localize_script('wu-checkout', 'wu_checkout', $this->get_checkout_variables());
|
||||
|
||||
@ -2326,7 +2326,7 @@ class Checkout {
|
||||
|
||||
$index = $current_step_index + 1;
|
||||
|
||||
return isset($keys[ $index ]) ? $keys[ $index ] : $keys[ $current_step_index ];
|
||||
return $keys[ $index ] ?? $keys[ $current_step_index ];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2390,7 +2390,7 @@ class Checkout {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_display_checkout_errors() {
|
||||
public function maybe_display_checkout_errors(): void {
|
||||
|
||||
if (wu_request('status') !== 'error') {
|
||||
return;
|
||||
|
@ -90,26 +90,26 @@ class Legacy_Checkout {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
$this->session = wu_get_session('signup');
|
||||
|
||||
$this->templates = array(
|
||||
$this->templates = [
|
||||
'signup-main.php' => __('WP Multisite WaaS Legacy Signup', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
|
||||
// add_filter('request', array($this, 'maybe_render_legacy_signup'));
|
||||
|
||||
add_action('wu_signup_enqueue_scripts', array($this, 'register_scripts'));
|
||||
add_action('wu_signup_enqueue_scripts', [$this, 'register_scripts']);
|
||||
|
||||
add_filter('theme_page_templates', array($this, 'add_new_template'));
|
||||
add_filter('theme_page_templates', [$this, 'add_new_template']);
|
||||
|
||||
// Add a filter to the save post to inject out template into the page cache
|
||||
add_filter('wp_insert_post_data', array($this, 'register_legacy_templates'));
|
||||
add_filter('wp_insert_post_data', [$this, 'register_legacy_templates']);
|
||||
|
||||
// Add a filter to the template include to determine if the page has our
|
||||
// template assigned and return it's path
|
||||
add_filter('template_include', array($this, 'view_legacy_template'));
|
||||
add_filter('template_include', [$this, 'view_legacy_template']);
|
||||
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ class Legacy_Checkout {
|
||||
|
||||
if (empty($templates)) {
|
||||
|
||||
$templates = array();
|
||||
$templates = [];
|
||||
|
||||
}
|
||||
|
||||
@ -228,21 +228,21 @@ class Legacy_Checkout {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
wp_enqueue_script('wu-block-ui');
|
||||
|
||||
wp_register_script('wu-legacy-signup', wu_get_asset('legacy-signup.js', 'js'), array('wu-functions'));
|
||||
wp_register_script('wu-legacy-signup', wu_get_asset('legacy-signup.js', 'js'), ['wu-functions']);
|
||||
|
||||
wp_localize_script('wu-legacy-signup', 'wpu', array(
|
||||
wp_localize_script('wu-legacy-signup', 'wpu', [
|
||||
'default_pricing_option' => 1,
|
||||
));
|
||||
]);
|
||||
|
||||
wp_enqueue_script('wu-legacy-signup');
|
||||
|
||||
wp_enqueue_style('legacy-signup', wu_get_asset('legacy-signup.css', 'css'), array('dashicons', 'install', 'admin-bar'));
|
||||
wp_enqueue_style('legacy-signup', wu_get_asset('legacy-signup.css', 'css'), ['dashicons', 'install', 'admin-bar']);
|
||||
|
||||
wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), array('dashicons', 'install'));
|
||||
wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), ['dashicons', 'install']);
|
||||
|
||||
wp_add_inline_style('legacy-signup', $this->get_legacy_dynamic_styles());
|
||||
|
||||
@ -315,9 +315,9 @@ class Legacy_Checkout {
|
||||
|
||||
$checkout_page_slug = 'register';
|
||||
|
||||
$page_name = isset($request['pagename']) ? $request['pagename'] : '';
|
||||
$page_name = $request['pagename'] ?? '';
|
||||
|
||||
if (strncmp((string) $page_name, $checkout_page_slug, strlen($checkout_page_slug)) === 0) {
|
||||
if (str_starts_with((string) $page_name, $checkout_page_slug)) {
|
||||
$page = explode('/', (string) $page_name);
|
||||
|
||||
/**
|
||||
@ -347,13 +347,13 @@ class Legacy_Checkout {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function legacy_signup() {
|
||||
public function legacy_signup(): void {
|
||||
|
||||
status_header(200);
|
||||
|
||||
$this->session = wu_get_session('signup');
|
||||
|
||||
$this->session->set('form', array('not-empty'));
|
||||
$this->session->set('form', ['not-empty']);
|
||||
|
||||
// Apply a filter so we can add steps in the future
|
||||
$this->steps = $this->get_steps();
|
||||
@ -365,9 +365,9 @@ class Legacy_Checkout {
|
||||
|
||||
wu_get_template(
|
||||
'legacy/signup/signup-main',
|
||||
array(
|
||||
[
|
||||
'signup' => $this,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
exit;
|
||||
@ -378,7 +378,7 @@ class Legacy_Checkout {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function check_geolocation() {
|
||||
public function check_geolocation(): void {
|
||||
|
||||
$location = \WP_Ultimo\Geolocation::geolocate_ip();
|
||||
|
||||
@ -425,7 +425,7 @@ class Legacy_Checkout {
|
||||
if (isset($current_step['handler']) && $current_step['handler']) {
|
||||
$handler_function = $current_step['handler'];
|
||||
} else {
|
||||
$handler_function = array($this, 'default_save');
|
||||
$handler_function = [$this, 'default_save'];
|
||||
}
|
||||
|
||||
/** Allows for handler rewrite */
|
||||
@ -441,7 +441,7 @@ class Legacy_Checkout {
|
||||
* @since 1.4.0
|
||||
* @return void
|
||||
*/
|
||||
public function begin_signup() {
|
||||
public function begin_signup(): void {
|
||||
|
||||
/**
|
||||
* Check Geo-location
|
||||
@ -452,9 +452,9 @@ class Legacy_Checkout {
|
||||
$uniqid = uniqid('', true);
|
||||
|
||||
/** Initializes the content holder with the honeypot unique id */
|
||||
$content = array(
|
||||
$content = [
|
||||
'honeypot_id' => uniqid(''),
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Saves the coupon code in the request, only if that option is available
|
||||
@ -519,7 +519,7 @@ class Legacy_Checkout {
|
||||
*/
|
||||
public static function is_customizer(): bool {
|
||||
|
||||
$exclude_list = apply_filters('wu_replace_signup_urls_exclude', array('wu-signup-customizer-preview'));
|
||||
$exclude_list = apply_filters('wu_replace_signup_urls_exclude', ['wu-signup-customizer-preview']);
|
||||
|
||||
foreach ($exclude_list as $replace_word) {
|
||||
if (isset($_GET[ $replace_word ])) {
|
||||
@ -556,7 +556,7 @@ class Legacy_Checkout {
|
||||
$current_step = wu_request('step', current(array_keys($this->steps)));
|
||||
|
||||
// Always get the first step for the customizer //
|
||||
if ($this->is_customizer()) {
|
||||
if (static::is_customizer()) {
|
||||
$current_step = $this->get_first_step();
|
||||
}
|
||||
|
||||
@ -569,7 +569,7 @@ class Legacy_Checkout {
|
||||
* @param string $step The current step.
|
||||
* @return void
|
||||
*/
|
||||
public function get_step_view($step) {
|
||||
public function get_step_view($step): void {
|
||||
|
||||
$transient = $this->session->get('form');
|
||||
$geo = $this->session->get('geolocation');
|
||||
@ -578,7 +578,7 @@ class Legacy_Checkout {
|
||||
* Set the errors
|
||||
*/
|
||||
if ($this->results === null) {
|
||||
$this->results = array('errors' => new \WP_Error());
|
||||
$this->results = ['errors' => new \WP_Error()];
|
||||
}
|
||||
|
||||
if (empty($_POST)) {
|
||||
@ -588,12 +588,12 @@ class Legacy_Checkout {
|
||||
/**
|
||||
* Builds the array containing the available elements inside the template
|
||||
*/
|
||||
$args = array(
|
||||
$args = [
|
||||
'signup' => $this,
|
||||
'transient' => $transient,
|
||||
'fields' => isset($this->steps[ $step ]['fields']) ? $this->steps[ $step ]['fields'] : array(),
|
||||
'fields' => $this->steps[ $step ]['fields'] ?? [],
|
||||
'results' => $this->results,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Checks if anything is passed to the view element
|
||||
@ -626,47 +626,47 @@ class Legacy_Checkout {
|
||||
public function get_steps($include_hidden = true, $filtered = true) {
|
||||
|
||||
// Set the Steps
|
||||
$steps = array();
|
||||
$steps = [];
|
||||
|
||||
// Plan Selector
|
||||
$steps['plan'] = array(
|
||||
$steps['plan'] = [
|
||||
'name' => __('Pick a Plan', 'wp-ultimo'),
|
||||
'desc' => __('Which one of our amazing plans you want to get?', 'wp-ultimo'),
|
||||
'view' => 'step-plans',
|
||||
'handler' => array($this, 'plans_save'),
|
||||
'handler' => [$this, 'plans_save'],
|
||||
'order' => 10,
|
||||
'fields' => false,
|
||||
'core' => true,
|
||||
);
|
||||
];
|
||||
|
||||
$site_templates = array(
|
||||
$site_templates = [
|
||||
2,
|
||||
);
|
||||
];
|
||||
|
||||
// We add template selection if this has template
|
||||
if ($site_templates) {
|
||||
$steps['template'] = array(
|
||||
$steps['template'] = [
|
||||
'name' => __('Template Selection', 'wp-ultimo'),
|
||||
'desc' => __('Select the base template of your new site.', 'wp-ultimo'),
|
||||
'view' => 'step-template',
|
||||
'order' => 20,
|
||||
'handler' => false,
|
||||
'core' => true,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// Domain registering
|
||||
$steps['domain'] = array(
|
||||
$steps['domain'] = [
|
||||
'name' => __('Site Details', 'wp-ultimo'),
|
||||
'desc' => __('Ok, now it\'s time to pick your site url and title!', 'wp-ultimo'),
|
||||
'handler' => array($this, 'domain_save'),
|
||||
'handler' => [$this, 'domain_save'],
|
||||
'view' => false,
|
||||
'order' => 30,
|
||||
'core' => true,
|
||||
'fields' => apply_filters(
|
||||
'wu_signup_fields_domain',
|
||||
array(
|
||||
'blog_title' => array(
|
||||
[
|
||||
'blog_title' => [
|
||||
'order' => 10,
|
||||
'name' => apply_filters('wu_signup_site_title_label', __('Site Title', 'wp-ultimo')),
|
||||
'type' => 'text',
|
||||
@ -675,8 +675,8 @@ class Legacy_Checkout {
|
||||
'tooltip' => apply_filters('wu_signup_site_title_tooltip', __('Select the title your site is going to have.', 'wp-ultimo')),
|
||||
'required' => true,
|
||||
'core' => true,
|
||||
),
|
||||
'blogname' => array(
|
||||
],
|
||||
'blogname' => [
|
||||
'order' => 20,
|
||||
'name' => apply_filters('wu_signup_site_url_label', __('URL', 'wp-ultimo')),
|
||||
'type' => 'text',
|
||||
@ -685,30 +685,30 @@ class Legacy_Checkout {
|
||||
'tooltip' => apply_filters('wu_signup_site_url_tooltip', __('Site urls can only contain lowercase letters (a-z) and numbers and must be at least 4 characters. .', 'wp-ultimo')),
|
||||
'required' => true,
|
||||
'core' => true,
|
||||
),
|
||||
'url_preview' => array(
|
||||
],
|
||||
'url_preview' => [
|
||||
'order' => 30,
|
||||
'name' => __('Site URL Preview', 'wp-ultimo'),
|
||||
'type' => 'html',
|
||||
'content' => wu_get_template_contents('legacy/signup/steps/step-domain-url-preview'),
|
||||
),
|
||||
'submit' => array(
|
||||
],
|
||||
'submit' => [
|
||||
'order' => 100,
|
||||
'type' => 'submit',
|
||||
'name' => __('Continue to the next step', 'wp-ultimo'),
|
||||
'core' => true,
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
),
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Since there are some conditional fields on the accounts step, we need to declare the variable before
|
||||
* so we can append items and filter it later
|
||||
*/
|
||||
$account_fields = array(
|
||||
$account_fields = [
|
||||
|
||||
'user_name' => array(
|
||||
'user_name' => [
|
||||
'order' => 10,
|
||||
'name' => apply_filters('wu_signup_username_label', __('Username', 'wp-ultimo')),
|
||||
'type' => 'text',
|
||||
@ -717,9 +717,9 @@ class Legacy_Checkout {
|
||||
'tooltip' => apply_filters('wu_signup_username_tooltip', __('Username must be at least 4 characters.', 'wp-ultimo')),
|
||||
'required' => true,
|
||||
'core' => true,
|
||||
),
|
||||
],
|
||||
|
||||
'user_email' => array(
|
||||
'user_email' => [
|
||||
'order' => 20,
|
||||
'name' => apply_filters('wu_signup_email_label', __('Email', 'wp-ultimo')),
|
||||
'type' => 'email',
|
||||
@ -728,9 +728,9 @@ class Legacy_Checkout {
|
||||
'tooltip' => apply_filters('wu_signup_email_tooltip', ''),
|
||||
'required' => true,
|
||||
'core' => true,
|
||||
),
|
||||
],
|
||||
|
||||
'user_pass' => array(
|
||||
'user_pass' => [
|
||||
'order' => 30,
|
||||
'name' => apply_filters('wu_signup_password_label', __('Password', 'wp-ultimo')),
|
||||
'type' => 'password',
|
||||
@ -739,9 +739,9 @@ class Legacy_Checkout {
|
||||
'tooltip' => apply_filters('wu_signup_password_tooltip', __('Your password should be at least 6 characters long.', 'wp-ultimo')),
|
||||
'required' => true,
|
||||
'core' => true,
|
||||
),
|
||||
],
|
||||
|
||||
'user_pass_conf' => array(
|
||||
'user_pass_conf' => [
|
||||
'order' => 40,
|
||||
'name' => apply_filters('wu_signup_password_conf_label', __('Confirm Password', 'wp-ultimo')),
|
||||
'type' => 'password',
|
||||
@ -750,28 +750,28 @@ class Legacy_Checkout {
|
||||
'tooltip' => apply_filters('wu_signup_password_conf_tooltip', ''),
|
||||
'required' => true,
|
||||
'core' => true,
|
||||
),
|
||||
],
|
||||
|
||||
/**
|
||||
* HoneyPot Field
|
||||
*/
|
||||
'site_url' => array(
|
||||
'order' => rand(1, 59), // Use random order for Honeypot
|
||||
'site_url' => [
|
||||
'order' => random_int(1, 59), // Use random order for Honeypot
|
||||
'name' => __('Site URL', 'wp-ultimo'),
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
'placeholder' => '',
|
||||
'tooltip' => '',
|
||||
'core' => true,
|
||||
'wrapper_attributes' => array(
|
||||
'wrapper_attributes' => [
|
||||
'style' => 'display: none;',
|
||||
),
|
||||
'attributes' => array(
|
||||
],
|
||||
'attributes' => [
|
||||
'autocomplete' => 'nope',
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Check and Add Coupon Code Fields
|
||||
@ -819,22 +819,22 @@ class Legacy_Checkout {
|
||||
/**
|
||||
* Submit Field
|
||||
*/
|
||||
$account_fields['submit'] = array(
|
||||
$account_fields['submit'] = [
|
||||
'order' => 100,
|
||||
'type' => 'submit',
|
||||
'name' => __('Create Account', 'wp-ultimo'),
|
||||
'core' => true,
|
||||
);
|
||||
];
|
||||
|
||||
// Account registering
|
||||
$steps['account'] = array(
|
||||
$steps['account'] = [
|
||||
'name' => __('Account Details', 'wp-ultimo'),
|
||||
'view' => false,
|
||||
'handler' => array($this, 'account_save'),
|
||||
'handler' => [$this, 'account_save'],
|
||||
'order' => 40,
|
||||
'core' => true,
|
||||
'fields' => apply_filters('wu_signup_fields_account', $account_fields),
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Add additional steps via filters
|
||||
@ -842,21 +842,21 @@ class Legacy_Checkout {
|
||||
$steps = $filtered ? apply_filters('wp_ultimo_registration_steps', $steps) : $steps;
|
||||
|
||||
// Sort elements based on their order
|
||||
uasort($steps, array($this, 'sort_steps_and_fields'));
|
||||
uasort($steps, [$this, 'sort_steps_and_fields']);
|
||||
|
||||
// Sorts each of the fields block
|
||||
foreach ($steps as &$step) {
|
||||
$step = wp_parse_args(
|
||||
$step,
|
||||
array(
|
||||
[
|
||||
'hidden' => false,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
if (isset($step['fields']) && is_array($step['fields'])) {
|
||||
|
||||
// Sort elements based on their order
|
||||
uasort($step['fields'], array($this, 'sort_steps_and_fields'));
|
||||
uasort($step['fields'], [$this, 'sort_steps_and_fields']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -865,32 +865,32 @@ class Legacy_Checkout {
|
||||
*
|
||||
* @since 1.4.0
|
||||
*/
|
||||
$begin_signup = array(
|
||||
'begin-signup' => array(
|
||||
$begin_signup = [
|
||||
'begin-signup' => [
|
||||
'name' => __('Begin Signup Process', 'wp-ultimo'),
|
||||
'handler' => array($this, 'begin_signup'),
|
||||
'handler' => [$this, 'begin_signup'],
|
||||
'view' => false,
|
||||
'hidden' => true,
|
||||
'order' => 0,
|
||||
'core' => true,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Adds the hidden step now responsible for validating data entry and the actual account creation
|
||||
*
|
||||
* @since 1.4.0
|
||||
*/
|
||||
$create_account = array(
|
||||
'create-account' => array(
|
||||
$create_account = [
|
||||
'create-account' => [
|
||||
'name' => __('Creating Account', 'wp-ultimo'),
|
||||
'handler' => array($this, 'create_account'),
|
||||
'handler' => [$this, 'create_account'],
|
||||
'view' => false,
|
||||
'hidden' => true,
|
||||
'core' => true,
|
||||
'order' => 1_000_000_000,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Glue the required steps together with the filterable ones
|
||||
@ -923,9 +923,9 @@ class Legacy_Checkout {
|
||||
public static function get_transient($die = true) {
|
||||
|
||||
if (self::is_customizer()) {
|
||||
$transient = array(
|
||||
$transient = [
|
||||
'not-empty' => '',
|
||||
);
|
||||
];
|
||||
} else {
|
||||
$transient = wu_get_session('signup')->get('form');
|
||||
}
|
||||
@ -936,7 +936,7 @@ class Legacy_Checkout {
|
||||
}
|
||||
|
||||
if (is_null($transient)) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
return $transient;
|
||||
@ -947,7 +947,7 @@ class Legacy_Checkout {
|
||||
*
|
||||
* @param array $transient Array containing the transient data.
|
||||
*/
|
||||
public function update_transient($transient) {
|
||||
public function update_transient($transient): void {
|
||||
|
||||
$this->session->set('form', $transient);
|
||||
|
||||
@ -958,7 +958,7 @@ class Legacy_Checkout {
|
||||
*/
|
||||
public function has_plan_step(): bool {
|
||||
|
||||
$transient = $this->get_transient();
|
||||
$transient = static::get_transient();
|
||||
|
||||
if (isset($transient['skip_plan']) && isset($transient['plan_id']) && isset($transient['plan_freq'])) {
|
||||
return false;
|
||||
@ -973,7 +973,7 @@ class Legacy_Checkout {
|
||||
* @param array $params The params.
|
||||
* @return string The link for the next step
|
||||
*/
|
||||
public function get_next_step_link($params = array()) {
|
||||
public function get_next_step_link($params = []) {
|
||||
|
||||
// Add CS
|
||||
if (isset($_GET['cs'])) {
|
||||
@ -1020,7 +1020,7 @@ class Legacy_Checkout {
|
||||
* @param array $args Arguments to build the URL.
|
||||
* @return void
|
||||
*/
|
||||
public function next_step($args = array()) {
|
||||
public function next_step($args = []): void {
|
||||
|
||||
/** Redirect the user to the next step */
|
||||
wp_redirect(esc_url_raw($this->get_next_step_link($args)));
|
||||
@ -1035,7 +1035,7 @@ class Legacy_Checkout {
|
||||
* @param array $params The params.
|
||||
* @return string The link for the previous step
|
||||
*/
|
||||
public function get_prev_step_link($params = array()) {
|
||||
public function get_prev_step_link($params = []) {
|
||||
|
||||
// Add CS
|
||||
if (isset($_GET['cs'])) {
|
||||
@ -1089,10 +1089,10 @@ class Legacy_Checkout {
|
||||
* @param integer $freq The freq.
|
||||
* @return void
|
||||
*/
|
||||
public function form_fields($current_plan = false, $step = 'plan', $freq = false) {
|
||||
public function form_fields($current_plan = false, $step = 'plan', $freq = false): void {
|
||||
|
||||
/** Select the default frequency */
|
||||
$freq = $freq ? $freq : wu_get_setting('default_pricing_option');
|
||||
$freq = $freq ?: wu_get_setting('default_pricing_option');
|
||||
|
||||
?>
|
||||
|
||||
@ -1127,7 +1127,7 @@ class Legacy_Checkout {
|
||||
*/
|
||||
public function get_site_url_for_previewer() {
|
||||
|
||||
$domain_options = array();
|
||||
$domain_options = [];
|
||||
|
||||
$site = get_current_site();
|
||||
|
||||
@ -1153,10 +1153,10 @@ class Legacy_Checkout {
|
||||
/**
|
||||
* We pass the following info
|
||||
*/
|
||||
public function plans_save() {
|
||||
public function plans_save(): void {
|
||||
|
||||
// Get transient
|
||||
$transient = $this->get_transient();
|
||||
$transient = static::get_transient();
|
||||
|
||||
// Check referer
|
||||
check_admin_referer('signup_form_1', '_signup_form');
|
||||
@ -1200,10 +1200,10 @@ class Legacy_Checkout {
|
||||
/**
|
||||
* Personal Info Settings.
|
||||
*/
|
||||
public function domain_save() {
|
||||
public function domain_save(): void {
|
||||
|
||||
// Get transient
|
||||
$transient = $this->get_transient();
|
||||
$transient = static::get_transient();
|
||||
|
||||
// Check referer
|
||||
check_admin_referer('signup_form_1', '_signup_form');
|
||||
@ -1247,7 +1247,7 @@ class Legacy_Checkout {
|
||||
*/
|
||||
public function filter_post_array($post, $exclude_list = false) {
|
||||
|
||||
$exclude_list = $exclude_list ? $exclude_list : array('_signup_form', '_wp_http_referer');
|
||||
$exclude_list = $exclude_list ?: ['_signup_form', '_wp_http_referer'];
|
||||
|
||||
/** Filter Array */
|
||||
$post = $this->array_filter_key($post, fn($element_key) => ! in_array($element_key, $exclude_list, true));
|
||||
@ -1267,7 +1267,7 @@ class Legacy_Checkout {
|
||||
*/
|
||||
public function array_filter_key(array $array, $callback): array {
|
||||
|
||||
$matched_keys = array_filter(array_keys($array), $callback === null ? fn($v, $k): bool => ! empty($v) : $callback, $callback === null ? ARRAY_FILTER_USE_BOTH : 0);
|
||||
$matched_keys = array_filter(array_keys($array), $callback ?? fn($v, $k): bool => ! empty($v), $callback === null ? ARRAY_FILTER_USE_BOTH : 0);
|
||||
|
||||
return array_intersect_key($array, array_flip($matched_keys));
|
||||
}
|
||||
@ -1296,7 +1296,7 @@ class Legacy_Checkout {
|
||||
* @param array $step The step info.
|
||||
* @return void
|
||||
*/
|
||||
public function add_signup_step($id, $order, $step) {
|
||||
public function add_signup_step($id, $order, $step): void {
|
||||
|
||||
add_filter(
|
||||
'wp_ultimo_registration_steps',
|
||||
@ -1325,7 +1325,7 @@ class Legacy_Checkout {
|
||||
* @param array $field The field.
|
||||
* @return void
|
||||
*/
|
||||
public function add_signup_field($step, $id, $order, $field) {
|
||||
public function add_signup_field($step, $id, $order, $field): void {
|
||||
|
||||
add_filter(
|
||||
'wp_ultimo_registration_steps',
|
||||
|
@ -305,7 +305,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param array $data Array of key => values billing address fields.
|
||||
* @return void
|
||||
*/
|
||||
public function attributes($data) {
|
||||
public function attributes($data): void {
|
||||
/*
|
||||
* Set type first to allow for overriding the other parameters.
|
||||
*/
|
||||
@ -368,7 +368,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param string $type The line item type.
|
||||
* @return void
|
||||
*/
|
||||
public function set_type($type) {
|
||||
public function set_type($type): void {
|
||||
|
||||
$this->type = $type;
|
||||
}
|
||||
@ -407,7 +407,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param Product $product Product associated with this line item.
|
||||
* @return void
|
||||
*/
|
||||
public function set_product($product) {
|
||||
public function set_product($product): void {
|
||||
|
||||
$this->product_id = $product->get_id();
|
||||
|
||||
@ -491,12 +491,12 @@ class Line_Item implements \JsonSerializable {
|
||||
$taxes = 0;
|
||||
}
|
||||
|
||||
$totals = array(
|
||||
$totals = [
|
||||
'subtotal' => $sub_total,
|
||||
'discount_total' => $discounts,
|
||||
'tax_total' => $taxes,
|
||||
'total' => $total,
|
||||
);
|
||||
];
|
||||
|
||||
$this->attributes($totals);
|
||||
|
||||
@ -521,7 +521,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param float $quantity Quantity of the given product.
|
||||
* @return void
|
||||
*/
|
||||
public function set_quantity($quantity) {
|
||||
public function set_quantity($quantity): void {
|
||||
|
||||
$this->quantity = $quantity;
|
||||
}
|
||||
@ -544,7 +544,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param integer $unit_price Unit price of the product.
|
||||
* @return void
|
||||
*/
|
||||
public function set_unit_price($unit_price) {
|
||||
public function set_unit_price($unit_price): void {
|
||||
|
||||
$this->unit_price = $unit_price;
|
||||
}
|
||||
@ -567,7 +567,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param float $tax_rate Tax amount, absolute or percentage.
|
||||
* @return void
|
||||
*/
|
||||
public function set_tax_rate($tax_rate) {
|
||||
public function set_tax_rate($tax_rate): void {
|
||||
|
||||
$this->tax_rate = $tax_rate;
|
||||
}
|
||||
@ -590,7 +590,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param string $tax_type Type of the tax, percentage or absolute.
|
||||
* @return void
|
||||
*/
|
||||
public function set_tax_type($tax_type) {
|
||||
public function set_tax_type($tax_type): void {
|
||||
|
||||
$this->tax_type = $tax_type;
|
||||
}
|
||||
@ -613,7 +613,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param boolean $tax_inclusive If tax are included in the price or not.
|
||||
* @return void
|
||||
*/
|
||||
public function set_tax_inclusive($tax_inclusive) {
|
||||
public function set_tax_inclusive($tax_inclusive): void {
|
||||
|
||||
$this->tax_inclusive = $tax_inclusive;
|
||||
}
|
||||
@ -636,7 +636,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param boolean $tax_exempt If the line item is tax exempt ot not.
|
||||
* @return void
|
||||
*/
|
||||
public function set_tax_exempt($tax_exempt) {
|
||||
public function set_tax_exempt($tax_exempt): void {
|
||||
|
||||
$this->tax_exempt = $tax_exempt;
|
||||
}
|
||||
@ -659,7 +659,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param float $tax_total The amount, in currency, of the tax.
|
||||
* @return void
|
||||
*/
|
||||
public function set_tax_total($tax_total) {
|
||||
public function set_tax_total($tax_total): void {
|
||||
|
||||
$this->tax_total = $tax_total;
|
||||
}
|
||||
@ -682,7 +682,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param float $total The total value of the line.
|
||||
* @return void
|
||||
*/
|
||||
public function set_total($total) {
|
||||
public function set_total($total): void {
|
||||
|
||||
$this->total = $total;
|
||||
}
|
||||
@ -705,7 +705,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param boolean $recurring If this item is recurring or not.
|
||||
* @return void
|
||||
*/
|
||||
public function set_recurring($recurring) {
|
||||
public function set_recurring($recurring): void {
|
||||
|
||||
$this->recurring = $recurring;
|
||||
}
|
||||
@ -728,7 +728,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param float $subtotal Value before taxes, discounts, fees and etc.
|
||||
* @return void
|
||||
*/
|
||||
public function set_subtotal($subtotal) {
|
||||
public function set_subtotal($subtotal): void {
|
||||
|
||||
$this->subtotal = $subtotal;
|
||||
}
|
||||
@ -751,7 +751,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param int $duration The billing cycle duration.
|
||||
* @return void
|
||||
*/
|
||||
public function set_duration($duration) {
|
||||
public function set_duration($duration): void {
|
||||
|
||||
$this->duration = $duration;
|
||||
}
|
||||
@ -774,7 +774,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param string $duration_unit The duration unit.
|
||||
* @return void
|
||||
*/
|
||||
public function set_duration_unit($duration_unit) {
|
||||
public function set_duration_unit($duration_unit): void {
|
||||
|
||||
$this->duration_unit = $duration_unit;
|
||||
}
|
||||
@ -797,7 +797,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param int $billing_cycles The number of billing cycles.
|
||||
* @return void
|
||||
*/
|
||||
public function set_billing_cycles($billing_cycles) {
|
||||
public function set_billing_cycles($billing_cycles): void {
|
||||
|
||||
$this->billing_cycles = $billing_cycles;
|
||||
}
|
||||
@ -820,7 +820,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param float $discount_total The total value of discounts.
|
||||
* @return void
|
||||
*/
|
||||
public function set_discount_total($discount_total) {
|
||||
public function set_discount_total($discount_total): void {
|
||||
|
||||
$this->discount_total = $discount_total;
|
||||
}
|
||||
@ -843,7 +843,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param string $tax_category The tax category.
|
||||
* @return void
|
||||
*/
|
||||
public function set_tax_category($tax_category) {
|
||||
public function set_tax_category($tax_category): void {
|
||||
|
||||
$this->tax_category = $tax_category;
|
||||
}
|
||||
@ -866,7 +866,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param boolean $discountable If the line is discountable.
|
||||
* @return void
|
||||
*/
|
||||
public function set_discountable($discountable) {
|
||||
public function set_discountable($discountable): void {
|
||||
|
||||
$this->discountable = $discountable;
|
||||
}
|
||||
@ -889,7 +889,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param boolean $taxable If the item is taxable or not.
|
||||
* @return void
|
||||
*/
|
||||
public function set_taxable($taxable) {
|
||||
public function set_taxable($taxable): void {
|
||||
|
||||
$this->taxable = $taxable;
|
||||
}
|
||||
@ -912,7 +912,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param float $discount_rate The discount amount (flat or percentage).
|
||||
* @return void
|
||||
*/
|
||||
public function set_discount_rate($discount_rate) {
|
||||
public function set_discount_rate($discount_rate): void {
|
||||
|
||||
$this->discount_rate = $discount_rate;
|
||||
}
|
||||
@ -935,7 +935,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param string $discount_type The type of discount, percentage or absolute.
|
||||
* @return void
|
||||
*/
|
||||
public function set_discount_type($discount_type) {
|
||||
public function set_discount_type($discount_type): void {
|
||||
|
||||
$this->discount_type = $discount_type;
|
||||
}
|
||||
@ -958,7 +958,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param string $discount_label Discount Label.
|
||||
* @return void
|
||||
*/
|
||||
public function set_discount_label($discount_label) {
|
||||
public function set_discount_label($discount_label): void {
|
||||
|
||||
$this->discount_label = $discount_label;
|
||||
}
|
||||
@ -981,7 +981,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param boolean $apply_discount_to_renewals If we should apply discount to renewals.
|
||||
* @return void
|
||||
*/
|
||||
public function set_apply_discount_to_renewals($apply_discount_to_renewals) {
|
||||
public function set_apply_discount_to_renewals($apply_discount_to_renewals): void {
|
||||
|
||||
$this->apply_discount_to_renewals = $apply_discount_to_renewals;
|
||||
}
|
||||
@ -1004,7 +1004,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param int $product_id The product id.
|
||||
* @return void
|
||||
*/
|
||||
public function set_product_id($product_id) {
|
||||
public function set_product_id($product_id): void {
|
||||
|
||||
$this->product_id = $product_id;
|
||||
}
|
||||
@ -1027,7 +1027,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param string $title The line item title.
|
||||
* @return void
|
||||
*/
|
||||
public function set_title($title) {
|
||||
public function set_title($title): void {
|
||||
|
||||
$this->title = $title;
|
||||
}
|
||||
@ -1050,7 +1050,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param string $description The line item description.
|
||||
* @return void
|
||||
*/
|
||||
public function set_description($description) {
|
||||
public function set_description($description): void {
|
||||
|
||||
$this->description = $description;
|
||||
}
|
||||
@ -1073,7 +1073,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param string $tax_label Label of the tax applied.
|
||||
* @return void
|
||||
*/
|
||||
public function set_tax_label($tax_label) {
|
||||
public function set_tax_label($tax_label): void {
|
||||
|
||||
$this->tax_label = $tax_label;
|
||||
}
|
||||
@ -1135,17 +1135,17 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param array $query Query arguments.
|
||||
* @return array
|
||||
*/
|
||||
public static function get_line_items($query = array()) {
|
||||
public static function get_line_items($query = []) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$query = wp_parse_args(
|
||||
$query,
|
||||
array(
|
||||
[
|
||||
'number' => 100,
|
||||
'date_query' => array(),
|
||||
'date_query' => [],
|
||||
'payment_status' => false,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$query['date_query']['column'] = 'p.date_created';
|
||||
@ -1154,7 +1154,7 @@ class Line_Item implements \JsonSerializable {
|
||||
|
||||
$date_query_sql = $date_query->get_sql();
|
||||
|
||||
$taxes_paid_list = array();
|
||||
$taxes_paid_list = [];
|
||||
|
||||
$status_query_sql = '';
|
||||
|
||||
@ -1219,7 +1219,7 @@ class Line_Item implements \JsonSerializable {
|
||||
* @param null|string $product_slug The product slug.
|
||||
* @return void
|
||||
*/
|
||||
public function set_product_slug($product_slug) {
|
||||
public function set_product_slug($product_slug): void {
|
||||
|
||||
$this->product_slug = $product_slug;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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';
|
||||
|
@ -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',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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(),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -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'],
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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' => ' ',
|
||||
'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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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(),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -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(),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -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(),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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'],
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -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' => __('← 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. ← Go Back', 'wp-ultimo'),
|
||||
'value' => __('← 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;
|
||||
|
@ -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'
|
||||
);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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(),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user