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
.phpcs.xml.distcomposer.jsoncomposer.lock
data
inc
admin-pages
class-about-admin-page.phpclass-base-admin-page.phpclass-base-customer-facing-admin-page.phpclass-broadcast-edit-admin-page.phpclass-broadcast-list-admin-page.phpclass-checkout-form-edit-admin-page.phpclass-checkout-form-list-admin-page.phpclass-customer-edit-admin-page.phpclass-customer-list-admin-page.phpclass-customizer-admin-page.phpclass-dashboard-admin-page.phpclass-discount-code-edit-admin-page.phpclass-discount-code-list-admin-page.phpclass-domain-edit-admin-page.phpclass-domain-list-admin-page.phpclass-edit-admin-page.phpclass-email-edit-admin-page.phpclass-email-list-admin-page.phpclass-email-template-customize-admin-page.phpclass-event-list-admin-page.phpclass-event-view-admin-page.phpclass-hosting-integration-wizard-admin-page.phpclass-invoice-template-customize-admin-page.phpclass-jobs-list-admin-page.phpclass-list-admin-page.phpclass-membership-edit-admin-page.phpclass-membership-list-admin-page.phpclass-migration-alert-admin-page.phpclass-payment-edit-admin-page.phpclass-payment-list-admin-page.phpclass-placeholders-admin-page.phpclass-product-edit-admin-page.phpclass-product-list-admin-page.phpclass-settings-admin-page.phpclass-setup-wizard-admin-page.phpclass-shortcodes-admin-page.phpclass-site-edit-admin-page.phpclass-site-list-admin-page.phpclass-system-info-admin-page.phpclass-tax-rates-admin-page.phpclass-template-previewer-customize-admin-page.phpclass-top-admin-nav-menu.phpclass-view-logs-admin-page.phpclass-webhook-edit-admin-page.phpclass-webhook-list-admin-page.phpclass-wizard-admin-page.php
customer-panel
debug
api
builders
checkout
class-cart.phpclass-checkout-pages.phpclass-checkout.phpclass-legacy-checkout.phpclass-line-item.php
signup-fields
class-admin-notices.phpclass-admin-themes-compatibility.phpclass-ajax.phpclass-api.phpclass-async-calls.phpclass-autoloader.phpclass-cron.phpclass-current.phpclass-dashboard-statistics.phpclass-dashboard-widgets.phpclass-documentation.phpclass-domain-mapping.phpclass-faker.phpclass-geolocation.phpclass-helper.phpclass-hooks.phpclass-light-ajax.phpclass-logger.phpclass-maintenance-mode.phpclass-newsletter.phpclass-requirements.phpclass-scripts.phpclass-session-cookie.phpclass-settings.phpclass-sunrise.phpclass-user-switching.phpclass-views.phpclass-whitelabel.phpclass-wp-ultimo.php
compat
country
database
debug
deprecated
development
domain-mapping
duplication
functions
gateways
helpers
installers
integrations
internal
invoices
limitations
limits
list-tables
loaders
managers
models
objects
site-templates
sso
tax
traits
ui
phpstan.neon.distrector.phpsunrise.php
tests
uninstall.php
views
about.phpadmin-notices.php
admin-pages
base
broadcast
emails
checkout
customers
dashboard-statistics
dashboard-widgets
events
legacy
memberships
settings
ui
wizards

@ -46,11 +46,11 @@ class Customer_List_Admin_Page extends List_Admin_Page {
* @since 2.1
* @return void
*/
public function init() {
public function init(): void {
parent::init();
add_action('plugins_loaded', array($this, 'export_customers'));
add_action('plugins_loaded', [$this, 'export_customers']);
}
/**
@ -59,7 +59,7 @@ class Customer_List_Admin_Page extends List_Admin_Page {
* @since 2.1
* @return void
*/
public function export_customers() {
public function export_customers(): void {
if (wu_request('wu_action') !== 'wu_export_customers') {
return;
@ -81,7 +81,7 @@ class Customer_List_Admin_Page extends List_Admin_Page {
$billing_address = array_map(fn($field) => $field['value'], $customer->get_billing_address()->get_fields());
return array_merge(
array(
[
$customer->get_id(),
$customer->get_user_id(),
$customer->get_hash(),
@ -93,12 +93,12 @@ class Customer_List_Admin_Page extends List_Admin_Page {
$customer->get_signup_form(),
$membership_amount,
implode('|', $memberships_ids),
),
],
$billing_address,
array(
[
$customer->get_last_login(),
$customer->get_date_registered(),
)
]
);
},
wu_get_customers()
@ -107,7 +107,7 @@ class Customer_List_Admin_Page extends List_Admin_Page {
$billing_fields = array_keys(\WP_Ultimo\Objects\Billing_Address::fields());
$headers = array_merge(
array(
[
'id',
'user_id',
'customer_hash',
@ -119,17 +119,17 @@ class Customer_List_Admin_Page extends List_Admin_Page {
'signup_form',
'membership_amount',
'membership_ids',
),
],
$billing_fields,
array(
[
'last_login',
'date_registered',
)
]
);
$file_name = sprintf('wp-ultimo-customers-(%s)', gmdate('Y-m-d', wu_get_current_time('timestamp')));
wu_generate_csv($file_name, array_merge(array($headers), $customer_data));
wu_generate_csv($file_name, array_merge([$headers], $customer_data));
die;
}
@ -144,9 +144,9 @@ class Customer_List_Admin_Page extends List_Admin_Page {
* @since 2.0.0
* @var array
*/
protected $supported_panels = array(
protected $supported_panels = [
'network_admin_menu' => 'wu_read_customers',
);
];
/**
* Register ajax forms that we use for payments.
@ -154,17 +154,17 @@ class Customer_List_Admin_Page extends List_Admin_Page {
* @since 2.0.0
* @return void
*/
public function register_forms() {
public function register_forms(): void {
/*
* Add new Customer
*/
wu_register_form(
'add_new_customer',
array(
'render' => array($this, 'render_add_new_customer_modal'),
'handler' => array($this, 'handle_add_new_customer_modal'),
[
'render' => [$this, 'render_add_new_customer_modal'],
'handler' => [$this, 'handle_add_new_customer_modal'],
'capability' => 'wu_invite_customers',
)
]
);
}
@ -174,100 +174,100 @@ class Customer_List_Admin_Page extends List_Admin_Page {
* @since 2.0.0
* @return void
*/
public function render_add_new_customer_modal() {
public function render_add_new_customer_modal(): void {
$fields = array(
'type' => array(
$fields = [
'type' => [
'type' => 'tab-select',
'html_attr' => array(
'html_attr' => [
'v-model' => 'type',
),
'options' => array(
],
'options' => [
'existing' => __('Existing User', 'wp-ultimo'),
'new' => __('Invite New', 'wp-ultimo'),
),
),
'user_id' => array(
],
],
'user_id' => [
'type' => 'model',
'title' => __('Existing User', 'wp-ultimo'),
'placeholder' => __('Search WordPress user...', 'wp-ultimo'),
'tooltip' => '',
'min' => 1,
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-show' => "require('type', 'existing')",
),
'html_attr' => array(
],
'html_attr' => [
'data-model' => 'user',
'data-value-field' => 'ID',
'data-label-field' => 'display_name',
'data-search-field' => 'display_name',
'data-max-items' => 1,
),
),
'username' => array(
],
],
'username' => [
'type' => 'text',
'title' => __('Username', 'wp-ultimo'),
'placeholder' => __('E.g. johnsmith', 'wp-ultimo'),
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-show' => "require('type', 'new')",
),
),
'email_address' => array(
],
],
'email_address' => [
'type' => 'email',
'title' => __('Email Address', 'wp-ultimo'),
'placeholder' => __('E.g. customer@wpultimo.dev', 'wp-ultimo'),
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-show' => "require('type', 'new')",
),
),
'set_password' => array(
],
],
'set_password' => [
'type' => 'toggle',
'title' => __('Set Password', 'wp-ultimo'),
'desc' => __('If not set, the user will be asked to set a password after accepting the invite.', 'wp-ultimo'),
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-show' => "require('type', 'new')",
),
'html_attr' => array(
],
'html_attr' => [
'v-model' => 'set_password',
),
),
'password' => array(
],
],
'password' => [
'type' => 'password',
'title' => __('Password', 'wp-ultimo'),
'placeholder' => __('E.g. p@$$w0rd', 'wp-ultimo'),
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-show' => "require('type', 'new') && require('set_password', true)",
),
),
'submit_button' => array(
],
],
'submit_button' => [
'type' => 'submit',
'title' => __('Create Customer', 'wp-ultimo'),
'value' => 'save',
'classes' => 'button button-primary wu-w-full',
'wrapper_classes' => 'wu-items-end',
'html_attr' => array(
'html_attr' => [
// 'v-bind:disabled' => '!confirmed',
),
),
);
],
],
];
$form = new \WP_Ultimo\UI\Form(
'add_new_customer',
$fields,
array(
[
'views' => 'admin-pages/fields',
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
'html_attr' => array(
'html_attr' => [
'data-wu-app' => 'add_new_customer',
'data-state' => json_encode(
array(
[
'set_password' => false,
'type' => 'existing',
)
]
),
),
)
],
]
);
$form->render();
@ -279,19 +279,19 @@ class Customer_List_Admin_Page extends List_Admin_Page {
* @since 2.0.0
* @return void
*/
public function handle_add_new_customer_modal() {
public function handle_add_new_customer_modal(): void {
if (wu_request('type', 'existing') === 'new') {
$customer_data = array(
$customer_data = [
'email' => wu_request('email_address'),
'username' => wu_request('username'),
'password' => wu_request('password', false),
'meta' => array(),
);
'meta' => [],
];
} else {
$customer_data = array(
$customer_data = [
'user_id' => wu_request('user_id', 0),
);
];
}
/*
@ -304,14 +304,14 @@ class Customer_List_Admin_Page extends List_Admin_Page {
}
wp_send_json_success(
array(
[
'redirect_url' => wu_network_admin_url(
'wp-ultimo-edit-customer',
array(
[
'id' => $customer->get_id(),
)
]
),
)
]
);
}
@ -331,10 +331,10 @@ class Customer_List_Admin_Page extends List_Admin_Page {
*/
public function get_labels() {
return array(
return [
'deleted_message' => __('Customer removed successfully.', 'wp-ultimo'),
'search_label' => __('Search Customer', 'wp-ultimo'),
);
];
}
/**
@ -378,24 +378,24 @@ class Customer_List_Admin_Page extends List_Admin_Page {
*/
public function action_links() {
return array(
array(
return [
[
'label' => __('Add Customer', 'wp-ultimo'),
'icon' => 'wu-circle-with-plus',
'classes' => 'wubox',
'url' => wu_get_form_url('add_new_customer'),
),
array(
],
[
'label' => __('Export as CSV', 'wp-ultimo'),
'icon' => 'wu-export',
'url' => add_query_arg(
array(
[
'wu_action' => 'wu_export_customers',
'nonce' => wp_create_nonce('wu_export_customers'),
)
]
),
),
);
],
];
}
/**