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

@ -71,7 +71,7 @@ class Site_Actions_Element extends Base_Element {
* @since 2.0.0
* @return void
*/
public function register_scripts() {
public function register_scripts(): void {
add_wubox();
}
@ -141,60 +141,60 @@ class Site_Actions_Element extends Base_Element {
*/
public function fields() {
$fields = array();
$fields = [];
$fields['header'] = array(
$fields['header'] = [
'title' => __('General', 'wp-ultimo'),
'desc' => __('General', 'wp-ultimo'),
'type' => 'header',
);
];
$fields['show_change_password'] = array(
$fields['show_change_password'] = [
'type' => 'toggle',
'title' => __('Show Change Password', 'wp-ultimo'),
'desc' => __('Toggle to show/hide the password link.', 'wp-ultimo'),
'tooltip' => '',
'value' => 1,
);
];
$fields['show_change_default_site'] = array(
$fields['show_change_default_site'] = [
'type' => 'toggle',
'title' => __('Show Change Default Site', 'wp-ultimo'),
'desc' => __('Toggle to show/hide the change default site link.', 'wp-ultimo'),
'tooltip' => '',
'value' => 1,
);
];
$fields['show_change_payment_method'] = array(
$fields['show_change_payment_method'] = [
'type' => 'toggle',
'title' => __('Show Change Payment Method', 'wp-ultimo'),
'desc' => __('Toggle to show/hide the option to cancel the current payment method.', 'wp-ultimo'),
'tooltip' => '',
'value' => 1,
);
];
$pages = get_pages(
array(
'exclude' => array(get_the_ID()),
)
[
'exclude' => [get_the_ID()],
]
);
$pages = $pages ? $pages : array();
$pages = $pages ?: [];
$pages_list = array(0 => __('Default', 'wp-ultimo'));
$pages_list = [0 => __('Default', 'wp-ultimo')];
foreach ($pages as $page) {
$pages_list[ $page->ID ] = $page->post_title;
}
$fields['redirect_after_delete'] = array(
$fields['redirect_after_delete'] = [
'type' => 'select',
'title' => __('Redirect After Delete', 'wp-ultimo'),
'value' => 0,
'desc' => __('The page to redirect user after delete current site.', 'wp-ultimo'),
'tooltip' => '',
'options' => $pages_list,
);
];
return $fields;
}
@ -218,13 +218,13 @@ class Site_Actions_Element extends Base_Element {
*/
public function keywords() {
return array(
return [
'WP Ultimo',
'WP Multisite WaaS',
'Actions',
'Form',
'Cart',
);
];
}
/**
@ -243,12 +243,12 @@ class Site_Actions_Element extends Base_Element {
*/
public function defaults() {
return array(
return [
'show_change_password' => 1,
'show_change_default_site' => 1,
'show_change_payment_method' => 1,
'redirect_after_delete' => 0,
);
];
}
/**
@ -257,7 +257,7 @@ class Site_Actions_Element extends Base_Element {
* @since 2.0.0
* @return void
*/
public function setup() {
public function setup(): void {
$this->site = WP_Ultimo()->currents->get_site();
@ -280,7 +280,7 @@ class Site_Actions_Element extends Base_Element {
* @since 2.0.0
* @return void
*/
public function setup_preview() {
public function setup_preview(): void {
$this->site = wu_mock_site();
@ -293,7 +293,7 @@ class Site_Actions_Element extends Base_Element {
* @since 2.0.21
* @return void
*/
public function init() {
public function init(): void {
parent::init();
@ -306,51 +306,51 @@ class Site_Actions_Element extends Base_Element {
* @since 2.0.21
* @return void
*/
public function register_forms() {
public function register_forms(): void {
wu_register_form(
'change_password',
array(
'render' => array($this, 'render_change_password'),
'handler' => array($this, 'handle_change_password'),
[
'render' => [$this, 'render_change_password'],
'handler' => [$this, 'handle_change_password'],
'capability' => 'exist',
)
]
);
wu_register_form(
'delete_site',
array(
'render' => array($this, 'render_delete_site'),
'handler' => array($this, 'handle_delete_site'),
[
'render' => [$this, 'render_delete_site'],
'handler' => [$this, 'handle_delete_site'],
'capability' => 'exist',
)
]
);
wu_register_form(
'change_default_site',
array(
'render' => array($this, 'render_change_default_site'),
'handler' => array($this, 'handle_change_default_site'),
[
'render' => [$this, 'render_change_default_site'],
'handler' => [$this, 'handle_change_default_site'],
'capability' => 'exist',
)
]
);
wu_register_form(
'cancel_payment_method',
array(
'render' => array($this, 'render_cancel_payment_method'),
'handler' => array($this, 'handle_cancel_payment_method'),
[
'render' => [$this, 'render_cancel_payment_method'],
'handler' => [$this, 'handle_cancel_payment_method'],
'capability' => 'exist',
)
]
);
wu_register_form(
'cancel_membership',
array(
'render' => array($this, 'render_cancel_membership'),
'handler' => array($this, 'handle_cancel_membership'),
[
'render' => [$this, 'render_cancel_membership'],
'handler' => [$this, 'handle_cancel_membership'],
'capability' => 'exist',
)
]
);
}
@ -363,58 +363,58 @@ class Site_Actions_Element extends Base_Element {
*/
public function get_actions($atts) {
$actions = array();
$actions = [];
$all_blogs = get_blogs_of_user(get_current_user_id());
$is_template_switching_enabled = wu_get_setting('allow_template_switching', true);
if ($is_template_switching_enabled && $this->site) {
$actions['template_switching'] = array(
$actions['template_switching'] = [
'label' => __('Change Site Template', 'wp-ultimo'),
'icon_classes' => 'dashicons-wu-edit wu-align-middle',
'href' => add_query_arg(
array(
[
'page' => 'wu-template-switching',
),
],
get_admin_url($this->site->get_id())
),
);
];
}
if (count($all_blogs) > 1 && wu_get_isset($atts, 'show_change_default_site')) {
$actions['default_site'] = array(
$actions['default_site'] = [
'label' => __('Change Default Site', 'wp-ultimo'),
'icon_classes' => 'dashicons-wu-edit wu-align-middle',
'classes' => 'wubox',
'href' => wu_get_form_url('change_default_site'),
);
];
}
if (wu_get_isset($atts, 'show_change_password')) {
$actions['change_password'] = array(
$actions['change_password'] = [
'label' => __('Change Password', 'wp-ultimo'),
'icon_classes' => 'dashicons-wu-edit wu-align-middle',
'classes' => 'wubox',
'href' => wu_get_form_url('change_password'),
);
];
}
$payment_gateway = $this->membership ? $this->membership->get_gateway() : false;
if (wu_get_isset($atts, 'show_change_payment_method') && $payment_gateway) {
$actions['cancel_payment_method'] = array(
$actions['cancel_payment_method'] = [
'label' => __('Cancel Current Payment Method', 'wp-ultimo'),
'icon_classes' => 'dashicons-wu-edit wu-align-middle',
'classes' => 'wubox',
'href' => wu_get_form_url(
'cancel_payment_method',
array(
[
'membership' => $this->membership->get_hash(),
'redirect_url' => wu_get_current_url(),
)
]
),
);
];
}
return apply_filters('wu_element_get_site_actions', $actions, $atts, $this->site, $this->membership);
@ -429,44 +429,44 @@ class Site_Actions_Element extends Base_Element {
*/
public function get_danger_zone_actions($atts) {
$actions = array();
$actions = [];
if ($this->site) {
$actions = array_merge(
array(
'delete_site' => array(
[
'delete_site' => [
'label' => __('Delete Site', 'wp-ultimo'),
'icon_classes' => 'dashicons-wu-edit wu-align-middle',
'classes' => 'wubox wu-text-red-500',
'href' => wu_get_form_url(
'delete_site',
array(
[
'site' => $this->site->get_hash(),
'redirect_url' => ! $atts['redirect_after_delete'] ? false : get_page_link($atts['redirect_after_delete']),
)
]
),
),
),
],
],
$actions
);
}
if ($this->membership && $this->membership->is_recurring() && $this->membership->get_status() !== Membership_Status::CANCELLED) {
$actions = array_merge(
array(
'cancel_membership' => array(
[
'cancel_membership' => [
'label' => __('Cancel Membership', 'wp-ultimo'),
'icon_classes' => 'dashicons-wu-edit wu-align-middle',
'classes' => 'wubox wu-text-red-500',
'href' => wu_get_form_url(
'cancel_membership',
array(
[
'membership' => $this->membership->get_hash(),
'redirect_url' => wu_get_current_url(),
)
]
),
),
),
],
],
$actions
);
}
@ -480,7 +480,7 @@ class Site_Actions_Element extends Base_Element {
* @since 2.0.21
* @return void
*/
public function render_delete_site() {
public function render_delete_site(): void {
$site = wu_get_site_by_hash(wu_request('site'));
@ -497,21 +497,21 @@ class Site_Actions_Element extends Base_Element {
}
if ( ! empty($error)) {
$error_field = array(
'error_message' => array(
$error_field = [
'error_message' => [
'type' => 'note',
'desc' => $error,
),
);
],
];
$form = new \WP_Ultimo\UI\Form(
'change_password',
$error_field,
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',
)
]
);
$form->render();
@ -519,52 +519,52 @@ class Site_Actions_Element extends Base_Element {
return;
}
$fields = array(
'site' => array(
$fields = [
'site' => [
'type' => 'hidden',
'value' => wu_request('site'),
),
'redirect_url' => array(
],
'redirect_url' => [
'type' => 'hidden',
'value' => wu_request('redirect_url'),
),
'confirm' => array(
],
'confirm' => [
'type' => 'toggle',
'title' => __('Confirm Site Deletion', 'wp-ultimo'),
'desc' => __('This action can not be undone.', 'wp-ultimo'),
'html_attr' => array(
'html_attr' => [
'v-model' => 'confirmed',
),
),
'submit_button' => array(
],
],
'submit_button' => [
'type' => 'submit',
'title' => __('Delete Site', 'wp-ultimo'),
'placeholder' => __('Delete Site', '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(
'change_password',
$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' => 'change_password',
'data-state' => wu_convert_to_state(
array(
[
'confirmed' => false,
)
]
),
),
)
],
]
);
$form->render();
@ -614,16 +614,16 @@ class Site_Actions_Element extends Base_Element {
$redirect_url = wu_request('redirect_url');
$redirect_url = add_query_arg(
array(
[
'site_deleted' => true,
),
],
wu_request('redirect_url') ?? user_admin_url()
);
wp_send_json_success(
array(
[
'redirect_url' => $redirect_url,
)
]
);
}
@ -633,49 +633,49 @@ class Site_Actions_Element extends Base_Element {
* @since 2.0.21
* @return void
*/
public function render_change_password() {
public function render_change_password(): void {
$fields = array(
'password' => array(
$fields = [
'password' => [
'type' => 'password',
'title' => __('Current Password', 'wp-ultimo'),
'placeholder' => __('******', 'wp-ultimo'),
),
'new_password' => array(
],
'new_password' => [
'type' => 'password',
'title' => __('New Password', 'wp-ultimo'),
'placeholder' => __('******', 'wp-ultimo'),
'meter' => true,
),
'new_password_conf' => array(
],
'new_password_conf' => [
'type' => 'password',
'placeholder' => __('******', 'wp-ultimo'),
'title' => __('Confirm New Password', 'wp-ultimo'),
),
'submit_button' => array(
],
'submit_button' => [
'type' => 'submit',
'title' => __('Reset Password', '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(
'change_password',
$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' => 'change_password',
'data-state' => wu_convert_to_state(),
),
)
],
]
);
$form->render();
@ -687,7 +687,7 @@ class Site_Actions_Element extends Base_Element {
* @since 2.0.21
* @return void
*/
public function handle_change_password() {
public function handle_change_password(): void {
$user = wp_get_current_user();
@ -728,9 +728,9 @@ class Site_Actions_Element extends Base_Element {
do_action('wp_login', $user->user_login, $user); // PHPCS:ignore
wp_send_json_success(
array(
[
'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']),
)
]
);
}
@ -740,11 +740,11 @@ class Site_Actions_Element extends Base_Element {
* @since 2.0.21
* @return void
*/
public function render_change_default_site() {
public function render_change_default_site(): void {
$all_blogs = get_blogs_of_user(get_current_user_id());
$option_blogs = array();
$option_blogs = [];
foreach ($all_blogs as $key => $blog) {
$option_blogs[ $blog->userblog_id ] = get_home_url($blog->userblog_id);
@ -752,45 +752,45 @@ class Site_Actions_Element extends Base_Element {
$primary_blog = get_user_meta(get_current_user_id(), 'primary_blog', true);
$fields = array(
'new_primary_site' => array(
$fields = [
'new_primary_site' => [
'type' => 'select',
'title' => __('Primary Site', 'wp-ultimo'),
'desc' => __('Change the primary site of your network.', 'wp-ultimo'),
'options' => $option_blogs,
'value' => $primary_blog,
'html_attr' => array(
'html_attr' => [
'v-model' => 'new_primary_site',
),
),
'submit_button' => array(
],
],
'submit_button' => [
'type' => 'submit',
'title' => __('Change Default Site', 'wp-ultimo'),
'value' => 'save',
'classes' => 'button button-primary wu-w-full',
'wrapper_classes' => 'wu-items-end',
'html_attr' => array(
'html_attr' => [
'v-bind:disabled' => 'new_primary_site === "' . $primary_blog . '"',
),
),
);
],
],
];
$form = new \WP_Ultimo\UI\Form(
'change_default_site',
$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' => 'change_default_site',
'data-state' => wu_convert_to_state(
array(
[
'new_primary_site' => $primary_blog,
)
]
),
),
)
],
]
);
$form->render();
@ -802,7 +802,7 @@ class Site_Actions_Element extends Base_Element {
* @since 2.0.21
* @return void
*/
public function handle_change_default_site() {
public function handle_change_default_site(): void {
$new_primary_site = wu_request('new_primary_site');
@ -810,9 +810,9 @@ class Site_Actions_Element extends Base_Element {
update_user_meta(get_current_user_id(), 'primary_blog', $new_primary_site);
wp_send_json_success(
array(
[
'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']),
)
]
);
}
@ -827,7 +827,7 @@ class Site_Actions_Element extends Base_Element {
* @since 2.1.2
* @return void
*/
public function render_cancel_payment_method() {
public function render_cancel_payment_method(): void {
$membership = wu_get_membership_by_hash(wu_request('membership'));
@ -844,21 +844,21 @@ class Site_Actions_Element extends Base_Element {
}
if ( ! empty($error)) {
$error_field = array(
'error_message' => array(
$error_field = [
'error_message' => [
'type' => 'note',
'desc' => $error,
),
);
],
];
$form = new \WP_Ultimo\UI\Form(
'cancel_payment_method',
$error_field,
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',
)
]
);
$form->render();
@ -866,52 +866,52 @@ class Site_Actions_Element extends Base_Element {
return;
}
$fields = array(
'membership' => array(
$fields = [
'membership' => [
'type' => 'hidden',
'value' => wu_request('membership'),
),
'redirect_url' => array(
],
'redirect_url' => [
'type' => 'hidden',
'value' => wu_request('redirect_url'),
),
'confirm' => array(
],
'confirm' => [
'type' => 'toggle',
'title' => __('Confirm Payment Method Cancellation', 'wp-ultimo'),
'desc' => __('This action can not be undone.', 'wp-ultimo'),
'html_attr' => array(
'html_attr' => [
'v-model' => 'confirmed',
),
),
'submit_button' => array(
],
],
'submit_button' => [
'type' => 'submit',
'title' => __('Cancel Payment Method', 'wp-ultimo'),
'placeholder' => __('Cancel Payment Method', '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(
'cancel_payment_method',
$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' => 'cancel_payment_method',
'data-state' => wu_convert_to_state(
array(
[
'confirmed' => false,
)
]
),
),
)
],
]
);
$form->render();
@ -923,7 +923,7 @@ class Site_Actions_Element extends Base_Element {
* @since 2.1.2
* @return void
*/
public function handle_cancel_payment_method() {
public function handle_cancel_payment_method(): void {
$membership = wu_get_membership_by_hash(wu_request('membership'));
@ -955,16 +955,16 @@ class Site_Actions_Element extends Base_Element {
$redirect_url = wu_request('redirect_url');
$redirect_url = add_query_arg(
array(
[
'payment_gateway_cancelled' => true,
),
],
$redirect_url ?? user_admin_url()
);
wp_send_json_success(
array(
[
'redirect_url' => $redirect_url,
)
]
);
}
@ -974,7 +974,7 @@ class Site_Actions_Element extends Base_Element {
* @since 2.1.2
* @return void
*/
public function render_cancel_membership() {
public function render_cancel_membership(): void {
$membership = wu_get_membership_by_hash(wu_request('membership'));
@ -991,21 +991,21 @@ class Site_Actions_Element extends Base_Element {
}
if ( ! empty($error)) {
$error_field = array(
'error_message' => array(
$error_field = [
'error_message' => [
'type' => 'note',
'desc' => $error,
),
);
],
];
$form = new \WP_Ultimo\UI\Form(
'cancel_membership',
$error_field,
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',
)
]
);
$form->render();
@ -1013,24 +1013,24 @@ class Site_Actions_Element extends Base_Element {
return;
}
$fields = array(
'membership' => array(
$fields = [
'membership' => [
'type' => 'hidden',
'value' => wu_request('membership'),
),
'redirect_url' => array(
],
'redirect_url' => [
'type' => 'hidden',
'value' => wu_request('redirect_url'),
),
'cancellation_reason' => array(
],
'cancellation_reason' => [
'type' => 'select',
'title' => __('Please tell us why you are cancelling.', 'wp-ultimo'),
'desc' => __('We would love your feedback.', 'wp-ultimo'),
'html_attr' => array(
'html_attr' => [
'v-model' => 'cancellation_reason',
),
],
'default' => '',
'options' => array(
'options' => [
'' => __('Select a reason', 'wp-ultimo'),
'unused' => __('I no longer need it', 'wp-ultimo'),
'too_expensive' => __('It\'s too expensive', 'wp-ultimo'),
@ -1039,23 +1039,23 @@ class Site_Actions_Element extends Base_Element {
'customer_service' => __('Customer support is less than expected', 'wp-ultimo'),
'too_complex' => __('Too complex', 'wp-ultimo'),
'other' => __('Other', 'wp-ultimo'),
),
),
'cancellation_explanation' => array(
],
],
'cancellation_explanation' => [
'type' => 'textarea',
'title' => __('Please provide additional details.', 'wp-ultimo'),
'wrapper_html_attr' => array(
'wrapper_html_attr' => [
'v-show' => 'cancellation_reason === "other"',
),
),
'confirm' => array(
],
],
'confirm' => [
'type' => 'text',
'title' => __('Type <code class="wu-text-red-600">CANCEL</code> to confirm this membership cancellation.', 'wp-ultimo'),
'html_attr' => array(
'html_attr' => [
'v-model' => 'confirmation',
),
),
);
],
],
];
$next_charge = false;
@ -1064,42 +1064,42 @@ class Site_Actions_Element extends Base_Element {
}
if ($next_charge && $next_charge > time()) {
$fields['next_charge'] = array(
$fields['next_charge'] = [
'type' => 'note',
// translators: %s: Next charge date.
'desc' => sprintf(__('Your sites will stay working until %s.', 'wp-ultimo'), date_i18n(get_option('date_format'), $next_charge)),
);
];
}
$fields['submit_button'] = array(
$fields['submit_button'] = [
'type' => 'submit',
'title' => __('Cancel Membership', 'wp-ultimo'),
'placeholder' => __('Cancel Membership', 'wp-ultimo'),
'value' => 'save',
'classes' => 'button button-primary wu-w-full',
'wrapper_classes' => 'wu-items-end',
'html_attr' => array(
'html_attr' => [
'v-bind:disabled' => 'confirmation !== "' . __('CANCEL', 'wp-ultimo') . '" || cancellation_reason === ""',
),
);
],
];
$form = new \WP_Ultimo\UI\Form(
'cancel_membership',
$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' => 'cancel_membership',
'data-state' => wu_convert_to_state(
array(
[
'confirmation' => '',
'cancellation_reason' => '',
)
]
),
),
)
],
]
);
$form->render();
@ -1111,7 +1111,7 @@ class Site_Actions_Element extends Base_Element {
* @since 2.1.2
* @return void
*/
public function handle_cancel_membership() {
public function handle_cancel_membership(): void {
$membership = wu_get_membership_by_hash(wu_request('membership'));
@ -1133,7 +1133,7 @@ class Site_Actions_Element extends Base_Element {
return;
}
$cancellation_options = array(
$cancellation_options = [
'unused' => __('I no longer need it', 'wp-ultimo'),
'too_expensive' => __('It\'s too expensive', 'wp-ultimo'),
'missing_features' => __('I need more features', 'wp-ultimo'),
@ -1141,7 +1141,7 @@ class Site_Actions_Element extends Base_Element {
'customer_service' => __('Customer support is less than expected', 'wp-ultimo'),
'too_complex' => __('Too complex', 'wp-ultimo'),
'other' => wu_request('cancellation_explanation'),
);
];
$reason = wu_get_isset($cancellation_options, wu_request('cancellation_reason'), '');
@ -1150,16 +1150,16 @@ class Site_Actions_Element extends Base_Element {
$redirect_url = wu_request('redirect_url');
$redirect_url = add_query_arg(
array(
[
'payment_gateway_cancelled' => true,
),
],
! empty($redirect_url) ? $redirect_url : user_admin_url()
);
wp_send_json_success(
array(
[
'redirect_url' => $redirect_url,
)
]
);
}