Use PHP 7.4 featers and PHP 8 polyfills

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

View File

@ -16,9 +16,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-title',
array(
[
'field' => $field,
)
]
);
?>
@ -44,9 +44,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-errors',
array(
[
'field' => $field,
)
]
);
?>

View File

@ -28,9 +28,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-errors',
array(
[
'field' => $field,
)
]
);
?>

View File

@ -18,9 +18,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-title',
array(
[
'field' => $field,
)
]
);
?>
@ -34,15 +34,15 @@
$form = new \WP_Ultimo\UI\Form(
$field->id,
$field->fields,
array(
[
'views' => 'checkout/fields',
'classes' => 'wu-flex wu-my-1',
'field_wrapper_classes' => 'wu-bg-transparent',
'wrap_tag' => 'span',
'step' => (object) array(
'step' => (object) [
'classes' => '',
),
)
],
]
);
$form->render();
@ -54,9 +54,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-errors',
array(
[
'field' => $field,
)
]
);
?>

View File

@ -29,9 +29,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-errors',
array(
[
'field' => $field,
)
]
);
?>

View File

@ -19,9 +19,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-title',
array(
[
'field' => $field,
)
]
);
/**
@ -31,9 +31,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-description',
array(
[
'field' => $field,
)
]
);
?>
@ -53,9 +53,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-errors',
array(
[
'field' => $field,
)
]
);
?>

View File

@ -16,9 +16,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-title',
array(
[
'field' => $field,
)
]
);
?>
@ -48,9 +48,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-errors',
array(
[
'field' => $field,
)
]
);
?>

View File

@ -19,9 +19,9 @@ $active_gateways = wu_get_active_gateway_as_options();
*/
wu_get_template(
'checkout/fields/partials/field-title',
array(
[
'field' => $field,
)
]
);
?>
@ -71,9 +71,9 @@ $active_gateways = wu_get_active_gateway_as_options();
*/
wu_get_template(
'checkout/fields/partials/field-errors',
array(
[
'field' => $field,
)
]
);
/**

View File

@ -16,9 +16,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-title',
array(
[
'field' => $field,
)
]
);
?>
@ -44,9 +44,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-errors',
array(
[
'field' => $field,
)
]
);
?>

View File

@ -16,9 +16,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-title',
array(
[
'field' => $field,
)
]
);
?>
@ -44,9 +44,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-errors',
array(
[
'field' => $field,
)
]
);
?>

View File

@ -16,9 +16,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-title',
array(
[
'field' => $field,
)
]
);
?>
@ -65,9 +65,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-errors',
array(
[
'field' => $field,
)
]
);
?>

View File

@ -16,9 +16,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-title',
array(
[
'field' => $field,
)
]
);
?>
@ -27,7 +27,7 @@
<div class="sm:wu-flex wu-items-stretch wu-content-center">
<div <?php echo wu_array_to_html_attrs($field->prefix_html_attr ?? array()); ?>>
<div <?php echo wu_array_to_html_attrs($field->prefix_html_attr ?? []); ?>>
<?php echo $field->prefix; ?>
</div>
@ -37,7 +37,7 @@
<?php if ($field->suffix) : ?>
<div <?php echo wu_array_to_html_attrs($field->suffix_html_attr ?? array()); ?>>
<div <?php echo wu_array_to_html_attrs($field->suffix_html_attr ?? []); ?>>
<?php echo $field->suffix; ?>
</div>
@ -58,9 +58,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-errors',
array(
[
'field' => $field,
)
]
);
?>

View File

@ -28,9 +28,9 @@
*/
wu_get_template(
'checkout/fields/partials/field-errors',
array(
[
'field' => $field,
)
]
);
?>

View File

@ -28,18 +28,18 @@
$form = new \WP_Ultimo\UI\Form(
"checkout-{$step_name}",
$final_fields,
array(
[
'title' => $display_title ? $step['name'] : '',
'views' => 'checkout/fields',
'classes' => wu_get_isset($step, 'classes', '') . ' wu-grid wu-grid-cols-2 wu-gap-4',
'field_wrapper_classes' => 'wu-col-span-2',
'html_attr' => array(
'id' => wu_get_isset($step, 'element_id') ? wu_get_isset($step, 'element_id') : "wu-step-{$step_name}",
),
'variables' => array(
'html_attr' => [
'id' => wu_get_isset($step, 'element_id') ?: "wu-step-{$step_name}",
],
'variables' => [
'step' => (object) $step,
),
)
],
]
);
/**

View File

@ -7,7 +7,7 @@
$is_trial_setup = $membership->is_trialing() && empty($payment->get_total());
$notes = array();
$notes = [];
if ($is_trial_setup) {
$desc = $membership->get_recurring_description();
@ -24,7 +24,7 @@ $should_auto_renew = ! empty($original_cart) ? $original_cart->should_auto_renew
$recurring_total = $membership->get_amount();
if ($membership->is_recurring() && $should_auto_renew) {
$payment_total = $payment->get_total() ? $payment->get_total() : $membership->get_initial_amount();
$payment_total = $payment->get_total() ?: $membership->get_initial_amount();
$desc = $membership->get_recurring_description();

View File

@ -10,10 +10,10 @@
$order_form = new \WP_Ultimo\UI\Form(
'product-fields',
$product_fields,
array(
[
'title' => __('Products', 'wp-ultimo'),
'views' => 'checkout/fields',
)
]
);
/**
@ -29,7 +29,7 @@
*
* @since 2.0.0
*/
$submit = new \WP_Ultimo\UI\Form('submit-fields', $submit_fields, array('views' => 'checkout/fields'));
$submit = new \WP_Ultimo\UI\Form('submit-fields', $submit_fields, ['views' => 'checkout/fields']);
/**
* Render form fields.

View File

@ -13,7 +13,7 @@
* @param string $label The field label.
*/
$products_to_reduce = array_merge(array(false), $products);
$products_to_reduce = array_merge([false], $products);
$first_recurring_product = array_reduce(
$products_to_reduce,
@ -195,7 +195,7 @@ if ($first_recurring_product !== null) {
* Price display.
*/
$symbol_left = in_array(wu_get_setting('currency_position', '%s%v'), array('%s%v', '%s %v'));
$symbol_left = in_array(wu_get_setting('currency_position', '%s%v'), ['%s%v', '%s %v']);
?>
@ -222,7 +222,7 @@ if ($first_recurring_product !== null) {
</span>
<?php
foreach (array(3, 12) as $freq) :
foreach ([3, 12] as $freq) :
$price_variation = $product->get_price_variation($freq, 'month');
if ( ! $price_variation) {
@ -303,10 +303,10 @@ if ($first_recurring_product !== null) {
*
* Display quarterly and Annually plans, to be hidden.
*/
$prices_total = array(
$prices_total = [
3 => __('every 3 months', 'wp-ultimo'),
12 => __('yearly', 'wp-ultimo'),
);
];
foreach ($prices_total as $freq => $string) {
$price_variation = $product->get_price_variation($freq, 'month');

View File

@ -25,13 +25,13 @@ if (isset($should_display) && ! $should_display) {
return;
} // end if;
$sites = array_map('wu_get_site', isset($sites) ? $sites : array());
$sites = array_map('wu_get_site', $sites ?? []);
$categories = isset($categories) ? $categories : array();
$categories ??= [];
$customer_sites_category = __('Your Sites', 'wp_ultimo');
$customer_sites = isset($customer_sites) ? array_map('intval', $customer_sites) : array();
$customer_sites = isset($customer_sites) ? array_map('intval', $customer_sites) : [];
?>
@ -82,7 +82,7 @@ $customer_sites = isset($customer_sites) ? array_map('intval', $customer_sites)
</ul>
<div id="wu-site-template-container-grid" class="wu-grid wu-grid-cols-1 sm:wu-grid-cols-2 md:wu-grid-cols-<?php echo isset($cols) ? $cols : '3'; ?> wu-gap-4">
<div id="wu-site-template-container-grid" class="wu-grid wu-grid-cols-1 sm:wu-grid-cols-2 md:wu-grid-cols-<?php echo $cols ?? '3'; ?> wu-gap-4">
<?php foreach ($sites as $site_template) : ?>
@ -93,7 +93,7 @@ $customer_sites = isset($customer_sites) ? array_map('intval', $customer_sites)
<?php $is_template = $site_template->get_type() === 'site_template'; ?>
<?php $categories = array_merge($site_template->get_categories(), ! $is_template ? array($customer_sites_category) : array()); ?>
<?php $categories = array_merge($site_template->get_categories(), ! $is_template ? [$customer_sites_category] : []); ?>
<div
id="wu-site-template-<?php echo esc_attr($site_template->get_id()); ?>"

View File

@ -22,13 +22,13 @@ if ( ! $should_display) {
return;
} // end if;
$sites = array_map('wu_get_site', isset($sites) ? $sites : array());
$sites = array_map('wu_get_site', $sites ?? []);
$categories = isset($categories) ? $categories : array();
$categories ??= [];
$customer_sites_category = __('Your Sites', 'wp_ultimo');
$customer_sites = isset($customer_sites) ? array_map('intval', $customer_sites) : array();
$customer_sites = isset($customer_sites) ? array_map('intval', $customer_sites) : [];
?>
@ -181,7 +181,7 @@ $customer_sites = isset($customer_sites) ? array_map('intval', $customer_sites)
<?php $is_template = $site->get_type() === 'site_template'; ?>
<?php $categories = array_merge($site->get_categories(), ! $is_template ? array($customer_sites_category) : array()); ?>
<?php $categories = array_merge($site->get_categories(), ! $is_template ? [$customer_sites_category] : []); ?>
<div
class="theme"

View File

@ -22,13 +22,13 @@ if ( ! $should_display) {
return;
} // end if;
$sites = array_map('wu_get_site', isset($sites) ? $sites : array());
$sites = array_map('wu_get_site', $sites ?? []);
$categories = isset($categories) ? $categories : array();
$categories ??= [];
$customer_sites_category = __('Your Sites', 'wp_ultimo');
$customer_sites = isset($customer_sites) ? array_map('intval', $customer_sites) : array();
$customer_sites = isset($customer_sites) ? array_map('intval', $customer_sites) : [];
?>
<div id="wu-site-template-container">
@ -89,7 +89,7 @@ $customer_sites = isset($customer_sites) ? array_map('intval', $customer_sites)
<?php $is_template = $site_template->get_type() === 'site_template'; ?>
<?php $categories = array_merge($site_template->get_categories(), ! $is_template ? array($customer_sites_category) : array()); ?>
<?php $categories = array_merge($site_template->get_categories(), ! $is_template ? [$customer_sites_category] : []); ?>
<div
id="wu-site-template-<?php echo esc_attr($site_template->get_id()); ?>"