';
- $fields[$field_name] = array(
+ $fields[ $field_name ] = array(
'type' => 'toggle',
'title' => $field_title,
'desc' => $default_email_value['event'] . ' ' . $default_email_value['target'] . '',
@@ -422,14 +422,10 @@ class Email_List_Admin_Page extends List_Admin_Page {
);
if (isset($fields['import_note'])) {
-
unset($fields['import_note']);
-
- } // end if;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
+ }
$fields['submit_button'] = array(
'type' => 'submit',
@@ -439,22 +435,27 @@ class Email_List_Admin_Page extends List_Admin_Page {
'wrapper_classes' => 'wu-items-end wu-text-right',
);
- $form = new \WP_Ultimo\UI\Form('reset_import', $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(
- 'data-wu-app' => 'reset_import',
- 'data-state' => json_encode(array(
- 'reset_emails' => false,
- 'import_emails' => false
- )),
- ),
- ));
+ $form = new \WP_Ultimo\UI\Form(
+ 'reset_import',
+ $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(
+ 'data-wu-app' => 'reset_import',
+ 'data-state' => json_encode(
+ array(
+ 'reset_emails' => false,
+ 'import_emails' => false,
+ )
+ ),
+ ),
+ )
+ );
$form->render();
-
- } // end render_reset_import_modal;
+ }
/**
* Handles the modal to reset or import system emails.
@@ -474,48 +475,37 @@ class Email_List_Admin_Page extends List_Admin_Page {
$created_emails = wu_get_all_system_emails();
if ($reset) {
-
foreach ($created_emails as $created_email) {
-
$slug = $created_email->get_slug();
$maybe_reset = wu_request('reset_' . $slug, '');
if ($maybe_reset) {
-
$created_email->delete();
wu_create_default_system_email($slug);
-
- } // end if;
-
- } // end foreach;
-
- } // end if;
+ }
+ }
+ }
if ($import) {
-
foreach ($default_system_emails as $default_system_emails_key => $default_system_emails_value) {
-
$slug = $default_system_emails_value['slug'];
$maybe_import = wu_request('import_' . $slug, '');
if ($maybe_import) {
-
wu_create_default_system_email($slug);
+ }
+ }
+ }
- } // end if;
-
- } // end foreach;
-
- } // end if;
-
- wp_send_json_success(array(
- 'redirect_url' => wu_network_admin_url('wp-ultimo-emails')
- ));
-
- } // end handle_reset_import_modal;
+ wp_send_json_success(
+ array(
+ 'redirect_url' => wu_network_admin_url('wp-ultimo-emails'),
+ )
+ );
+ }
/**
* Handles the redirect notice from sent new test modal.
@@ -526,9 +516,7 @@ class Email_List_Admin_Page extends List_Admin_Page {
public function handle_page_redirect($page) {
if ($page->get_id() === 'wp-ultimo-emails') {
-
if (wu_request('notice')) {
-
$notice = wu_request('notice');
?>
@@ -541,11 +529,9 @@ class Email_List_Admin_Page extends List_Admin_Page {
0,
'html_attr' => array(
'required' => 'required',
- )
+ ),
),
'email_id' => array(
'type' => 'hidden',
@@ -578,18 +564,21 @@ class Email_List_Admin_Page extends List_Admin_Page {
),
);
- $form = new \WP_Ultimo\UI\Form('reset_confirmation', $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(
- 'data-wu-app' => 'reset_confirmation',
- ),
- ));
+ $form = new \WP_Ultimo\UI\Form(
+ 'reset_confirmation',
+ $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(
+ 'data-wu-app' => 'reset_confirmation',
+ ),
+ )
+ );
$form->render();
-
- } // end render_reset_confirmation_modal;
+ }
/**
* Handles the reset confirmation modal.
@@ -604,13 +593,11 @@ class Email_List_Admin_Page extends List_Admin_Page {
$email_id = wu_request('email_id');
- if (!$single_reset || !$email_id) {
-
+ if ( ! $single_reset || ! $email_id) {
$error = new \WP_Error('error', __('Something wrong happened.', 'wp-ultimo'));
return wp_send_json_error($error);
-
- } // end if;
+ }
$email = wu_get_email($email_id);
@@ -618,31 +605,31 @@ class Email_List_Admin_Page extends List_Admin_Page {
$default_system_emails = wu_get_default_system_emails();
- if (isset($default_system_emails[$slug])) {
-
+ if (isset($default_system_emails[ $slug ])) {
$email->delete();
wu_create_default_system_email($slug);
$new_email = wu_get_email_by('slug', $slug);
- if (!$new_email) {
-
+ if ( ! $new_email) {
$error = new \WP_Error('error', __('Something wrong happened.', 'wp-ultimo'));
return wp_send_json_error($error);
+ }
- } // end if;
-
- wp_send_json_success(array(
- 'redirect_url' => wu_network_admin_url('wp-ultimo-edit-email', array(
- 'id' => $new_email->get_id(),
- ))
- ));
-
- } // end if;
-
- } // end handle_reset_confirmation_modal;
+ wp_send_json_success(
+ array(
+ 'redirect_url' => wu_network_admin_url(
+ 'wp-ultimo-edit-email',
+ array(
+ 'id' => $new_email->get_id(),
+ )
+ ),
+ )
+ );
+ }
+ }
/**
* Returns the action links for that page.
@@ -672,8 +659,7 @@ class Email_List_Admin_Page extends List_Admin_Page {
'icon' => 'wu-cycle',
),
);
-
- } // end action_links;
+ }
/**
* Loads the list table for this particular page.
@@ -684,7 +670,5 @@ class Email_List_Admin_Page extends List_Admin_Page {
public function table() {
return new \WP_Ultimo\List_Tables\Email_List_Table();
-
- } // end table;
-
-} // end class Email_List_Admin_Page;
+ }
+}
diff --git a/inc/admin-pages/class-email-template-customize-admin-page.php b/inc/admin-pages/class-email-template-customize-admin-page.php
index 8d1f05a..8445a49 100644
--- a/inc/admin-pages/class-email-template-customize-admin-page.php
+++ b/inc/admin-pages/class-email-template-customize-admin-page.php
@@ -81,8 +81,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
parent::init();
add_action('wp_ajax_wu-email-template-preview', array($this, 'email_template_preview'));
-
- } // end init;
+ }
/**
* Return the page object
@@ -94,8 +93,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
public function get_object() {
return $this;
-
- } // end get_object;
+ }
/**
* Renders the preview of a given form being customized.
@@ -107,12 +105,12 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
$object = $this;
- $content = wpautop('
+ $content = wpautop(
+ '
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam nulla diam, iaculis sit amet tellus sit amet, tempus hendrerit risus. Proin elementum aliquet lorem ut cursus. Ut varius pharetra magna, eu malesuada metus feugiat id. Aenean cursus purus et massa commodo pretium id ut erat. Suspendisse erat odio, auctor ac elit eget, rhoncus iaculis nulla. Aliquam turpis leo, egestas eget dui a, imperdiet ullamcorper felis. Suspendisse ut lacinia mauris.
Phasellus vitae diam euismod diam tristique faucibus. Proin gravida, augue in molestie porttitor, orci justo aliquam mauris, et commodo mauris nisi vitae tortor. Mauris vulputate fringilla purus et finibus. Duis lacus turpis, tincidunt vel dui ac, fermentum aliquet dolor. Donec auctor tristique consequat. In pharetra lacus quis mi dictum, ut dapibus eros bibendum. Donec tristique nibh ac sem bibendum, at feugiat turpis molestie. Suspendisse eget eleifend nunc. Sed tempor varius nisi non tincidunt. Sed leo arcu, feugiat dapibus sollicitudin a, tincidunt eu ligula. Nam ut arcu id arcu auctor vulputate non molestie quam. Nunc non diam mauris. Praesent erat est, posuere sit amet hendrerit non, molestie eget sem. Cras ac tempor est.'
-
);
$content .= '
@@ -149,37 +147,39 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
/*
* use arbitrary field to determine if this is the first request for the preview.
*/
- $first_request = !wu_request('background_color');
+ $first_request = ! wu_request('background_color');
- wu_get_template('broadcast/emails/base', array(
- 'site_name' => get_network_option(null, 'site_name'),
- 'site_url' => get_site_url(),
- 'logo_url' => wu_get_network_logo(),
- 'content' => $content,
- 'subject' => __('Sample Subject', 'wp-ultimo'),
- 'is_editor' => true,
- 'template_settings' => array(
- 'use_custom_logo' => wu_string_to_bool(wu_request('use_custom_logo', $first_request ? $object->get_setting('use_custom_logo', false) : false)),
- 'custom_logo' => wu_request('custom_logo', $object->get_setting('custom_logo', false)),
- 'background_color' => wu_request('background_color', $object->get_setting('background_color', '#f9f9f9')),
- 'title_color' => wu_request('title_color', $object->get_setting('title_color', '#000000')),
- 'title_size' => wu_request('title_size', $object->get_setting('title_size', 'h3')),
- 'title_align' => wu_request('title_align', $object->get_setting('title_align', 'center')),
- 'title_font' => wu_request('title_font', $object->get_setting('title_font', 'Helvetica Neue, Helvetica, Helvetica, Arial, sans-serif')),
- 'content_color' => wu_request('content_color', $object->get_setting('content_color', '#000000')),
- 'content_align' => wu_request('content_align', $object->get_setting('content_align', 'left')),
- 'content_font' => wu_request('content_font', $object->get_setting('content_font', 'Helvetica Neue, Helvetica, Helvetica, Arial, sans-serif')),
- 'footer_text' => wu_request('footer_text', $object->get_setting('footer_text', '')),
- 'footer_font' => wu_request('footer_font', $object->get_setting('footer_font', 'Helvetica Neue, Helvetica, Helvetica, Arial, sans-serif')),
- 'footer_color' => wu_request('footer_color', $object->get_setting('footer_color', '#000000')),
- 'footer_align' => wu_request('footer_align', $object->get_setting('footer_align', 'center')),
- 'display_company_address' => wu_string_to_bool(wu_request('display_company_address', $first_request ? $object->get_setting('display_company_address', true) : false)),
+ wu_get_template(
+ 'broadcast/emails/base',
+ array(
+ 'site_name' => get_network_option(null, 'site_name'),
+ 'site_url' => get_site_url(),
+ 'logo_url' => wu_get_network_logo(),
+ 'content' => $content,
+ 'subject' => __('Sample Subject', 'wp-ultimo'),
+ 'is_editor' => true,
+ 'template_settings' => array(
+ 'use_custom_logo' => wu_string_to_bool(wu_request('use_custom_logo', $first_request ? $object->get_setting('use_custom_logo', false) : false)),
+ 'custom_logo' => wu_request('custom_logo', $object->get_setting('custom_logo', false)),
+ 'background_color' => wu_request('background_color', $object->get_setting('background_color', '#f9f9f9')),
+ 'title_color' => wu_request('title_color', $object->get_setting('title_color', '#000000')),
+ 'title_size' => wu_request('title_size', $object->get_setting('title_size', 'h3')),
+ 'title_align' => wu_request('title_align', $object->get_setting('title_align', 'center')),
+ 'title_font' => wu_request('title_font', $object->get_setting('title_font', 'Helvetica Neue, Helvetica, Helvetica, Arial, sans-serif')),
+ 'content_color' => wu_request('content_color', $object->get_setting('content_color', '#000000')),
+ 'content_align' => wu_request('content_align', $object->get_setting('content_align', 'left')),
+ 'content_font' => wu_request('content_font', $object->get_setting('content_font', 'Helvetica Neue, Helvetica, Helvetica, Arial, sans-serif')),
+ 'footer_text' => wu_request('footer_text', $object->get_setting('footer_text', '')),
+ 'footer_font' => wu_request('footer_font', $object->get_setting('footer_font', 'Helvetica Neue, Helvetica, Helvetica, Arial, sans-serif')),
+ 'footer_color' => wu_request('footer_color', $object->get_setting('footer_color', '#000000')),
+ 'footer_align' => wu_request('footer_align', $object->get_setting('footer_align', 'center')),
+ 'display_company_address' => wu_string_to_bool(wu_request('display_company_address', $first_request ? $object->get_setting('display_company_address', true) : false)),
+ ),
)
- ));
+ );
die;
-
- } // end email_template_preview;
+ }
/**
* Returns the preview URL. This is then added to the iframe.
@@ -191,12 +191,14 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
$url = get_admin_url(wu_get_main_site_id(), 'admin-ajax.php');
- return add_query_arg(array(
- 'action' => 'wu-email-template-preview',
- 'customizer' => 1,
- ), $url);
-
- } // end get_preview_url;
+ return add_query_arg(
+ array(
+ 'action' => 'wu-email-template-preview',
+ 'customizer' => 1,
+ ),
+ $url
+ );
+ }
/**
* Allow child classes to register widgets, if they need them.
@@ -206,18 +208,21 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
*/
public function register_widgets() {
- $this->add_save_widget('save', array(
- 'html_attr' => array(
- 'data-wu-app' => 'save',
- 'data-state' => wu_convert_to_state(),
- ),
- 'fields' => array(
- 'note' => array(
- 'type' => 'note',
- 'desc' => __('System emails and broadcasts will be sent using this template.', 'wp-ultimo'),
+ $this->add_save_widget(
+ 'save',
+ array(
+ 'html_attr' => array(
+ 'data-wu-app' => 'save',
+ 'data-state' => wu_convert_to_state(),
+ ),
+ 'fields' => array(
+ 'note' => array(
+ 'type' => 'note',
+ 'desc' => __('System emails and broadcasts will be sent using this template.', 'wp-ultimo'),
+ ),
),
)
- ));
+ );
$settings = $this->get_attributes();
@@ -473,24 +478,29 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
),
);
- $state = array_merge($settings, array(
- 'tab' => 'header',
- 'refresh' => true,
- ));
+ $state = array_merge(
+ $settings,
+ array(
+ 'tab' => 'header',
+ 'refresh' => true,
+ )
+ );
- $this->add_fields_widget('customizer', array(
- 'title' => __('Customizer', 'wp-ultimo'),
- 'position' => 'side',
- 'fields' => $fields,
- 'html_attr' => array(
- 'style' => 'margin-top: -6px;',
- 'data-wu-app' => 'email_template_customizer',
- 'data-wu-customizer-panel' => true,
- 'data-state' => json_encode($state),
- ),
- ));
-
- } // end register_widgets;
+ $this->add_fields_widget(
+ 'customizer',
+ array(
+ 'title' => __('Customizer', 'wp-ultimo'),
+ 'position' => 'side',
+ 'fields' => $fields,
+ 'html_attr' => array(
+ 'style' => 'margin-top: -6px;',
+ 'data-wu-app' => 'email_template_customizer',
+ 'data-wu-customizer-panel' => true,
+ 'data-state' => json_encode($state),
+ ),
+ )
+ );
+ }
/**
* Returns the title of the page.
@@ -501,8 +511,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
public function get_title() {
return __('Customize Email Template:', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the title of menu for this page.
@@ -513,8 +522,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
public function get_menu_title() {
return __('Customize Email Template', 'wp-ultimo');
-
- } // end get_menu_title;
+ }
/**
* Returns the action links for that page.
@@ -525,8 +533,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
public function action_links() {
return array();
-
- } // end action_links;
+ }
/**
* Returns the labels to be used on the admin page.
@@ -548,8 +555,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
'delete_button_label' => __('Delete Email Template', 'wp-ultimo'),
'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'),
);
-
- } // end get_labels;
+ }
/**
* Should implement the processes necessary to save the changes made to the object.
@@ -574,8 +580,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
wp_redirect($url);
exit;
-
- } // end handle_save;
+ }
/**
* Get the value of attributes.
@@ -590,8 +595,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
$attributes = wp_parse_args($saved_atts, $this->get_default_settings());
return $attributes;
-
- } // end get_attributes;
+ }
/**
* Gets the default email template settings.
@@ -618,8 +622,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
'footer_color' => '#000000',
'footer_align' => 'center',
);
-
- } // end get_default_settings;
+ }
/**
* Returns the list of saved settings to customize the email template.
@@ -631,8 +634,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
public static function get_settings() {
return wu_get_option('email_template', array());
-
- } // end get_settings;
+ }
/**
* Returns a specitic email template setting.
@@ -646,24 +648,17 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
public function get_setting($setting, $default = false) {
if ($setting) {
-
$return = wu_get_option('email_template', array());
- if ($return && isset($return[$setting])) {
-
- $return = $return[$setting];
-
+ if ($return && isset($return[ $setting ])) {
+ $return = $return[ $setting ];
} else {
-
$return = $default;
-
- } // end if;
+ }
return $return;
-
- } // end if;
-
- } // end get_setting;
+ }
+ }
/**
* Save settings.
@@ -678,17 +673,11 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page {
$allowed_keys = $this->get_attributes();
foreach ($settings_to_save as $setting_to_save => $value) {
-
- if (!array_key_exists($setting_to_save, $allowed_keys)) {
-
- unset($settings_to_save[$setting_to_save]);
-
- } // end if;
-
- } // end foreach;
+ if ( ! array_key_exists($setting_to_save, $allowed_keys)) {
+ unset($settings_to_save[ $setting_to_save ]);
+ }
+ }
return wu_save_option('email_template', $settings_to_save);
-
- } // end save_settings;
-
-} // end class Email_Template_Customize_Admin_Page;
+ }
+}
diff --git a/inc/admin-pages/class-event-list-admin-page.php b/inc/admin-pages/class-event-list-admin-page.php
index 0e14338..57adf47 100644
--- a/inc/admin-pages/class-event-list-admin-page.php
+++ b/inc/admin-pages/class-event-list-admin-page.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\Admin_Pages;
-use \WP_Ultimo\Models\Event;
+use WP_Ultimo\Models\Event;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -65,8 +65,7 @@ class Event_List_Admin_Page extends List_Admin_Page {
public function init() {
add_action('init', array($this, 'set_badge_count'));
-
- } // end init;
+ }
/**
* Adds hooks when the page loads.
@@ -79,8 +78,7 @@ class Event_List_Admin_Page extends List_Admin_Page {
parent::page_loaded();
add_action('in_admin_header', array($this, 'count_seen_events'));
-
- } // end page_loaded;
+ }
/**
* Sets events badge notification subtracting the total number of events from the seen events in the user meta.
@@ -97,12 +95,10 @@ class Event_List_Admin_Page extends List_Admin_Page {
$cache = get_site_transient("wu_{$user_id}_unseen_events_count");
if ($cache) {
-
$this->badge_count = $cache;
return;
-
- } // end if;
+ }
$table_name = "{$wpdb->base_prefix}wu_events";
@@ -115,8 +111,7 @@ class Event_List_Admin_Page extends List_Admin_Page {
$this->badge_count = $unseen;
set_site_transient("wu_{$user_id}_unseen_events_count", $unseen, 5 * MINUTE_IN_SECONDS);
-
- } // end set_badge_count;
+ }
/**
* Sets the seen events in the current user meta.
@@ -130,24 +125,23 @@ class Event_List_Admin_Page extends List_Admin_Page {
delete_site_transient("wu_{$user_id}_unseen_events_count");
- $last_event = wu_get_events(array(
- 'orderby' => 'id',
- 'fields' => 'ids',
- 'order' => 'DESC',
- 'number' => 1,
- ));
-
- if (!empty($last_event)) {
+ $last_event = wu_get_events(
+ array(
+ 'orderby' => 'id',
+ 'fields' => 'ids',
+ 'order' => 'DESC',
+ 'number' => 1,
+ )
+ );
+ if ( ! empty($last_event)) {
$last_event_id = current($last_event);
update_user_meta($user_id, 'wu_seen_events', $last_event_id);
-
- } // end if;
+ }
$this->badge_count = '';
-
- } // end count_seen_events;
+ }
/**
* Allow child classes to register widgets, if they need them.
@@ -155,7 +149,7 @@ class Event_List_Admin_Page extends List_Admin_Page {
* @since 1.8.2
* @return void
*/
- public function register_widgets() {} // end register_widgets;
+ public function register_widgets() {}
/**
* Returns an array with the labels for the edit page.
@@ -169,8 +163,7 @@ class Event_List_Admin_Page extends List_Admin_Page {
'deleted_message' => __('Event removed successfully.', 'wp-ultimo'),
'search_label' => __('Search Event', 'wp-ultimo'),
);
-
- } // end get_labels;
+ }
/**
* Returns the title of the page.
@@ -181,8 +174,7 @@ class Event_List_Admin_Page extends List_Admin_Page {
public function get_title() {
return __('Events', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the title of menu for this page.
@@ -193,8 +185,7 @@ class Event_List_Admin_Page extends List_Admin_Page {
public function get_menu_title() {
return __('Events', 'wp-ultimo');
-
- } // end get_menu_title;
+ }
/**
* Allows admins to rename the sub-menu (first item) for a top-level page.
@@ -205,8 +196,7 @@ class Event_List_Admin_Page extends List_Admin_Page {
public function get_submenu_title() {
return __('Events', 'wp-ultimo');
-
- } // end get_submenu_title;
+ }
/**
* Returns the action links for that page.
@@ -223,8 +213,7 @@ class Event_List_Admin_Page extends List_Admin_Page {
'icon' => 'dashicons dashicons-editor-ol',
),
);
-
- } // end action_links;
+ }
/**
* Loads the list table for this particular page.
@@ -235,7 +224,5 @@ class Event_List_Admin_Page extends List_Admin_Page {
public function table() {
return new \WP_Ultimo\List_Tables\Event_List_Table();
-
- } // end table;
-
-} // end class Event_List_Admin_Page;
+ }
+}
diff --git a/inc/admin-pages/class-event-view-admin-page.php b/inc/admin-pages/class-event-view-admin-page.php
index 8613db9..d431e9c 100644
--- a/inc/admin-pages/class-event-view-admin-page.php
+++ b/inc/admin-pages/class-event-view-admin-page.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Admin_Pages;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Models\Event;
+use WP_Ultimo\Models\Event;
/**
* WP Multisite WaaS Event View Admin Page.
@@ -97,8 +97,7 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
wp_enqueue_script('clipboard');
wp_enqueue_script('wu-vue');
-
- } // end register_scripts;
+ }
/**
* Register ajax forms that we use for membership.
@@ -111,11 +110,13 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
* Delete Event - Confirmation modal
*/
- add_filter('wu_data_json_success_delete_event_modal', fn($data_json) => array(
- 'redirect_url' => wu_network_admin_url('wp-ultimo-events', array('deleted' => 1))
- ));
-
- } // end register_forms;
+ add_filter(
+ 'wu_data_json_success_delete_event_modal',
+ fn($data_json) => array(
+ 'redirect_url' => wu_network_admin_url('wp-ultimo-events', array('deleted' => 1)),
+ )
+ );
+ }
/**
* Allow child classes to register widgets, if they need them.
@@ -133,13 +134,15 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
add_meta_box('wp-ultimo-payload', __('Event Payload', 'wp-ultimo'), array($this, 'output_default_widget_payload'), get_current_screen()->id, 'normal', 'default');
- $this->add_info_widget('info', array(
- 'title' => __('Timestamps', 'wp-ultimo'),
- 'position' => 'side',
- 'modified' => false,
- ));
-
- } // end register_widgets;
+ $this->add_info_widget(
+ 'info',
+ array(
+ 'title' => __('Timestamps', 'wp-ultimo'),
+ 'position' => 'side',
+ 'modified' => false,
+ )
+ );
+ }
/**
* Outputs the markup for the default Save widget.
@@ -149,14 +152,16 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
*/
public function output_default_widget_message() {
- wu_get_template('events/widget-message', array(
- 'screen' => get_current_screen(),
- 'page' => $this,
- 'labels' => $this->get_labels(),
- 'object' => $this->get_object(),
- ));
-
- } // end output_default_widget_message;
+ wu_get_template(
+ 'events/widget-message',
+ array(
+ 'screen' => get_current_screen(),
+ 'page' => $this,
+ 'labels' => $this->get_labels(),
+ 'object' => $this->get_object(),
+ )
+ );
+ }
/**
* Outputs the markup for the payload widget.
@@ -168,13 +173,15 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
$object = $this->get_object();
- wu_get_template('events/widget-payload', array(
- 'title' => __('Event Payload', 'wp-ultimo'),
- 'loading_text' => __('Loading Payload', 'wp-ultimo'),
- 'payload' => json_encode($object->get_payload(), JSON_PRETTY_PRINT),
- ));
-
- } // end output_default_widget_payload;
+ wu_get_template(
+ 'events/widget-payload',
+ array(
+ 'title' => __('Event Payload', 'wp-ultimo'),
+ 'loading_text' => __('Loading Payload', 'wp-ultimo'),
+ 'payload' => json_encode($object->get_payload(), JSON_PRETTY_PRINT),
+ )
+ );
+ }
/**
* Outputs the markup for the initiator widget.
@@ -191,8 +198,7 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
);
wu_get_template('events/widget-initiator', $args);
-
- } // end output_default_widget_initiator;
+ }
/**
* Returns the title of the page.
@@ -203,8 +209,7 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
public function get_title() {
return $this->edit ? __('Edit Event', 'wp-ultimo') : __('Add new Event', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the title of menu for this page.
@@ -215,8 +220,7 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
public function get_menu_title() {
return __('Edit Event', 'wp-ultimo');
-
- } // end get_menu_title;
+ }
/**
* Returns the action links for that page.
@@ -227,8 +231,7 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
public function action_links() {
return array();
-
- } // end action_links;
+ }
/**
* Returns the labels to be used on the admin page.
@@ -249,8 +252,7 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
'delete_button_label' => __('Delete Event', 'wp-ultimo'),
'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'),
);
-
- } // end get_labels;
+ }
/**
* Returns the object being edit at the moment.
@@ -261,24 +263,19 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
public function get_object() {
if (isset($_GET['id'])) {
-
- $query = new \WP_Ultimo\Database\Events\Event_Query;
+ $query = new \WP_Ultimo\Database\Events\Event_Query();
$item = $query->get_item_by('id', $_GET['id']);
if ($item) {
-
return $item;
-
- } // end if;
-
- } // end if;
+ }
+ }
wp_redirect(wu_network_admin_url('wp-ultimo-events'));
exit;
-
- } // end get_object;
+ }
/**
* Events have titles.
*
@@ -287,8 +284,7 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
public function has_title(): bool {
return false;
-
- } // end has_title;
+ }
/**
* Handles the save of this form.
*
@@ -297,7 +293,5 @@ class Event_View_Admin_Page extends Edit_Admin_Page {
public function handle_save(): bool {
return true;
-
- } // end handle_save;
-
-} // end class Event_View_Admin_Page;
+ }
+}
diff --git a/inc/admin-pages/class-hosting-integration-wizard-admin-page.php b/inc/admin-pages/class-hosting-integration-wizard-admin-page.php
index 332cda1..d39534c 100644
--- a/inc/admin-pages/class-hosting-integration-wizard-admin-page.php
+++ b/inc/admin-pages/class-hosting-integration-wizard-admin-page.php
@@ -87,24 +87,19 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
public function page_loaded() {
if (isset($_GET['integration'])) {
-
$domain_manager = \WP_Ultimo\Managers\Domain_Manager::get_instance();
$this->integration = $domain_manager->get_integration_instance($_GET['integration']);
+ }
- } // end if;
-
- if (!$this->integration) {
-
+ if ( ! $this->integration) {
wp_redirect(network_admin_url('admin.php?page=wp-ultimo-settings'));
exit;
-
- } // end if;
+ }
parent::page_loaded();
-
- } // end page_loaded;
+ }
/**
* Returns the title of the page.
@@ -115,8 +110,7 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
public function get_title(): string {
return sprintf(__('Integration Setup', 'wp-ultimo'));
-
- } // end get_title;
+ }
/**
* Returns the title of menu for this page.
@@ -127,8 +121,7 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
public function get_menu_title() {
return __('Host Provider Integration', 'wp-ultimo');
-
- } // end get_menu_title;
+ }
/**
* Returns the sections for this Wizard.
@@ -167,23 +160,18 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
* Some host providers require no instructions.
*/
if ($this->integration->supports('no-instructions')) {
-
unset($sections['instructions']);
-
- } // end if;
+ }
/*
* Some host providers require no additional setup.
*/
if ($this->integration->supports('no-config')) {
-
unset($sections['config']);
-
- } // end if;
+ }
return $sections;
-
- } // end get_sections;
+ }
/**
* Displays the content of the activation section.
@@ -195,15 +183,17 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
$explainer_lines = $this->integration->get_explainer_lines();
- wu_get_template('wizards/host-integrations/activation', array(
- 'screen' => get_current_screen(),
- 'page' => $this,
- 'integration' => $this->integration,
- 'will' => $explainer_lines['will'],
- 'will_not' => $explainer_lines['will_not'],
- ));
-
- } // end section_activation;
+ wu_get_template(
+ 'wizards/host-integrations/activation',
+ array(
+ 'screen' => get_current_screen(),
+ 'page' => $this,
+ 'integration' => $this->integration,
+ 'will' => $explainer_lines['will'],
+ 'will_not' => $explainer_lines['will_not'],
+ )
+ );
+ }
/**
* Displays the contents of the instructions section.
@@ -216,8 +206,7 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
call_user_func(array($this->integration, 'get_instructions'));
$this->render_submit_box();
-
- } // end section_instructions;
+ }
/**
* Displays the content of the configuration section.
@@ -230,39 +219,44 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
$fields = $this->integration->get_fields();
foreach ($fields as $field_constant => &$field) {
-
$field['value'] = defined($field_constant) && constant($field_constant) ? constant($field_constant) : '';
+ }
- } // end foreach;
-
- $form = new \WP_Ultimo\UI\Form($this->get_current_section(), $fields, array(
- 'views' => 'admin-pages/fields',
- 'classes' => 'wu-widget-list wu-striped wu-m-0 wu--mt-2 wu--mb-3 wu--mx-3',
- 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-px-6 wu-py-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 = new \WP_Ultimo\UI\Form(
+ $this->get_current_section(),
+ $fields,
+ array(
+ 'views' => 'admin-pages/fields',
+ 'classes' => 'wu-widget-list wu-striped wu-m-0 wu--mt-2 wu--mb-3 wu--mx-3',
+ 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-px-6 wu-py-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',
+ )
+ );
if (wu_request('manual')) {
+ wu_get_template(
+ 'wizards/host-integrations/configuration-results',
+ array(
+ 'screen' => get_current_screen(),
+ 'page' => $this,
+ 'integration' => $this->integration,
+ 'form' => $form,
+ 'post' => $_GET['post'],
+ )
+ );
- wu_get_template('wizards/host-integrations/configuration-results', array(
+ return;
+ }
+
+ wu_get_template(
+ 'wizards/host-integrations/configuration',
+ array(
'screen' => get_current_screen(),
'page' => $this,
'integration' => $this->integration,
'form' => $form,
- 'post' => $_GET['post'],
- ));
-
- return;
-
- } // end if;
-
- wu_get_template('wizards/host-integrations/configuration', array(
- 'screen' => get_current_screen(),
- 'page' => $this,
- 'integration' => $this->integration,
- 'form' => $form,
- ));
-
- } // end section_configuration;
+ )
+ );
+ }
/**
* Displays the content of the final section.
@@ -272,13 +266,15 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
*/
public function section_ready() {
- wu_get_template('wizards/host-integrations/ready', array(
- 'screen' => get_current_screen(),
- 'page' => $this,
- 'integration' => $this->integration,
- ));
-
- } // end section_ready;
+ wu_get_template(
+ 'wizards/host-integrations/ready',
+ array(
+ 'screen' => get_current_screen(),
+ 'page' => $this,
+ 'integration' => $this->integration,
+ )
+ );
+ }
/**
* Handles the activation of a given integration.
@@ -291,20 +287,17 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
$is_enabled = $this->integration->is_enabled();
if ($is_enabled) {
-
$this->integration->disable();
return;
-
- } // end if;
+ }
$this->integration->enable();
wp_redirect($this->get_next_section_link());
exit;
-
- } // end handle_activation;
+ }
/**
* Handles the configuration of a given integration.
@@ -316,22 +309,22 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
if (wu_request('submit') == '0') { // phpcs:ignore
- $redirect_url = add_query_arg(array(
- 'manual' => '1',
- 'post' => $_POST,
- ));
+ $redirect_url = add_query_arg(
+ array(
+ 'manual' => '1',
+ 'post' => $_POST,
+ )
+ );
wp_redirect($redirect_url);
exit;
-
- } // end if;
+ }
if (wu_request('submit') == '1') { // phpcs:ignore
$this->integration->setup_constants($_POST);
-
- } // end if;
+ }
$redirect_url = $this->get_next_section_link();
@@ -342,8 +335,7 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
wp_redirect($redirect_url);
exit;
-
- } // end handle_configuration;
+ }
/**
* Handles the testing of a given configuration.
@@ -356,12 +348,13 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page {
wp_enqueue_script('wu-vue');
- wu_get_template('wizards/host-integrations/test', array(
- 'screen' => get_current_screen(),
- 'page' => $this,
- 'integration' => $this->integration,
- ));
-
- } // end section_test;
-
-} // end class Hosting_Integration_Wizard_Admin_Page;
+ wu_get_template(
+ 'wizards/host-integrations/test',
+ array(
+ 'screen' => get_current_screen(),
+ 'page' => $this,
+ 'integration' => $this->integration,
+ )
+ );
+ }
+}
diff --git a/inc/admin-pages/class-invoice-template-customize-admin-page.php b/inc/admin-pages/class-invoice-template-customize-admin-page.php
index bca0405..c5b1d53 100644
--- a/inc/admin-pages/class-invoice-template-customize-admin-page.php
+++ b/inc/admin-pages/class-invoice-template-customize-admin-page.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\Admin_Pages;
-use \WP_Ultimo\Invoices\Invoice;
+use WP_Ultimo\Invoices\Invoice;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -83,8 +83,7 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
parent::init();
add_action('wp_ajax_wu-preview-invoice', array($this, 'generate_invoice_preview'));
-
- } // end init;
+ }
/**
* Ajax endpoint to generate the Ajax Preview.
@@ -94,11 +93,9 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
*/
public function generate_invoice_preview() {
- if (!current_user_can('wu_manage_invoice')) {
-
+ if ( ! current_user_can('wu_manage_invoice')) {
return;
-
- } // end if;
+ }
$order = false;
@@ -109,8 +106,7 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
$invoice->print_file();
die;
-
- } // end generate_invoice_preview;
+ }
/**
* Returns the preview URL. This is then added to the iframe.
@@ -122,13 +118,15 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
$url = get_admin_url(wu_get_main_site_id(), 'admin-ajax.php');
- return add_query_arg(array(
- 'action' => 'wu-preview-invoice',
- 'customizer' => 1,
- 'invoice-customize' => 1
- ), $url);
-
- } // end get_preview_url;
+ return add_query_arg(
+ array(
+ 'action' => 'wu-preview-invoice',
+ 'customizer' => 1,
+ 'invoice-customize' => 1,
+ ),
+ $url
+ );
+ }
/**
* Allow child classes to register widgets, if they need them.
@@ -140,14 +138,17 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
$settings = Invoice::get_settings();
- $this->add_save_widget('save', array(
- 'fields' => array(
- 'note' => array(
- 'type' => 'note',
- 'desc' => __('Changes to this template will be applied to all PDF invoices generated after the change.
Existing PDF Invoices will not be affected unless explicitly re-generated', 'wp-ultimo'),
+ $this->add_save_widget(
+ 'save',
+ array(
+ 'fields' => array(
+ 'note' => array(
+ 'type' => 'note',
+ 'desc' => __('Changes to this template will be applied to all PDF invoices generated after the change.
Existing PDF Invoices will not be affected unless explicitly re-generated', 'wp-ultimo'),
+ ),
),
)
- ));
+ );
$custom_logo = wu_get_isset($settings, 'custom_logo');
@@ -267,24 +268,29 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
'font' => wu_get_isset($settings, 'font', 'DejaVuSansCondensed'),
);
- $state = array_merge($settings, array(
- 'tab' => 'general',
- 'refresh' => true,
- ));
+ $state = array_merge(
+ $settings,
+ array(
+ 'tab' => 'general',
+ 'refresh' => true,
+ )
+ );
- $this->add_fields_widget('customizer', array(
- 'title' => __('Customizer', 'wp-ultimo'),
- 'position' => 'side',
- 'fields' => $fields,
- 'html_attr' => array(
- 'style' => 'margin-top: -6px;',
- 'data-wu-app' => 'invoice_customizer',
- 'data-wu-customizer-panel' => true,
- 'data-state' => json_encode($state),
- ),
- ));
-
- } // end register_widgets;
+ $this->add_fields_widget(
+ 'customizer',
+ array(
+ 'title' => __('Customizer', 'wp-ultimo'),
+ 'position' => 'side',
+ 'fields' => $fields,
+ 'html_attr' => array(
+ 'style' => 'margin-top: -6px;',
+ 'data-wu-app' => 'invoice_customizer',
+ 'data-wu-customizer-panel' => true,
+ 'data-state' => json_encode($state),
+ ),
+ )
+ );
+ }
/**
* Returns the title of the page.
@@ -295,8 +301,7 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
public function get_title() {
return __('Customize Invoice Template', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the title of menu for this page.
@@ -307,8 +312,7 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
public function get_menu_title() {
return __('Customize Invoice Template', 'wp-ultimo');
-
- } // end get_menu_title;
+ }
/**
* Returns the action links for that page.
@@ -319,8 +323,7 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
public function action_links() {
return array();
-
- } // end action_links;
+ }
/**
* Returns the labels to be used on the admin page.
@@ -340,8 +343,7 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
'save_button_label' => __('Save Invoice Template', 'wp-ultimo'),
'save_description' => __('Save Invoice Template', 'wp-ultimo'),
);
-
- } // end get_labels;
+ }
/**
* Should implement the processes necessary to save the changes made to the object.
@@ -358,7 +360,5 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page {
wp_redirect($url);
exit;
-
- } // end handle_save;
-
-} // end class Invoice_Template_Customize_Admin_Page;
+ }
+}
diff --git a/inc/admin-pages/class-jobs-list-admin-page.php b/inc/admin-pages/class-jobs-list-admin-page.php
index 13d37c3..5f25672 100644
--- a/inc/admin-pages/class-jobs-list-admin-page.php
+++ b/inc/admin-pages/class-jobs-list-admin-page.php
@@ -81,8 +81,7 @@ class Jobs_List_Admin_Page extends Base_Admin_Page {
parent::init();
add_filter('action_scheduler_admin_view_class', array($this, 'hide_as_admin_page'), 9999, 1);
-
- } // end init;
+ }
/**
* Hide the Action Scheduler admin page on sub-sites.
@@ -95,14 +94,11 @@ class Jobs_List_Admin_Page extends Base_Admin_Page {
public function hide_as_admin_page($admin_view_class) {
if (is_network_admin() || class_exists('WooCommerce')) {
-
return $admin_view_class;
-
- } // end if;
+ }
return '\WP_Ultimo\Compat\AS_Admin_View';
-
- } // end hide_as_admin_page;
+ }
/**
* Returns the title of the page.
@@ -113,8 +109,7 @@ class Jobs_List_Admin_Page extends Base_Admin_Page {
public function get_title() {
return __('Jobs', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the title of menu for this page.
@@ -125,8 +120,7 @@ class Jobs_List_Admin_Page extends Base_Admin_Page {
public function get_menu_title() {
return __('Jobs', 'wp-ultimo');
-
- } // end get_menu_title;
+ }
/**
* Allows admins to rename the sub-menu (first item) for a top-level page.
@@ -137,8 +131,7 @@ class Jobs_List_Admin_Page extends Base_Admin_Page {
public function get_submenu_title() {
return __('Jobs', 'wp-ultimo');
-
- } // end get_submenu_title;
+ }
/**
* Runs the hooks for the admin list table.
@@ -151,8 +144,7 @@ class Jobs_List_Admin_Page extends Base_Admin_Page {
public function page_loaded() {
\ActionScheduler_AdminView::instance()->process_admin_ui();
-
- } // end page_loaded;
+ }
/**
* Calls the Action Scheduler renderer.
@@ -163,7 +155,5 @@ class Jobs_List_Admin_Page extends Base_Admin_Page {
public function output() {
\ActionScheduler_AdminView::instance()->render_admin_ui();
-
- } // end output;
-
-} // end class Jobs_List_Admin_Page;
+ }
+}
diff --git a/inc/admin-pages/class-list-admin-page.php b/inc/admin-pages/class-list-admin-page.php
index 2b15820..837e08e 100644
--- a/inc/admin-pages/class-list-admin-page.php
+++ b/inc/admin-pages/class-list-admin-page.php
@@ -23,15 +23,15 @@ defined('ABSPATH') || exit;
abstract class List_Admin_Page extends Base_Admin_Page {
/**
- * @var bool
- */
+ * @var bool
+ */
public $has_search;
/**
- * The id/name/slug of the object being edited/created. e.g: plan
- *
- * @since 1.8.2
- * @var object
- */
+ * The id/name/slug of the object being edited/created. e.g: plan
+ *
+ * @since 1.8.2
+ * @var object
+ */
protected $object_id;
/**
@@ -82,8 +82,7 @@ abstract class List_Admin_Page extends Base_Admin_Page {
* Adds the process for process actions
*/
$this->process_single_action();
-
- } // end page_loaded;
+ }
/**
* Initializes the class
@@ -99,8 +98,7 @@ abstract class List_Admin_Page extends Base_Admin_Page {
parent::init();
add_filter('set-screen-option', array($this, 'save_screen_option'), 8, 3);
-
- } // end init;
+ }
/**
* Process lins actions of the tables
@@ -111,12 +109,9 @@ abstract class List_Admin_Page extends Base_Admin_Page {
public function process_single_action() {
if ($this->table) {
-
$this->table->process_single_action();
-
- } // end if;
-
- } // end process_single_action;
+ }
+ }
/**
* Returns an array with the labels for the edit page.
@@ -130,8 +125,7 @@ abstract class List_Admin_Page extends Base_Admin_Page {
'deleted_message' => __('Object removed successfully.', 'wp-ultimo'),
'search_label' => __('Search Object', 'wp-ultimo'),
);
-
- } // end get_labels;
+ }
/**
* Allow child classes to register scripts and styles that can be loaded on the output function, for example.
@@ -150,8 +144,7 @@ abstract class List_Admin_Page extends Base_Admin_Page {
wp_enqueue_style('wp-color-picker');
wp_enqueue_script('wu-selectizer');
-
- } // end register_scripts;
+ }
/**
* Sets the default list template
@@ -164,13 +157,15 @@ abstract class List_Admin_Page extends Base_Admin_Page {
/**
* Renders the base list page layout, with the columns and everything else =)
*/
- wu_get_template('base/list', array(
- 'page' => $this,
- 'table' => $this->get_table(),
- 'classes' => $this->table->get_filters() ? 'wu-advanced-filters' : 'wu-no-advanced-filters',
- ));
-
- } // end output;
+ wu_get_template(
+ 'base/list',
+ array(
+ 'page' => $this,
+ 'table' => $this->get_table(),
+ 'classes' => $this->table->get_filters() ? 'wu-advanced-filters' : 'wu-no-advanced-filters',
+ )
+ );
+ }
/**
* Child classes can to implement to hide the search field
@@ -181,8 +176,7 @@ abstract class List_Admin_Page extends Base_Admin_Page {
public function has_search() {
return true;
-
- } // end has_search;
+ }
/**
* Set the screen options to allow users to set the pagination options of the subscriptions list
@@ -193,7 +187,6 @@ abstract class List_Admin_Page extends Base_Admin_Page {
public function screen_options() {
if ($this->table) {
-
$args = array(
'default' => 20,
'label' => $this->table->get_per_page_option_label(),
@@ -201,10 +194,8 @@ abstract class List_Admin_Page extends Base_Admin_Page {
);
add_screen_option('per_page', $args);
-
- } // end if;
-
- } // end screen_options;
+ }
+ }
/**
* Tells WordPress we want to save screen options on our pages.
@@ -219,8 +210,7 @@ abstract class List_Admin_Page extends Base_Admin_Page {
public function save_screen_option($value, $option, $other_value) {
return $value === false && is_numeric($other_value) ? (int) $other_value : $value;
-
- } // end save_screen_option;
+ }
/**
* Dumb function. Child classes need to implement this to set the table that WP Multisite WaaS will use
@@ -231,8 +221,7 @@ abstract class List_Admin_Page extends Base_Admin_Page {
public function get_table() {
return $this->table;
-
- } // end get_table;
+ }
/**
* Loads the list table for this particular page.
@@ -241,5 +230,4 @@ abstract class List_Admin_Page extends Base_Admin_Page {
* @return \WP_Ultimo\List_Tables\Base_List_Table
*/
abstract function table();
-
-} // end class List_Admin_Page;
+}
diff --git a/inc/admin-pages/class-membership-edit-admin-page.php b/inc/admin-pages/class-membership-edit-admin-page.php
index 801ca87..b868fd1 100644
--- a/inc/admin-pages/class-membership-edit-admin-page.php
+++ b/inc/admin-pages/class-membership-edit-admin-page.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Admin_Pages;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Database\Memberships\Membership_Status;
+use WP_Ultimo\Database\Memberships\Membership_Status;
/**
* WP Multisite WaaS Membership Edit/Add New Admin Page.
@@ -102,8 +102,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
* Adds the swap notices, if needed.
*/
$this->add_swap_notices();
-
- } // end page_loaded;
+ }
/**
* Displays swap notices, if necessary.
@@ -115,11 +114,9 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
$swap_order = $this->get_object()->get_scheduled_swap();
- if (!$swap_order || wu_request('preview-swap')) {
-
+ if ( ! $swap_order || wu_request('preview-swap')) {
return;
-
- } // end if;
+ }
$actions = array(
'preview' => array(
@@ -134,8 +131,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
$message = sprintf(__('There is a change scheduled to take place on this membership in %s. You can preview the changes here. Scheduled changes are usually created by downgrades.', 'wp-ultimo'), $date->format(get_option('date_format')));
WP_Ultimo()->notices->add($message, 'warning', 'network-admin', false, $actions);
-
- } // end add_swap_notices;
+ }
/**
* Registers the necessary scripts and styles for this admin page.
@@ -148,8 +144,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
parent::register_scripts();
wp_enqueue_editor();
-
- } // end register_scripts;
+ }
/**
* Register ajax forms that we use for membership.
@@ -161,41 +156,55 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
/*
* Transfer membership - Confirmation modal
*/
- wu_register_form('transfer_membership', array(
- 'render' => array($this, 'render_transfer_membership_modal'),
- 'handler' => array($this, 'handle_transfer_membership_modal'),
- 'capability' => 'wu_transfer_memberships',
- ));
+ wu_register_form(
+ 'transfer_membership',
+ array(
+ 'render' => array($this, 'render_transfer_membership_modal'),
+ 'handler' => array($this, 'handle_transfer_membership_modal'),
+ 'capability' => 'wu_transfer_memberships',
+ )
+ );
/*
* Edit/Add product
*/
- wu_register_form('edit_membership_product', array(
- 'render' => array($this, 'render_edit_membership_product_modal'),
- 'handler' => array($this, 'handle_edit_membership_product_modal'),
- ));
+ wu_register_form(
+ 'edit_membership_product',
+ array(
+ 'render' => array($this, 'render_edit_membership_product_modal'),
+ 'handler' => array($this, 'handle_edit_membership_product_modal'),
+ )
+ );
/*
* Change Plan
*/
- wu_register_form('change_membership_plan', array(
- 'render' => array($this, 'render_change_membership_plan_modal'),
- 'handler' => array($this, 'handle_change_membership_plan_modal'),
- ));
+ wu_register_form(
+ 'change_membership_plan',
+ array(
+ 'render' => array($this, 'render_change_membership_plan_modal'),
+ 'handler' => array($this, 'handle_change_membership_plan_modal'),
+ )
+ );
/*
* Delete Product
*/
- wu_register_form('remove_membership_product', array(
- 'render' => array($this, 'render_remove_membership_product'),
- 'handler' => array($this, 'handle_remove_membership_product'),
- ));
+ wu_register_form(
+ 'remove_membership_product',
+ array(
+ 'render' => array($this, 'render_remove_membership_product'),
+ 'handler' => array($this, 'handle_remove_membership_product'),
+ )
+ );
- add_filter('wu_data_json_success_delete_membership_modal', fn($data_json) => array(
- 'redirect_url' => wu_network_admin_url('wp-ultimo-memberships', array('deleted' => 1))
- ));
-
- } // end register_forms;
+ add_filter(
+ 'wu_data_json_success_delete_membership_modal',
+ fn($data_json) => array(
+ 'redirect_url' => wu_network_admin_url('wp-ultimo-memberships', array('deleted' => 1)),
+ )
+ );
+ }
/**
* Renders the deletion confirmation form.
@@ -207,11 +216,9 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
$membership = wu_get_membership(wu_request('id'));
- if (!$membership) {
-
+ if ( ! $membership) {
return;
-
- } // end if;
+ }
$fields = array(
'confirm' => array(
@@ -243,21 +250,26 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
),
);
- $form = new \WP_Ultimo\UI\Form('total-actions', $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(
- 'data-wu-app' => 'true',
- 'data-state' => json_encode(array(
- 'confirmed' => false,
- )),
- ),
- ));
+ $form = new \WP_Ultimo\UI\Form(
+ 'total-actions',
+ $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(
+ 'data-wu-app' => 'true',
+ 'data-state' => json_encode(
+ array(
+ 'confirmed' => false,
+ )
+ ),
+ ),
+ )
+ );
$form->render();
-
- } // end render_transfer_membership_modal;
+ }
/**
* Handles the deletion of line items.
@@ -269,25 +281,19 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
$membership = wu_get_membership(wu_request('id'));
- if (!$membership) {
-
+ if ( ! $membership) {
wp_send_json_error(new \WP_Error('not-found', __('Membership not found.', 'wp-ultimo')));
-
- } // end if;
+ }
$target_customer = wu_get_customer(wu_request('target_customer_id'));
- if (!$target_customer) {
-
+ if ( ! $target_customer) {
wp_send_json_error(new \WP_Error('not-found', __('Target customer not found.', 'wp-ultimo')));
-
- } // end if;
+ }
if ($target_customer->get_id() === $membership->get_customer_id()) {
-
wp_send_json_error(new \WP_Error('not-found', __('Cannot transfer to the same customer.', 'wp-ultimo')));
-
- } // end if;
+ }
/*
* Lock the membership to prevent memberships.
@@ -297,19 +303,27 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
/*
* Enqueue task
*/
- wu_enqueue_async_action('wu_async_transfer_membership', array(
- 'membership_id' => $membership->get_id(),
- 'target_customer_id' => $target_customer->get_id(),
- ), 'membership');
+ wu_enqueue_async_action(
+ 'wu_async_transfer_membership',
+ array(
+ 'membership_id' => $membership->get_id(),
+ 'target_customer_id' => $target_customer->get_id(),
+ ),
+ 'membership'
+ );
- wp_send_json_success(array(
- 'redirect_url' => wu_network_admin_url('wp-ultimo-edit-membership', array(
- 'id' => $membership->get_id(),
- 'transfer-started' => 1,
- ))
- ));
-
- } // end handle_transfer_membership_modal;
+ wp_send_json_success(
+ array(
+ 'redirect_url' => wu_network_admin_url(
+ 'wp-ultimo-edit-membership',
+ array(
+ 'id' => $membership->get_id(),
+ 'transfer-started' => 1,
+ )
+ ),
+ )
+ );
+ }
/**
* Allow child classes to register widgets, if they need them.
@@ -331,104 +345,125 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
$gateway_message = false;
- if (!empty($this->get_object()->get_gateway())) {
-
+ if ( ! empty($this->get_object()->get_gateway())) {
$gateway = wu_get_gateway($this->get_object()->get_gateway());
$gateway_message = $gateway ? $gateway->get_amount_update_message() : '';
+ }
- } // end if;
-
- $this->add_fields_widget('at_a_glance', array(
- 'title' => __('At a Glance', 'wp-ultimo'),
- 'position' => 'normal',
- 'classes' => 'wu-overflow-hidden wu-widget-inset',
- 'field_wrapper_classes' => 'wu-w-1/3 wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t-0 wu-border-l-0 wu-border-r wu-border-b-0 wu-border-gray-300 wu-border-solid wu-float-left wu-relative',
- 'fields' => array(
- 'status' => array(
- 'type' => 'text-display',
- 'title' => __('Membership Status', 'wp-ultimo'),
- 'display_value' => $tag,
- 'tooltip' => '',
- ),
- 'hash' => array(
- 'copy' => true,
- 'type' => 'text-display',
- 'title' => __('Reference ID', 'wp-ultimo'),
- 'display_value' => $this->get_object()->get_hash(),
- ),
- 'total_grossed' => array(
- 'type' => 'text-display',
- 'title' => __('Total Grossed', 'wp-ultimo'),
- 'display_value' => wu_format_currency($this->get_object()->get_total_grossed(), $this->get_object()->get_currency()),
- 'wrapper_classes' => 'sm:wu-border-r-0',
- ),
- ),
- ));
-
- $this->add_list_table_widget('membership-products', array(
- 'position' => 'normal',
- 'title' => __('Products', 'wp-ultimo'),
- 'table' => new \WP_Ultimo\List_Tables\Membership_Line_Item_List_Table(),
- 'after' => $this->output_widget_products(),
- ));
-
- $this->add_list_table_widget('payments', array(
- 'title' => __('Payments', 'wp-ultimo'),
- 'table' => new \WP_Ultimo\List_Tables\Customers_Payment_List_Table(),
- 'query_filter' => array($this, 'payments_query_filter'),
- ));
-
- $this->add_list_table_widget('sites', array(
- 'title' => __('Sites', 'wp-ultimo'),
- 'table' => new \WP_Ultimo\List_Tables\Memberships_Site_List_Table(),
- 'query_filter' => array($this, 'sites_query_filter'),
- ));
-
- $this->add_list_table_widget('customer', array(
- 'title' => __('Linked Customer', 'wp-ultimo'),
- 'table' => new \WP_Ultimo\List_Tables\Site_Customer_List_Table(),
- 'query_filter' => array($this, 'customer_query_filter'),
- ));
-
- $this->add_tabs_widget('options', array(
- 'title' => __('Membership Options', 'wp-ultimo'),
- 'position' => 'normal',
- 'sections' => apply_filters('wu_membership_options_sections', array(
- 'general' => array(
- 'title' => __('General', 'wp-ultimo'),
- 'desc' => __('General membership options', 'wp-ultimo'),
- 'icon' => 'dashicons-wu-globe',
- 'fields' => array(
- 'blocking' => array(
- 'type' => 'toggle',
- 'title' => __('Is Blocking?', 'wp-ultimo'),
- 'desc' => __('Should we block access to the site, plugins, themes, and services after the expiration date is reached?', 'wp-ultimo'),
- 'value' => true,
- ),
+ $this->add_fields_widget(
+ 'at_a_glance',
+ array(
+ 'title' => __('At a Glance', 'wp-ultimo'),
+ 'position' => 'normal',
+ 'classes' => 'wu-overflow-hidden wu-widget-inset',
+ 'field_wrapper_classes' => 'wu-w-1/3 wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t-0 wu-border-l-0 wu-border-r wu-border-b-0 wu-border-gray-300 wu-border-solid wu-float-left wu-relative',
+ 'fields' => array(
+ 'status' => array(
+ 'type' => 'text-display',
+ 'title' => __('Membership Status', 'wp-ultimo'),
+ 'display_value' => $tag,
+ 'tooltip' => '',
+ ),
+ 'hash' => array(
+ 'copy' => true,
+ 'type' => 'text-display',
+ 'title' => __('Reference ID', 'wp-ultimo'),
+ 'display_value' => $this->get_object()->get_hash(),
+ ),
+ 'total_grossed' => array(
+ 'type' => 'text-display',
+ 'title' => __('Total Grossed', 'wp-ultimo'),
+ 'display_value' => wu_format_currency($this->get_object()->get_total_grossed(), $this->get_object()->get_currency()),
+ 'wrapper_classes' => 'sm:wu-border-r-0',
),
),
- 'billing_info' => array(
- 'title' => __('Billing Info', 'wp-ultimo'),
- 'desc' => __('Billing information for this particular membership.', 'wp-ultimo'),
- 'icon' => 'dashicons-wu-address',
- 'fields' => $this->get_object()->get_billing_address()->get_fields(),
+ )
+ );
+
+ $this->add_list_table_widget(
+ 'membership-products',
+ array(
+ 'position' => 'normal',
+ 'title' => __('Products', 'wp-ultimo'),
+ 'table' => new \WP_Ultimo\List_Tables\Membership_Line_Item_List_Table(),
+ 'after' => $this->output_widget_products(),
+ )
+ );
+
+ $this->add_list_table_widget(
+ 'payments',
+ array(
+ 'title' => __('Payments', 'wp-ultimo'),
+ 'table' => new \WP_Ultimo\List_Tables\Customers_Payment_List_Table(),
+ 'query_filter' => array($this, 'payments_query_filter'),
+ )
+ );
+
+ $this->add_list_table_widget(
+ 'sites',
+ array(
+ 'title' => __('Sites', 'wp-ultimo'),
+ 'table' => new \WP_Ultimo\List_Tables\Memberships_Site_List_Table(),
+ 'query_filter' => array($this, 'sites_query_filter'),
+ )
+ );
+
+ $this->add_list_table_widget(
+ 'customer',
+ array(
+ 'title' => __('Linked Customer', 'wp-ultimo'),
+ 'table' => new \WP_Ultimo\List_Tables\Site_Customer_List_Table(),
+ 'query_filter' => array($this, 'customer_query_filter'),
+ )
+ );
+
+ $this->add_tabs_widget(
+ 'options',
+ array(
+ 'title' => __('Membership Options', 'wp-ultimo'),
+ 'position' => 'normal',
+ 'sections' => apply_filters(
+ 'wu_membership_options_sections',
+ array(
+ 'general' => array(
+ 'title' => __('General', 'wp-ultimo'),
+ 'desc' => __('General membership options', 'wp-ultimo'),
+ 'icon' => 'dashicons-wu-globe',
+ 'fields' => array(
+ 'blocking' => array(
+ 'type' => 'toggle',
+ 'title' => __('Is Blocking?', 'wp-ultimo'),
+ 'desc' => __('Should we block access to the site, plugins, themes, and services after the expiration date is reached?', 'wp-ultimo'),
+ 'value' => true,
+ ),
+ ),
+ ),
+ 'billing_info' => array(
+ 'title' => __('Billing Info', 'wp-ultimo'),
+ 'desc' => __('Billing information for this particular membership.', 'wp-ultimo'),
+ 'icon' => 'dashicons-wu-address',
+ 'fields' => $this->get_object()->get_billing_address()->get_fields(),
+ ),
+ ),
+ $this->get_object()
),
- ), $this->get_object()),
- ));
+ )
+ );
/*
* Hide sensitive things when in swap preview.
*/
- if (!$this->is_swap_preview) {
-
- $this->add_list_table_widget('events', array(
- 'title' => __('Events', 'wp-ultimo'),
- 'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(),
- 'query_filter' => array($this, 'events_query_filter'),
- ));
-
- } // end if;
+ if ( ! $this->is_swap_preview) {
+ $this->add_list_table_widget(
+ 'events',
+ array(
+ 'title' => __('Events', 'wp-ultimo'),
+ 'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(),
+ 'query_filter' => array($this, 'events_query_filter'),
+ )
+ );
+ }
$regular_fields = array(
'status' => array(
@@ -461,7 +496,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
'desc' => __('If enable we will cancel the subscription on payment method', 'wp-ultimo'),
'value' => false,
'wrapper_html_attr' => array(
- 'v-show' => !empty($this->get_object()->get_gateway_customer_id()) ? 'status == \'cancelled\'' : 'false',
+ 'v-show' => ! empty($this->get_object()->get_gateway_customer_id()) ? 'status == \'cancelled\'' : 'false',
'v-cloak' => '1',
),
),
@@ -521,17 +556,19 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
'v-cloak' => '1',
),
'html_attr' => array(
- 'v-bind:href' => "'" . wu_get_form_url('transfer_membership', array(
- 'id' => $this->get_object()->get_id(),
- 'target_customer_id' => '',
- )) . "=' + customer_id",
+ 'v-bind:href' => "'" . wu_get_form_url(
+ 'transfer_membership',
+ array(
+ 'id' => $this->get_object()->get_id(),
+ 'target_customer_id' => '',
+ )
+ ) . "=' + customer_id",
'title' => __('Transfer Membership', 'wp-ultimo'),
),
),
);
if ($this->get_object()->is_locked()) {
-
unset($regular_fields['transfer_note']);
unset($regular_fields['transfer']);
@@ -539,301 +576,309 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
$regular_fields['submit_save']['title'] = __('Locked', 'wp-ultimo');
$regular_fields['submit_save']['value'] = 'none';
$regular_fields['submit_save']['html_attr']['disabled'] = 'disabled';
+ }
- } // end if;
+ $this->add_fields_widget(
+ 'save',
+ array(
+ 'html_attr' => array(
+ 'data-wu-app' => 'membership_save',
+ 'data-state' => json_encode(
+ array(
+ 'status' => $this->get_object()->get_status(),
+ 'original_customer_id' => $this->get_object()->get_customer_id(),
+ 'customer_id' => $this->get_object()->get_customer_id(),
+ 'plan_id' => $this->get_object()->get_plan_id(),
+ )
+ ),
+ ),
+ 'fields' => $regular_fields,
+ )
+ );
- $this->add_fields_widget('save', array(
- 'html_attr' => array(
- 'data-wu-app' => 'membership_save',
- 'data-state' => json_encode(array(
- 'status' => $this->get_object()->get_status(),
- 'original_customer_id' => $this->get_object()->get_customer_id(),
- 'customer_id' => $this->get_object()->get_customer_id(),
- 'plan_id' => $this->get_object()->get_plan_id(),
- )),
- ),
- 'fields' => $regular_fields,
- ));
-
- $this->add_fields_widget('pricing', array(
- 'title' => __('Billing Amount', 'wp-ultimo'),
- 'html_attr' => array(
- 'data-wu-app' => 'true',
- 'data-state' => json_encode(array(
- 'is_recurring' => $this->get_object()->is_recurring(),
- 'is_auto_renew' => $this->get_object()->should_auto_renew(),
- 'amount' => $this->get_object()->get_amount(),
- 'initial_amount' => $this->get_object()->get_initial_amount(),
- 'duration' => $this->get_object()->get_duration(),
- 'duration_unit' => $this->get_object()->get_duration_unit(),
- 'gateway' => $this->get_object()->get_gateway(),
- 'gateway_subscription_id' => $this->get_object()->get_gateway_subscription_id(),
- 'gateway_customer_id' => $this->get_object()->get_gateway_customer_id(),
- )),
- ),
- 'fields' => array(
- // Fields for price
- '_initial_amount' => array(
- 'type' => 'text',
- 'title' => __('Initial Amount', 'wp-ultimo'),
- // translators: %s is a price placeholder value.
- 'placeholder' => sprintf(__('E.g. %s', 'wp-ultimo'), wu_format_currency(199)),
- 'desc' => __('The initial amount collected on the first payment.', 'wp-ultimo'),
- 'value' => $this->get_object()->get_initial_amount(),
- 'money' => true,
- 'html_attr' => array(
- 'v-model' => 'initial_amount',
- ),
- 'wrapper_html_attr' => array(
- 'v-cloak' => '1',
+ $this->add_fields_widget(
+ 'pricing',
+ array(
+ 'title' => __('Billing Amount', 'wp-ultimo'),
+ 'html_attr' => array(
+ 'data-wu-app' => 'true',
+ 'data-state' => json_encode(
+ array(
+ 'is_recurring' => $this->get_object()->is_recurring(),
+ 'is_auto_renew' => $this->get_object()->should_auto_renew(),
+ 'amount' => $this->get_object()->get_amount(),
+ 'initial_amount' => $this->get_object()->get_initial_amount(),
+ 'duration' => $this->get_object()->get_duration(),
+ 'duration_unit' => $this->get_object()->get_duration_unit(),
+ 'gateway' => $this->get_object()->get_gateway(),
+ 'gateway_subscription_id' => $this->get_object()->get_gateway_subscription_id(),
+ 'gateway_customer_id' => $this->get_object()->get_gateway_customer_id(),
+ )
),
),
- 'initial_amount' => array(
- 'type' => 'hidden',
- 'html_attr' => array(
- 'v-model' => 'initial_amount',
- ),
- ),
- 'recurring' => array(
- 'type' => 'toggle',
- 'title' => __('Is Recurring', 'wp-ultimo'),
- 'desc' => __('Use this option to manually enable or disable this membership.', 'wp-ultimo'),
- 'value' => $this->get_object()->is_recurring(),
- 'html_attr' => array(
- 'v-model' => 'is_recurring',
- ),
- 'wrapper_html_attr' => array(
- 'v-cloak' => '1',
- ),
- ),
- 'amount' => array(
- 'type' => 'hidden',
- 'html_attr' => array(
- 'v-model' => 'amount',
- ),
- ),
- 'recurring_amount_group' => array(
- 'type' => 'group',
- 'title' => __('Recurring Amount', 'wp-ultimo'),
- // translators: placeholder %1$s is the amount, %2$s is the duration (such as 1, 2, 3), and %3$s is the unit (such as month, year, week)
- 'desc' => sprintf(__('The customer will be charged %1$s every %2$s %3$s(s).', 'wp-ultimo'), '{{ wu_format_money(amount) }}', '{{ duration }}', '{{ duration_unit }}'),
- 'wrapper_html_attr' => array(
- 'v-show' => 'is_recurring',
- 'v-cloak' => '1',
- ),
- 'fields' => array(
- '_amount' => array(
- 'type' => 'text',
- 'value' => $this->get_object()->get_amount(),
- 'placeholder' => wu_format_currency('99'),
- 'wrapper_classes' => '',
- 'money' => true,
- 'html_attr' => array(
- 'v-model' => 'amount',
- ),
+ 'fields' => array(
+ // Fields for price
+ '_initial_amount' => array(
+ 'type' => 'text',
+ 'title' => __('Initial Amount', 'wp-ultimo'),
+ // translators: %s is a price placeholder value.
+ 'placeholder' => sprintf(__('E.g. %s', 'wp-ultimo'), wu_format_currency(199)),
+ 'desc' => __('The initial amount collected on the first payment.', 'wp-ultimo'),
+ 'value' => $this->get_object()->get_initial_amount(),
+ 'money' => true,
+ 'html_attr' => array(
+ 'v-model' => 'initial_amount',
),
- 'duration' => array(
- 'type' => 'number',
- 'value' => $this->get_object()->get_duration(),
- 'placeholder' => '',
- 'wrapper_classes' => 'wu-mx-2 wu-w-1/3',
- 'min' => 0,
- 'html_attr' => array(
- 'v-model' => 'duration',
- 'steps' => 1,
- ),
+ 'wrapper_html_attr' => array(
+ 'v-cloak' => '1',
),
- 'duration_unit' => array(
- 'type' => 'select',
- 'value' => $this->get_object()->get_duration_unit(),
- 'placeholder' => '',
- 'wrapper_classes' => 'wu-w-2/3',
- 'html_attr' => array(
- 'v-model' => 'duration_unit',
+ ),
+ 'initial_amount' => array(
+ 'type' => 'hidden',
+ 'html_attr' => array(
+ 'v-model' => 'initial_amount',
+ ),
+ ),
+ 'recurring' => array(
+ 'type' => 'toggle',
+ 'title' => __('Is Recurring', 'wp-ultimo'),
+ 'desc' => __('Use this option to manually enable or disable this membership.', 'wp-ultimo'),
+ 'value' => $this->get_object()->is_recurring(),
+ 'html_attr' => array(
+ 'v-model' => 'is_recurring',
+ ),
+ 'wrapper_html_attr' => array(
+ 'v-cloak' => '1',
+ ),
+ ),
+ 'amount' => array(
+ 'type' => 'hidden',
+ 'html_attr' => array(
+ 'v-model' => 'amount',
+ ),
+ ),
+ 'recurring_amount_group' => array(
+ 'type' => 'group',
+ 'title' => __('Recurring Amount', 'wp-ultimo'),
+ // translators: placeholder %1$s is the amount, %2$s is the duration (such as 1, 2, 3), and %3$s is the unit (such as month, year, week)
+ 'desc' => sprintf(__('The customer will be charged %1$s every %2$s %3$s(s).', 'wp-ultimo'), '{{ wu_format_money(amount) }}', '{{ duration }}', '{{ duration_unit }}'),
+ 'wrapper_html_attr' => array(
+ 'v-show' => 'is_recurring',
+ 'v-cloak' => '1',
+ ),
+ 'fields' => array(
+ '_amount' => array(
+ 'type' => 'text',
+ 'value' => $this->get_object()->get_amount(),
+ 'placeholder' => wu_format_currency('99'),
+ 'wrapper_classes' => '',
+ 'money' => true,
+ 'html_attr' => array(
+ 'v-model' => 'amount',
+ ),
),
- 'options' => array(
- 'day' => __('Days', 'wp-ultimo'),
- 'week' => __('Weeks', 'wp-ultimo'),
- 'month' => __('Months', 'wp-ultimo'),
- 'year' => __('Years', 'wp-ultimo'),
+ 'duration' => array(
+ 'type' => 'number',
+ 'value' => $this->get_object()->get_duration(),
+ 'placeholder' => '',
+ 'wrapper_classes' => 'wu-mx-2 wu-w-1/3',
+ 'min' => 0,
+ 'html_attr' => array(
+ 'v-model' => 'duration',
+ 'steps' => 1,
+ ),
+ ),
+ 'duration_unit' => array(
+ 'type' => 'select',
+ 'value' => $this->get_object()->get_duration_unit(),
+ 'placeholder' => '',
+ 'wrapper_classes' => 'wu-w-2/3',
+ 'html_attr' => array(
+ 'v-model' => 'duration_unit',
+ ),
+ 'options' => array(
+ 'day' => __('Days', 'wp-ultimo'),
+ 'week' => __('Weeks', 'wp-ultimo'),
+ 'month' => __('Months', 'wp-ultimo'),
+ 'year' => __('Years', 'wp-ultimo'),
+ ),
),
),
),
- ),
- 'recurring_note' => array(
- 'type' => 'note',
- 'desc' => $gateway_message,
- 'classes' => 'wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-w-full',
- 'wrapper_html_attr' => array(
- 'v-show' => implode(' && ', array(
- 'is_recurring',
- 'gateway',
- 'gateway === "' . $this->get_object()->get_gateway() . '"',
- 'gateway_subscription_id === "' . $this->get_object()->get_gateway_subscription_id() . '"',
- 'gateway_customer_id === "' . $this->get_object()->get_gateway_customer_id() . '"',
- '(' . implode(' || ', array(
- $this->get_object()->get_amount() . ' !== amount',
- $this->get_object()->get_duration() . ' != duration',
- '"' . $this->get_object()->get_duration_unit() . '" !== duration_unit',
- )) . ')',
- )),
- 'v-cloak' => '1',
+ 'recurring_note' => array(
+ 'type' => 'note',
+ 'desc' => $gateway_message,
+ 'classes' => 'wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-w-full',
+ 'wrapper_html_attr' => array(
+ 'v-show' => implode(
+ ' && ',
+ array(
+ 'is_recurring',
+ 'gateway',
+ 'gateway === "' . $this->get_object()->get_gateway() . '"',
+ 'gateway_subscription_id === "' . $this->get_object()->get_gateway_subscription_id() . '"',
+ 'gateway_customer_id === "' . $this->get_object()->get_gateway_customer_id() . '"',
+ '(' . implode(
+ ' || ',
+ array(
+ $this->get_object()->get_amount() . ' !== amount',
+ $this->get_object()->get_duration() . ' != duration',
+ '"' . $this->get_object()->get_duration_unit() . '" !== duration_unit',
+ )
+ ) . ')',
+ )
+ ),
+ 'v-cloak' => '1',
+ ),
),
- ),
- 'billing_cycles' => array(
- 'type' => 'number',
- 'title' => __('Billing Cycles', 'wp-ultimo'),
- 'placeholder' => __('E.g. 0', 'wp-ultimo'),
- 'desc' => __('How many times should we bill this customer. Leave 0 to charge until cancelled.', 'wp-ultimo'),
- 'value' => $this->get_object()->get_billing_cycles(),
- 'min' => 0,
- 'wrapper_html_attr' => array(
- 'v-show' => 'is_recurring',
- 'v-cloak' => '1',
+ 'billing_cycles' => array(
+ 'type' => 'number',
+ 'title' => __('Billing Cycles', 'wp-ultimo'),
+ 'placeholder' => __('E.g. 0', 'wp-ultimo'),
+ 'desc' => __('How many times should we bill this customer. Leave 0 to charge until cancelled.', 'wp-ultimo'),
+ 'value' => $this->get_object()->get_billing_cycles(),
+ 'min' => 0,
+ 'wrapper_html_attr' => array(
+ 'v-show' => 'is_recurring',
+ 'v-cloak' => '1',
+ ),
),
- ),
- 'times_billed' => array(
- 'type' => 'number',
- 'title' => __('Times Billed', 'wp-ultimo'),
- 'desc' => __('The number of times this membership was billed so far.', 'wp-ultimo'),
- 'value' => $this->get_object()->get_times_billed(),
- 'min' => 0,
- 'wrapper_html_attr' => array(
- 'v-show' => 'is_recurring',
- 'v-cloak' => '1',
+ 'times_billed' => array(
+ 'type' => 'number',
+ 'title' => __('Times Billed', 'wp-ultimo'),
+ 'desc' => __('The number of times this membership was billed so far.', 'wp-ultimo'),
+ 'value' => $this->get_object()->get_times_billed(),
+ 'min' => 0,
+ 'wrapper_html_attr' => array(
+ 'v-show' => 'is_recurring',
+ 'v-cloak' => '1',
+ ),
),
- ),
- 'auto_renew' => array(
- 'type' => 'toggle',
- 'title' => __('Auto-Renew?', 'wp-ultimo'),
- 'desc' => __('Activating this will tell the gateway to try to automatically charge for this membership.', 'wp-ultimo'),
- 'value' => $this->get_object()->should_auto_renew(),
- 'wrapper_html_attr' => array(
- 'v-show' => 'is_recurring',
- 'v-cloak' => '1',
+ 'auto_renew' => array(
+ 'type' => 'toggle',
+ 'title' => __('Auto-Renew?', 'wp-ultimo'),
+ 'desc' => __('Activating this will tell the gateway to try to automatically charge for this membership.', 'wp-ultimo'),
+ 'value' => $this->get_object()->should_auto_renew(),
+ 'wrapper_html_attr' => array(
+ 'v-show' => 'is_recurring',
+ 'v-cloak' => '1',
+ ),
+ 'html_attr' => array(
+ 'v-model' => 'is_auto_renew',
+ ),
),
- 'html_attr' => array(
- 'v-model' => 'is_auto_renew',
+ 'gateway' => array(
+ 'type' => 'text',
+ 'title' => __('Gateway', 'wp-ultimo'),
+ 'placeholder' => __('e.g. stripe', 'wp-ultimo'),
+ 'description' => __('e.g. stripe', 'wp-ultimo'),
+ 'desc' => __('Payment gateway used to process the payment.', 'wp-ultimo'),
+ 'value' => $this->get_object()->get_gateway(),
+ 'wrapper_classes' => 'wu-w-full',
+ 'html_attr' => array(
+ 'v-on:input' => 'gateway = $event.target.value.toLowerCase().replace(/[^a-z0-9-_]+/g, "")',
+ 'v-bind:value' => 'gateway',
+ ),
+ 'wrapper_html_attr' => array(
+ 'v-cloak' => '1',
+ ),
),
- ),
- 'gateway' => array(
- 'type' => 'text',
- 'title' => __('Gateway', 'wp-ultimo'),
- 'placeholder' => __('e.g. stripe', 'wp-ultimo'),
- 'description' => __('e.g. stripe', 'wp-ultimo'),
- 'desc' => __('Payment gateway used to process the payment.', 'wp-ultimo'),
- 'value' => $this->get_object()->get_gateway(),
- 'wrapper_classes' => 'wu-w-full',
- 'html_attr' => array(
- 'v-on:input' => 'gateway = $event.target.value.toLowerCase().replace(/[^a-z0-9-_]+/g, "")',
- 'v-bind:value' => 'gateway',
- ),
- 'wrapper_html_attr' => array(
- 'v-cloak' => '1',
- ),
- ),
- 'gateway_customer_id_group' => array(
- 'type' => 'group',
- 'desc' => function(): string {
+ 'gateway_customer_id_group' => array(
+ 'type' => 'group',
+ 'desc' => function (): string {
- $gateway_id = $this->get_object()->get_gateway();
+ $gateway_id = $this->get_object()->get_gateway();
- if (empty($this->get_object()->get_gateway_customer_id())) {
+ if (empty($this->get_object()->get_gateway_customer_id())) {
+ return '';
+ }
+
+ $url = apply_filters("wu_{$gateway_id}_remote_customer_url", $this->get_object()->get_gateway_customer_id());
+
+ if ($url) {
+ return sprintf('%s', esc_attr($url), __('View on Gateway →', 'wp-ultimo'));
+ }
return '';
-
- } // end if;
-
- $url = apply_filters("wu_{$gateway_id}_remote_customer_url", $this->get_object()->get_gateway_customer_id());
-
- if ($url) {
-
- return sprintf('%s', esc_attr($url), __('View on Gateway →', 'wp-ultimo'));
-
- } // end if;
-
- return '';
-
- },
- 'wrapper_html_attr' => array(
- 'v-show' => 'is_recurring && is_auto_renew',
- 'v-cloak' => '1',
- ),
- 'fields' => array(
- 'gateway_customer_id' => array(
- 'type' => 'text',
- 'title' => __('Gateway Customer ID', 'wp-ultimo'),
- 'placeholder' => __('Gateway Customer ID', 'wp-ultimo'),
- 'value' => $this->get_object()->get_gateway_customer_id(),
- 'tooltip' => '',
- 'wrapper_classes' => 'wu-w-full',
- 'wrapper_html_attr' => array(),
- 'html_attr' => array(
- 'v-model' => 'gateway_customer_id',
+ },
+ 'wrapper_html_attr' => array(
+ 'v-show' => 'is_recurring && is_auto_renew',
+ 'v-cloak' => '1',
+ ),
+ 'fields' => array(
+ 'gateway_customer_id' => array(
+ 'type' => 'text',
+ 'title' => __('Gateway Customer ID', 'wp-ultimo'),
+ 'placeholder' => __('Gateway Customer ID', 'wp-ultimo'),
+ 'value' => $this->get_object()->get_gateway_customer_id(),
+ 'tooltip' => '',
+ 'wrapper_classes' => 'wu-w-full',
+ 'wrapper_html_attr' => array(),
+ 'html_attr' => array(
+ 'v-model' => 'gateway_customer_id',
+ ),
),
),
),
- ),
- 'gateway_subscription_id_group' => array(
- 'type' => 'group',
- 'desc' => function(): string {
+ 'gateway_subscription_id_group' => array(
+ 'type' => 'group',
+ 'desc' => function (): string {
- $gateway_id = $this->get_object()->get_gateway();
+ $gateway_id = $this->get_object()->get_gateway();
- if (empty($this->get_object()->get_gateway_subscription_id())) {
+ if (empty($this->get_object()->get_gateway_subscription_id())) {
+ return '';
+ }
+
+ $url = apply_filters("wu_{$gateway_id}_remote_subscription_url", $this->get_object()->get_gateway_subscription_id());
+
+ if ($url) {
+ return sprintf('%s', esc_attr($url), __('View on Gateway →', 'wp-ultimo'));
+ }
return '';
-
- } // end if;
-
- $url = apply_filters("wu_{$gateway_id}_remote_subscription_url", $this->get_object()->get_gateway_subscription_id());
-
- if ($url) {
-
- return sprintf('%s', esc_attr($url), __('View on Gateway →', 'wp-ultimo'));
-
- } // end if;
-
- return '';
-
- },
- 'wrapper_html_attr' => array(
- 'v-show' => 'is_recurring && is_auto_renew',
- 'v-cloak' => '1',
- ),
- 'fields' => array(
- 'gateway_subscription_id' => array(
- 'type' => 'text',
- 'title' => __('Gateway Subscription ID', 'wp-ultimo'),
- 'placeholder' => __('Gateway Subscription ID', 'wp-ultimo'),
- 'value' => $this->get_object()->get_gateway_subscription_id(),
- 'tooltip' => '',
- 'wrapper_classes' => 'wu-w-full',
- 'wrapper_html_attr' => array(),
- 'html_attr' => array(
- 'v-model' => 'gateway_subscription_id',
+ },
+ 'wrapper_html_attr' => array(
+ 'v-show' => 'is_recurring && is_auto_renew',
+ 'v-cloak' => '1',
+ ),
+ 'fields' => array(
+ 'gateway_subscription_id' => array(
+ 'type' => 'text',
+ 'title' => __('Gateway Subscription ID', 'wp-ultimo'),
+ 'placeholder' => __('Gateway Subscription ID', 'wp-ultimo'),
+ 'value' => $this->get_object()->get_gateway_subscription_id(),
+ 'tooltip' => '',
+ 'wrapper_classes' => 'wu-w-full',
+ 'wrapper_html_attr' => array(),
+ 'html_attr' => array(
+ 'v-model' => 'gateway_subscription_id',
+ ),
),
),
),
- ),
- 'gateway_note' => array(
- 'type' => 'note',
- 'desc' => __('We will try to cancel the old subscription on the gateway.', 'wp-ultimo'),
- 'classes' => 'wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-w-full',
- 'wrapper_html_attr' => array(
- 'v-show' => 'is_recurring && (' . implode(' || ', array(
- '"' . $this->get_object()->get_gateway() . '" !== "" && gateway !== "' . $this->get_object()->get_gateway() . '"',
- '"' . $this->get_object()->get_gateway_subscription_id() . '" !== "" && gateway_subscription_id !== "' . $this->get_object()->get_gateway_subscription_id() . '"',
- '"' . $this->get_object()->get_gateway_customer_id() . '" !== "" && gateway_customer_id !== "' . $this->get_object()->get_gateway_customer_id() . '"',
- )) . ')',
- 'v-cloak' => '1',
+ 'gateway_note' => array(
+ 'type' => 'note',
+ 'desc' => __('We will try to cancel the old subscription on the gateway.', 'wp-ultimo'),
+ 'classes' => 'wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-w-full',
+ 'wrapper_html_attr' => array(
+ 'v-show' => 'is_recurring && (' . implode(
+ ' || ',
+ array(
+ '"' . $this->get_object()->get_gateway() . '" !== "" && gateway !== "' . $this->get_object()->get_gateway() . '"',
+ '"' . $this->get_object()->get_gateway_subscription_id() . '" !== "" && gateway_subscription_id !== "' . $this->get_object()->get_gateway_subscription_id() . '"',
+ '"' . $this->get_object()->get_gateway_customer_id() . '" !== "" && gateway_customer_id !== "' . $this->get_object()->get_gateway_customer_id() . '"',
+ )
+ ) . ')',
+ 'v-cloak' => '1',
+ ),
),
),
- ),
- ));
+ )
+ );
$timestamp_fields = array();
@@ -845,10 +890,9 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
);
foreach ($timestamps as $timestamp_name => $timestamp_label) {
-
$value = $this->get_object()->{"get_$timestamp_name"}();
- $timestamp_fields[$timestamp_name] = array(
+ $timestamp_fields[ $timestamp_name ] = array(
'title' => $timestamp_label,
'type' => 'text-edit',
'date' => true,
@@ -862,11 +906,9 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
'data-allow-time' => 'true',
),
);
+ }
- } // end foreach;
-
- if (!$this->get_object()->is_lifetime()) {
-
+ if ( ! $this->get_object()->is_lifetime()) {
$timestamp_fields['convert_to_lifetime'] = array(
'type' => 'submit',
'title' => __('Convert to Lifetime', 'wp-ultimo'),
@@ -874,15 +916,16 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
'classes' => 'button wu-w-full',
'wrapper_html_attr' => array(),
);
+ }
- } // end if;
-
- $this->add_fields_widget('membership-timestamps', array(
- 'title' => __('Important Timestamps', 'wp-ultimo'),
- 'fields' => $timestamp_fields,
- ));
-
- } // end register_widgets;
+ $this->add_fields_widget(
+ 'membership-timestamps',
+ array(
+ 'title' => __('Important Timestamps', 'wp-ultimo'),
+ 'fields' => $timestamp_fields,
+ )
+ );
+ }
/**
* Renders the widget used to display the product list.
@@ -892,11 +935,13 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
*/
public function output_widget_products() {
- return wu_get_template_contents('memberships/product-list', array(
- 'membership' => $this->get_object(),
- ));
-
- } // end output_widget_products;
+ return wu_get_template_contents(
+ 'memberships/product-list',
+ array(
+ 'membership' => $this->get_object(),
+ )
+ );
+ }
/**
* Returns the title of the page.
@@ -907,8 +952,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
public function get_title() {
return $this->edit ? __('Edit Membership', 'wp-ultimo') : __('Add new Membership', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the title of menu for this page.
@@ -919,8 +963,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
public function get_menu_title() {
return __('Edit Membership', 'wp-ultimo');
-
- } // end get_menu_title;
+ }
/**
* Returns the action links for that page.
@@ -931,8 +974,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
public function action_links() {
return array();
-
- } // end action_links;
+ }
/**
* Returns the labels to be used on the admin page.
@@ -953,8 +995,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
'delete_button_label' => __('Delete Membership', 'wp-ultimo'),
'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'),
);
-
- } // end get_labels;
+ }
/**
* Filters the list table to return only relevant payments.
@@ -969,8 +1010,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
$args['membership_id'] = $this->get_object()->get_id();
return $args;
-
- } // end payments_query_filter;
+ }
/**
* Filters the list table to return only relevant sites.
@@ -990,8 +1030,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
);
return $args;
-
- } // end sites_query_filter;
+ }
/**
* Filters the list table to return only relevant customer.
@@ -1006,8 +1045,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
$args['id'] = $this->get_object()->get_customer_id();
return $args;
-
- } // end customer_query_filter;
+ }
/**
* Filters the list table to return only relevant events.
@@ -1025,8 +1063,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
);
return array_merge($args, $extra_args);
-
- } // end events_query_filter;
+ }
/**
* Returns the object being edit at the moment.
@@ -1037,22 +1074,18 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
public function get_object() {
if ($this->object !== null) {
-
return $this->object;
-
- } // end if;
+ }
$item_id = wu_request('id', 0);
$item = wu_get_membership($item_id);
- if (!$item) {
-
+ if ( ! $item) {
wp_redirect(wu_network_admin_url('wp-ultimo-memberships'));
exit;
-
- } // end if;
+ }
$this->object = $item;
@@ -1060,14 +1093,11 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
* Deal with scheduled swaps.
*/
if (wu_request('preview-swap')) {
-
$swap_order = $this->get_object()->get_scheduled_swap();
- if (!$swap_order) {
-
+ if ( ! $swap_order) {
return $this->object;
-
- } // end if;
+ }
$this->is_swap_preview = true;
@@ -1086,12 +1116,10 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
WP_Ultimo()->notices->add($message, 'info', 'network-admin', false, $actions);
$this->object->swap($swap_order->order);
-
- } // end if;
+ }
return $this->object;
-
- } // end get_object;
+ }
/**
* Memberships have titles.
*
@@ -1100,8 +1128,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
public function has_title(): bool {
return false;
-
- } // end has_title;
+ }
/**
* Handle convert to lifetime.
*
@@ -1116,32 +1143,27 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
$save = $object->save();
if (is_wp_error($save)) {
-
$errors = implode(' ', $save->get_error_messages());
WP_Ultimo()->notices->add($errors, 'error', 'network-admin');
return false;
-
- } // end if;
+ }
$array_params = array(
'updated' => 1,
);
if ($this->edit === false) {
-
$array_params['id'] = $object->get_id();
-
- } // end if;
+ }
$url = add_query_arg($array_params);
wp_redirect($url);
return true;
-
- } // end handle_convert_to_lifetime;
+ }
/**
* Should implement the processes necessary to save the changes made to the object.
@@ -1154,25 +1176,19 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
$object = $this->get_object();
// Cancel membership on gateway
- if ((bool) wu_request('cancel_gateway', false) && wu_request('status', Membership_Status::CANCELLED)) {
-
+ if ( (bool) wu_request('cancel_gateway', false) && wu_request('status', Membership_Status::CANCELLED)) {
$gateway = wu_get_gateway(wu_request('gateway'));
if ($gateway) {
-
$gateway->process_cancellation($object, $object->get_customer());
$_POST['gateway'] = '';
-
- } // end if;
-
- } // end if;
+ }
+ }
if (wu_request('submit_button') === 'convert_to_lifetime') {
-
return $this->handle_convert_to_lifetime();
-
- } // end if;
+ }
$_POST['auto_renew'] = (bool) wu_request('auto_renew', false);
@@ -1183,14 +1199,12 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
$valid_address = $billing_address->validate();
if (is_wp_error($valid_address)) {
-
$errors = implode(' ', $valid_address->get_error_messages());
WP_Ultimo()->notices->add($errors, 'error', 'network-admin');
return false;
-
- } // end if;
+ }
$object->set_billing_address($billing_address);
@@ -1199,7 +1213,6 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
$status = parent::handle_save();
if ($this->is_swap_preview) {
-
ob_clean();
$object->delete_scheduled_swap();
@@ -1215,12 +1228,10 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
wp_redirect($url);
return true;
-
- } // end if;
+ }
return $status;
-
- } // end handle_save;
+ }
/**
* Renders the add/edit line items form.
@@ -1232,21 +1243,17 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
$membership = wu_get_membership(wu_request('id'));
- if (!$membership) {
-
+ if ( ! $membership) {
return;
-
- } // end if;
+ }
$gateway_message = false;
- if (!empty($membership->get_gateway())) {
-
+ if ( ! empty($membership->get_gateway())) {
$gateway = wu_get_gateway($membership->get_gateway());
$gateway_message = $gateway ? $gateway->get_amount_update_message() : '';
-
- } // end if;
+ }
$fields = array(
'product_id' => array(
@@ -1306,27 +1313,30 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
),
);
- if (!$gateway_message) {
-
+ if ( ! $gateway_message) {
unset($fields['transfer_note']);
+ }
- } // end if;
-
- $form = new \WP_Ultimo\UI\Form('edit_membership_product', $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(
- 'data-wu-app' => 'edit_membership_product',
- 'data-state' => wu_convert_to_state(array(
- 'update_pricing' => 0,
- )),
- ),
- ));
+ $form = new \WP_Ultimo\UI\Form(
+ 'edit_membership_product',
+ $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(
+ 'data-wu-app' => 'edit_membership_product',
+ 'data-state' => wu_convert_to_state(
+ array(
+ 'update_pricing' => 0,
+ )
+ ),
+ ),
+ )
+ );
$form->render();
-
- } // end render_edit_membership_product_modal;
+ }
/**
* Handles the add/edit of line items.
@@ -1338,54 +1348,45 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
$membership = wu_get_membership(wu_request('id'));
- if (!$membership) {
-
+ if ( ! $membership) {
$error = new \WP_Error('membership-not-found', __('Membership not found.', 'wp-ultimo'));
wp_send_json_error($error);
-
- } // end if;
+ }
$product = wu_get_product(wu_request('product_id'));
- if (!$product) {
-
+ if ( ! $product) {
$error = new \WP_Error('product-not-found', __('Product not found.', 'wp-ultimo'));
wp_send_json_error($error);
-
- } // end if;
+ }
$membership->add_product($product->get_id(), (int) wu_request('quantity', 1));
// if we are updating the pricing, we need to update the membership price.
if (wu_request('update_price')) {
-
$value_to_add = wu_get_membership_product_price($membership, $product->get_id(), (int) wu_request('quantity', 1));
if (is_wp_error($value_to_add)) {
-
wp_send_json_error($value_to_add);
-
- } // end if;
+ }
$membership->set_amount($membership->get_amount() + $value_to_add);
-
- } // end if;
+ }
$saved = $membership->save();
if (is_wp_error($saved)) {
-
wp_send_json_error($saved);
+ }
- } // end if;
-
- wp_send_json_success(array(
- 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']),
- ));
-
- } // end handle_edit_membership_product_modal;
+ wp_send_json_success(
+ array(
+ 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']),
+ )
+ );
+ }
/**
* Renders the deletion confirmation form.
@@ -1397,21 +1398,17 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
$membership = wu_get_membership(wu_request('id'));
- if (!$membership) {
-
+ if ( ! $membership) {
return;
-
- } // end if;
+ }
$gateway_message = false;
if ($membership->get_gateway()) {
-
$gateway = wu_get_gateway($membership->get_gateway());
$gateway_message = $gateway ? $gateway->get_amount_update_message() : '';
-
- } // end if;
+ }
$fields = array(
'quantity' => array(
@@ -1460,27 +1457,30 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
),
);
- if (!$gateway_message) {
-
+ if ( ! $gateway_message) {
unset($fields['transfer_note']);
+ }
- } // end if;
-
- $form = new \WP_Ultimo\UI\Form('edit_membership_product', $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(
- 'data-wu-app' => 'edit_membership_product',
- 'data-state' => wu_convert_to_state(array(
- 'update_pricing' => 0,
- )),
- ),
- ));
+ $form = new \WP_Ultimo\UI\Form(
+ 'edit_membership_product',
+ $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(
+ 'data-wu-app' => 'edit_membership_product',
+ 'data-state' => wu_convert_to_state(
+ array(
+ 'update_pricing' => 0,
+ )
+ ),
+ ),
+ )
+ );
$form->render();
-
- } // end render_remove_membership_product;
+ }
/**
* Handles the deletion of line items.
@@ -1492,23 +1492,19 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
$membership = wu_get_membership(wu_request('id'));
- if (!$membership) {
-
+ if ( ! $membership) {
$error = new \WP_Error('membership-not-found', __('Membership not found.', 'wp-ultimo'));
wp_send_json_error($error);
-
- } // end if;
+ }
$product = wu_get_product(wu_request('product_id'));
- if (!$product) {
-
+ if ( ! $product) {
$error = new \WP_Error('product-not-found', __('Product not found.', 'wp-ultimo'));
wp_send_json_error($error);
-
- } // end if;
+ }
// Get the existing quantity by filtering the products array.
$existing_quantity = array_filter($membership->get_addon_products(), fn($item) => $item['product']->get_id() === $product->get_id())[0]['quantity'];
@@ -1520,32 +1516,27 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
// if we are updating the pricing, we need to update the membership price.
if (wu_request('update_price')) {
-
$value_to_remove = wu_get_membership_product_price($membership, $product->get_id(), $quantity);
if (is_wp_error($value_to_remove)) {
-
wp_send_json_error($value_to_remove);
-
- } // end if;
+ }
$membership->set_amount($membership->get_amount() - $value_to_remove);
-
- } // end if;
+ }
$saved = $membership->save();
if (is_wp_error($saved)) {
-
wp_send_json_error($saved);
+ }
- } // end if;
-
- wp_send_json_success(array(
- 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']),
- ));
-
- } // end handle_remove_membership_product;
+ wp_send_json_success(
+ array(
+ 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']),
+ )
+ );
+ }
/**
* Renders the add/edit line items form.
@@ -1557,29 +1548,23 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
$membership = wu_get_membership(wu_request('id'));
- if (!$membership) {
-
+ if ( ! $membership) {
return;
-
- } // end if;
+ }
$product = wu_get_product(wu_request('product_id'));
- if (!$product) {
-
+ if ( ! $product) {
return;
-
- } // end if;
+ }
$gateway_message = false;
if ($membership->get_gateway()) {
-
$gateway = wu_get_gateway($membership->get_gateway());
$gateway_message = $gateway ? $gateway->get_amount_update_message() : '';
-
- } // end if;
+ }
$fields = array(
'plan_id' => array(
@@ -1634,29 +1619,32 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
),
);
- if (!$gateway_message) {
-
+ if ( ! $gateway_message) {
unset($fields['transfer_note']);
+ }
- } // end if;
-
- $form = new \WP_Ultimo\UI\Form('change_membership_plan', $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(
- 'data-wu-app' => 'change_membership_plan',
- 'data-state' => wu_convert_to_state(array(
- 'update_pricing' => 0,
- 'original_plan_id' => $product->get_id(),
- 'plan_id' => $product->get_id(),
- )),
- ),
- ));
+ $form = new \WP_Ultimo\UI\Form(
+ 'change_membership_plan',
+ $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(
+ 'data-wu-app' => 'change_membership_plan',
+ 'data-state' => wu_convert_to_state(
+ array(
+ 'update_pricing' => 0,
+ 'original_plan_id' => $product->get_id(),
+ 'plan_id' => $product->get_id(),
+ )
+ ),
+ ),
+ )
+ );
$form->render();
-
- } // end render_change_membership_plan_modal;
+ }
/**
* Handles the add/edit of line items.
@@ -1668,71 +1656,57 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page {
$membership = wu_get_membership(wu_request('id'));
- if (!$membership) {
-
+ if ( ! $membership) {
$error = new \WP_Error('membership-not-found', __('Membership not found.', 'wp-ultimo'));
wp_send_json_error($error);
-
- } // end if;
+ }
$plan = wu_get_product(wu_request('plan_id'));
- if (!$plan) {
-
+ if ( ! $plan) {
$error = new \WP_Error('plan-not-found', __('Plan not found.', 'wp-ultimo'));
wp_send_json_error($error);
-
- } // end if;
+ }
$original_plan_id = $membership->get_plan_id();
if (absint($original_plan_id) === absint($plan->get_id())) {
-
$error = new \WP_Error('same-plan', __('No change performed. The same plan selected.', 'wp-ultimo'));
wp_send_json_error($error);
-
- } // end if;
+ }
$membership->set_plan_id($plan->get_id());
// if we are updating the pricing, we need to update the membership price.
if (wu_request('update_price')) {
-
$value_to_add = wu_get_membership_product_price($membership, $plan->get_id(), 1);
if (is_wp_error($value_to_add)) {
-
wp_send_json_error($value_to_add);
-
- } // end if;
+ }
$value_to_remove = wu_get_membership_product_price($membership, $original_plan_id, 1);
if (is_wp_error($value_to_remove)) {
-
wp_send_json_error($value_to_remove);
-
- } // end if;
+ }
$membership->set_amount($membership->get_amount() + $value_to_add - $value_to_remove);
-
- } // end if;
+ }
$saved = $membership->save();
if (is_wp_error($saved)) {
-
wp_send_json_error($saved);
+ }
- } // end if;
-
- wp_send_json_success(array(
- 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']),
- ));
-
- } // end handle_change_membership_plan_modal;
-
-} // end class Membership_Edit_Admin_Page;
+ wp_send_json_success(
+ array(
+ 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']),
+ )
+ );
+ }
+}
diff --git a/inc/admin-pages/class-membership-list-admin-page.php b/inc/admin-pages/class-membership-list-admin-page.php
index bf6e491..94b0870 100644
--- a/inc/admin-pages/class-membership-list-admin-page.php
+++ b/inc/admin-pages/class-membership-list-admin-page.php
@@ -12,8 +12,8 @@ namespace WP_Ultimo\Admin_Pages;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Models\Membership;
-use \WP_Ultimo\Database\Memberships\Membership_Status;
+use WP_Ultimo\Models\Membership;
+use WP_Ultimo\Database\Memberships\Membership_Status;
/**
* WP Multisite WaaS Membership Admin Page.
@@ -67,13 +67,15 @@ class Membership_List_Admin_Page extends List_Admin_Page {
/*
* Add new Membership
*/
- wu_register_form('add_new_membership', array(
- 'render' => array($this, 'render_add_new_membership_modal'),
- 'handler' => array($this, 'handle_add_new_membership_modal'),
- 'capability' => 'wu_edit_memberships',
- ));
-
- } // end register_forms;
+ wu_register_form(
+ 'add_new_membership',
+ array(
+ 'render' => array($this, 'render_add_new_membership_modal'),
+ 'handler' => array($this, 'handle_add_new_membership_modal'),
+ 'capability' => 'wu_edit_memberships',
+ )
+ );
+ }
/**
* Renders the add new customer modal.
@@ -155,22 +157,27 @@ class Membership_List_Admin_Page extends List_Admin_Page {
),
);
- $form = new \WP_Ultimo\UI\Form('add_new_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(
- 'data-wu-app' => 'add_new_membership',
- 'data-on-load' => 'wu_initialize_datepickers',
- 'data-state' => wu_convert_to_state(array(
- 'lifetime' => 1
- )),
- ),
- ));
+ $form = new \WP_Ultimo\UI\Form(
+ 'add_new_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(
+ 'data-wu-app' => 'add_new_membership',
+ 'data-on-load' => 'wu_initialize_datepickers',
+ 'data-state' => wu_convert_to_state(
+ array(
+ 'lifetime' => 1,
+ )
+ ),
+ ),
+ )
+ );
$form->render();
-
- } // end render_add_new_membership_modal;
+ }
/**
* Handles creation of a new memberships.
@@ -187,29 +194,31 @@ class Membership_List_Admin_Page extends List_Admin_Page {
$products = explode(',', (string) $products);
if (empty($products)) {
-
- wp_send_json_error(new \WP_Error(
- 'empty-products',
- __('Products can not be empty.', 'wp-ultimo')
- ));
-
- } // end if;
+ wp_send_json_error(
+ new \WP_Error(
+ 'empty-products',
+ __('Products can not be empty.', 'wp-ultimo')
+ )
+ );
+ }
$customer = wu_get_customer(wu_request('customer_id', 0));
if (empty($customer)) {
+ wp_send_json_error(
+ new \WP_Error(
+ 'customer-not-found',
+ __('The selected customer does not exist.', 'wp-ultimo')
+ )
+ );
+ }
- wp_send_json_error(new \WP_Error(
- 'customer-not-found',
- __('The selected customer does not exist.', 'wp-ultimo')
- ));
-
- } // end if;
-
- $cart = new \WP_Ultimo\Checkout\Cart(array(
- 'products' => $products,
- 'country' => $customer->get_country(),
- ));
+ $cart = new \WP_Ultimo\Checkout\Cart(
+ array(
+ 'products' => $products,
+ 'country' => $customer->get_country(),
+ )
+ );
$data = $cart->to_membership_data();
@@ -222,28 +231,28 @@ class Membership_List_Admin_Page extends List_Admin_Page {
$maybe_lifetime = wu_request('lifetime');
if ($maybe_lifetime) {
-
$date_expiration = null;
-
- } // end if;
+ }
$data['date_expiration'] = $date_expiration;
$membership = wu_create_membership($data);
if (is_wp_error($membership)) {
-
wp_send_json_error($membership);
+ }
- } // end if;
-
- wp_send_json_success(array(
- 'redirect_url' => wu_network_admin_url('wp-ultimo-edit-membership', array(
- 'id' => $membership->get_id(),
- ))
- ));
-
- } // end handle_add_new_membership_modal;
+ wp_send_json_success(
+ array(
+ 'redirect_url' => wu_network_admin_url(
+ 'wp-ultimo-edit-membership',
+ array(
+ 'id' => $membership->get_id(),
+ )
+ ),
+ )
+ );
+ }
/**
* Returns an array with the labels for the edit page.
@@ -257,8 +266,7 @@ class Membership_List_Admin_Page extends List_Admin_Page {
'deleted_message' => __('Membership removed successfully.', 'wp-ultimo'),
'search_label' => __('Search Membership', 'wp-ultimo'),
);
-
- } // end get_labels;
+ }
/**
* Returns the title of the page.
@@ -269,8 +277,7 @@ class Membership_List_Admin_Page extends List_Admin_Page {
public function get_title() {
return __('Memberships', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the title of menu for this page.
@@ -281,8 +288,7 @@ class Membership_List_Admin_Page extends List_Admin_Page {
public function get_menu_title() {
return __('Memberships', 'wp-ultimo');
-
- } // end get_menu_title;
+ }
/**
* Allows admins to rename the sub-menu (first item) for a top-level page.
@@ -293,8 +299,7 @@ class Membership_List_Admin_Page extends List_Admin_Page {
public function get_submenu_title() {
return __('Memberships', 'wp-ultimo');
-
- } // end get_submenu_title;
+ }
/**
* Returns the action links for that page.
@@ -312,8 +317,7 @@ class Membership_List_Admin_Page extends List_Admin_Page {
'url' => wu_get_form_url('add_new_membership'),
),
);
-
- } // end action_links;
+ }
/**
* Loads the list table for this particular page.
@@ -324,7 +328,5 @@ class Membership_List_Admin_Page extends List_Admin_Page {
public function table() {
return new \WP_Ultimo\List_Tables\Membership_List_Table();
-
- } // end table;
-
-} // end class Membership_List_Admin_Page;
+ }
+}
diff --git a/inc/admin-pages/class-migration-alert-admin-page.php b/inc/admin-pages/class-migration-alert-admin-page.php
index a9a993b..65e28c0 100644
--- a/inc/admin-pages/class-migration-alert-admin-page.php
+++ b/inc/admin-pages/class-migration-alert-admin-page.php
@@ -83,8 +83,7 @@ class Migration_Alert_Admin_Page extends Wizard_Admin_Page {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Returns the logo for the wizard.
@@ -95,8 +94,7 @@ class Migration_Alert_Admin_Page extends Wizard_Admin_Page {
public function get_logo() {
return wu_get_asset('logo.png', 'img');
-
- } // end get_logo;
+ }
/**
* Returns the title of the page.
@@ -107,8 +105,7 @@ class Migration_Alert_Admin_Page extends Wizard_Admin_Page {
public function get_title(): string {
return sprintf(__('Migration', 'wp-ultimo'));
-
- } // end get_title;
+ }
/**
* Returns the title of menu for this page.
@@ -119,8 +116,7 @@ class Migration_Alert_Admin_Page extends Wizard_Admin_Page {
public function get_menu_title() {
return WP_Ultimo()->is_loaded() ? __('WP Multisite WaaS Migration Alert', 'wp-ultimo') : __('WP Multisite WaaS', 'wp-ultimo');
-
- } // end get_menu_title;
+ }
/**
* Returns the sections for this Wizard.
@@ -137,8 +133,7 @@ class Migration_Alert_Admin_Page extends Wizard_Admin_Page {
'handler' => array($this, 'handle_proceed'),
),
);
-
- } // end get_sections;
+ }
/**
* Displays the content of the final section.
@@ -148,12 +143,14 @@ class Migration_Alert_Admin_Page extends Wizard_Admin_Page {
*/
public function section_alert() {
- wu_get_template('wizards/setup/alert', array(
- 'screen' => get_current_screen(),
- 'page' => $this,
- ));
-
- } // end section_alert;
+ wu_get_template(
+ 'wizards/setup/alert',
+ array(
+ 'screen' => get_current_screen(),
+ 'page' => $this,
+ )
+ );
+ }
/**
* Handles the proceed action.
@@ -169,7 +166,5 @@ class Migration_Alert_Admin_Page extends Wizard_Admin_Page {
wp_redirect(wu_network_admin_url('wp-ultimo-setup'));
exit;
-
- } // end handle_proceed;
-
-} // end class Migration_Alert_Admin_Page;
+ }
+}
diff --git a/inc/admin-pages/class-payment-edit-admin-page.php b/inc/admin-pages/class-payment-edit-admin-page.php
index fb21edc..0fb0698 100644
--- a/inc/admin-pages/class-payment-edit-admin-page.php
+++ b/inc/admin-pages/class-payment-edit-admin-page.php
@@ -12,8 +12,8 @@ namespace WP_Ultimo\Admin_Pages;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Models\Payment;
-use \WP_Ultimo\Database\Payments\Payment_Status;
+use WP_Ultimo\Models\Payment;
+use WP_Ultimo\Database\Payments\Payment_Status;
/**
* WP Multisite WaaS Payment Edit/Add New Admin Page.
@@ -92,8 +92,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
parent::register_scripts();
wp_enqueue_editor();
-
- } // end register_scripts;
+ }
/**
* Register ajax forms that we use for payments.
@@ -105,38 +104,49 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
/*
* Edit/Add Line Item
*/
- wu_register_form('edit_line_item', array(
- 'render' => array($this, 'render_edit_line_item_modal'),
- 'handler' => array($this, 'handle_edit_line_item_modal'),
- 'capability' => 'wu_edit_payments',
- ));
+ wu_register_form(
+ 'edit_line_item',
+ array(
+ 'render' => array($this, 'render_edit_line_item_modal'),
+ 'handler' => array($this, 'handle_edit_line_item_modal'),
+ 'capability' => 'wu_edit_payments',
+ )
+ );
/*
* Delete Line Item - Confirmation modal
*/
- wu_register_form('delete_line_item', array(
- 'render' => array($this, 'render_delete_line_item_modal'),
- 'handler' => array($this, 'handle_delete_line_item_modal'),
- 'capability' => 'wu_delete_payments',
- ));
+ wu_register_form(
+ 'delete_line_item',
+ array(
+ 'render' => array($this, 'render_delete_line_item_modal'),
+ 'handler' => array($this, 'handle_delete_line_item_modal'),
+ 'capability' => 'wu_delete_payments',
+ )
+ );
/*
* Refund Line Item
*/
- wu_register_form('refund_payment', array(
- 'render' => array($this, 'render_refund_payment_modal'),
- 'handler' => array($this, 'handle_refund_payment_modal'),
- 'capability' => 'wu_refund_payments',
- ));
+ wu_register_form(
+ 'refund_payment',
+ array(
+ 'render' => array($this, 'render_refund_payment_modal'),
+ 'handler' => array($this, 'handle_refund_payment_modal'),
+ 'capability' => 'wu_refund_payments',
+ )
+ );
/*
* Delete - Confirmation modal
*/
- add_filter('wu_data_json_success_delete_payment_modal', fn($data_json) => array(
- 'redirect_url' => wu_network_admin_url('wp-ultimo-payments', array('deleted' => 1))
- ));
-
- } // end register_forms;
+ add_filter(
+ 'wu_data_json_success_delete_payment_modal',
+ fn($data_json) => array(
+ 'redirect_url' => wu_network_admin_url('wp-ultimo-payments', array('deleted' => 1)),
+ )
+ );
+ }
/**
* Renders the deletion confirmation form.
@@ -150,11 +160,9 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
$line_item = wu_get_line_item(wu_request('line_item_id'), $payment->get_id());
- if (!$line_item || !$payment) {
-
+ if ( ! $line_item || ! $payment) {
return;
-
- } // end if;
+ }
$fields = array(
'confirm' => array(
@@ -185,21 +193,26 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
),
);
- $form = new \WP_Ultimo\UI\Form('total-actions', $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(
- 'data-wu-app' => 'true',
- 'data-state' => wu_convert_to_state(array(
- 'confirmed' => false,
- )),
- ),
- ));
+ $form = new \WP_Ultimo\UI\Form(
+ 'total-actions',
+ $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(
+ 'data-wu-app' => 'true',
+ 'data-state' => wu_convert_to_state(
+ array(
+ 'confirmed' => false,
+ )
+ ),
+ ),
+ )
+ );
$form->render();
-
- } // end render_delete_line_item_modal;
+ }
/**
* Handles the deletion of line items.
@@ -213,31 +226,28 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
$line_item = wu_get_line_item(wu_request('line_item_id'), $payment->get_id());
- if (!$payment || !$line_item) {
-
+ if ( ! $payment || ! $line_item) {
wp_send_json_error(new \WP_Error('not-found', __('Payment not found.', 'wp-ultimo')));
-
- } // end if;
+ }
$line_items = $payment->get_line_items();
- unset($line_items[$line_item->get_id()]);
+ unset($line_items[ $line_item->get_id() ]);
$payment->set_line_items($line_items);
$saved = $payment->recalculate_totals()->save();
if (is_wp_error($saved)) {
-
wp_send_json_error($saved);
+ }
- } // end if;
-
- wp_send_json_success(array(
- 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']),
- ));
-
- } // end handle_delete_line_item_modal;
+ wp_send_json_success(
+ array(
+ 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']),
+ )
+ );
+ }
/**
* Renders the refund line item modal.
@@ -249,11 +259,9 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
$payment = wu_get_payment(wu_request('id'));
- if (!$payment) {
-
+ if ( ! $payment) {
return;
-
- } // end if;
+ }
$fields = array(
'_amount' => array(
@@ -265,7 +273,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
'html_attr' => array(
'v-model' => 'amount',
'step' => '0.01',
- 'v-bind:max' => 'total'
+ 'v-bind:max' => 'total',
),
'wrapper_html_attr' => array(
'v-show' => 'step === 1',
@@ -317,7 +325,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
),
'html_attr' => array(
'v-bind:disabled' => 'amount <= 0 || amount > total',
- 'v-on:click.prevent' => 'step = 2'
+ 'v-on:click.prevent' => 'step = 2',
),
),
'submit_button_2' => array(
@@ -340,24 +348,29 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
),
);
- $form = new \WP_Ultimo\UI\Form('total-actions', $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(
- 'data-wu-app' => 'refund',
- 'data-state' => wu_convert_to_state(array(
- 'step' => 1,
- 'confirmed' => false,
- 'total' => round($payment->get_total(), 2),
- 'amount' => round($payment->get_total(), 2),
- )),
- ),
- ));
+ $form = new \WP_Ultimo\UI\Form(
+ 'total-actions',
+ $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(
+ 'data-wu-app' => 'refund',
+ 'data-state' => wu_convert_to_state(
+ array(
+ 'step' => 1,
+ 'confirmed' => false,
+ 'total' => round($payment->get_total(), 2),
+ 'amount' => round($payment->get_total(), 2),
+ )
+ ),
+ ),
+ )
+ );
$form->render();
-
- } // end render_refund_payment_modal;
+ }
/**
* Handles the deletion of line items.
@@ -371,20 +384,16 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
$payment = wu_get_payment(wu_request('id'));
- if (!$payment) {
-
+ if ( ! $payment) {
wp_send_json_error(new \WP_Error('not-found', __('Payment not found.', 'wp-ultimo')));
-
- } // end if;
+ }
/*
* Checks for a valid amount.
*/
if (empty($amount) || $amount > $payment->get_total()) {
-
wp_send_json_error(new \WP_Error('invalid-amount', __('The refund amount is out of bounds.', 'wp-ultimo')));
-
- } // end if;
+ }
/*
* Check if the payment is in a
@@ -392,11 +401,9 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
*/
$is_refundable = in_array($payment->get_status(), wu_get_refundable_payment_types(), true);
- if (!$is_refundable) {
-
+ if ( ! $is_refundable) {
wp_send_json_error(new \WP_Error('payment-not-refunded', __('This payment is not in a refundable state.', 'wp-ultimo')));
-
- } // end if;
+ }
/*
* First we set the flag to cancel membership
@@ -415,7 +422,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
*/
$gateway_id = $payment->get_gateway();
- if (!$gateway_id) {
+ if ( ! $gateway_id) {
/*
* The payment does not have a
* gateway attached to it.
@@ -424,30 +431,30 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
$status = $payment->refund($amount, $should_cancel_membership_on_refund);
if (is_wp_error($status)) {
-
wp_send_json_error($status);
-
- } // end if;
+ }
/*
* Done! Redirect back.
*/
- wp_send_json_success(array(
- 'redirect_url' => wu_network_admin_url('wp-ultimo-edit-payment', array(
- 'id' => $payment->get_id(),
- 'updated' => 1,
- )),
- ));
-
- } // end if;
+ wp_send_json_success(
+ array(
+ 'redirect_url' => wu_network_admin_url(
+ 'wp-ultimo-edit-payment',
+ array(
+ 'id' => $payment->get_id(),
+ 'updated' => 1,
+ )
+ ),
+ )
+ );
+ }
$gateway = wu_get_gateway($gateway_id);
- if (!$gateway) {
-
+ if ( ! $gateway) {
wp_send_json_error(new \WP_Error('gateway-not-found', __('Payment gateway not found.', 'wp-ultimo')));
-
- } // end if;
+ }
/*
* Process the refund on the gateway.
@@ -478,29 +485,30 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
$error = new \WP_Error('refund-error', sprintf(__('An error occurred: %s', 'wp-ultimo'), $status->get_error_message()));
wp_send_json_error($error);
-
- } // end if;
-
+ }
} catch (\Throwable $e) {
// translators: %s is the exception error message.
$error = new \WP_Error('refund-error', sprintf(__('An error occurred: %s', 'wp-ultimo'), $e->getMessage()));
wp_send_json_error($error);
-
- } // end try;
+ }
/*
* Done! Redirect back.
*/
- wp_send_json_success(array(
- 'redirect_url' => wu_network_admin_url('wp-ultimo-edit-payment', array(
- 'id' => $payment->get_id(),
- 'updated' => 1,
- )),
- ));
-
- } // end handle_refund_payment_modal;
+ wp_send_json_success(
+ array(
+ 'redirect_url' => wu_network_admin_url(
+ 'wp-ultimo-edit-payment',
+ array(
+ 'id' => $payment->get_id(),
+ 'updated' => 1,
+ )
+ ),
+ )
+ );
+ }
/**
* Handles the add/edit of line items.
@@ -514,11 +522,9 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
$line_item = wu_get_line_item(wu_request('line_item_id'), $payment->get_id());
- if (!$line_item) {
-
+ if ( ! $line_item) {
$line_item = new \WP_Ultimo\Checkout\Line_Item(array());
-
- } // end if;
+ }
/*
* First, we get the type.
@@ -532,16 +538,13 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
$type = wu_request('type', 'product');
if ($type === 'product') {
-
$product = wu_get_product(wu_request('product_id'));
if (empty($product)) {
-
$error = new \WP_Error('missing-product', __('The product was not found.', 'wp-ultimo'));
wp_send_json_error($error);
-
- } // end if;
+ }
/*
* Constructs the arguments
@@ -557,7 +560,6 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
'tax_type' => wu_request('tax_type', 'percentage'),
'tax_label' => wu_request('tax_label', ''),
);
-
} else {
/**
@@ -566,19 +568,20 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
*
* First, check the valid types.
*/
- $allowed_types = apply_filters('wu_allowed_line_item_types', array(
- 'fee',
- 'refund',
- 'credit',
- ));
-
- if (!in_array($type, $allowed_types, true)) {
+ $allowed_types = apply_filters(
+ 'wu_allowed_line_item_types',
+ array(
+ 'fee',
+ 'refund',
+ 'credit',
+ )
+ );
+ if ( ! in_array($type, $allowed_types, true)) {
$error = new \WP_Error('invalid-type', __('The line item type is invalid.', 'wp-ultimo'));
wp_send_json_error($error);
-
- } // end if;
+ }
/*
* Set the new attributes
@@ -592,8 +595,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
'tax_type' => 'percentage',
'tax_label' => '',
);
-
- } // end if;
+ }
$line_item->attributes($atts);
@@ -601,29 +603,26 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
$line_items = $payment->get_line_items();
- $line_items[$line_item->get_id()] = $line_item;
+ $line_items[ $line_item->get_id() ] = $line_item;
$payment->set_line_items($line_items);
$saved = $payment->recalculate_totals()->save();
- if (!$saved) {
-
+ if ( ! $saved) {
wp_send_json_error(new \WP_Error('error', __('Something wrong happened.', 'wp-ultimo')));
-
- } // end if;
+ }
if (is_wp_error($saved)) {
-
wp_send_json_error($saved);
+ }
- } // end if;
-
- wp_send_json_success(array(
- 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']),
- ));
-
- } // end handle_edit_line_item_modal;
+ wp_send_json_success(
+ array(
+ 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']),
+ )
+ );
+ }
/**
* Renders the add/edit line items form.
@@ -637,14 +636,13 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
*/
$line_item = wu_get_line_item(wu_request('line_item_id'), wu_request('id'));
- if (!$line_item) {
+ if ( ! $line_item) {
/*
* If that doesn't work,
* we start a new line.
*/
$line_item = new \WP_Ultimo\Checkout\Line_Item(array());
-
- } // end if;
+ }
$fields = array(
'tab' => array(
@@ -845,24 +843,29 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
),
);
- $form = new \WP_Ultimo\UI\Form('edit_line_item', $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(
- 'data-wu-app' => 'edit_line_item',
- 'data-state' => wu_convert_to_state(array(
- 'tab' => 'type',
- 'type' => $line_item->get_type(),
- 'taxable' => $line_item->get_tax_rate() > 0,
- 'unit_price' => $line_item->get_unit_price(),
- )),
- ),
- ));
+ $form = new \WP_Ultimo\UI\Form(
+ 'edit_line_item',
+ $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(
+ 'data-wu-app' => 'edit_line_item',
+ 'data-state' => wu_convert_to_state(
+ array(
+ 'tab' => 'type',
+ 'type' => $line_item->get_type(),
+ 'taxable' => $line_item->get_tax_rate() > 0,
+ 'unit_price' => $line_item->get_unit_price(),
+ )
+ ),
+ ),
+ )
+ );
$form->render();
-
- } // end render_edit_line_item_modal;
+ }
/**
* Display the payment actions.
@@ -877,33 +880,39 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
$is_refundable = in_array($this->get_object()->get_status(), wu_get_refundable_payment_types(), true);
if ($is_refundable) {
-
$actions['refund_payment'] = array(
'label' => __('Refund Payment', 'wp-ultimo'),
'icon_classes' => 'dashicons-wu-ccw wu-align-text-bottom',
'classes' => 'button wubox',
- 'href' => wu_get_form_url('refund_payment', array(
- 'id' => $this->get_object()->get_id(),
- )),
+ 'href' => wu_get_form_url(
+ 'refund_payment',
+ array(
+ 'id' => $this->get_object()->get_id(),
+ )
+ ),
);
-
- } // end if;
+ }
$actions['add_line_item'] = array(
'label' => __('Add Line Item', 'wp-ultimo'),
'icon_classes' => 'dashicons-wu-circle-with-plus wu-align-text-bottom',
'classes' => 'button wubox',
- 'href' => wu_get_form_url('edit_line_item', array(
- 'id' => $this->get_object()->get_id(),
- )),
+ 'href' => wu_get_form_url(
+ 'edit_line_item',
+ array(
+ 'id' => $this->get_object()->get_id(),
+ )
+ ),
);
- return wu_get_template_contents('payments/line-item-actions', array(
- 'payment' => $this->get_object(),
- 'actions' => $actions,
- ));
-
- } // end display_payment_actions;
+ return wu_get_template_contents(
+ 'payments/line-item-actions',
+ array(
+ 'payment' => $this->get_object(),
+ 'actions' => $actions,
+ )
+ );
+ }
/**
* Displays the tax tax breakthrough.
@@ -915,12 +924,14 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
$tax_breakthrough = $this->get_object()->get_tax_breakthrough();
- wu_get_template('payments/tax-details', array(
- 'tax_breakthrough' => $tax_breakthrough,
- 'payment' => $this->get_object(),
- ));
-
- } // end display_tax_breakthrough;
+ wu_get_template(
+ 'payments/tax-details',
+ array(
+ 'tax_breakthrough' => $tax_breakthrough,
+ 'payment' => $this->get_object(),
+ )
+ );
+ }
/**
* Allow child classes to register widgets, if they need them.
@@ -938,192 +949,206 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
$tag = "{$label}";
- $this->add_fields_widget('at_a_glance', array(
- 'title' => __('At a Glance', 'wp-ultimo'),
- 'position' => 'normal',
- 'classes' => 'wu-overflow-hidden wu-widget-inset',
- 'field_wrapper_classes' => 'wu-w-1/3 wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t-0 wu-border-l-0 wu-border-r wu-border-b-0 wu-border-gray-300 wu-border-solid wu-float-left wu-relative',
- 'fields' => array(
- 'status' => array(
- 'type' => 'text-display',
- 'title' => __('Payment Status', 'wp-ultimo'),
- 'display_value' => $tag,
- 'tooltip' => '',
+ $this->add_fields_widget(
+ 'at_a_glance',
+ array(
+ 'title' => __('At a Glance', 'wp-ultimo'),
+ 'position' => 'normal',
+ 'classes' => 'wu-overflow-hidden wu-widget-inset',
+ 'field_wrapper_classes' => 'wu-w-1/3 wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t-0 wu-border-l-0 wu-border-r wu-border-b-0 wu-border-gray-300 wu-border-solid wu-float-left wu-relative',
+ 'fields' => array(
+ 'status' => array(
+ 'type' => 'text-display',
+ 'title' => __('Payment Status', 'wp-ultimo'),
+ 'display_value' => $tag,
+ 'tooltip' => '',
+ ),
+ 'hash' => array(
+ 'copy' => true,
+ 'type' => 'text-display',
+ 'title' => __('Reference ID', 'wp-ultimo'),
+ 'display_value' => $this->get_object()->get_hash(),
+ ),
+ 'total' => array(
+ 'type' => 'text-display',
+ 'title' => __('Total', 'wp-ultimo'),
+ 'display_value' => wu_format_currency($this->get_object()->get_total(), $this->get_object()->get_currency()),
+ 'wrapper_classes' => 'sm:wu-border-r-0',
+ ),
),
- 'hash' => array(
- 'copy' => true,
- 'type' => 'text-display',
- 'title' => __('Reference ID', 'wp-ultimo'),
- 'display_value' => $this->get_object()->get_hash(),
- ),
- 'total' => array(
- 'type' => 'text-display',
- 'title' => __('Total', 'wp-ultimo'),
- 'display_value' => wu_format_currency($this->get_object()->get_total(), $this->get_object()->get_currency()),
- 'wrapper_classes' => 'sm:wu-border-r-0',
- ),
- ),
- ));
+ )
+ );
- $this->add_list_table_widget('line-items', array(
- 'title' => __('Line Items', 'wp-ultimo'),
- 'table' => new \WP_Ultimo\List_Tables\Payment_Line_Item_List_Table(),
- 'position' => 'normal',
- 'query_filter' => array($this, 'payments_query_filter'),
- 'after' => $this->display_payment_actions(),
- ));
+ $this->add_list_table_widget(
+ 'line-items',
+ array(
+ 'title' => __('Line Items', 'wp-ultimo'),
+ 'table' => new \WP_Ultimo\List_Tables\Payment_Line_Item_List_Table(),
+ 'position' => 'normal',
+ 'query_filter' => array($this, 'payments_query_filter'),
+ 'after' => $this->display_payment_actions(),
+ )
+ );
- $this->add_widget('tax-rates', array(
- 'title' => __('Tax Rate Breakthrough', 'wp-ultimo'),
- 'position' => 'normal',
- 'display' => array($this, 'display_tax_breakthrough'),
- ));
+ $this->add_widget(
+ 'tax-rates',
+ array(
+ 'title' => __('Tax Rate Breakthrough', 'wp-ultimo'),
+ 'position' => 'normal',
+ 'display' => array($this, 'display_tax_breakthrough'),
+ )
+ );
- $this->add_tabs_widget('options', array(
- 'title' => __('Payment Options', 'wp-ultimo'),
- 'position' => 'normal',
- 'sections' => apply_filters('wu_payments_options_sections', array(), $this->get_object()),
- ));
+ $this->add_tabs_widget(
+ 'options',
+ array(
+ 'title' => __('Payment Options', 'wp-ultimo'),
+ 'position' => 'normal',
+ 'sections' => apply_filters('wu_payments_options_sections', array(), $this->get_object()),
+ )
+ );
- $this->add_list_table_widget('events', array(
- 'title' => __('Events', 'wp-ultimo'),
- 'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(),
- 'query_filter' => array($this, 'events_query_filter'),
- ));
+ $this->add_list_table_widget(
+ 'events',
+ array(
+ 'title' => __('Events', 'wp-ultimo'),
+ 'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(),
+ 'query_filter' => array($this, 'events_query_filter'),
+ )
+ );
$membership = $this->get_object()->get_membership();
- $this->add_save_widget('save', array(
- 'html_attr' => array(
- 'data-wu-app' => 'payment_save',
- 'data-state' => wu_convert_to_state(array(
- 'status' => $this->get_object()->get_status(),
- 'original_status' => $this->get_object()->get_status(),
- 'membership_id' => $membership ? $this->get_object()->get_membership_id() : '',
- 'membership_status' => $membership ? $membership->get_status() : 'active',
- 'gateway' => $this->get_object()->get_gateway(),
- )),
- ),
- 'fields' => array(
- 'status' => array(
- 'type' => 'select',
- 'title' => __('Status', 'wp-ultimo'),
- 'placeholder' => __('Status', 'wp-ultimo'),
- 'desc' => __('The payment current status.', 'wp-ultimo'),
- 'value' => $this->get_object()->get_status(),
- 'options' => Payment_Status::to_array(),
- 'tooltip' => '',
- 'wrapper_html_attr' => array(
- 'v-cloak' => '1',
- ),
- 'html_attr' => array(
- 'v-model' => 'status',
+ $this->add_save_widget(
+ 'save',
+ array(
+ 'html_attr' => array(
+ 'data-wu-app' => 'payment_save',
+ 'data-state' => wu_convert_to_state(
+ array(
+ 'status' => $this->get_object()->get_status(),
+ 'original_status' => $this->get_object()->get_status(),
+ 'membership_id' => $membership ? $this->get_object()->get_membership_id() : '',
+ 'membership_status' => $membership ? $membership->get_status() : 'active',
+ 'gateway' => $this->get_object()->get_gateway(),
+ )
),
),
- 'confirm_membership' => array(
- 'type' => 'toggle',
- 'title' => __('Activate Membership?', 'wp-ultimo'),
- 'desc' => __('This payment belongs to a pending membership. If you toggle this option, this change in status will also apply to the membership. If any sites are pending, they are also going to be published automatically.', 'wp-ultimo'),
- 'value' => 0,
- 'wrapper_html_attr' => array(
- 'v-if' => 'status !== original_status && status === "completed" && membership_status === "pending"',
- 'v-cloak' => '1',
+ 'fields' => array(
+ 'status' => array(
+ 'type' => 'select',
+ 'title' => __('Status', 'wp-ultimo'),
+ 'placeholder' => __('Status', 'wp-ultimo'),
+ 'desc' => __('The payment current status.', 'wp-ultimo'),
+ 'value' => $this->get_object()->get_status(),
+ 'options' => Payment_Status::to_array(),
+ 'tooltip' => '',
+ 'wrapper_html_attr' => array(
+ 'v-cloak' => '1',
+ ),
+ 'html_attr' => array(
+ 'v-model' => 'status',
+ ),
),
- ),
- 'membership_id' => array(
- 'type' => 'model',
- 'title' => __('Membership', 'wp-ultimo'),
- 'desc' => __('The membership associated with this payment.', 'wp-ultimo'),
- 'value' => $this->get_object()->get_membership_id(),
- 'tooltip' => '',
- 'html_attr' => array(
- 'v-model' => 'membership_id',
- 'data-base-link' => wu_network_admin_url('wp-ultimo-edit-membership', array('id' => '')),
- 'data-model' => 'membership',
- 'data-value-field' => 'id',
- 'data-label-field' => 'reference_code',
- 'data-max-items' => 1,
- 'data-selected' => $this->get_object()->get_membership() ? json_encode($this->get_object()->get_membership()->to_search_results()) : '',
+ 'confirm_membership' => array(
+ 'type' => 'toggle',
+ 'title' => __('Activate Membership?', 'wp-ultimo'),
+ 'desc' => __('This payment belongs to a pending membership. If you toggle this option, this change in status will also apply to the membership. If any sites are pending, they are also going to be published automatically.', 'wp-ultimo'),
+ 'value' => 0,
+ 'wrapper_html_attr' => array(
+ 'v-if' => 'status !== original_status && status === "completed" && membership_status === "pending"',
+ 'v-cloak' => '1',
+ ),
),
- 'wrapper_html_attr' => array(
- 'v-cloak' => '1',
+ 'membership_id' => array(
+ 'type' => 'model',
+ 'title' => __('Membership', 'wp-ultimo'),
+ 'desc' => __('The membership associated with this payment.', 'wp-ultimo'),
+ 'value' => $this->get_object()->get_membership_id(),
+ 'tooltip' => '',
+ 'html_attr' => array(
+ 'v-model' => 'membership_id',
+ 'data-base-link' => wu_network_admin_url('wp-ultimo-edit-membership', array('id' => '')),
+ 'data-model' => 'membership',
+ 'data-value-field' => 'id',
+ 'data-label-field' => 'reference_code',
+ 'data-max-items' => 1,
+ 'data-selected' => $this->get_object()->get_membership() ? json_encode($this->get_object()->get_membership()->to_search_results()) : '',
+ ),
+ 'wrapper_html_attr' => array(
+ 'v-cloak' => '1',
+ ),
),
- ),
- 'gateway' => array(
- 'type' => 'text',
- 'title' => __('Gateway', 'wp-ultimo'),
- 'placeholder' => __('e.g. stripe', 'wp-ultimo'),
- 'description' => __('e.g. stripe', 'wp-ultimo'),
- 'desc' => __('Payment gateway used to process the payment.', 'wp-ultimo'),
- 'value' => $this->get_object()->get_gateway(),
- 'wrapper_classes' => 'wu-w-full',
- 'html_attr' => array(
- 'v-on:input' => 'gateway = $event.target.value.toLowerCase().replace(/[^a-z0-9-_]+/g, "")',
- 'v-bind:value' => 'gateway',
+ 'gateway' => array(
+ 'type' => 'text',
+ 'title' => __('Gateway', 'wp-ultimo'),
+ 'placeholder' => __('e.g. stripe', 'wp-ultimo'),
+ 'description' => __('e.g. stripe', 'wp-ultimo'),
+ 'desc' => __('Payment gateway used to process the payment.', 'wp-ultimo'),
+ 'value' => $this->get_object()->get_gateway(),
+ 'wrapper_classes' => 'wu-w-full',
+ 'html_attr' => array(
+ 'v-on:input' => 'gateway = $event.target.value.toLowerCase().replace(/[^a-z0-9-_]+/g, "")',
+ 'v-bind:value' => 'gateway',
+ ),
+ 'wrapper_html_attr' => array(
+ 'v-cloak' => '1',
+ ),
),
- 'wrapper_html_attr' => array(
- 'v-cloak' => '1',
- ),
- ),
- 'gateway_payment_id_group' => array(
- 'type' => 'group',
- 'desc' => function(): string {
+ 'gateway_payment_id_group' => array(
+ 'type' => 'group',
+ 'desc' => function (): string {
- $gateway_id = $this->get_object()->get_gateway();
+ $gateway_id = $this->get_object()->get_gateway();
- if (empty($this->get_object()->get_gateway_payment_id())) {
+ if (empty($this->get_object()->get_gateway_payment_id())) {
+ return '';
+ }
+
+ $url = apply_filters("wu_{$gateway_id}_remote_payment_url", $this->get_object()->get_gateway_payment_id());
+
+ if ($url) {
+ return sprintf('%s', esc_attr($url), __('View on Gateway →', 'wp-ultimo'));
+ }
return '';
-
- } // end if;
-
- $url = apply_filters("wu_{$gateway_id}_remote_payment_url", $this->get_object()->get_gateway_payment_id());
-
- if ($url) {
-
- return sprintf('%s', esc_attr($url), __('View on Gateway →', 'wp-ultimo'));
-
- } // end if;
-
- return '';
-
- },
- 'wrapper_html_attr' => array(
- 'v-cloak' => '1',
- 'v-show' => 'gateway',
+ },
+ 'wrapper_html_attr' => array(
+ 'v-cloak' => '1',
+ 'v-show' => 'gateway',
+ ),
+ 'fields' => array(
+ 'gateway_payment_id' => array(
+ 'type' => 'text',
+ 'title' => __('Gateway Payment ID', 'wp-ultimo'),
+ 'placeholder' => __('e.g. EX897540987913', 'wp-ultimo'),
+ 'description' => __('e.g. EX897540987913', 'wp-ultimo'),
+ 'tooltip' => __('This will usually be set automatically by the payment gateway.', 'wp-ultimo'),
+ 'value' => $this->get_object()->get_gateway_payment_id(),
+ 'wrapper_classes' => 'wu-w-full',
+ 'html_attr' => array(),
+ 'wrapper_html_attr' => array(),
+ ),
+ ),
),
- 'fields' => array(
- 'gateway_payment_id' => array(
- 'type' => 'text',
- 'title' => __('Gateway Payment ID', 'wp-ultimo'),
- 'placeholder' => __('e.g. EX897540987913', 'wp-ultimo'),
- 'description' => __('e.g. EX897540987913', 'wp-ultimo'),
- 'tooltip' => __('This will usually be set automatically by the payment gateway.', 'wp-ultimo'),
- 'value' => $this->get_object()->get_gateway_payment_id(),
- 'wrapper_classes' => 'wu-w-full',
- 'html_attr' => array(),
- 'wrapper_html_attr' => array(),
+ 'invoice_number' => array(
+ 'type' => 'number',
+ 'min' => 0,
+ 'title' => __('Invoice Number', 'wp-ultimo'),
+ 'placeholder' => __('e.g. 20', 'wp-ultimo'),
+ 'tooltip' => __('This number gets saved automatically when a payment transitions to a complete state. You can change it to generate invoices with a particular number. The number chosen here has no effect on other invoices in the platform.', 'wp-ultimo'),
+ 'desc' => __('The invoice number for this particular payment.', 'wp-ultimo'),
+ 'value' => $this->get_object()->get_saved_invoice_number(),
+ 'wrapper_classes' => 'wu-w-full',
+ 'wrapper_html_attr' => array(
+ 'v-show' => json_encode(wu_get_setting('invoice_numbering_scheme', 'reference_code') === 'sequential_number'),
+ 'v-cloak' => '1',
),
),
),
- 'invoice_number' => array(
- 'type' => 'number',
- 'min' => 0,
- 'title' => __('Invoice Number', 'wp-ultimo'),
- 'placeholder' => __('e.g. 20', 'wp-ultimo'),
- 'tooltip' => __('This number gets saved automatically when a payment transitions to a complete state. You can change it to generate invoices with a particular number. The number chosen here has no effect on other invoices in the platform.', 'wp-ultimo'),
- 'desc' => __('The invoice number for this particular payment.', 'wp-ultimo'),
- 'value' => $this->get_object()->get_saved_invoice_number(),
- 'wrapper_classes' => 'wu-w-full',
- 'wrapper_html_attr' => array(
- 'v-show' => json_encode(wu_get_setting('invoice_numbering_scheme', 'reference_code') === 'sequential_number'),
- 'v-cloak' => '1',
- ),
- ),
- ),
- ));
-
- } // end register_widgets;
+ )
+ );
+ }
/**
* Returns the title of the page.
@@ -1134,8 +1159,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
public function get_title() {
return $this->edit ? __('Edit Payment', 'wp-ultimo') : __('Add new Payment', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the title of menu for this page.
@@ -1146,8 +1170,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
public function get_menu_title() {
return __('Edit Payment', 'wp-ultimo');
-
- } // end get_menu_title;
+ }
/**
* Returns the action links for that page.
@@ -1162,7 +1185,6 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
$payment = $this->get_object();
if ($payment) {
-
$actions[] = array(
'url' => $payment->get_invoice_url(),
'label' => __('Generate Invoice', 'wp-ultimo'),
@@ -1170,20 +1192,16 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
);
if ($payment->is_payable()) {
-
$actions[] = array(
'url' => $payment->get_payment_url(),
'label' => __('Payment URL', 'wp-ultimo'),
'icon' => 'wu-credit-card',
);
-
- } // end if;
-
- } // end if;
+ }
+ }
return $actions;
-
- } // end action_links;
+ }
/**
* Returns the labels to be used on the admin page.
@@ -1204,8 +1222,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
'delete_button_label' => __('Delete Payment', 'wp-ultimo'),
'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'),
);
-
- } // end get_labels;
+ }
/**
* Filters the list table to return only relevant events.
@@ -1223,8 +1240,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
);
return array_merge($args, $extra_args);
-
- } // end events_query_filter;
+ }
/**
* Filters the list table to return only relevant events.
@@ -1242,8 +1258,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
);
return array_merge($args, $extra_args);
-
- } // end payments_query_filter;
+ }
/**
* Returns the object being edit at the moment.
@@ -1256,34 +1271,27 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
static $payment;
if ($payment !== null) {
-
return $payment;
-
- } // end if;
+ }
if (isset($_GET['id'])) {
-
- $query = new \WP_Ultimo\Database\Payments\Payment_Query;
+ $query = new \WP_Ultimo\Database\Payments\Payment_Query();
$item = $query->get_item_by('id', $_GET['id']);
- if (!$item || $item->get_parent_id()) {
-
+ if ( ! $item || $item->get_parent_id()) {
wp_redirect(wu_network_admin_url('wp-ultimo-payments'));
exit;
-
- } // end if;
+ }
$payment = $item;
return $item;
+ }
- } // end if;
-
- return new Payment;
-
- } // end get_object;
+ return new Payment();
+ }
/**
* Payments have titles.
*
@@ -1292,8 +1300,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
public function has_title(): bool {
return false;
-
- } // end has_title;
+ }
/**
* WIP: Handles saving by recalculating totals for a payment.
@@ -1309,21 +1316,15 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page {
$should_confirm_membership = wu_request('confirm_membership');
if ($should_confirm_membership) {
-
$membership = $this->get_object()->get_membership();
if ($membership) {
-
$membership->add_to_times_billed(1);
$membership->renew(false, 'active');
-
- } // end if;
-
- } // end if;
+ }
+ }
parent::handle_save();
-
- } // end handle_save;
-
-} // end class Payment_Edit_Admin_Page;
+ }
+}
diff --git a/inc/admin-pages/class-payment-list-admin-page.php b/inc/admin-pages/class-payment-list-admin-page.php
index 99400e0..b879956 100644
--- a/inc/admin-pages/class-payment-list-admin-page.php
+++ b/inc/admin-pages/class-payment-list-admin-page.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Admin_Pages;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Database\Payments\Payment_Status;
+use WP_Ultimo\Database\Payments\Payment_Status;
/**
* WP Multisite WaaS Payment Admin Page.
@@ -66,13 +66,15 @@ class Payment_List_Admin_Page extends List_Admin_Page {
/*
* Edit/Add Line Item
*/
- wu_register_form('add_new_payment', array(
- 'render' => array($this, 'render_add_new_payment_modal'),
- 'handler' => array($this, 'handle_add_new_payment_modal'),
- 'capability' => 'wu_edit_payments',
- ));
-
- } // end register_forms;
+ wu_register_form(
+ 'add_new_payment',
+ array(
+ 'render' => array($this, 'render_add_new_payment_modal'),
+ 'handler' => array($this, 'handle_add_new_payment_modal'),
+ 'capability' => 'wu_edit_payments',
+ )
+ );
+ }
/**
* Renders the add/edit line items form.
@@ -137,22 +139,27 @@ class Payment_List_Admin_Page extends List_Admin_Page {
),
);
- $form = new \WP_Ultimo\UI\Form('add_payment', $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(
- 'data-wu-app' => 'add_payment',
- 'data-state' => wu_convert_to_state(array(
- 'taxable' => 0,
- 'type' => 'product',
- )),
- ),
- ));
+ $form = new \WP_Ultimo\UI\Form(
+ 'add_payment',
+ $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(
+ 'data-wu-app' => 'add_payment',
+ 'data-state' => wu_convert_to_state(
+ array(
+ 'taxable' => 0,
+ 'type' => 'product',
+ )
+ ),
+ ),
+ )
+ );
$form->render();
-
- } // end render_add_new_payment_modal;
+ }
/**
* Handles the add/edit of line items.
@@ -164,40 +171,45 @@ class Payment_List_Admin_Page extends List_Admin_Page {
$membership = wu_get_membership(wu_request('membership_id'));
- if (!$membership) {
-
+ if ( ! $membership) {
$error = new \WP_Error('invalid-membership', __('Invalid membership.', 'wp-ultimo'));
return wp_send_json_error($error);
+ }
- } // end if;
+ $cart = new \WP_Ultimo\Checkout\Cart(
+ array(
+ 'products' => explode(',', (string) wu_request('products')),
+ 'cart_type' => wu_request('add_setup_fees') ? 'new' : 'renewal',
+ )
+ );
- $cart = new \WP_Ultimo\Checkout\Cart(array(
- 'products' => explode(',', (string) wu_request('products')),
- 'cart_type' => wu_request('add_setup_fees') ? 'new' : 'renewal',
- ));
-
- $payment_data = array_merge($cart->to_payment_data(), array(
- 'status' => wu_request('status'),
- 'membership_id' => $membership->get_id(),
- 'customer_id' => $membership->get_customer_id(),
- ));
+ $payment_data = array_merge(
+ $cart->to_payment_data(),
+ array(
+ 'status' => wu_request('status'),
+ 'membership_id' => $membership->get_id(),
+ 'customer_id' => $membership->get_customer_id(),
+ )
+ );
$payment = wu_create_payment($payment_data);
if (is_wp_error($payment)) {
-
return wp_send_json_error($payment);
+ }
- } // end if;
-
- wp_send_json_success(array(
- 'redirect_url' => wu_network_admin_url('wp-ultimo-edit-payment', array(
- 'id' => $payment->get_id(),
- ))
- ));
-
- } // end handle_add_new_payment_modal;
+ wp_send_json_success(
+ array(
+ 'redirect_url' => wu_network_admin_url(
+ 'wp-ultimo-edit-payment',
+ array(
+ 'id' => $payment->get_id(),
+ )
+ ),
+ )
+ );
+ }
/**
* Allow child classes to register widgets, if they need them.
@@ -205,7 +217,7 @@ class Payment_List_Admin_Page extends List_Admin_Page {
* @since 1.8.2
* @return void
*/
- public function register_widgets() {} // end register_widgets;
+ public function register_widgets() {}
/**
* Returns an array with the labels for the edit page.
@@ -219,8 +231,7 @@ class Payment_List_Admin_Page extends List_Admin_Page {
'deleted_message' => __('Payment removed successfully.', 'wp-ultimo'),
'search_label' => __('Search Payment', 'wp-ultimo'),
);
-
- } // end get_labels;
+ }
/**
* Returns the title of the page.
@@ -231,8 +242,7 @@ class Payment_List_Admin_Page extends List_Admin_Page {
public function get_title() {
return __('Payments', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the title of menu for this page.
@@ -243,8 +253,7 @@ class Payment_List_Admin_Page extends List_Admin_Page {
public function get_menu_title() {
return __('Payments', 'wp-ultimo');
-
- } // end get_menu_title;
+ }
/**
* Allows admins to rename the sub-menu (first item) for a top-level page.
@@ -255,8 +264,7 @@ class Payment_List_Admin_Page extends List_Admin_Page {
public function get_submenu_title() {
return __('Payments', 'wp-ultimo');
-
- } // end get_submenu_title;
+ }
/**
* Returns the action links for that page.
@@ -274,8 +282,7 @@ class Payment_List_Admin_Page extends List_Admin_Page {
'url' => wu_get_form_url('add_new_payment'),
),
);
-
- } // end action_links;
+ }
/**
* Loads the list table for this particular page.
@@ -286,7 +293,5 @@ class Payment_List_Admin_Page extends List_Admin_Page {
public function table() {
return new \WP_Ultimo\List_Tables\Payment_List_Table();
-
- } // end table;
-
-} // end class Payment_List_Admin_Page;
+ }
+}
diff --git a/inc/admin-pages/class-placeholders-admin-page.php b/inc/admin-pages/class-placeholders-admin-page.php
index 1cfbbf1..68c78ef 100644
--- a/inc/admin-pages/class-placeholders-admin-page.php
+++ b/inc/admin-pages/class-placeholders-admin-page.php
@@ -71,8 +71,7 @@ class Placeholders_Admin_Page extends Base_Admin_Page {
public function get_title() {
return __('Edit Template Placeholders', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the title of menu for this page.
@@ -83,8 +82,7 @@ class Placeholders_Admin_Page extends Base_Admin_Page {
public function get_menu_title() {
return __('Edit Template Placeholders', 'wp-ultimo');
-
- } // end get_menu_title;
+ }
/**
* Allows admins to rename the sub-menu (first item) for a top-level page.
@@ -95,8 +93,7 @@ class Placeholders_Admin_Page extends Base_Admin_Page {
public function get_submenu_title() {
return __('Edit Template Placeholders', 'wp-ultimo');
-
- } // end get_submenu_title;
+ }
/**
* Every child class should implement the output method to display the contents of the page.
@@ -108,17 +105,22 @@ class Placeholders_Admin_Page extends Base_Admin_Page {
do_action('wu_load_edit_placeholders_list_page');
- $columns = apply_filters('wu_edit_placeholders_columns', array(
- 'placeholder' => __('Placeholder', 'wp-ultimo'),
- 'content' => __('Content', 'wp-ultimo'),
- ));
+ $columns = apply_filters(
+ 'wu_edit_placeholders_columns',
+ array(
+ 'placeholder' => __('Placeholder', 'wp-ultimo'),
+ 'content' => __('Content', 'wp-ultimo'),
+ )
+ );
- wu_get_template('sites/edit-placeholders', array(
- 'columns' => $columns,
- 'types' => array(),
- ));
-
- } // end output;
+ wu_get_template(
+ 'sites/edit-placeholders',
+ array(
+ 'columns' => $columns,
+ 'types' => array(),
+ )
+ );
+ }
/**
* Adds the cure bg image here as well.
@@ -132,14 +134,16 @@ class Placeholders_Admin_Page extends Base_Admin_Page {
wp_register_script('wu-edit-placeholders', wu_get_asset('edit-placeholders.js', 'js'), array('wu-admin', 'wu-vue', 'underscore'), wu_get_version(), false);
- wp_localize_script('wu-edit-placeholders', 'wu_placeholdersl10n', array(
- 'name' => __('Tax', 'wp-ultimo'),
- 'confirm_message' => __('Are you sure you want to delete this rows?', 'wp-ultimo'),
- 'confirm_delete_tax_category_message' => __('Are you sure you want to delete this tax category?', 'wp-ultimo'),
- ));
+ wp_localize_script(
+ 'wu-edit-placeholders',
+ 'wu_placeholdersl10n',
+ array(
+ 'name' => __('Tax', 'wp-ultimo'),
+ 'confirm_message' => __('Are you sure you want to delete this rows?', 'wp-ultimo'),
+ 'confirm_delete_tax_category_message' => __('Are you sure you want to delete this tax category?', 'wp-ultimo'),
+ )
+ );
wp_enqueue_script('wu-edit-placeholders');
-
- } // end register_scripts;
-
-} // end class Placeholders_Admin_Page;
+ }
+}
diff --git a/inc/admin-pages/class-product-edit-admin-page.php b/inc/admin-pages/class-product-edit-admin-page.php
index fb2d52a..2d81934 100644
--- a/inc/admin-pages/class-product-edit-admin-page.php
+++ b/inc/admin-pages/class-product-edit-admin-page.php
@@ -12,8 +12,8 @@ namespace WP_Ultimo\Admin_Pages;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Models\Product;
-use \WP_Ultimo\Database\Products\Product_Type;
+use WP_Ultimo\Models\Product;
+use WP_Ultimo\Database\Products\Product_Type;
/**
* WP Multisite WaaS Product Edit/Add New Admin Page.
@@ -96,8 +96,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
add_action('wu_after_delete_product_modal', array($this, 'product_after_delete_actions'));
add_filter("wu_page_{$this->id}_load", array($this, 'add_new_product_warning_message'));
-
- } // end register_forms;
+ }
/**
* Adds the new product warning.
@@ -108,39 +107,37 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
public function add_new_product_warning_message() {
if (wu_request('wu-new-model')) {
-
- if (!$this->get_object() || $this->get_object()->get_type() !== Product_Type::PLAN) {
-
+ if ( ! $this->get_object() || $this->get_object()->get_type() !== Product_Type::PLAN) {
return;
+ }
- } // end if;
-
- \WP_Ultimo\UI\Tours::get_instance()->create_tour('new_product_warning', array(
+ \WP_Ultimo\UI\Tours::get_instance()->create_tour(
+ 'new_product_warning',
array(
- 'id' => 'new-product-warning',
- 'title' => __('On adding a new product...', 'wp-ultimo'),
- 'text' => array(
- __("You just successfully added a new product to your WP Multisite WaaS network and that's awesome!", 'wp-ultimo'),
- __('Keep in mind that newly created products do not appear automatically in your checkout forms.', 'wp-ultimo'),
- __('To make a product available on registration, you will need to manually add it to the pricing table field of your checkout forms.', 'wp-ultimo'),
+ array(
+ 'id' => 'new-product-warning',
+ 'title' => __('On adding a new product...', 'wp-ultimo'),
+ 'text' => array(
+ __("You just successfully added a new product to your WP Multisite WaaS network and that's awesome!", 'wp-ultimo'),
+ __('Keep in mind that newly created products do not appear automatically in your checkout forms.', 'wp-ultimo'),
+ __('To make a product available on registration, you will need to manually add it to the pricing table field of your checkout forms.', 'wp-ultimo'),
+ ),
+ 'buttons' => array(
+ array(
+ 'classes' => 'button wu-text-xs sm:wu-normal-case wu-float-left',
+ 'text' => __('Go to Checkout Forms', 'wp-ultimo'),
+ 'url' => wu_network_admin_url('wp-ultimo-checkout-forms'),
+ ),
+ ),
+ 'attachTo' => array(
+ 'element' => '#message.updated',
+ 'on' => 'top',
+ ),
),
- 'buttons' => array(
- array(
- 'classes' => 'button wu-text-xs sm:wu-normal-case wu-float-left',
- 'text' => __('Go to Checkout Forms', 'wp-ultimo'),
- 'url' => wu_network_admin_url('wp-ultimo-checkout-forms'),
- )
- ),
- 'attachTo' => array(
- 'element' => '#message.updated',
- 'on' => 'top',
- ),
- ),
- ));
-
- } // end if;
-
- } // end add_new_product_warning_message;
+ )
+ );
+ }
+ }
/**
* Adds the extra delete fields to the delete form.
@@ -165,14 +162,13 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
'data-label-field' => 'name',
'data-search-field' => 'name',
'data-max-items' => 1,
- 'data-exclude' => json_encode(array($product->get_id()))
+ 'data-exclude' => json_encode(array($product->get_id())),
),
),
);
return array_merge($custom_fields, $fields);
-
- } // end product_extra_delete_fields;
+ }
/**
* Adds the primary domain handling to the product deletion.
@@ -191,7 +187,6 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
$re_assignment_product = wu_get_product($new_product_id);
if ($re_assignment_product) {
-
$query = $wpdb->prepare(
"UPDATE {$wpdb->base_prefix}wu_memberships
SET product_id = %d
@@ -201,10 +196,8 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
);
$wpdb->query($query); // phpcs:ignore
-
- } // end if;
-
- } // end product_after_delete_actions;
+ }
+ }
/**
* Registers the necessary scripts and styles for this admin page.
@@ -217,8 +210,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
parent::register_scripts();
wp_enqueue_media();
-
- } // end register_scripts;
+ }
/**
* Allow child classes to register widgets, if they need them.
@@ -230,303 +222,323 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
parent::register_widgets();
- $this->add_fields_widget('description', array(
- 'title' => __('Description', 'wp-ultimo'),
- 'position' => 'normal',
- 'fields' => array(
- 'description' => array(
- 'type' => 'textarea',
- 'title' => __('Product Description', 'wp-ultimo'),
- 'placeholder' => __('Tell your customers what this product is about.', 'wp-ultimo'),
- 'tooltip' => __('This description is made available for layouts and can be shown to end customers.', 'wp-ultimo'),
- 'value' => $this->get_object()->get_description(),
- 'html_attr' => array(
- 'rows' => 3,
+ $this->add_fields_widget(
+ 'description',
+ array(
+ 'title' => __('Description', 'wp-ultimo'),
+ 'position' => 'normal',
+ 'fields' => array(
+ 'description' => array(
+ 'type' => 'textarea',
+ 'title' => __('Product Description', 'wp-ultimo'),
+ 'placeholder' => __('Tell your customers what this product is about.', 'wp-ultimo'),
+ 'tooltip' => __('This description is made available for layouts and can be shown to end customers.', 'wp-ultimo'),
+ 'value' => $this->get_object()->get_description(),
+ 'html_attr' => array(
+ 'rows' => 3,
+ ),
),
),
- ),
- ));
+ )
+ );
- $this->add_tabs_widget('product_options', array(
- 'title' => __('Product Options', 'wp-ultimo'),
- 'position' => 'normal',
- 'sections' => $this->get_product_option_sections(),
- ));
+ $this->add_tabs_widget(
+ 'product_options',
+ array(
+ 'title' => __('Product Options', 'wp-ultimo'),
+ 'position' => 'normal',
+ 'sections' => $this->get_product_option_sections(),
+ )
+ );
/*
* Handle legacy options for back-compat.
*/
$this->handle_legacy_options();
- $this->add_list_table_widget('events', array(
- 'title' => __('Events', 'wp-ultimo'),
- 'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(),
- 'query_filter' => array($this, 'query_filter'),
- ));
+ $this->add_list_table_widget(
+ 'events',
+ array(
+ 'title' => __('Events', 'wp-ultimo'),
+ 'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(),
+ 'query_filter' => array($this, 'query_filter'),
+ )
+ );
- $save_widget_args = apply_filters('wu_product_edit_save_widget', array(
- 'html_attr' => array(
- 'data-wu-app' => 'product_pricing',
- 'data-state' => json_encode(array(
- 'is_recurring' => $this->get_object()->is_recurring(),
- 'pricing_type' => $this->get_object()->get_pricing_type(),
- 'has_trial' => $this->get_object()->get_trial_duration() > 0,
- 'has_setup_fee' => $this->get_object()->has_setup_fee(),
- 'setup_fee' => $this->get_object()->get_setup_fee(),
- 'amount' => $this->get_object()->get_formatted_amount(),
- 'duration' => $this->get_object()->get_duration(),
- 'duration_unit' => $this->get_object()->get_duration_unit(),
- )),
- ),
- 'fields' => array(
- // Fields for price
- 'pricing_type' => array(
- 'type' => 'select',
- 'title' => __('Pricing Type', 'wp-ultimo'),
- 'placeholder' => __('Select Pricing Type', 'wp-ultimo'),
- 'desc' => __('Products can be free, paid, or require further contact for pricing.', 'wp-ultimo'),
- 'value' => $this->get_object()->get_pricing_type(),
- 'tooltip' => '',
- 'options' => array(
- 'paid' => __('Paid', 'wp-ultimo'),
- 'free' => __('Free', 'wp-ultimo'),
- 'contact_us' => __('Contact Us', 'wp-ultimo'),
- ),
- 'wrapper_html_attr' => array(
- 'v-cloak' => '1',
- ),
- 'html_attr' => array(
- 'v-model' => 'pricing_type',
+ $save_widget_args = apply_filters(
+ 'wu_product_edit_save_widget',
+ array(
+ 'html_attr' => array(
+ 'data-wu-app' => 'product_pricing',
+ 'data-state' => json_encode(
+ array(
+ 'is_recurring' => $this->get_object()->is_recurring(),
+ 'pricing_type' => $this->get_object()->get_pricing_type(),
+ 'has_trial' => $this->get_object()->get_trial_duration() > 0,
+ 'has_setup_fee' => $this->get_object()->has_setup_fee(),
+ 'setup_fee' => $this->get_object()->get_setup_fee(),
+ 'amount' => $this->get_object()->get_formatted_amount(),
+ 'duration' => $this->get_object()->get_duration(),
+ 'duration_unit' => $this->get_object()->get_duration_unit(),
+ )
),
),
- 'contact_us_label' => array(
- 'type' => 'text',
- 'title' => __('Button Label', 'wp-ultimo'),
- 'placeholder' => __('E.g. Contact us', 'wp-ultimo'),
- 'desc' => __('This will be used on the pricing table CTA button, as the label.', 'wp-ultimo'),
- 'value' => $this->get_object()->get_contact_us_label(),
- 'wrapper_html_attr' => array(
- 'v-show' => "pricing_type == 'contact_us'",
- 'v-cloak' => '1',
- ),
- ),
- 'contact_us_link' => array(
- 'type' => 'url',
- 'title' => __('Button Link', 'wp-ultimo'),
- 'placeholder' => __('E.g. https://contactus.page.com', 'wp-ultimo'),
- 'desc' => __('This will be used on the pricing table CTA button.', 'wp-ultimo'),
- 'value' => $this->get_object()->get_contact_us_link(),
- 'wrapper_html_attr' => array(
- 'v-show' => "pricing_type == 'contact_us'",
- 'v-cloak' => '1',
- ),
- ),
- 'recurring' => array(
- 'type' => 'toggle',
- 'title' => __('Is Recurring?', 'wp-ultimo'),
- 'desc' => __('Check this if this product has a recurring charge.', 'wp-ultimo'),
- 'value' => $this->get_object()->is_recurring(),
- 'wrapper_html_attr' => array(
- 'v-show' => "pricing_type == 'paid'",
- 'v-cloak' => '1',
- ),
- 'html_attr' => array(
- 'v-model' => 'is_recurring',
- ),
- ),
- 'amount' => array(
- 'type' => 'hidden',
- 'html_attr' => array(
- 'v-model' => 'amount',
- ),
- ),
- '_amount' => array(
- 'type' => 'text',
- 'title' => __('Price', 'wp-ultimo'),
- 'placeholder' => __('Price', 'wp-ultimo'),
- 'value' => $this->get_object()->get_formatted_amount(),
- 'tooltip' => '',
- 'money' => true,
- 'wrapper_html_attr' => array(
- 'v-show' => "pricing_type == 'paid' && !is_recurring ",
- 'v-cloak' => '1',
- ),
- 'html_attr' => array(
- 'v-bind:name' => '""',
- 'v-model' => 'amount',
- ),
- ),
- 'amount_group' => array(
- 'type' => 'group',
- 'title' => __('Price', 'wp-ultimo'),
- // translators: placeholder %1$s is the amount, %2$s is the duration (such as 1, 2, 3), and %3$s is the unit (such as month, year, week)
- 'desc' => sprintf(__('The customer will be charged %1$s every %2$s %3$s(s).', 'wp-ultimo'), '{{ wu_format_money(amount) }}', '{{ duration }}', '{{ duration_unit }}'),
- 'tooltip' => '',
- 'wrapper_html_attr' => array(
- 'v-show' => "is_recurring && pricing_type == 'paid'",
- 'v-cloak' => '1',
- ),
- 'fields' => array(
- '_amount' => array(
- 'type' => 'text',
- 'value' => $this->get_object()->get_formatted_amount(),
- 'placeholder' => wu_format_currency('99'),
- 'wrapper_classes' => '',
- 'money' => true,
- 'html_attr' => array(
- 'v-bind:name' => '""',
- 'v-model' => 'amount',
- ),
+ 'fields' => array(
+ // Fields for price
+ 'pricing_type' => array(
+ 'type' => 'select',
+ 'title' => __('Pricing Type', 'wp-ultimo'),
+ 'placeholder' => __('Select Pricing Type', 'wp-ultimo'),
+ 'desc' => __('Products can be free, paid, or require further contact for pricing.', 'wp-ultimo'),
+ 'value' => $this->get_object()->get_pricing_type(),
+ 'tooltip' => '',
+ 'options' => array(
+ 'paid' => __('Paid', 'wp-ultimo'),
+ 'free' => __('Free', 'wp-ultimo'),
+ 'contact_us' => __('Contact Us', 'wp-ultimo'),
),
- 'duration' => array(
- 'type' => 'number',
- 'value' => $this->get_object()->get_duration(),
- 'placeholder' => '',
- 'wrapper_classes' => 'wu-mx-2 wu-w-1/3',
- 'min' => 0,
- 'html_attr' => array(
- 'v-model' => 'duration',
- 'steps' => 1,
- ),
+ 'wrapper_html_attr' => array(
+ 'v-cloak' => '1',
),
- 'duration_unit' => array(
- 'type' => 'select',
- 'value' => $this->get_object()->get_duration_unit(),
- 'placeholder' => '',
- 'wrapper_classes' => 'wu-w-2/3',
- 'html_attr' => array(
- 'v-model' => 'duration_unit',
+ 'html_attr' => array(
+ 'v-model' => 'pricing_type',
+ ),
+ ),
+ 'contact_us_label' => array(
+ 'type' => 'text',
+ 'title' => __('Button Label', 'wp-ultimo'),
+ 'placeholder' => __('E.g. Contact us', 'wp-ultimo'),
+ 'desc' => __('This will be used on the pricing table CTA button, as the label.', 'wp-ultimo'),
+ 'value' => $this->get_object()->get_contact_us_label(),
+ 'wrapper_html_attr' => array(
+ 'v-show' => "pricing_type == 'contact_us'",
+ 'v-cloak' => '1',
+ ),
+ ),
+ 'contact_us_link' => array(
+ 'type' => 'url',
+ 'title' => __('Button Link', 'wp-ultimo'),
+ 'placeholder' => __('E.g. https://contactus.page.com', 'wp-ultimo'),
+ 'desc' => __('This will be used on the pricing table CTA button.', 'wp-ultimo'),
+ 'value' => $this->get_object()->get_contact_us_link(),
+ 'wrapper_html_attr' => array(
+ 'v-show' => "pricing_type == 'contact_us'",
+ 'v-cloak' => '1',
+ ),
+ ),
+ 'recurring' => array(
+ 'type' => 'toggle',
+ 'title' => __('Is Recurring?', 'wp-ultimo'),
+ 'desc' => __('Check this if this product has a recurring charge.', 'wp-ultimo'),
+ 'value' => $this->get_object()->is_recurring(),
+ 'wrapper_html_attr' => array(
+ 'v-show' => "pricing_type == 'paid'",
+ 'v-cloak' => '1',
+ ),
+ 'html_attr' => array(
+ 'v-model' => 'is_recurring',
+ ),
+ ),
+ 'amount' => array(
+ 'type' => 'hidden',
+ 'html_attr' => array(
+ 'v-model' => 'amount',
+ ),
+ ),
+ '_amount' => array(
+ 'type' => 'text',
+ 'title' => __('Price', 'wp-ultimo'),
+ 'placeholder' => __('Price', 'wp-ultimo'),
+ 'value' => $this->get_object()->get_formatted_amount(),
+ 'tooltip' => '',
+ 'money' => true,
+ 'wrapper_html_attr' => array(
+ 'v-show' => "pricing_type == 'paid' && !is_recurring ",
+ 'v-cloak' => '1',
+ ),
+ 'html_attr' => array(
+ 'v-bind:name' => '""',
+ 'v-model' => 'amount',
+ ),
+ ),
+ 'amount_group' => array(
+ 'type' => 'group',
+ 'title' => __('Price', 'wp-ultimo'),
+ // translators: placeholder %1$s is the amount, %2$s is the duration (such as 1, 2, 3), and %3$s is the unit (such as month, year, week)
+ 'desc' => sprintf(__('The customer will be charged %1$s every %2$s %3$s(s).', 'wp-ultimo'), '{{ wu_format_money(amount) }}', '{{ duration }}', '{{ duration_unit }}'),
+ 'tooltip' => '',
+ 'wrapper_html_attr' => array(
+ 'v-show' => "is_recurring && pricing_type == 'paid'",
+ 'v-cloak' => '1',
+ ),
+ 'fields' => array(
+ '_amount' => array(
+ 'type' => 'text',
+ 'value' => $this->get_object()->get_formatted_amount(),
+ 'placeholder' => wu_format_currency('99'),
+ 'wrapper_classes' => '',
+ 'money' => true,
+ 'html_attr' => array(
+ 'v-bind:name' => '""',
+ 'v-model' => 'amount',
+ ),
),
- 'options' => array(
- 'day' => __('Days', 'wp-ultimo'),
- 'week' => __('Weeks', 'wp-ultimo'),
- 'month' => __('Months', 'wp-ultimo'),
- 'year' => __('Years', 'wp-ultimo'),
+ 'duration' => array(
+ 'type' => 'number',
+ 'value' => $this->get_object()->get_duration(),
+ 'placeholder' => '',
+ 'wrapper_classes' => 'wu-mx-2 wu-w-1/3',
+ 'min' => 0,
+ 'html_attr' => array(
+ 'v-model' => 'duration',
+ 'steps' => 1,
+ ),
+ ),
+ 'duration_unit' => array(
+ 'type' => 'select',
+ 'value' => $this->get_object()->get_duration_unit(),
+ 'placeholder' => '',
+ 'wrapper_classes' => 'wu-w-2/3',
+ 'html_attr' => array(
+ 'v-model' => 'duration_unit',
+ ),
+ 'options' => array(
+ 'day' => __('Days', 'wp-ultimo'),
+ 'week' => __('Weeks', 'wp-ultimo'),
+ 'month' => __('Months', 'wp-ultimo'),
+ 'year' => __('Years', 'wp-ultimo'),
+ ),
),
),
),
- ),
- 'billing_cycles' => array(
- 'type' => 'number',
- 'title' => __('Billing Cycles', 'wp-ultimo'),
- 'placeholder' => __('E.g. 1', 'wp-ultimo'),
- 'desc' => __('How many times should we bill this customer. Leave 0 to charge until cancelled.', 'wp-ultimo'),
- 'value' => $this->get_object()->get_billing_cycles(),
- 'tooltip' => '',
- 'wrapper_html_attr' => array(
- 'v-show' => "is_recurring && pricing_type == 'paid'",
- 'v-cloak' => '1',
- ),
- ),
- 'has_trial' => array(
- 'type' => 'toggle',
- 'title' => __('Offer Trial', 'wp-ultimo'),
- 'desc' => __('Check if you want to add a trial period to this product.', 'wp-ultimo'),
- 'value' => $this->get_object()->has_trial(),
- 'wrapper_html_attr' => array(
- 'v-show' => "pricing_type == 'paid'",
- 'v-cloak' => '1',
- ),
- 'html_attr' => array(
- 'v-model' => 'has_trial',
- ),
- ),
- 'trial_group' => array(
- 'type' => 'group',
- 'title' => __('Trial', 'wp-ultimo'),
- 'tooltip' => '',
- 'wrapper_html_attr' => array(
- 'v-show' => "has_trial && pricing_type == 'paid'",
- 'v-cloak' => '1',
- ),
- 'fields' => array(
- 'trial_duration' => array(
- 'type' => 'number',
- 'value' => $this->get_object()->get_trial_duration(),
- 'placeholder' => '',
- 'wrapper_classes' => 'wu-mr-2 wu-w-1/3',
+ 'billing_cycles' => array(
+ 'type' => 'number',
+ 'title' => __('Billing Cycles', 'wp-ultimo'),
+ 'placeholder' => __('E.g. 1', 'wp-ultimo'),
+ 'desc' => __('How many times should we bill this customer. Leave 0 to charge until cancelled.', 'wp-ultimo'),
+ 'value' => $this->get_object()->get_billing_cycles(),
+ 'tooltip' => '',
+ 'wrapper_html_attr' => array(
+ 'v-show' => "is_recurring && pricing_type == 'paid'",
+ 'v-cloak' => '1',
),
- 'trial_duration_unit' => array(
- 'type' => 'select',
- 'value' => $this->get_object()->get_trial_duration_unit(),
- 'placeholder' => '',
- 'wrapper_classes' => 'wu-w-2/3',
- 'options' => array(
- 'day' => __('Days', 'wp-ultimo'),
- 'week' => __('Weeks', 'wp-ultimo'),
- 'month' => __('Months', 'wp-ultimo'),
- 'year' => __('Years', 'wp-ultimo'),
+ ),
+ 'has_trial' => array(
+ 'type' => 'toggle',
+ 'title' => __('Offer Trial', 'wp-ultimo'),
+ 'desc' => __('Check if you want to add a trial period to this product.', 'wp-ultimo'),
+ 'value' => $this->get_object()->has_trial(),
+ 'wrapper_html_attr' => array(
+ 'v-show' => "pricing_type == 'paid'",
+ 'v-cloak' => '1',
+ ),
+ 'html_attr' => array(
+ 'v-model' => 'has_trial',
+ ),
+ ),
+ 'trial_group' => array(
+ 'type' => 'group',
+ 'title' => __('Trial', 'wp-ultimo'),
+ 'tooltip' => '',
+ 'wrapper_html_attr' => array(
+ 'v-show' => "has_trial && pricing_type == 'paid'",
+ 'v-cloak' => '1',
+ ),
+ 'fields' => array(
+ 'trial_duration' => array(
+ 'type' => 'number',
+ 'value' => $this->get_object()->get_trial_duration(),
+ 'placeholder' => '',
+ 'wrapper_classes' => 'wu-mr-2 wu-w-1/3',
+ ),
+ 'trial_duration_unit' => array(
+ 'type' => 'select',
+ 'value' => $this->get_object()->get_trial_duration_unit(),
+ 'placeholder' => '',
+ 'wrapper_classes' => 'wu-w-2/3',
+ 'options' => array(
+ 'day' => __('Days', 'wp-ultimo'),
+ 'week' => __('Weeks', 'wp-ultimo'),
+ 'month' => __('Months', 'wp-ultimo'),
+ 'year' => __('Years', 'wp-ultimo'),
+ ),
),
),
),
- ),
- 'has_setup_fee' => array(
- 'type' => 'toggle',
- 'title' => __('Add Setup Fee?', 'wp-ultimo'),
- 'desc' => __('Check if you want to add a setup fee.', 'wp-ultimo'),
- 'value' => $this->get_object()->has_setup_fee(),
- 'wrapper_html_attr' => array(
- 'v-show' => "pricing_type == 'paid'",
- 'v-cloak' => '1',
+ 'has_setup_fee' => array(
+ 'type' => 'toggle',
+ 'title' => __('Add Setup Fee?', 'wp-ultimo'),
+ 'desc' => __('Check if you want to add a setup fee.', 'wp-ultimo'),
+ 'value' => $this->get_object()->has_setup_fee(),
+ 'wrapper_html_attr' => array(
+ 'v-show' => "pricing_type == 'paid'",
+ 'v-cloak' => '1',
+ ),
+ 'html_attr' => array(
+ 'v-model' => 'has_setup_fee',
+ ),
),
- 'html_attr' => array(
- 'v-model' => 'has_setup_fee',
+ 'setup_fee' => array(
+ 'type' => 'hidden',
+ 'html_attr' => array(
+ 'v-model' => 'setup_fee',
+ ),
),
- ),
- 'setup_fee' => array(
- 'type' => 'hidden',
- 'html_attr' => array(
- 'v-model' => 'setup_fee',
- ),
- ),
- '_setup_fee' => array(
- 'type' => 'text',
- 'money' => true,
- 'title' => __('Setup Fee', 'wp-ultimo'),
- 'desc' => __('The setup fee will be added to the first charge, in addition to the regular price of the product.', 'wp-ultimo'),
- // translators: %s is a price placeholder value.
- 'placeholder' => sprintf(__('E.g. %s', 'wp-ultimo'), wu_format_currency(199)),
- 'value' => $this->get_object()->get_formatted_amount('setup_fee'),
- 'wrapper_html_attr' => array(
- 'v-show' => "has_setup_fee && pricing_type == 'paid'",
- 'v-cloak' => '1',
- ),
- 'html_attr' => array(
- 'v-model' => 'setup_fee',
+ '_setup_fee' => array(
+ 'type' => 'text',
+ 'money' => true,
+ 'title' => __('Setup Fee', 'wp-ultimo'),
+ 'desc' => __('The setup fee will be added to the first charge, in addition to the regular price of the product.', 'wp-ultimo'),
+ // translators: %s is a price placeholder value.
+ 'placeholder' => sprintf(__('E.g. %s', 'wp-ultimo'), wu_format_currency(199)),
+ 'value' => $this->get_object()->get_formatted_amount('setup_fee'),
+ 'wrapper_html_attr' => array(
+ 'v-show' => "has_setup_fee && pricing_type == 'paid'",
+ 'v-cloak' => '1',
+ ),
+ 'html_attr' => array(
+ 'v-model' => 'setup_fee',
+ ),
),
),
),
- ), $this->get_object());
+ $this->get_object()
+ );
$this->add_save_widget('save', $save_widget_args);
- $this->add_fields_widget('active', array(
- 'title' => __('Active', 'wp-ultimo'),
- 'fields' => array(
- 'active' => array(
- 'type' => 'toggle',
- 'title' => __('Active', 'wp-ultimo'),
- 'desc' => __('Use this option to manually enable or disable this product for new sign-ups.', 'wp-ultimo'),
- 'value' => $this->get_object()->is_active(),
+ $this->add_fields_widget(
+ 'active',
+ array(
+ 'title' => __('Active', 'wp-ultimo'),
+ 'fields' => array(
+ 'active' => array(
+ 'type' => 'toggle',
+ 'title' => __('Active', 'wp-ultimo'),
+ 'desc' => __('Use this option to manually enable or disable this product for new sign-ups.', 'wp-ultimo'),
+ 'value' => $this->get_object()->is_active(),
+ ),
),
- ),
- ));
+ )
+ );
- $this->add_fields_widget('image', array(
- 'title' => __('Product Image', 'wp-ultimo'),
- 'fields' => array(
- 'featured_image_id' => array(
- 'type' => 'image',
- 'stacked' => true,
- 'title' => __('Product Image', 'wp-ultimo'),
- 'desc' => __('This image is used on product list tables and other places.', 'wp-ultimo'),
- 'value' => $this->get_object()->get_featured_image_id(),
- 'img' => $this->get_object()->get_featured_image(),
+ $this->add_fields_widget(
+ 'image',
+ array(
+ 'title' => __('Product Image', 'wp-ultimo'),
+ 'fields' => array(
+ 'featured_image_id' => array(
+ 'type' => 'image',
+ 'stacked' => true,
+ 'title' => __('Product Image', 'wp-ultimo'),
+ 'desc' => __('This image is used on product list tables and other places.', 'wp-ultimo'),
+ 'value' => $this->get_object()->get_featured_image_id(),
+ 'img' => $this->get_object()->get_featured_image(),
+ ),
),
- ),
- ));
-
- } // end register_widgets;
+ )
+ );
+ }
/**
* Handles legacy advanced options for plans.
@@ -538,15 +550,18 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
global $wp_filter;
- $tabs = apply_filters_deprecated('wu_plans_advanced_options_tabs', array(
- array(),
- ), '2.0.0', 'wu_product_options_sections');
-
- if (!isset($wp_filter['wu_plans_advanced_options_after_panels'])) {
+ $tabs = apply_filters_deprecated(
+ 'wu_plans_advanced_options_tabs',
+ array(
+ array(),
+ ),
+ '2.0.0',
+ 'wu_product_options_sections'
+ );
+ if ( ! isset($wp_filter['wu_plans_advanced_options_after_panels'])) {
return;
-
- } // end if;
+ }
wp_enqueue_style('wu-legacy-admin-tabs', wu_get_asset('legacy-admin-tabs.css', 'css'), false, wu_get_version());
@@ -562,35 +577,32 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
);
foreach ($priorities as $priority => $callbacks) {
-
foreach ($callbacks as $id => $callable) {
-
- $fields[$id] = array(
+ $fields[ $id ] = array(
'type' => 'html',
'classes' => 'wu--mt-2',
- 'content' => function() use ($callable) {
+ 'content' => function () use ($callable) {
call_user_func($callable['function'], new \WU_Plan($this->get_object()));
-
},
);
+ }
+ }
- } // end foreach;
-
- } // end foreach;
-
- $this->add_fields_widget('legacy-options', array(
- 'title' => __('Legacy Options', 'wp-ultimo'),
- 'position' => 'normal',
- 'fields' => $fields,
- 'classes' => 'wu-legacy-options-panel',
- '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(
- 'style' => 'margin-top: -5px;',
- ),
- ));
-
- } // end handle_legacy_options;
+ $this->add_fields_widget(
+ 'legacy-options',
+ array(
+ 'title' => __('Legacy Options', 'wp-ultimo'),
+ 'position' => 'normal',
+ 'fields' => $fields,
+ 'classes' => 'wu-legacy-options-panel',
+ '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(
+ 'style' => 'margin-top: -5px;',
+ ),
+ )
+ );
+ }
/**
* Returns the list of sections and its fields for the product page.
@@ -693,10 +705,14 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
'data-label-field' => 'name',
'data-search-field' => 'name',
'data-max-items' => 99,
- 'data-selected' => json_encode(wu_get_products(array(
- 'id__in' => $this->get_object()->get_available_addons(),
- 'id__not_in' => array_keys(wu_get_plans_as_options()),
- ))),
+ 'data-selected' => json_encode(
+ wu_get_products(
+ array(
+ 'id__in' => $this->get_object()->get_available_addons(),
+ 'id__not_in' => array_keys(wu_get_plans_as_options()),
+ )
+ )
+ ),
),
),
),
@@ -707,7 +723,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
'desc' => __('Discounts for longer membership commitments.', 'wp-ultimo'),
'icon' => 'dashicons-wu-price-tag',
'state' => array(
- 'enable_price_variations' => !empty($this->get_object()->get_price_variations()),
+ 'enable_price_variations' => ! empty($this->get_object()->get_price_variations()),
'price_variations' => $this->get_object()->get_price_variations(),
),
'fields' => array(
@@ -770,7 +786,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
'type' => 'hidden',
'html_attr' => array(
'v-bind:value' => 'price_variation.amount',
- 'v-bind:name' => '"price_variations[" + index + "][amount]"'
+ 'v-bind:name' => '"price_variations[" + index + "][amount]"',
),
),
'_price_variations_amount' => array(
@@ -869,7 +885,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
'options' => array(
'default' => __('Default', 'wp-ultimo'),
'assign_template' => __('Assign Site Template', 'wp-ultimo'),
- 'choose_available_templates' => __('Choose Available Site Templates', 'wp-ultimo')
+ 'choose_available_templates' => __('Choose Available Site Templates', 'wp-ultimo'),
),
'html_attr' => array(
'v-model' => 'site_template_selection_mode',
@@ -893,8 +909,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
);
return apply_filters('wu_product_options_sections', $sections, $this->get_object());
-
- } // end get_product_option_sections;
+ }
/**
* Returns the HTML markup for the plugin selector list.
@@ -908,12 +923,14 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
$all_templates = wu_get_site_templates();
- return wu_get_template_contents('limitations/site-template-selector', array(
- 'templates' => $all_templates,
- 'product' => $product,
- ));
-
- } // end get_site_template_selection_list;
+ return wu_get_template_contents(
+ 'limitations/site-template-selector',
+ array(
+ 'templates' => $all_templates,
+ 'product' => $product,
+ )
+ );
+ }
/**
* Returns the title of the page.
@@ -924,8 +941,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
public function get_title() {
return $this->edit ? __('Edit Product', 'wp-ultimo') : __('Add new Product', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the title of menu for this page.
@@ -936,8 +952,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
public function get_menu_title() {
return __('Edit Product', 'wp-ultimo');
-
- } // end get_menu_title;
+ }
/**
* Returns the action links for that page.
@@ -950,7 +965,6 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
$actions = array();
if ($this->get_object()->get_type() === 'plan' && $this->edit) {
-
$shareable_link = $this->get_object()->get_shareable_link();
$actions[] = array(
@@ -960,12 +974,10 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
'classes' => 'wu-copy',
'attrs' => 'data-clipboard-text="' . esc_attr($shareable_link) . '"',
);
-
- } // end if;
+ }
return $actions;
-
- } // end action_links;
+ }
/**
* Returns the labels to be used on the admin page.
@@ -986,8 +998,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
'delete_button_label' => __('Delete Product', 'wp-ultimo'),
'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'),
);
-
- } // end get_labels;
+ }
/**
* Filters the list table to return only relevant events.
@@ -1005,8 +1016,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
);
return array_merge($args, $extra_args);
-
- } // end query_filter;
+ }
/**
* Returns the object being edit at the moment.
@@ -1017,36 +1027,29 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
public function get_object() {
if ($this->object !== null) {
-
return $this->object;
-
- } // end if;
+ }
if (isset($_GET['id'])) {
-
- $query = new \WP_Ultimo\Database\Products\Product_Query;
+ $query = new \WP_Ultimo\Database\Products\Product_Query();
$item = $query->get_item_by('id', $_GET['id']);
- if (!$item) {
-
+ if ( ! $item) {
wp_redirect(wu_network_admin_url('wp-ultimo-products'));
exit;
-
- } // end if;
+ }
$this->object = $item;
return $this->object;
+ }
- } // end if;
-
- $this->object = new Product;
+ $this->object = new Product();
return $this->object;
-
- } // end get_object;
+ }
/**
* Products have titles.
*
@@ -1055,8 +1058,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
public function has_title(): bool {
return true;
-
- } // end has_title;
+ }
/**
* Should implement the processes necessary to save the changes made to the object.
@@ -1068,62 +1070,46 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
/*
* Set the recurring value to zero if the toggle is disabled.
*/
- if (!wu_request('recurring')) {
-
+ if ( ! wu_request('recurring')) {
$_POST['recurring'] = false;
+ }
- } // end if;
-
- if (!wu_request('legacy_options')) {
-
+ if ( ! wu_request('legacy_options')) {
$_POST['legacy_options'] = false;
+ }
- } // end if;
-
- if (!wu_request('featured_plan')) {
-
+ if ( ! wu_request('featured_plan')) {
$_POST['featured_plan'] = false;
-
- } // end if;
+ }
/*
* Set the setup fee value to zero if the toggle is disabled.
*/
- if (!wu_request('has_setup_fee')) {
-
+ if ( ! wu_request('has_setup_fee')) {
$_POST['setup_fee'] = 0;
-
- } // end if;
+ }
/*
* Disabled Trial
*/
- if (!wu_request('has_trial')) {
-
+ if ( ! wu_request('has_trial')) {
$_POST['trial_duration'] = 0;
-
- } // end if;
+ }
/*
* Set the setup fee value to zero if the toggle is disabled.
*/
- if (!wu_request('price_variations')) {
-
+ if ( ! wu_request('price_variations')) {
$_POST['price_variations'] = array();
-
- } // end if;
+ }
/*
* Set the taxable value to zero if the toggle is disabled.
*/
- if (!wu_request('taxable')) {
-
+ if ( ! wu_request('taxable')) {
$_POST['taxable'] = 0;
-
- } // end if;
+ }
parent::handle_save();
-
- } // end handle_save;
-
-} // end class Product_Edit_Admin_Page;
+ }
+}
diff --git a/inc/admin-pages/class-product-list-admin-page.php b/inc/admin-pages/class-product-list-admin-page.php
index fff2ea7..9683304 100644
--- a/inc/admin-pages/class-product-list-admin-page.php
+++ b/inc/admin-pages/class-product-list-admin-page.php
@@ -60,7 +60,7 @@ class Product_List_Admin_Page extends List_Admin_Page {
* @since 1.8.2
* @return void
*/
- public function hooks() {} // end hooks;
+ public function hooks() {}
/**
* Returns an array with the labels for the edit page.
@@ -74,8 +74,7 @@ class Product_List_Admin_Page extends List_Admin_Page {
'deleted_message' => __('Product removed successfully.', 'wp-ultimo'),
'search_label' => __('Search Product', 'wp-ultimo'),
);
-
- } // end get_labels;
+ }
/**
* Returns the title of the page.
@@ -86,8 +85,7 @@ class Product_List_Admin_Page extends List_Admin_Page {
public function get_title() {
return __('Products', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the title of menu for this page.
@@ -98,8 +96,7 @@ class Product_List_Admin_Page extends List_Admin_Page {
public function get_menu_title() {
return __('Products', 'wp-ultimo');
-
- } // end get_menu_title;
+ }
/**
* Allows admins to rename the sub-menu (first item) for a top-level page.
@@ -110,8 +107,7 @@ class Product_List_Admin_Page extends List_Admin_Page {
public function get_submenu_title() {
return __('Products', 'wp-ultimo');
-
- } // end get_submenu_title;
+ }
/**
* Returns the action links for that page.
@@ -128,8 +124,7 @@ class Product_List_Admin_Page extends List_Admin_Page {
'icon' => 'wu-circle-with-plus',
),
);
-
- } // end action_links;
+ }
/**
* Loads the list table for this particular page.
@@ -140,7 +135,5 @@ class Product_List_Admin_Page extends List_Admin_Page {
public function table() {
return new \WP_Ultimo\List_Tables\Product_List_Table();
-
- } // end table;
-
-} // end class Product_List_Admin_Page;
+ }
+}
diff --git a/inc/admin-pages/class-settings-admin-page.php b/inc/admin-pages/class-settings-admin-page.php
index 3f9b6ba..fb98554 100644
--- a/inc/admin-pages/class-settings-admin-page.php
+++ b/inc/admin-pages/class-settings-admin-page.php
@@ -9,9 +9,9 @@
namespace WP_Ultimo\Admin_Pages;
-use \WP_Ultimo\Settings;
-use \WP_Ultimo\UI\Form;
-use \WP_Ultimo\UI\Field;
+use WP_Ultimo\Settings;
+use WP_Ultimo\UI\Form;
+use WP_Ultimo\UI\Field;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -118,8 +118,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
wp_enqueue_script('wu-fields');
wp_enqueue_style('wp-color-picker');
-
- } // end register_scripts;
+ }
/**
* Registers widgets to the edit page.
@@ -135,37 +134,54 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
parent::register_widgets();
- wu_register_settings_side_panel('login-and-registration', array(
- 'title' => __('Checkout Forms', 'wp-ultimo'),
- 'render' => array($this, 'render_checkout_forms_side_panel'),
- ));
+ wu_register_settings_side_panel(
+ 'login-and-registration',
+ array(
+ 'title' => __('Checkout Forms', 'wp-ultimo'),
+ 'render' => array($this, 'render_checkout_forms_side_panel'),
+ )
+ );
- wu_register_settings_side_panel('sites', array(
- 'title' => __('Template Previewer', 'wp-ultimo'),
- 'render' => array($this, 'render_site_template_side_panel'),
- ));
+ wu_register_settings_side_panel(
+ 'sites',
+ array(
+ 'title' => __('Template Previewer', 'wp-ultimo'),
+ 'render' => array($this, 'render_site_template_side_panel'),
+ )
+ );
- wu_register_settings_side_panel('sites', array(
- 'title' => __('Placeholder Editor', 'wp-ultimo'),
- 'render' => array($this, 'render_site_placeholders_side_panel'),
- ));
+ wu_register_settings_side_panel(
+ 'sites',
+ array(
+ 'title' => __('Placeholder Editor', 'wp-ultimo'),
+ 'render' => array($this, 'render_site_placeholders_side_panel'),
+ )
+ );
- wu_register_settings_side_panel('payment-gateways', array(
- 'title' => __('Invoices', 'wp-ultimo'),
- 'render' => array($this, 'render_invoice_side_panel'),
- ));
+ wu_register_settings_side_panel(
+ 'payment-gateways',
+ array(
+ 'title' => __('Invoices', 'wp-ultimo'),
+ 'render' => array($this, 'render_invoice_side_panel'),
+ )
+ );
- wu_register_settings_side_panel('emails', array(
- 'title' => __('System Emails', 'wp-ultimo'),
- 'render' => array($this, 'render_system_emails_side_panel'),
- ));
+ wu_register_settings_side_panel(
+ 'emails',
+ array(
+ 'title' => __('System Emails', 'wp-ultimo'),
+ 'render' => array($this, 'render_system_emails_side_panel'),
+ )
+ );
- wu_register_settings_side_panel('emails', array(
- 'title' => __('Email Template', 'wp-ultimo'),
- 'render' => array($this, 'render_email_template_side_panel'),
- ));
-
- } // end register_widgets;
+ wu_register_settings_side_panel(
+ 'emails',
+ array(
+ 'title' => __('Email Template', 'wp-ultimo'),
+ 'render' => array($this, 'render_email_template_side_panel'),
+ )
+ );
+ }
/**
* Renders the addons side panel
@@ -173,7 +189,8 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
* @since 2.0.0
* @return void
*/
- public function render_checkout_forms_side_panel() { ?>
+ public function render_checkout_forms_side_panel() {
+ ?>
@@ -206,8 +223,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
+ public function render_site_template_side_panel() {
+
+ ?>
@@ -248,8 +266,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
+ public function render_site_placeholders_side_panel() {
+
+ ?>
@@ -290,8 +309,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
+ public function render_invoice_side_panel() {
+
+ ?>
@@ -332,8 +352,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
+ public function render_system_emails_side_panel() {
+
+ ?>
@@ -374,8 +395,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
+ public function render_email_template_side_panel() {
+
+ ?>
@@ -416,8 +438,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
get_current_screen(),
- 'page' => $this,
- 'classes' => '',
- 'sections' => $this->get_sections(),
- 'current_section' => $this->get_current_section(),
- 'clickable_navigation' => $this->clickable_navigation,
- ));
-
- } // end output;
+ wu_get_template(
+ 'base/settings',
+ array(
+ 'screen' => get_current_screen(),
+ 'page' => $this,
+ 'classes' => '',
+ 'sections' => $this->get_sections(),
+ 'current_section' => $this->get_current_section(),
+ 'clickable_navigation' => $this->clickable_navigation,
+ )
+ );
+ }
/**
* Returns the list of settings sections.
@@ -485,8 +506,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
public function get_sections() {
return WP_Ultimo()->settings->get_sections();
-
- } // end get_sections;
+ }
/**
* Default handler for step submission. Simply redirects to the next step.
@@ -496,25 +516,20 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
*/
public function default_handler() {
- if (!current_user_can('wu_edit_settings')) {
-
+ if ( ! current_user_can('wu_edit_settings')) {
wp_die(__('You do not have the permissions required to change settings.', 'wp-ultimo'));
+ }
- } // end if;
-
- if (!isset($_POST['active_gateways']) && wu_request('tab') === 'payment-gateways') {
-
+ if ( ! isset($_POST['active_gateways']) && wu_request('tab') === 'payment-gateways') {
$_POST['active_gateways'] = array();
-
- } // end if;
+ }
WP_Ultimo()->settings->save_settings($_POST);
wp_redirect(add_query_arg('updated', 1, wu_get_current_url()));
exit;
-
- } // end default_handler;
+ }
/**
* Default method for views.
@@ -543,30 +558,30 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
'classes' => 'button button-primary button-large wu-ml-auto wu-w-full md:wu-w-auto',
'wrapper_classes' => 'wu-sticky wu-bottom-0 wu-save-button wu-mr-px wu-w-full md:wu-w-auto',
'html_attr' => array(
- 'v-on:click' => 'send("window", "wu_block_ui", "#wpcontent")'
+ 'v-on:click' => 'send("window", "wu_block_ui", "#wpcontent")',
),
);
- if (!current_user_can('wu_edit_settings')) {
-
+ if ( ! current_user_can('wu_edit_settings')) {
$fields['save']['html_attr']['disabled'] = 'disabled';
+ }
- } // end if;
-
- $form = new Form($section_slug, $fields, array(
- 'views' => 'admin-pages/fields',
- 'classes' => 'wu-modal-form wu-widget-list wu-striped wu--mt-5 wu--mx-in wu--mb-in',
- 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-py-5 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(
- 'style' => '',
- 'data-on-load' => 'remove_block_ui',
- 'data-wu-app' => str_replace('-', '_', $section_slug),
- 'data-state' => json_encode(wu_array_map_keys('wu_replace_dashes', Settings::get_instance()->get_all(true))),
- ),
- ));
+ $form = new Form(
+ $section_slug,
+ $fields,
+ array(
+ 'views' => 'admin-pages/fields',
+ 'classes' => 'wu-modal-form wu-widget-list wu-striped wu--mt-5 wu--mx-in wu--mb-in',
+ 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-py-5 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(
+ 'style' => '',
+ 'data-on-load' => 'remove_block_ui',
+ 'data-wu-app' => str_replace('-', '_', $section_slug),
+ 'data-state' => json_encode(wu_array_map_keys('wu_replace_dashes', Settings::get_instance()->get_all(true))),
+ ),
+ )
+ );
$form->render();
-
- } // end default_view;
-
-} // end class Settings_Admin_Page;
+ }
+}
diff --git a/inc/admin-pages/class-setup-wizard-admin-page.php b/inc/admin-pages/class-setup-wizard-admin-page.php
index e0751e7..f3007af 100644
--- a/inc/admin-pages/class-setup-wizard-admin-page.php
+++ b/inc/admin-pages/class-setup-wizard-admin-page.php
@@ -12,10 +12,10 @@ namespace WP_Ultimo\Admin_Pages;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Installers\Migrator;
-use \WP_Ultimo\Installers\Core_Installer;
-use \WP_Ultimo\Installers\Default_Content_Installer;
-use \WP_Ultimo\Logger;
+use WP_Ultimo\Installers\Migrator;
+use WP_Ultimo\Installers\Core_Installer;
+use WP_Ultimo\Installers\Default_Content_Installer;
+use WP_Ultimo\Logger;
/**
* WP Multisite WaaS Dashboard Admin Page.
@@ -23,10 +23,10 @@ use \WP_Ultimo\Logger;
class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
/**
- * Holds the ID for this page, this is also used as the page slug.
- *
- * @var string
- */
+ * Holds the ID for this page, this is also used as the page slug.
+ *
+ * @var string
+ */
protected $id = 'wp-ultimo-setup';
/**
@@ -76,11 +76,11 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
);
/**
- * Is this an old install migrating.
- *
- * @since 2.0.0
- * @var bool|null
- */
+ * Is this an old install migrating.
+ *
+ * @since 2.0.0
+ * @var bool|null
+ */
private ?bool $is_migration = null;
/**
@@ -103,8 +103,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
*/
public function __construct() {
- if (!$this->is_core_loaded()) {
-
+ if ( ! $this->is_core_loaded()) {
require_once wu_path('inc/functions/documentation.php');
/**
@@ -121,8 +120,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
$this->menu_icon = 'dashicons-wu-wp-ultimo';
add_action('admin_enqueue_scripts', array($this, 'register_scripts'));
-
- } // end if;
+ }
parent::__construct();
@@ -144,8 +142,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
* Redirect on activation
*/
add_action('wu_activation', array($this, 'redirect_to_wizard'));
-
- } // end __construct;
+ }
/**
* Download the migration logs.
@@ -172,8 +169,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
readfile($file);
exit;
-
- } // end download_migration_logs;
+ }
/**
* Loads the extra elements we need on the wizard itself.
@@ -186,8 +182,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
parent::page_loaded();
$this->set_settings();
-
- } // end page_loaded;
+ }
/**
* Checks if this is a migration or not.
@@ -198,14 +193,11 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
public function is_migration() {
if ($this->is_migration === null) {
-
$this->is_migration = Migrator::is_legacy_network();
-
- } // end if;
+ }
return $this->is_migration;
-
- } // end is_migration;
+ }
/**
* Adds missing setup from settings when WP Multisite WaaS is not fully loaded.
@@ -216,8 +208,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
public function set_settings() {
WP_Ultimo()->settings->default_sections();
-
- } // end set_settings;
+ }
/**
* Redirects to the wizard, if we need to.
@@ -227,15 +218,12 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
*/
public function redirect_to_wizard() {
- if (!\WP_Ultimo\Requirements::run_setup() && wu_request('page') !== 'wp-ultimo-setup') {
-
+ if ( ! \WP_Ultimo\Requirements::run_setup() && wu_request('page') !== 'wp-ultimo-setup') {
wp_redirect(wu_network_admin_url('wp-ultimo-setup'));
exit;
-
- } // end if;
-
- } // end redirect_to_wizard;
+ }
+ }
/**
* Handles the ajax actions for installers and migrators.
@@ -247,13 +235,11 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
global $wpdb;
- if (!current_user_can('manage_network')) {
-
+ if ( ! current_user_can('manage_network')) {
wp_send_json_error(new \WP_Error('not-allowed', __('Permission denied.', 'wp-ultimo')));
exit;
-
- } // end if;
+ }
/*
* Load tables.
@@ -268,14 +254,11 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
$status = apply_filters('wu_handle_ajax_installers', true, $installer, $this);
if (is_wp_error($status)) {
-
wp_send_json_error($status);
-
- } // end if;
+ }
wp_send_json_success();
-
- } // end setup_install;
+ }
/**
* Check if the core was loaded.
@@ -286,8 +269,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
public function is_core_loaded() {
return \WP_Ultimo\Requirements::met() && \WP_Ultimo\Requirements::run_setup();
-
- } // end is_core_loaded;
+ }
/**
* Returns the logo for the wizard.
@@ -298,8 +280,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
public function get_logo() {
return wu_get_asset('logo.png', 'img');
-
- } // end get_logo;
+ }
/**
* Returns the title of the page.
@@ -310,8 +291,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
public function get_title(): string {
return sprintf(__('Installation', 'wp-ultimo'));
-
- } // end get_title;
+ }
/**
* Returns the title of menu for this page.
@@ -322,8 +302,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
public function get_menu_title() {
return WP_Ultimo()->is_loaded() ? __('WP Multisite WaaS Install', 'wp-ultimo') : __('WP Multisite WaaS', 'wp-ultimo');
-
- } // end get_menu_title;
+ }
/**
* Returns the sections for this Wizard.
@@ -336,11 +315,14 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
$sections = array(
'welcome' => array(
'title' => __('Welcome', 'wp-ultimo'),
- 'description' => implode('
', array(
- __('...and thanks for choosing WP Multisite WaaS!', 'wp-ultimo'),
- __('This quick setup wizard will make sure your server is correctly setup, help you configure your new network, and migrate data from previous WP Multisite WaaS versions if necessary.', 'wp-ultimo'),
- __('You will also have the option of importing default content. It should take 10 minutes or less!', 'wp-ultimo')
- )),
+ 'description' => implode(
+ '
',
+ array(
+ __('...and thanks for choosing WP Multisite WaaS!', 'wp-ultimo'),
+ __('This quick setup wizard will make sure your server is correctly setup, help you configure your new network, and migrate data from previous WP Multisite WaaS versions if necessary.', 'wp-ultimo'),
+ __('You will also have the option of importing default content. It should take 10 minutes or less!', 'wp-ultimo'),
+ )
+ ),
'next_label' => __('Get Started →', 'wp-ultimo'),
'back' => false,
),
@@ -354,7 +336,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
'requirements' => array(
'type' => 'note',
'desc' => array($this, 'renders_requirements_table'),
- )
+ ),
),
),
'installation' => array(
@@ -374,7 +356,6 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
* In case of migrations, add different sections.
*/
if ($this->is_migration()) {
-
$dry_run = wu_request('dry-run', true);
$next = true;
@@ -388,12 +369,10 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
$description = __('No errors found during dry run! Now it is time to actually migrate!
We strongly recommend creating a backup of your database before moving forward with the migration.', 'wp-ultimo');
if ($dry_run) {
-
$next_label = __('Run Check', 'wp-ultimo');
$description = __('It seems that you were running WP Multisite WaaS 1.X on this network. This migrator will convert the data from the old version to the new one.', 'wp-ultimo') . '
' . __('First, let\'s run a test migration to see if we can spot any potential errors.', 'wp-ultimo');
-
- } // end if;
+ }
$fields = array(
'migration' => array(
@@ -403,7 +382,6 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
);
if ($errors) {
-
$subject = 'Errors on migrating my network';
$user = wp_get_current_user();
@@ -415,7 +393,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
'Here are the error messages I got:',
sprintf('```%s%s%s```', PHP_EOL, implode(PHP_EOL, $errors), PHP_EOL),
sprintf('```%s%s%s```', PHP_EOL, $back_traces ? implode(PHP_EOL, $back_traces) : 'No backtraces found.', PHP_EOL),
- 'Kind regards.'
+ 'Kind regards.',
);
$message = implode(PHP_EOL . PHP_EOL, $message_lines);
@@ -428,35 +406,50 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page {
$error_list = '' . __('List of errors detected:', 'wp-ultimo') . '
';
-
- } // end render_debug_pages;
+ }
/**
* Returns the title of the page.
@@ -127,8 +127,7 @@ class Debug_Admin_Page extends Base_Admin_Page {
public function get_title() {
return __('Registered Pages', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the title of menu for this page.
@@ -139,8 +138,7 @@ class Debug_Admin_Page extends Base_Admin_Page {
public function get_menu_title() {
return __('Registered Pages', 'wp-ultimo');
-
- } // end get_menu_title;
+ }
/**
* Allows admins to rename the sub-menu (first item) for a top-level page.
@@ -151,8 +149,7 @@ class Debug_Admin_Page extends Base_Admin_Page {
public function get_submenu_title() {
return __('Registered Pages', 'wp-ultimo');
-
- } // end get_submenu_title;
+ }
/**
* Every child class should implement the output method to display the contents of the page.
@@ -162,12 +159,13 @@ class Debug_Admin_Page extends Base_Admin_Page {
*/
public function output() {
- wu_get_template('base/dash', array(
- 'page' => $this,
- 'screen' => get_current_screen(),
- 'has_full_position' => false,
- ));
-
- } // end output;
-
-} // end class Debug_Admin_Page;
+ wu_get_template(
+ 'base/dash',
+ array(
+ 'page' => $this,
+ 'screen' => get_current_screen(),
+ 'has_full_position' => false,
+ )
+ );
+ }
+}
diff --git a/inc/api/class-register-endpoint.php b/inc/api/class-register-endpoint.php
index 4056511..d7e7626 100644
--- a/inc/api/class-register-endpoint.php
+++ b/inc/api/class-register-endpoint.php
@@ -9,11 +9,11 @@
namespace WP_Ultimo\API;
-use \WP_Ultimo\Checkout\Cart;
-use \WP_Ultimo\Database\Sites\Site_Type;
-use \WP_Ultimo\Database\Payments\Payment_Status;
-use \WP_Ultimo\Database\Memberships\Membership_Status;
-use \WP_Ultimo\Objects\Billing_Address;
+use WP_Ultimo\Checkout\Cart;
+use WP_Ultimo\Database\Sites\Site_Type;
+use WP_Ultimo\Database\Payments\Payment_Status;
+use WP_Ultimo\Database\Memberships\Membership_Status;
+use WP_Ultimo\Objects\Billing_Address;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -36,8 +36,7 @@ class Register_Endpoint {
public function init() {
add_action('wu_register_rest_routes', array($this, 'register_route'));
-
- } // end init;
+ }
/**
* Adds a new route to the wu namespace, for the register endpoint.
@@ -51,20 +50,27 @@ class Register_Endpoint {
$namespace = $api->get_namespace();
- register_rest_route($namespace, '/register', array(
- 'methods' => \WP_REST_Server::READABLE,
- 'callback' => array($this, 'handle_get'),
- 'permission_callback' => \Closure::fromCallable([$api, 'check_authorization']),
- ));
+ register_rest_route(
+ $namespace,
+ '/register',
+ array(
+ 'methods' => \WP_REST_Server::READABLE,
+ 'callback' => array($this, 'handle_get'),
+ 'permission_callback' => \Closure::fromCallable(array($api, 'check_authorization')),
+ )
+ );
- register_rest_route($namespace, '/register', array(
- 'methods' => \WP_REST_Server::CREATABLE,
- 'callback' => array($this, 'handle_endpoint'),
- 'permission_callback' => \Closure::fromCallable([$api, 'check_authorization']),
- 'args' => $this->get_rest_args(),
- ));
-
- } // end register_route;
+ register_rest_route(
+ $namespace,
+ '/register',
+ array(
+ 'methods' => \WP_REST_Server::CREATABLE,
+ 'callback' => array($this, 'handle_endpoint'),
+ 'permission_callback' => \Closure::fromCallable(array($api, 'check_authorization')),
+ 'args' => $this->get_rest_args(),
+ )
+ );
+ }
/**
* Handle the register endpoint get for zapier integration reasons.
@@ -79,8 +85,7 @@ class Register_Endpoint {
return array(
'registration_status' => wu_get_setting('enable_registration', true) ? 'open' : 'closed',
);
-
- } // end handle_get;
+ }
/**
* Handle the register endpoint logic.
@@ -97,60 +102,63 @@ class Register_Endpoint {
$params = json_decode($request->get_body(), true);
if (\WP_Ultimo\API::get_instance()->should_log_api_calls()) {
-
wu_log_add('api-calls', json_encode($params, JSON_PRETTY_PRINT));
-
- } // end if;
+ }
$validation_errors = $this->validate($params);
if (is_wp_error($validation_errors)) {
-
- $validation_errors->add_data(array(
- 'status' => 400,
- ));
+ $validation_errors->add_data(
+ array(
+ 'status' => 400,
+ )
+ );
return $validation_errors;
-
- } // end if;
+ }
$wpdb->query('START TRANSACTION');
try {
-
$customer = $this->maybe_create_customer($params);
if (is_wp_error($customer)) {
-
return $this->rollback_and_return($customer);
-
- } // end if;
+ }
$customer->update_last_login(true, true);
- $customer->add_note(array(
- 'text' => __('Created via REST API', 'wp-ultimo'),
- 'author_id' => $customer->get_user_id(),
- ));
+ $customer->add_note(
+ array(
+ 'text' => __('Created via REST API', 'wp-ultimo'),
+ 'author_id' => $customer->get_user_id(),
+ )
+ );
/*
* Payment Method defaults
*/
- $payment_method = wp_parse_args(wu_get_isset($params, 'payment_method'), array(
- 'gateway' => '',
- 'gateway_customer_id' => '',
- 'gateway_subscription_id' => '',
- 'gateway_payment_id' => '',
- ));
+ $payment_method = wp_parse_args(
+ wu_get_isset($params, 'payment_method'),
+ array(
+ 'gateway' => '',
+ 'gateway_customer_id' => '',
+ 'gateway_subscription_id' => '',
+ 'gateway_payment_id' => '',
+ )
+ );
/*
* Cart params and creation
*/
$cart_params = $params;
- $cart_params = wp_parse_args($cart_params, array(
- 'type' => 'new',
- ));
+ $cart_params = wp_parse_args(
+ $cart_params,
+ array(
+ 'type' => 'new',
+ )
+ );
$cart = new Cart($cart_params);
@@ -158,21 +166,33 @@ class Register_Endpoint {
* Validates if the cart is valid.
*/
if ($cart->is_valid() && count($cart->get_line_items()) === 0) {
-
- return new \WP_Error('invalid_cart', __('Products are required.', 'wp-ultimo'), array_merge((array) $cart->done(), array(
- 'status' => 400,
- )));
-
- } // end if;
+ return new \WP_Error(
+ 'invalid_cart',
+ __('Products are required.', 'wp-ultimo'),
+ array_merge(
+ (array) $cart->done(),
+ array(
+ 'status' => 400,
+ )
+ )
+ );
+ }
/*
* Get Membership data
*/
$membership_data = $cart->to_membership_data();
- $membership_data = array_merge($membership_data, wu_get_isset($params, 'membership', array(
- 'status' => Membership_Status::PENDING,
- )));
+ $membership_data = array_merge(
+ $membership_data,
+ wu_get_isset(
+ $params,
+ 'membership',
+ array(
+ 'status' => Membership_Status::PENDING,
+ )
+ )
+ );
$membership_data['customer_id'] = $customer->get_id();
$membership_data['gateway'] = wu_get_isset($payment_method, 'gateway');
@@ -190,21 +210,28 @@ class Register_Endpoint {
$membership = wu_create_membership($membership_data);
if (is_wp_error($membership)) {
-
return $this->rollback_and_return($membership);
+ }
- } // end if;
-
- $membership->add_note(array(
- 'text' => __('Created via REST API', 'wp-ultimo'),
- 'author_id' => $customer->get_user_id(),
- ));
+ $membership->add_note(
+ array(
+ 'text' => __('Created via REST API', 'wp-ultimo'),
+ 'author_id' => $customer->get_user_id(),
+ )
+ );
$payment_data = $cart->to_payment_data();
- $payment_data = array_merge($payment_data, wu_get_isset($params, 'payment', array(
- 'status' => Payment_Status::PENDING,
- )));
+ $payment_data = array_merge(
+ $payment_data,
+ wu_get_isset(
+ $params,
+ 'payment',
+ array(
+ 'status' => Payment_Status::PENDING,
+ )
+ )
+ );
/*
* Unset the status because we are going to transition it later.
@@ -221,15 +248,15 @@ class Register_Endpoint {
$payment = wu_create_payment($payment_data);
if (is_wp_error($payment)) {
-
return $this->rollback_and_return($payment);
+ }
- } // end if;
-
- $payment->add_note(array(
- 'text' => __('Created via REST API', 'wp-ultimo'),
- 'author_id' => $customer->get_user_id(),
- ));
+ $payment->add_note(
+ array(
+ 'text' => __('Created via REST API', 'wp-ultimo'),
+ 'author_id' => $customer->get_user_id(),
+ )
+ );
$site = false;
@@ -237,22 +264,17 @@ class Register_Endpoint {
* Site creation.
*/
if (wu_get_isset($params, 'site')) {
-
$site = $this->maybe_create_site($params, $membership);
if (is_wp_error($site)) {
-
return $this->rollback_and_return($site);
-
- } // end if;
-
- } // end if;
+ }
+ }
/*
* Deal with status changes.
*/
if ($membership_status !== $membership->get_status()) {
-
$membership->set_status($membership_status);
$membership->save();
@@ -263,34 +285,24 @@ class Register_Endpoint {
* again, this time as a WU Site object.
*/
if ($site) {
-
$wp_site = get_site_by_path($site['domain'], $site['path']);
if ($wp_site) {
-
$site['id'] = $wp_site->blog_id;
-
- } // end if;
-
- } // end if;
-
- } // end if;
+ }
+ }
+ }
if ($payment_status !== $payment->get_status()) {
-
$payment->set_status($payment_status);
$payment->save();
-
- } // end if;
-
+ }
} catch (\Throwable $e) {
-
$wpdb->query('ROLLBACK');
return new \WP_Error('registration_error', $e->getMessage(), array('status' => 500));
-
- } // end try;
+ }
$wpdb->query('COMMIT');
@@ -303,8 +315,7 @@ class Register_Endpoint {
'payment' => $payment->to_array(),
'site' => $site ? $site : array('id' => 0),
);
-
- } // end handle_endpoint;
+ }
/**
* Returns the list of arguments allowed on to the endpoint.
@@ -351,7 +362,7 @@ class Register_Endpoint {
'billing_address' => array(
'type' => 'object',
'properties' => $billing_address_fields,
- )
+ ),
),
),
);
@@ -521,39 +532,31 @@ class Register_Endpoint {
$args = array_merge($customer_args, $membership_args, $cart_args, $payment_args, $site_args);
return apply_filters('wu_rest_register_endpoint_args', $args, $this);
-
- } // end get_rest_args;
- /**
- * Maybe create a customer, if needed.
- *
- * @since 2.0.0
- *
- * @param array $p The request parameters.
- * @return \WP_Ultimo\Models\Customer|\WP_Error
- */
- public function maybe_create_customer($p) {
+ }
+ /**
+ * Maybe create a customer, if needed.
+ *
+ * @since 2.0.0
+ *
+ * @param array $p The request parameters.
+ * @return \WP_Ultimo\Models\Customer|\WP_Error
+ */
+ public function maybe_create_customer($p) {
$customer_id = wu_get_isset($p, 'customer_id');
if ($customer_id) {
-
$customer = wu_get_customer($customer_id);
- if (!$customer) {
-
+ if ( ! $customer) {
return new \WP_Error('customer_not_found', __('The customer id sent does not correspond to a valid customer.', 'wp-ultimo'));
-
- } // end if;
-
+ }
} else {
-
$customer = wu_create_customer($p['customer']);
-
- } // end if;
+ }
return $customer;
-
- } // end maybe_create_customer;
+ }
/**
* Undocumented function
@@ -585,15 +588,14 @@ class Register_Endpoint {
* The get_sites method already includes pending sites,
* so we can safely rely on it.
*/
- if (!empty($sites)) {
+ if ( ! empty($sites)) {
/*
* Returns the first site on that list.
* This is not ideal, but since we'll usually only have
* one site here, it's ok. for now.
*/
return current($sites);
-
- } // end if;
+ }
$site_url = wu_get_isset($site_data, 'site_url');
@@ -605,10 +607,8 @@ class Register_Endpoint {
$results = wpmu_validate_blog_signup($site_url, wu_get_isset($site_data, 'site_title'), $membership->get_customer()->get_user());
if ($results['errors']->has_errors()) {
-
return $results['errors'];
-
- } // end if;
+ }
/*
* Get the transient data to save with the site
@@ -640,22 +640,17 @@ class Register_Endpoint {
$site_data['id'] = 0;
if (wu_get_isset($site_data, 'publish')) {
-
$membership->publish_pending_site();
$wp_site = get_site_by_path($site_data['domain'], $site_data['path']);
if ($wp_site) {
-
$site_data['id'] = $wp_site->blog_id;
-
- } // end if;
-
- } // end if;
+ }
+ }
return $site_data;
-
- } // end maybe_create_site;
+ }
/**
* Set the validation rules for this particular model.
@@ -679,30 +674,26 @@ class Register_Endpoint {
'site.site_url' => 'required_with:site|alpha_num|min:4|lowercase|unique_site',
'site.site_title' => 'required_with:site|min:4',
);
+ }
+ /**
+ * Validates the rules and make sure we only save models when necessary.
+ *
+ * @since 2.0.0
+ * @param array $args The params to validate.
+ * @return mixed[]|\WP_Error
+ */
+ public function validate($args) {
- } // end validation_rules;
- /**
- * Validates the rules and make sure we only save models when necessary.
- *
- * @since 2.0.0
- * @param array $args The params to validate.
- * @return mixed[]|\WP_Error
- */
- public function validate($args) {
-
- $validator = new \WP_Ultimo\Helpers\Validator;
+ $validator = new \WP_Ultimo\Helpers\Validator();
$validator->validate($args, $this->validation_rules());
if ($validator->fails()) {
-
return $validator->get_errors();
-
- } // end if;
+ }
return true;
-
- } // end validate;
+ }
/**
* Rolls back database changes and returns the error passed.
@@ -719,7 +710,5 @@ class Register_Endpoint {
$wpdb->query('ROLLBACK');
return $error;
-
- } // end rollback_and_return;
-
-} // end class Register_Endpoint;
+ }
+}
diff --git a/inc/api/trait-rest-api.php b/inc/api/trait-rest-api.php
index 1851471..f024b7c 100644
--- a/inc/api/trait-rest-api.php
+++ b/inc/api/trait-rest-api.php
@@ -45,9 +45,8 @@ trait Rest_Api {
*/
public function get_rest_base() {
- return (!empty($this->rest_base)) ? $this->rest_base : $this->slug;
-
- } // end get_rest_base;
+ return (! empty($this->rest_base)) ? $this->rest_base : $this->slug;
+ }
/**
* Registers the routes. Should be called by the entity
@@ -60,14 +59,11 @@ trait Rest_Api {
$is_enabled = \WP_Ultimo\API::get_instance()->is_api_enabled();
if ($is_enabled) {
-
add_action('rest_api_init', array($this, 'register_routes_general'));
add_action('rest_api_init', array($this, 'register_routes_with_id'));
-
- } // end if;
-
- } // end enable_rest_api;
+ }
+ }
/**
* Register the endpoints that don't need an ID,
@@ -80,7 +76,6 @@ trait Rest_Api {
$routes = array();
if (in_array('get_items', $this->enabled_rest_endpoints, true)) {
-
$routes = array(
array(
'methods' => \WP_REST_Server::READABLE,
@@ -88,34 +83,28 @@ trait Rest_Api {
'permission_callback' => array($this, 'get_items_permissions_check'),
),
);
-
- } // end if;
+ }
if (in_array('create_item', $this->enabled_rest_endpoints, true)) {
-
$routes[] = array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => array($this, 'create_item_rest'),
'permission_callback' => array($this, 'create_item_permissions_check'),
- 'args' => $this->get_arguments_schema()
+ 'args' => $this->get_arguments_schema(),
);
+ }
- } // end if;
-
- if (!empty($routes)) {
-
+ if ( ! empty($routes)) {
register_rest_route(
\WP_Ultimo\API::get_instance()->get_namespace(),
'/' . $this->get_rest_base(),
$routes,
true
);
-
- } // end if;
+ }
do_action('wu_rest_register_routes_general', $routes, $this->get_rest_base(), 'create', $this);
-
- } // end register_routes_general;
+ }
/**
* Register the endpoints that need an ID,
@@ -128,95 +117,82 @@ trait Rest_Api {
$routes = array();
if (in_array('get_item', $this->enabled_rest_endpoints, true)) {
-
$routes[] = array(
'methods' => \WP_REST_Server::READABLE,
'callback' => array($this, 'get_item_rest'),
'permission_callback' => array($this, 'get_item_permissions_check'),
);
-
- } // end if;
+ }
if (in_array('update_item', $this->enabled_rest_endpoints, true)) {
-
$routes[] = array(
'methods' => \WP_REST_Server::EDITABLE,
'callback' => array($this, 'update_item_rest'),
'permission_callback' => array($this, 'update_item_permissions_check'),
- 'args' => $this->get_arguments_schema(true)
+ 'args' => $this->get_arguments_schema(true),
);
-
- } // end if;
+ }
if (in_array('delete_item', $this->enabled_rest_endpoints, true)) {
-
$routes[] = array(
'methods' => \WP_REST_Server::DELETABLE,
'callback' => array($this, 'delete_item_rest'),
'permission_callback' => array($this, 'delete_item_permissions_check'),
);
+ }
- } // end if;
-
- if (!empty($routes)) {
-
+ if ( ! empty($routes)) {
register_rest_route(
\WP_Ultimo\API::get_instance()->get_namespace(),
'/' . $this->get_rest_base() . '/(?P[\d]+)',
$routes,
true
);
-
- } // end if;
+ }
do_action('wu_rest_register_routes_with_id', $routes, $this->get_rest_base(), 'update', $this);
-
- } // end register_routes_with_id;
- /**
- * Returns a specific item.
- *
- * @since 2.0.0
- *
- * @param WP_REST_Request $request The request sent.
- * @return \WP_REST_Response|\WP_Error
- */
- public function get_item_rest($request) {
+ }
+ /**
+ * Returns a specific item.
+ *
+ * @since 2.0.0
+ *
+ * @param WP_REST_Request $request The request sent.
+ * @return \WP_REST_Response|\WP_Error
+ */
+ public function get_item_rest($request) {
$item = $this->model_class::get_by_id($request['id']);
if (empty($item)) {
-
return new \WP_Error("wu_rest_{$this->slug}_invalid_id", __('Item not found.', 'wp-ultimo'), array('status' => 404));
-
- } // end if;
+ }
return rest_ensure_response($item);
-
- } // end get_item_rest;
- /**
- * Returns a list of items.
- *
- * @since 2.0.0
- *
- * @param WP_REST_Request $request The request sent.
- * @return \WP_REST_Response|\WP_Error
- */
- public function get_items_rest($request) {
+ }
+ /**
+ * Returns a list of items.
+ *
+ * @since 2.0.0
+ *
+ * @param WP_REST_Request $request The request sent.
+ * @return \WP_REST_Response|\WP_Error
+ */
+ public function get_items_rest($request) {
$items = $this->model_class::query($request->get_params());
return rest_ensure_response($items);
-
- } // end get_items_rest;
- /**
- * Creates an item.
- *
- * @since 2.0.0
- *
- * @param WP_REST_Request $request The request sent.
- * @return \WP_REST_Response|\WP_Error
- */
- public function create_item_rest($request) {
+ }
+ /**
+ * Creates an item.
+ *
+ * @since 2.0.0
+ *
+ * @param WP_REST_Request $request The request sent.
+ * @return \WP_REST_Response|\WP_Error
+ */
+ public function create_item_rest($request) {
$body = json_decode($request->get_body(), true);
@@ -225,53 +201,42 @@ trait Rest_Api {
$saver_function = "wu_create_{$model_name}";
if (function_exists($saver_function)) {
-
$item = call_user_func($saver_function, $body);
$saved = is_wp_error($item) ? $item : true;
-
} else {
-
$item = new $this->model_class($body);
$saved = $item->save();
-
- } // end if;
+ }
if (is_wp_error($saved)) {
-
return rest_ensure_response($saved);
+ }
- } // end if;
-
- if (!$saved) {
-
+ if ( ! $saved) {
return new \WP_Error("wu_rest_{$this->slug}", __('Something went wrong (Code 1).', 'wp-ultimo'), array('status' => 400));
-
- } // end if;
+ }
return rest_ensure_response($item);
-
- } // end create_item_rest;
- /**
- * Updates an item.
- *
- * @since 2.0.0
- *
- * @param WP_REST_Request $request The request sent.
- * @return \WP_REST_Response|\WP_Error
- */
- public function update_item_rest($request) {
+ }
+ /**
+ * Updates an item.
+ *
+ * @since 2.0.0
+ *
+ * @param WP_REST_Request $request The request sent.
+ * @return \WP_REST_Response|\WP_Error
+ */
+ public function update_item_rest($request) {
$id = wu_get_isset($request->get_url_params(), 'id');
$item = $this->model_class::get_by_id($id);
if (empty($item)) {
-
return new \WP_Error("wu_rest_{$this->slug}_invalid_id", __('Item not found.', 'wp-ultimo'), array('status' => 404));
-
- } // end if;
+ }
$params = array_filter(
json_decode($request->get_body(), true),
@@ -280,19 +245,13 @@ trait Rest_Api {
);
foreach ($params as $param => $value) {
-
$set_method = "set_{$param}";
if ($param === 'meta') {
-
$item->update_meta_batch($value);
-
} elseif (method_exists($item, $set_method)) {
-
call_user_func(array($item, $set_method), $value);
-
} else {
-
$error_message = sprintf(
/* translators: 1. Object class name; 2. Set method name */
__('The %1$s object does not have a %2$s method', 'wp-ultimo'),
@@ -305,51 +264,41 @@ trait Rest_Api {
$error_message,
array('status' => 400)
);
-
- } // end if;
-
- } // end foreach;
+ }
+ }
$saved = $item->save();
if (is_wp_error($saved)) {
-
return rest_ensure_response($saved);
+ }
- } // end if;
-
- if (!$saved) {
-
+ if ( ! $saved) {
return new \WP_Error("wu_rest_{$this->slug}", __('Something went wrong (Code 2).', 'wp-ultimo'));
-
- } // end if;
+ }
return rest_ensure_response($item);
-
- } // end update_item_rest;
- /**
- * Deletes an item.
- *
- * @since 2.0.0
- *
- * @param WP_REST_Request $request The request sent.
- * @return \WP_REST_Response|\WP_Error
- */
- public function delete_item_rest($request) {
+ }
+ /**
+ * Deletes an item.
+ *
+ * @since 2.0.0
+ *
+ * @param WP_REST_Request $request The request sent.
+ * @return \WP_REST_Response|\WP_Error
+ */
+ public function delete_item_rest($request) {
$item = $this->model_class::get_by_id($request['id']);
if (empty($item)) {
-
return new \WP_Error("wu_rest_{$this->slug}_invalid_id", __('Item not found.', 'wp-ultimo'), array('status' => 404));
-
- } // end if;
+ }
$result = $item->delete();
return rest_ensure_response($result);
-
- } // end delete_item_rest;
+ }
/**
* Check permissions to list items.
@@ -361,11 +310,9 @@ trait Rest_Api {
*/
public function get_items_permissions_check($request) {
- if (!\WP_Ultimo\API::get_instance()->check_authorization($request)) {
-
+ if ( ! \WP_Ultimo\API::get_instance()->check_authorization($request)) {
return false;
-
- } // end if;
+ }
/**
* Filters if it is allowed to proceed with the request or not.
@@ -377,8 +324,7 @@ trait Rest_Api {
* @param Base_Manager $this The object instance.
*/
return apply_filters('wu_rest_get_items', true, $this->get_rest_base(), $this);
-
- } // end get_items_permissions_check;
+ }
/**
* Check permissions to create an item.
@@ -390,11 +336,9 @@ trait Rest_Api {
*/
public function create_item_permissions_check($request) {
- if (!\WP_Ultimo\API::get_instance()->check_authorization($request)) {
-
+ if ( ! \WP_Ultimo\API::get_instance()->check_authorization($request)) {
return false;
-
- } // end if;
+ }
/**
* Filters if it is allowed to proceed with the request or not.
@@ -406,8 +350,7 @@ trait Rest_Api {
* @param Base_Manager $this The object instance.
*/
return apply_filters('wu_rest_create_item', true, $this->get_rest_base(), $this);
-
- } // end create_item_permissions_check;
+ }
/**
* Check permissions to get an item.
@@ -419,11 +362,9 @@ trait Rest_Api {
*/
public function get_item_permissions_check($request) {
- if (!\WP_Ultimo\API::get_instance()->check_authorization($request)) {
-
+ if ( ! \WP_Ultimo\API::get_instance()->check_authorization($request)) {
return false;
-
- } // end if;
+ }
/**
* Filters if it is allowed to proceed with the request or not.
@@ -435,8 +376,7 @@ trait Rest_Api {
* @param Base_Manager $this The object instance.
*/
return apply_filters('wu_rest_get_item', true, $this->get_rest_base(), $this);
-
- } // end get_item_permissions_check;
+ }
/**
* Check permissions to update an item.
@@ -448,11 +388,9 @@ trait Rest_Api {
*/
public function update_item_permissions_check($request) {
- if (!\WP_Ultimo\API::get_instance()->check_authorization($request)) {
-
+ if ( ! \WP_Ultimo\API::get_instance()->check_authorization($request)) {
return false;
-
- } // end if;
+ }
/**
* Filters if it is allowed to proceed with the request or not.
@@ -464,8 +402,7 @@ trait Rest_Api {
* @param Base_Manager $this The object instance.
*/
return apply_filters('wu_rest_update_item', true, $this->get_rest_base(), $this);
-
- } // end update_item_permissions_check;
+ }
/**
* Check permissions to delete an item.
@@ -477,11 +414,9 @@ trait Rest_Api {
*/
public function delete_item_permissions_check($request) {
- if (!\WP_Ultimo\API::get_instance()->check_authorization($request)) {
-
+ if ( ! \WP_Ultimo\API::get_instance()->check_authorization($request)) {
return false;
-
- } // end if;
+ }
/**
* Filters if it is allowed to proceed with the request or not.
@@ -493,8 +428,7 @@ trait Rest_Api {
* @param Base_Manager $this The object instance.
*/
return apply_filters('wu_rest_delete_item', true, $this->get_rest_base(), $this);
-
- } // end delete_item_permissions_check;
+ }
/**
* Checks if a value is not a credential key.
@@ -513,9 +447,8 @@ trait Rest_Api {
'api-secret',
);
- return !in_array($value, $credentials_keys, true);
-
- } // end is_not_credential_key;
+ return ! in_array($value, $credentials_keys, true);
+ }
/**
* Checks if a value is not equal to "id".
@@ -532,17 +465,14 @@ trait Rest_Api {
);
if ($this->slug === 'site') {
-
$arr = array(
'id',
'blog_id',
);
+ }
- } // end if;
-
- return !in_array($value, $arr, true);
-
- } // end is_not_id_key;
+ return ! in_array($value, $arr, true);
+ }
/**
* Get the arguments for an endpoint
@@ -559,8 +489,7 @@ trait Rest_Api {
$args = array_filter($schema, array($this, 'is_not_id_key'), ARRAY_FILTER_USE_KEY);
return $this->filter_schema_arguments($args);
-
- } // end get_arguments_schema;
+ }
/**
* Remove some properties from the API schema.
@@ -583,102 +512,78 @@ trait Rest_Api {
apply_filters('wu_before_' . $this->slug . '_api_arguments', $args, $this);
if ($this->slug !== 'broadcast' && isset($args['author_id'])) {
-
unset($args['author_id']);
-
- } // end if;
+ }
if (isset($args['list_order'])) {
-
unset($args['list_order']);
+ }
- } // end if;
-
- $remove_status = apply_filters("wu_api_{$this->slug}_remove_status", array(
- 'broadcast',
- 'membership',
- 'product',
- 'payment',
- ));
-
- if (!in_array($this->slug, $remove_status, true) && isset($args['status'])) {
+ $remove_status = apply_filters(
+ "wu_api_{$this->slug}_remove_status",
+ array(
+ 'broadcast',
+ 'membership',
+ 'product',
+ 'payment',
+ )
+ );
+ if ( ! in_array($this->slug, $remove_status, true) && isset($args['status'])) {
unset($args['status']);
+ }
- } // end if;
-
- $remove_slug = apply_filters("wu_api_{$this->slug}_remove_slug", array(
- 'broadcast',
- 'product',
- 'checkout_form',
- 'event',
- ));
-
- if (!in_array($this->slug, $remove_slug, true) && isset($args['slug'])) {
+ $remove_slug = apply_filters(
+ "wu_api_{$this->slug}_remove_slug",
+ array(
+ 'broadcast',
+ 'product',
+ 'checkout_form',
+ 'event',
+ )
+ );
+ if ( ! in_array($this->slug, $remove_slug, true) && isset($args['slug'])) {
unset($args['slug']);
-
- } // end if;
+ }
if ($this->slug === 'product' && isset($args['price_variations'])) {
-
unset($args['price_variations']);
-
- } // end if;
+ }
if ($this->slug === 'payment' && isset($args['line_items'])) {
-
unset($args['line_items']);
-
- } // end if;
+ }
if ($this->slug === 'site') {
-
if (isset($args['duplication_arguments'])) {
-
unset($args['duplication_arguments']);
-
- } // end if;
+ }
if (isset($args['transient'])) {
-
unset($args['transient']);
-
- } // end if;
-
- } // end if;
+ }
+ }
if ($this->slug === 'email') {
-
if (isset($args['status'])) {
-
unset($args['status']);
-
- } // end if;
+ }
if (isset($args['email_schedule'])) {
-
unset($args['email_schedule']);
-
- } // end if;
-
- } // end if;
+ }
+ }
if ($this->slug === 'broadcast') {
-
if (isset($args['message_targets'])) {
-
unset($args['message_targets']);
-
- } // end if;
-
- } // end if;
+ }
+ }
if (isset($args['billing_address'])) {
-
unset($args['billing_address']);
-
- } // end if;
+ }
/**
* Filter after being changed.
@@ -691,7 +596,5 @@ trait Rest_Api {
apply_filters('wu_after_' . $this->slug . '_api_arguments', $args, $this);
return $args;
-
- } // end filter_schema_arguments;
-
-} // end trait Rest_Api;
+ }
+}
diff --git a/inc/api/trait-wp-cli.php b/inc/api/trait-wp-cli.php
index 994989c..ef59231 100644
--- a/inc/api/trait-wp-cli.php
+++ b/inc/api/trait-wp-cli.php
@@ -39,9 +39,8 @@ trait WP_CLI {
*/
public function get_wp_cli_command_base() {
- return (!empty($this->wp_cli_command_base)) ? $this->wp_cli_command_base : $this->slug;
-
- } // end get_wp_cli_command_base;
+ return (! empty($this->wp_cli_command_base)) ? $this->wp_cli_command_base : $this->slug;
+ }
/**
* Registers the routes. Should be called by the entity
@@ -51,18 +50,15 @@ trait WP_CLI {
*/
public function enable_wp_cli() {
- if (!defined('WP_CLI')) {
-
+ if ( ! defined('WP_CLI')) {
return;
-
- } // end if;
+ }
$wp_cli_root = 'wu';
$this->set_wp_cli_enabled_sub_commands();
foreach ($this->wp_cli_enabled_sub_commands as $sub_command => $sub_command_data) {
-
\WP_CLI::add_command(
"{$wp_cli_root} {$this->get_wp_cli_command_base()} {$sub_command}",
$sub_command_data['callback'],
@@ -70,10 +66,8 @@ trait WP_CLI {
'synopsis' => $sub_command_data['synopsis'],
)
);
-
- } // end foreach;
-
- } // end enable_wp_cli;
+ }
+ }
/**
* Set wP-CLI Sub-command enabled for this entity.
@@ -105,34 +99,32 @@ trait WP_CLI {
/**
* Unset undesired Params.
*/
- $params_to_remove = apply_filters('wu_cli_params_to_remove', array(
- 'id',
- 'model',
- ));
+ $params_to_remove = apply_filters(
+ 'wu_cli_params_to_remove',
+ array(
+ 'id',
+ 'model',
+ )
+ );
- $params = array_filter($params, fn($param) => !in_array($param, $params_to_remove, true));
+ $params = array_filter($params, fn($param) => ! in_array($param, $params_to_remove, true));
foreach ($sub_commands as $sub_command => &$sub_command_data) {
-
$sub_command_data['synopsis'] = array();
if (in_array($sub_command, array('get', 'update', 'delete'), true)) {
-
$sub_command_data['synopsis'][] = array(
'name' => 'id',
'type' => 'positional',
'description' => __('The id for the resource.', 'wp-ultimo'),
'optional' => false,
);
-
- } // end if;
+ }
if (in_array($sub_command, array('list', 'update', 'create'), true)) {
-
$explanation_list = wu_rest_get_endpoint_schema($this->model_class, 'update');
foreach ($params as $name) {
-
$explanation = wu_get_isset($explanation_list, $name, array());
$type = wu_get_isset($explanation, 'type', 'assoc');
@@ -140,37 +132,30 @@ trait WP_CLI {
$field = array(
'name' => $name,
'description' => wu_get_isset($explanation, 'description', __('No description found.', 'wp-ultimo')),
- 'optional' => !wu_get_isset($explanation, 'required'),
+ 'optional' => ! wu_get_isset($explanation, 'required'),
'type' => 'assoc',
);
$options = wu_get_isset($explanation, 'options', array());
if ($options) {
-
$field['options'] = $options;
-
- } // end if;
+ }
$sub_command_data['synopsis'][] = $field;
-
- } // end foreach;
-
- } // end if;
+ }
+ }
if (in_array($sub_command, array('create', 'update'), true)) {
-
$sub_command_data['synopsis'][] = array(
'name' => 'porcelain',
'type' => 'flag',
'description' => __('Output just the id when the operation is successful.', 'wp-ultimo'),
'optional' => true,
);
-
- } // end if;
+ }
if (in_array($sub_command, array('list', 'get'), true)) {
-
$sub_command_data['synopsis'][] = array(
'name' => 'format',
'type' => 'assoc',
@@ -194,10 +179,8 @@ trait WP_CLI {
'optional' => true,
'options' => array_merge(array('id'), $params),
);
-
- } // end if;
-
- } // end foreach;
+ }
+ }
$this->wp_cli_enabled_sub_commands = $sub_commands;
@@ -216,8 +199,7 @@ trait WP_CLI {
$this->get_wp_cli_command_base(),
$this
);
-
- } // end set_wp_cli_enabled_sub_commands;
+ }
/**
* Allows the additional of additional parameters.
*
@@ -228,8 +210,7 @@ trait WP_CLI {
$model = new $this->model_class();
return array_keys($model->to_array());
-
- } // end wp_cli_extra_parameters;
+ }
/**
* Returns the list of default fields, based on the table schema.
@@ -242,8 +223,7 @@ trait WP_CLI {
$schema = $this->model_class::get_schema();
return array_column($schema, 'name');
-
- } // end wp_cli_get_fields;
+ }
/**
* Returns a specific item.
@@ -258,18 +238,15 @@ trait WP_CLI {
$item = $this->model_class::get_by_id($args[0]);
if (empty($item)) {
-
\WP_CLI::error('Invalid ID.');
+ }
- } // end if;
-
- $fields = (!empty($array_assoc['fields'])) ? $array_assoc['fields'] : $this->wp_cli_get_fields();
+ $fields = (! empty($array_assoc['fields'])) ? $array_assoc['fields'] : $this->wp_cli_get_fields();
$formatter = new \WP_CLI\Formatter($array_assoc, $fields);
$formatter->display_item($item->to_array());
-
- } // end wp_cli_get_item;
+ }
/**
* Returns a list of items.
@@ -281,7 +258,7 @@ trait WP_CLI {
*/
public function wp_cli_get_items($args, $array_assoc) {
- $fields = (!empty($array_assoc['fields'])) ? $array_assoc['fields'] : $this->wp_cli_get_fields();
+ $fields = (! empty($array_assoc['fields'])) ? $array_assoc['fields'] : $this->wp_cli_get_fields();
unset($array_assoc['fields']);
@@ -290,8 +267,7 @@ trait WP_CLI {
$items = array_map(fn($item) => $item->to_array(), $items);
\WP_CLI\Utils\format_items($array_assoc['format'], $items, $fields);
-
- } // end wp_cli_get_items;
+ }
/**
* Creates an item.
@@ -308,28 +284,19 @@ trait WP_CLI {
$success = $item->save();
if ($success === true) {
-
$item_id = $item->get_id();
- if (!empty($array_assoc['porcelain'])) {
-
+ if ( ! empty($array_assoc['porcelain'])) {
\WP_CLI::line($item_id);
-
} else {
-
$message = sprintf('Item created with ID %d', $item_id);
\WP_CLI::success($message);
-
- } // end if;
-
+ }
} else {
-
\WP_CLI::error($success);
-
- } // end if;
-
- } // end wp_cli_create_item;
+ }
+ }
/**
* Updates an item.
@@ -344,37 +311,27 @@ trait WP_CLI {
$item = $this->model_class::get_by_id($args[0]);
if (empty($item)) {
-
\WP_CLI::error('Invalid ID.');
-
- } // end if;
+ }
$porcelain = false;
- if (!empty($array_assoc['porcelain'])) {
-
+ if ( ! empty($array_assoc['porcelain'])) {
$porcelain = true;
unset($array_assoc['porcelain']);
-
- } // end if;
+ }
$params = $array_assoc;
foreach ($params as $param => $value) {
-
$set_method = "set_{$param}";
if ($param === 'meta') {
-
$item->update_meta_batch($value);
-
} elseif (method_exists($item, $set_method)) {
-
call_user_func(array($item, $set_method), $value);
-
} else {
-
$error_message = sprintf(
/* translators: 1. Object class name; 2. Set method name */
__('The %1$s object does not have a %2$s method', 'wp-ultimo'),
@@ -383,36 +340,25 @@ trait WP_CLI {
);
\WP_CLI::error($error_message);
-
- } // end if;
-
- } // end foreach;
+ }
+ }
$success = $item->save();
if ($success) {
-
$item_id = $item->get_id();
if ($porcelain) {
-
\WP_CLI::line($item_id);
-
} else {
-
$message = sprintf('Item updated with ID %d', $item_id);
\WP_CLI::success($message);
-
- } // end if;
-
+ }
} else {
-
\WP_CLI::error('Unexpected error. The item was not updated.');
-
- } // end if;
-
- } // end wp_cli_update_item;
+ }
+ }
/**
* Deletes an item.
@@ -426,23 +372,15 @@ trait WP_CLI {
$item = $this->model_class::get_by_id($args[0]);
if (empty($item)) {
-
\WP_CLI::error('Invalid ID.');
-
- } // end if;
+ }
$success = $item->delete();
- if (is_wp_error($success) || !$success) {
-
+ if (is_wp_error($success) || ! $success) {
\WP_CLI::error('Unexpected error. The item was not deleted.');
-
} else {
-
\WP_CLI::success('Item deleted.');
-
- } // end if;
-
- } // end wp_cli_delete_item;
-
-} // end trait WP_CLI;
+ }
+ }
+}
diff --git a/inc/builders/block-editor/assets/js/blocks.js b/inc/builders/block-editor/assets/js/blocks.js
index fecbd3a..39e39bc 100644
--- a/inc/builders/block-editor/assets/js/blocks.js
+++ b/inc/builders/block-editor/assets/js/blocks.js
@@ -44,7 +44,7 @@
},
});
- }); // end each;
+ });
function wu_fields_to_block_options(fields, props) {
@@ -72,7 +72,7 @@
field_slug = _.first(_.keys(sub_fields));
- } // end if;
+ }
const component = wu_get_field_component(field.type, field);
@@ -80,7 +80,7 @@
field.required = {};
- } // end if;
+ }
let should_display = true;
@@ -113,7 +113,7 @@
},
}));
- } // end if;
+ }
/*
* Handle header types differently
@@ -126,7 +126,7 @@
new_panel = true;
- } // end if;
+ }
if (new_panel) {
@@ -141,7 +141,7 @@
first_panel = false;
- } // end if;
+ }
current_panel = field;
@@ -149,7 +149,7 @@
gt_fields = [];
- } // end if;
+ }
});
@@ -164,7 +164,7 @@
return el(InspectorControls, { key: 'wp-ultimo' }, gt_panels);
- } // end wu_fields_to_block_options;
+ }
function wu_format_options(options) {
@@ -205,7 +205,7 @@
component = NumberControl;
- } // end if;
+ }
break;
@@ -233,7 +233,7 @@
break;
- } // end switch;
+ }
return component;
diff --git a/inc/builders/block-editor/class-block-editor-widget-manager.php b/inc/builders/block-editor/class-block-editor-widget-manager.php
index dfc0a1d..656f59b 100644
--- a/inc/builders/block-editor/class-block-editor-widget-manager.php
+++ b/inc/builders/block-editor/class-block-editor-widget-manager.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Builders\Block_Editor;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Database\Sites\Site_Type;
+use WP_Ultimo\Database\Sites\Site_Type;
/**
* Handles Block Editor Widget Support.
@@ -32,16 +32,13 @@ class Block_Editor_Widget_Manager {
public function init() {
if (\WP_Ultimo\Compat\Gutenberg_Support::get_instance()->should_load()) {
-
add_action('wu_element_loaded', array($this, 'handle_element'));
add_action('init', array($this, 'register_scripts'));
add_action('wu_element_is_preview', array($this, 'is_block_preview'));
-
- } // end if;
-
- } // end init;
+ }
+ }
/**
* Adds the required scripts.
@@ -56,8 +53,7 @@ class Block_Editor_Widget_Manager {
$blocks = apply_filters('wu_blocks', array());
wp_localize_script('wu-blocks', 'wu_blocks', $blocks);
-
- } // end register_scripts;
+ }
/**
* Checks if we are inside a block preview render.
@@ -69,14 +65,11 @@ class Block_Editor_Widget_Manager {
public function is_block_preview($is_preview) {
if (defined('REST_REQUEST') && true === REST_REQUEST && 'edit' === filter_input(INPUT_GET, 'context', FILTER_SANITIZE_STRING)) {
-
$is_preview = true;
-
- } // end if;
+ }
return $is_preview;
-
- } // end is_block_preview;
+ }
/**
* Gets called when a new element is registered
@@ -89,16 +82,13 @@ class Block_Editor_Widget_Manager {
public function handle_element($element) {
if (wu_get_current_site()->get_type() === Site_Type::CUSTOMER_OWNED) {
-
return;
-
- } // end if;
+ }
$this->register_block($element);
add_filter('wu_blocks', fn($blocks) => $this->load_block_settings($blocks, $element));
-
- } // end handle_element;
+ }
/**
* Registers block with WordPress.
@@ -111,20 +101,20 @@ class Block_Editor_Widget_Manager {
public function register_block($element) {
if (\WP_Block_Type_Registry::get_instance()->is_registered($element->get_id())) {
-
return;
-
- } // end if;
+ }
$attributes = $this->get_attributes_from_fields($element);
- register_block_type($element->get_id(), array(
- 'attributes' => $attributes,
- 'editor_script' => 'wu-blocks',
- 'render_callback' => \Closure::fromCallable([$element, 'display']),
- ));
-
- } // end register_block;
+ register_block_type(
+ $element->get_id(),
+ array(
+ 'attributes' => $attributes,
+ 'editor_script' => 'wu-blocks',
+ 'render_callback' => \Closure::fromCallable(array($element, 'display')),
+ )
+ );
+ }
/**
* Consolidate field attributes that are callables for blocks.
@@ -150,52 +140,36 @@ class Block_Editor_Widget_Manager {
* Discard fields that are notes and start with _
*/
if (in_array($field['type'], $fields_to_ignore, true) && strncmp($field_slug, '_', strlen('_')) === 0) {
-
- unset($fields[$field_slug]);
-
- } // end if;
+ unset($fields[ $field_slug ]);
+ }
/*
* Deal with the group type.
* On those, we need to loop the sub-fields.
*/
if ($field['type'] === 'group') {
-
foreach ($field['fields'] as &$sub_field) {
-
foreach ($sub_field as $sub_item => &$sub_value) {
-
if (in_array($sub_item, $callable_keys, true) && is_callable($sub_value)) {
-
$sub_value = call_user_func($sub_value);
-
- } // end if;
-
- } // end foreach;
-
- } // end foreach;
-
- } // end if;
+ }
+ }
+ }
+ }
/*
* Deal with the regular field types and its
* callables.
*/
foreach ($field as $item => &$value) {
-
if (in_array($item, $callable_keys, true) && is_callable($value)) {
-
$value = call_user_func($value);
-
- } // end if;
-
- } // end foreach;
-
- } // end foreach;
+ }
+ }
+ }
return $fields;
-
- } // end consolidate_callables;
+ }
/**
* Registers the block so WP Multisite WaaS can add it on the JS side.
@@ -219,8 +193,7 @@ class Block_Editor_Widget_Manager {
);
return $blocks;
-
- } // end load_block_settings;
+ }
/**
* Generates the list of attributes supported based on the fields.
@@ -238,32 +211,24 @@ class Block_Editor_Widget_Manager {
$_fields = array();
foreach ($fields as $field_id => $field) {
-
$type = 'string';
if ($field['type'] === 'toggle') {
-
$type = 'boolean';
-
- } // end if;
+ }
if ($field['type'] === 'number') {
-
$type = 'integer';
-
- } // end if;
+ }
$default_value = wu_get_isset($defaults, $field_id, '');
- $_fields[$field_id] = array(
+ $_fields[ $field_id ] = array(
'default' => wu_get_isset($field, 'value', $default_value),
'type' => $type,
);
-
- } // end foreach;
+ }
return $_fields;
-
- } // end get_attributes_from_fields;
-
-} // end class Block_Editor_Widget_Manager;
+ }
+}
diff --git a/inc/checkout/class-cart.php b/inc/checkout/class-cart.php
index 9d05a8a..3ffd4c4 100644
--- a/inc/checkout/class-cart.php
+++ b/inc/checkout/class-cart.php
@@ -9,9 +9,9 @@
namespace WP_Ultimo\Checkout;
-use \WP_Ultimo\Checkout\Line_Item;
-use \WP_Ultimo\Database\Memberships\Membership_Status;
-use \Arrch\Arrch as Array_Search;
+use WP_Ultimo\Checkout\Line_Item;
+use WP_Ultimo\Database\Memberships\Membership_Status;
+use Arrch\Arrch as Array_Search;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -39,16 +39,16 @@ class Cart implements \JsonSerializable {
public $errors;
/**
- * Cart Attributes.
- *
- * List of attributes passed to the
- * constructor.
- *
- * @since 2.0.0
- * @var object
- * @readonly
- */
- private \stdClass $attributes;
+ * Cart Attributes.
+ *
+ * List of attributes passed to the
+ * constructor.
+ *
+ * @since 2.0.0
+ * @var object
+ * @readonly
+ */
+ private \stdClass $attributes;
/**
* Type of registration: new, renewal, upgrade, downgrade, retry, and display.
@@ -254,66 +254,69 @@ class Cart implements \JsonSerializable {
* Since we're passing over the entire $_POST array
* this helps us to keep things cleaner and secure.
*/
- $args = shortcode_atts(array(
+ $args = shortcode_atts(
+ array(
- /*
- * Cart Type.
- */
- 'cart_type' => 'new',
+ /*
+ * Cart Type.
+ */
+ 'cart_type' => 'new',
- /*
- * The list of products being bought.
- */
- 'products' => array(),
+ /*
+ * The list of products being bought.
+ */
+ 'products' => array(),
- /*
- * The duration parameters
- * This will dictate which price variations we are going to use.
- */
- 'duration' => false,
- 'duration_unit' => false,
+ /*
+ * The duration parameters
+ * This will dictate which price variations we are going to use.
+ */
+ 'duration' => false,
+ 'duration_unit' => false,
- /*
- * The membership ID.
- * This is passed when we want to handle a upgrade/downgrade/addon.
- */
- 'membership_id' => false,
+ /*
+ * The membership ID.
+ * This is passed when we want to handle a upgrade/downgrade/addon.
+ */
+ 'membership_id' => false,
- /*
- * Payment ID.
- * This is passed when we are trying to recovered a abandoned/pending payment.
- */
- 'payment_id' => false,
+ /*
+ * Payment ID.
+ * This is passed when we are trying to recovered a abandoned/pending payment.
+ */
+ 'payment_id' => false,
- /*
- * The discount code to be used.
- */
- 'discount_code' => false,
+ /*
+ * The discount code to be used.
+ */
+ 'discount_code' => false,
- /*
- * If we should auto-renew or not.
- */
- 'auto_renew' => true,
+ /*
+ * If we should auto-renew or not.
+ */
+ 'auto_renew' => true,
- /*
- * The country, state, and city of the customer.
- * Used for taxation purposes.
- */
- 'country' => '',
- 'state' => '',
- 'city' => '',
+ /*
+ * The country, state, and city of the customer.
+ * Used for taxation purposes.
+ */
+ 'country' => '',
+ 'state' => '',
+ 'city' => '',
- /*
- * Currency
- */
- 'currency' => '',
+ /*
+ * Currency
+ */
+ 'currency' => '',
- ), $args);
+ ),
+ $args
+ );
/*
* Checks for errors
*/
- $this->errors = new \WP_Error;
+ $this->errors = new \WP_Error();
/*
* Save arguments in memory
@@ -363,11 +366,9 @@ class Cart implements \JsonSerializable {
* This setting can be forced if the settings say so,
* so we only set it if that is not enabled.
*/
- if (!wu_get_setting('force_auto_renew', true)) {
-
+ if ( ! wu_get_setting('force_auto_renew', true)) {
$this->auto_renew = wu_string_to_bool($this->attributes->auto_renew);
-
- } // end if;
+ }
/*
* Calculate-totals.
@@ -385,23 +386,21 @@ class Cart implements \JsonSerializable {
* @param $this \WP_Ultimo\Checkout\Cart The cart object.
*/
do_action('wu_cart_after_setup', $this); // @phpstan-ignore-line
-
- } // end __construct;
+ }
/**
* Get additional parameters set by integrations and add-ons.
*
- * @since 2.0.0
- *
* @param string $key The parameter key.
- * @param boolean $default The default value.
+ * @param boolean $default_value The default value.
+ *
* @return mixed
+ * @since 2.0.0
*/
- public function get_param($key, $default = false) {
+ public function get_param($key, $default_value = false) {
- return wu_get_isset($this->attributes, $key, $default);
-
- } // end get_param;
+ return wu_get_isset($this->attributes, $key, $default_value);
+ }
/**
* Set additional parameters set by integrations and add-ons.
@@ -417,8 +416,7 @@ class Cart implements \JsonSerializable {
$this->extra[] = $key;
$this->attributes->{$key} = $value;
-
- } // end set_param;
+ }
/**
* Gets the tax exempt status of the current cart.
@@ -429,8 +427,7 @@ class Cart implements \JsonSerializable {
public function is_tax_exempt() {
return apply_filters('wu_cart_is_tax_exempt', false, $this);
-
- } // end is_tax_exempt;
+ }
/**
* Builds the cart.
@@ -454,10 +451,8 @@ class Cart implements \JsonSerializable {
* in order to build the proper cart.
*/
if ($is_recovery_cart) {
-
return;
-
- } // end if;
+ }
/*
* The next step is to deal with membership changes.
@@ -470,10 +465,8 @@ class Cart implements \JsonSerializable {
* we can return as our work is done.
*/
if ($is_membership_change) {
-
return;
-
- } // end if;
+ }
/*
* Otherwise, we add the the products normally,
@@ -482,18 +475,14 @@ class Cart implements \JsonSerializable {
$this->cart_type = 'new';
if (is_array($this->attributes->products)) {
- /*
+ /*
* Otherwise, we add the products to build the cart.
*/
foreach ($this->attributes->products as $product_id) {
-
$this->add_product($product_id);
-
- } // end foreach;
-
- } // end if;
-
- } // end build_cart;
+ }
+ }
+ }
/**
* Creates a string that describes the cart.
@@ -509,35 +498,28 @@ class Cart implements \JsonSerializable {
*/
public function get_cart_descriptor() {
- if (!empty($this->cart_descriptor)) {
-
+ if ( ! empty($this->cart_descriptor)) {
return $this->cart_descriptor;
-
- } // end if;
+ }
$desc = wu_get_setting('company_name', __('Subscription', 'wp-ultimo'));
$products = array();
foreach ($this->get_line_items() as $line_item) {
-
$product = $line_item->get_product();
- if (!$product) {
-
+ if ( ! $product) {
continue;
-
- } // end if;
+ }
$products[] = $line_item->get_title();
-
- } // end foreach;
+ }
$descriptor = $desc . ' - ' . implode(', ', $products);
return trim($descriptor);
-
- } // end get_cart_descriptor;
+ }
/**
* Set a custom cart descriptor.
@@ -550,8 +532,7 @@ class Cart implements \JsonSerializable {
public function set_cart_descriptor($descriptor) {
$this->cart_descriptor = $descriptor;
-
- } // end set_cart_descriptor;
+ }
/**
* Decides if we are trying to recover a payment.
*
@@ -565,23 +546,19 @@ class Cart implements \JsonSerializable {
* are not trying to recover a payment.
*/
if (empty($payment_id)) {
-
return false;
-
- } // end if;
+ }
/*
* Now, let's try to fetch the payment in question.
*/
$payment = wu_get_payment($payment_id);
- if (!$payment) {
-
+ if ( ! $payment) {
$this->errors->add('payment_not_found', __('The payment in question was not found.', 'wp-ultimo'));
return true;
-
- } // end if;
+ }
/*
* The payment exists, set it globally.
@@ -605,25 +582,21 @@ class Cart implements \JsonSerializable {
* a payment can pay it. Let's check for that.
*/
if (empty($this->customer) || $this->customer->get_id() !== $payment->get_customer_id()) {
-
$this->errors->add('lacks_permission', __('You are not allowed to modify this payment.', 'wp-ultimo'));
return true;
-
- } // end if;
+ }
/*
* Sets the membership as well, to prevent issues
*/
$membership = $payment->get_membership();
- if (!$membership) {
-
+ if ( ! $membership) {
$this->errors->add('membership_not_found', __('The membership in question was not found.', 'wp-ultimo'));
return true;
-
- } // end if;
+ }
if ($payment->get_discount_code()) {
/**
@@ -632,16 +605,11 @@ class Cart implements \JsonSerializable {
$discount_code = $membership->get_discount_code();
if ($discount_code && $discount_code->get_code() === $payment->get_discount_code()) {
-
$this->add_discount_code($discount_code);
-
} else {
-
$this->add_discount_code($payment->get_discount_code());
-
- } // end if;
-
- } // end if;
+ }
+ }
/*
* Sets membership globally.
@@ -654,25 +622,19 @@ class Cart implements \JsonSerializable {
* Finally, copy the line items from the payment.
*/
foreach ($payment->get_line_items() as $line_item) {
-
$product = $line_item->get_product();
if ($product) {
-
if ($product->is_recurring() && ($this->duration_unit !== $product->get_duration_unit() || $this->duration !== $product->get_duration())) {
-
$product_variation = $product->get_as_variation($this->duration, $this->duration_unit);
/*
* Checks if the variation exists before re-setting the product.
*/
if ($product_variation) {
-
$product = $product_variation;
-
- } // end if;
-
- } // end if;
+ }
+ }
$this->products[] = $product;
@@ -682,22 +644,17 @@ class Cart implements \JsonSerializable {
* another one.
*/
if (empty($this->plan_id)) {
-
$this->plan_id = $product->get_id();
$this->billing_cycles = $product->get_billing_cycles();
$this->duration = $line_item->get_duration();
$this->duration_unit = $line_item->get_duration_unit();
-
- } // end if;
-
- } // end if;
-
- } // end if;
+ }
+ }
+ }
$this->add_line_item($line_item);
-
- } // end foreach;
+ }
/*
* If the payment is completed
@@ -709,8 +666,7 @@ class Cart implements \JsonSerializable {
* We should return false to continue in case of membership updates.
*/
return false;
-
- } // end if;
+ }
/*
* Check for payment status.
@@ -718,28 +674,27 @@ class Cart implements \JsonSerializable {
* We want to make sure we only allow for repayment of pending,
* cancelled, or abandoned payments
*/
- $allowed_status = apply_filters('wu_cart_set_payment_allowed_status', array(
- 'pending',
- ));
-
- if (!in_array($payment->get_status(), $allowed_status, true)) {
+ $allowed_status = apply_filters(
+ 'wu_cart_set_payment_allowed_status',
+ array(
+ 'pending',
+ )
+ );
+ if ( ! in_array($payment->get_status(), $allowed_status, true)) {
$this->errors->add('invalid_status', __('The payment in question has an invalid status.', 'wp-ultimo'));
return true;
-
- } // end if;
+ }
/*
* If the membership is active or is
* already in trial this can't be a
* retry, so we skip the rest.
*/
- if ($membership->is_active() || ($membership->get_status() === Membership_Status::TRIALING && !$this->has_trial())) {
-
+ if ($membership->is_active() || ($membership->get_status() === Membership_Status::TRIALING && ! $this->has_trial())) {
return false;
-
- } // end if;
+ }
/*
* We got here, that means
@@ -751,8 +706,7 @@ class Cart implements \JsonSerializable {
$this->cart_type = 'retry';
return true;
-
- } // end build_from_payment;
+ }
/**
* Uses the membership to decide if this is a upgrade/downgrade/addon cart.
*
@@ -766,10 +720,8 @@ class Cart implements \JsonSerializable {
* are not trying to change a membership.
*/
if (empty($membership_id)) {
-
return false;
-
- } // end if;
+ }
/*
* We got here, that means
@@ -787,13 +739,11 @@ class Cart implements \JsonSerializable {
*/
$membership = wu_get_membership($membership_id);
- if (!$membership) {
-
+ if ( ! $membership) {
$this->errors->add('membership_not_found', __('The membership in question was not found.', 'wp-ultimo'));
return true;
-
- } // end if;
+ }
/*
* The membership exists, set it globally.
@@ -810,12 +760,10 @@ class Cart implements \JsonSerializable {
* Only the customer that owns a membership can change it.
*/
if (empty($this->customer) || $this->customer->get_id() !== $membership->get_customer_id()) {
-
$this->errors->add('lacks_permission', __('You are not allowed to modify this membership.', 'wp-ultimo'));
return true;
-
- } // end if;
+ }
/*
* Adds the country to calculate taxes.
@@ -835,7 +783,6 @@ class Cart implements \JsonSerializable {
* being added, and process those.
*/
if (empty($this->attributes->products)) {
-
if ($this->payment) {
/**
* If we do not have any change but we have a already
@@ -843,23 +790,19 @@ class Cart implements \JsonSerializable {
* for this.
*/
return false;
-
- } // end if;
+ }
$this->errors->add('no_changes', __('This cart proposes no changes to the current membership.', 'wp-ultimo'));
return true;
-
- } // end if;
+ }
/*
* Otherwise, we add the products to build the cart.
*/
foreach ($this->attributes->products as $product_id) {
-
$this->add_product($product_id);
-
- } // end foreach;
+ }
/*
* With products added, let's check if this is an addon.
@@ -870,14 +813,11 @@ class Cart implements \JsonSerializable {
* must be added to the membership.
*/
if (empty($this->plan_id)) {
-
if (count($this->products) === 0) {
-
$this->errors->add('no_changes', __('This cart proposes no changes to the current membership.', 'wp-ultimo'));
return true;
-
- } // end if;
+ }
/*
* Set the type to addon.
@@ -890,12 +830,10 @@ class Cart implements \JsonSerializable {
*/
$plan_product = $membership->get_plan();
- if ($plan_product && !$membership->is_free()) {
-
+ if ($plan_product && ! $membership->is_free()) {
$this->duration = $plan_product->get_duration();
$this->duration_unit = $plan_product->get_duration_unit();
-
- } // end if;
+ }
/*
* Checks the membership to see if we need to add back the
@@ -920,8 +858,7 @@ class Cart implements \JsonSerializable {
$this->calculate_prorate_credits();
return true;
-
- } // end if;
+ }
/*
* With products added, let's check if the plan is changing.
@@ -938,10 +875,8 @@ class Cart implements \JsonSerializable {
$is_plan_change = false;
if ($membership->get_plan_id() !== $this->plan_id || $this->duration_unit !== $membership->get_duration_unit() || $this->duration !== $membership->get_duration()) {
-
$is_plan_change = true;
-
- } // end if;
+ }
/*
* Checks for periodicity changes.
@@ -950,17 +885,15 @@ class Cart implements \JsonSerializable {
$new_periodicity = sprintf('%s-%s', $this->duration, $this->duration_unit);
if ($old_periodicity !== $new_periodicity) {
-
$is_plan_change = true;
-
- } // end if;
+ }
/*
* If there is no plan change, but the product count is > 1
* We know that there is another product in this cart other than the
* plan, so this is again an addon cart.
*/
- if (count($this->products) > 1 && $is_plan_change === false) {
+ if (count($this->products) > 1 && false === $is_plan_change) {
/*
* Set the type to addon.
*/
@@ -972,12 +905,10 @@ class Cart implements \JsonSerializable {
*/
$plan_product = $membership->get_plan();
- if ($plan_product && !$membership->is_free()) {
-
+ if ($plan_product && ! $membership->is_free()) {
$this->duration = $plan_product->get_duration();
$this->duration_unit = $plan_product->get_duration_unit();
-
- } // end if;
+ }
/*
* Checks the membership to see if we need to add back the
@@ -995,28 +926,25 @@ class Cart implements \JsonSerializable {
$this->calculate_prorate_credits();
return true;
-
- } // end if;
+ }
/*
* We'll probably never enter in this if, but we
* 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())) {
-
+ 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->errors->add('no_changes', __('This cart proposes no changes to the current membership.', 'wp-ultimo'));
return true;
-
- } // end if;
+ }
/*
* Upgrade to Lifetime.
*/
- if (!$this->has_recurring() && !$this->is_free()) {
+ if ( ! $this->has_recurring() && ! $this->is_free()) {
/*
* Adds the credit line, after
* calculating pro-rate.
@@ -1024,8 +952,7 @@ class Cart implements \JsonSerializable {
$this->calculate_prorate_credits();
return true;
-
- } // end if;
+ }
/*
* If we get to this point, we know that this is either
@@ -1048,14 +975,12 @@ class Cart implements \JsonSerializable {
* when setting a downgrade cart.
*/
if ($days_in_old_cycle !== $days_in_new_cycle) {
-
$old_plan = $membership->get_plan();
$new_plan = $this->get_plan();
$variations = $this->search_for_same_period_plans($old_plan, $new_plan);
if ($variations) {
-
$old_plan = $variations[0];
$new_plan = $variations[1];
@@ -1064,13 +989,10 @@ class Cart implements \JsonSerializable {
$old_price_per_day = $days_in_old_cycle_plan > 0 ? $old_plan->get_amount() / $days_in_old_cycle_plan : $old_plan->get_amount();
$new_price_per_day = $days_in_new_cycle_plan > 0 ? $new_plan->get_amount() / $days_in_new_cycle_plan : $new_plan->get_amount();
+ }
+ }
- } // end if;
-
- } // end if;
-
- 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) {
-
+ 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();
@@ -1087,128 +1009,108 @@ class Cart implements \JsonSerializable {
$this->errors->add('no_changes', $message);
return true;
-
- } // end if;
+ }
/*
* If is the same product and the customer will start to pay less
* or if is not the same product and the price per day is smaller
* this is a downgrade
*/
- if (($is_same_product && $membership->get_amount() > $this->get_recurring_total()) || (!$is_same_product && $old_price_per_day > $new_price_per_day)) {
-
+ if (($is_same_product && $membership->get_amount() > $this->get_recurring_total()) || (! $is_same_product && $old_price_per_day > $new_price_per_day)) {
$this->cart_type = 'downgrade';
// If membership is active or trialing we will schendule the swap
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'),
- 'discountable' => false,
- 'taxable' => false,
- 'quantity' => 1,
- 'unit_price' => - $this->get_total(),
- ));
+ $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'),
+ 'discountable' => false,
+ 'taxable' => false,
+ 'quantity' => 1,
+ 'unit_price' => - $this->get_total(),
+ )
+ );
$credit_line_item = new Line_Item($line_item_params);
$this->add_line_item($credit_line_item);
+ }
+ }
- } // end if;
-
- } // end if;
-
- // If this is a upgrade, we need to prorate the current amount
- if ($this->cart_type === 'upgrade') {
-
+ // If this is an upgrade, we need to prorate the current amount
+ if ('upgrade' === $this->cart_type) {
$this->calculate_prorate_credits();
-
- } // end if;
+ }
/*
* All set!
*/
return true;
-
- } // end build_from_membership;
- /**
- * Search for variations of the plans with same duration.
- *
- * @since 2.0.20
- * @param \WP_Ultimo\Models\Product $plan_a The first plan without variations.
- * @param \WP_Ultimo\Models\Product $plan_b The second plan without variations.
- * @return mixed[]|false
- */
- protected function search_for_same_period_plans($plan_a, $plan_b) {
+ }
+ /**
+ * Search for variations of the plans with same duration.
+ *
+ * @since 2.0.20
+ * @param \WP_Ultimo\Models\Product $plan_a The first plan without variations.
+ * @param \WP_Ultimo\Models\Product $plan_b The second plan without variations.
+ * @return mixed[]|false
+ */
+ 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(
$plan_a,
$plan_b,
);
-
- } // end if;
+ }
$plan_a_variation = $plan_a->get_as_variation($plan_b->get_duration(), $plan_b->get_duration_unit());
if ($plan_a_variation) {
-
return array(
$plan_a_variation,
$plan_b,
);
-
- } // end if;
+ }
$plan_b_variation = $plan_b->get_as_variation($plan_a->get_duration(), $plan_a->get_duration_unit());
if ($plan_b_variation) {
-
return array(
$plan_a,
$plan_b_variation,
);
-
- } // end if;
+ }
if ($this->duration_unit && $this->duration && ($this->duration_unit !== $plan_b->get_duration_unit() || $this->duration !== $plan_b->get_duration())) {
-
$plan_a_variation = $plan_a->get_as_variation($this->duration, $this->duration_unit);
- if (!$plan_a_variation) {
-
+ if ( ! $plan_a_variation) {
return false;
-
- } // end if;
+ }
if ($plan_b->get_duration_unit() === $plan_a_variation->get_duration_unit() && $plan_b->get_duration() === $plan_a_variation->get_duration()) {
-
return array(
$plan_a_variation,
$plan_b,
);
-
- } // end if;
+ }
$plan_b_variation = $plan_b->get_as_variation($this->duration, $this->duration_unit);
if ($plan_b_variation) {
-
return array(
$plan_a_variation,
$plan_b_variation,
);
-
- } // end if;
-
- } // end if;
+ }
+ }
return false;
-
- } // end search_for_same_period_plans;
+ }
/**
* Calculate pro-rate credits.
@@ -1228,17 +1130,12 @@ class Cart implements \JsonSerializable {
* If the membership is in trial period theres nothing to prorate.
*/
if ($this->membership->get_status() === Membership_Status::TRIALING) {
-
return;
+ }
- } // end if;
-
- if ($this->membership->is_lifetime() || !$this->membership->is_recurring()) {
-
+ if ($this->membership->is_lifetime() || ! $this->membership->is_recurring()) {
$credit = $this->membership->get_initial_amount();
-
} else {
-
$days_unused = $this->membership->get_remaining_days_in_cycle();
$days_in_old_cycle = wu_get_days_in_cycle($this->membership->get_duration_unit(), $this->membership->get_duration());
@@ -1248,21 +1145,16 @@ class Cart implements \JsonSerializable {
$credit = $days_unused * $old_price_per_day;
if ($credit > $this->membership->get_amount()) {
-
$credit = $this->membership->get_amount();
-
- } // end if;
-
- } // end if;
+ }
+ }
/*
* No credits
*/
if (empty($credit)) {
-
return;
-
- } // end if;
+ }
/*
* Checks if we need to add back the value of the
@@ -1270,43 +1162,39 @@ class Cart implements \JsonSerializable {
*/
$has_setup_fee = $this->get_line_items_by_type('fee');
- if (!empty($has_setup_fee) || $this->get_cart_type() === 'upgrade') {
-
+ if ( ! empty($has_setup_fee) || $this->get_cart_type() === 'upgrade') {
$old_plan = $this->membership->get_plan();
$new_plan = $this->get_plan();
if ($old_plan && $new_plan) {
-
$old_setup_fee = $old_plan->get_setup_fee();
$new_setup_fee = $new_plan->get_setup_fee();
$fee_credit = $old_setup_fee < $new_setup_fee ? $old_setup_fee : $new_setup_fee;
if ($fee_credit > 0) {
-
- $new_line_item = new Line_Item(array(
- 'product' => $old_plan,
- 'type' => 'fee',
- 'description' => '--',
- 'title' => '',
- 'taxable' => $old_plan->is_taxable(),
- 'recurring' => false,
- 'unit_price' => $fee_credit,
- 'quantity' => 1,
- ));
+ $new_line_item = new Line_Item(
+ array(
+ 'product' => $old_plan,
+ 'type' => 'fee',
+ 'description' => '--',
+ 'title' => '',
+ 'taxable' => $old_plan->is_taxable(),
+ 'recurring' => false,
+ 'unit_price' => $fee_credit,
+ 'quantity' => 1,
+ )
+ );
$new_line_item = $this->apply_taxes_to_item($new_line_item);
$new_line_item->recalculate_totals();
$credit += $new_line_item->get_total();
-
- } // end if;
-
- } // end if;
-
- } // end if;
+ }
+ }
+ }
/**
* Allow plugin developers to meddle with the credit value.
@@ -1324,20 +1212,21 @@ class Cart implements \JsonSerializable {
* No credits
*/
if (empty($credit)) {
-
return;
+ }
- } // end if;
-
- $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'),
- 'discountable' => false,
- 'taxable' => false,
- 'quantity' => 1,
- 'unit_price' => - $credit,
- ));
+ $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'),
+ 'discountable' => false,
+ 'taxable' => false,
+ 'quantity' => 1,
+ 'unit_price' => - $credit,
+ )
+ );
/*
* Finally, we add the credit to the purchase.
@@ -1345,8 +1234,7 @@ class Cart implements \JsonSerializable {
$credit_line_item = new Line_Item($line_item_params);
$this->add_line_item($credit_line_item);
-
- } // end calculate_prorate_credits;
+ }
/**
* Adds a discount code to the cart.
*
@@ -1357,10 +1245,8 @@ class Cart implements \JsonSerializable {
protected function set_discount_code($code): bool {
if (empty($code)) {
-
return false;
-
- } // end if;
+ }
$code = strtoupper($code);
@@ -1372,18 +1258,15 @@ class Cart implements \JsonSerializable {
$this->errors->add('discount_code', sprintf(__('The code %s do not exist or is no longer valid.', 'wp-ultimo'), $code));
return false;
-
- } // end if;
+ }
$is_valid = $discount_code->is_valid();
if (is_wp_error($is_valid)) {
-
$this->errors->merge_from($is_valid);
return false;
-
- } // end if;
+ }
/*
* Set the coupon
@@ -1391,8 +1274,7 @@ class Cart implements \JsonSerializable {
$this->discount_code = $discount_code;
return true;
-
- } // end set_discount_code;
+ }
/**
* Returns the current errors.
@@ -1403,8 +1285,7 @@ class Cart implements \JsonSerializable {
public function get_errors() {
return $this->errors;
-
- } // end get_errors;
+ }
/**
* For an order to be valid, all the recurring products must have the same
@@ -1422,24 +1303,19 @@ class Cart implements \JsonSerializable {
* the setup, bail.
*/
if ($this->errors->has_errors()) {
-
return false;
-
- } // end if;
+ }
$interval = null;
foreach ($this->line_items as $line_item) {
-
$duration = $line_item->get_duration();
$duration_unit = $line_item->get_duration_unit();
$cycles = $line_item->get_billing_cycles();
- if (!$line_item->is_recurring()) {
-
+ if ( ! $line_item->is_recurring()) {
continue;
-
- } // end if;
+ }
/*
* Create a key that will tell us if something changes.
@@ -1454,25 +1330,20 @@ class Cart implements \JsonSerializable {
*/
$line_item_interval = "{$duration}-{$duration_unit}-{$cycles}";
- if (!$interval) {
-
+ if ( ! $interval) {
$interval = $line_item_interval;
-
- } // end if;
+ }
if ($line_item_interval !== $interval) {
-
+ // translators: two intervals
$this->errors->add('wrong', sprintf(__('Interval %1$s and %2$s do not match.', 'wp-ultimo'), $line_item_interval, $interval));
return false;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
return $is_valid;
-
- } // end is_valid;
+ }
/**
* Checks if this order is free.
@@ -1487,8 +1358,7 @@ class Cart implements \JsonSerializable {
public function is_free() {
return empty($this->get_total());
-
- } // end is_free;
+ }
/**
* Checks if we need to collect a payment method.
@@ -1504,18 +1374,13 @@ class Cart implements \JsonSerializable {
$should_collect_payment = true;
if ($this->is_free() && $this->get_recurring_total() === 0.0) {
-
$should_collect_payment = false;
-
} elseif ($this->has_trial()) {
-
- $should_collect_payment = !wu_get_setting('allow_trial_without_payment_method', false);
-
- } // end if;
+ $should_collect_payment = ! wu_get_setting('allow_trial_without_payment_method', false);
+ }
return (bool) apply_filters('wu_cart_should_collect_payment', $should_collect_payment, $this);
-
- } // end should_collect_payment;
+ }
/**
* Checks if the cart has a plan.
@@ -1526,8 +1391,7 @@ class Cart implements \JsonSerializable {
public function has_plan() {
return (bool) $this->get_plan();
-
- } // end has_plan;
+ }
/**
* Returns the cart plan.
@@ -1538,8 +1402,7 @@ class Cart implements \JsonSerializable {
public function get_plan() {
return wu_get_product((int) $this->plan_id);
-
- } // end get_plan;
+ }
/**
* Returns the recurring products added to the cart.
@@ -1550,8 +1413,7 @@ class Cart implements \JsonSerializable {
public function get_recurring_products() {
return $this->recurring_products;
-
- } // end get_recurring_products;
+ }
/**
* Returns the non-recurring products added to the cart.
@@ -1562,8 +1424,7 @@ class Cart implements \JsonSerializable {
public function get_non_recurring_products() {
return $this->additional_products;
-
- } // end get_non_recurring_products;
+ }
/**
* Returns an array containing all products added to the cart, recurring or not.
@@ -1574,8 +1435,7 @@ class Cart implements \JsonSerializable {
public function get_all_products() {
return $this->products;
-
- } // end get_all_products;
+ }
/**
* Returns the duration value for this cart.
@@ -1586,8 +1446,7 @@ class Cart implements \JsonSerializable {
public function get_duration() {
return $this->duration;
-
- } // end get_duration;
+ }
/**
* Returns the duration unit for this cart.
@@ -1598,8 +1457,7 @@ class Cart implements \JsonSerializable {
public function get_duration_unit() {
return $this->duration_unit;
-
- } // end get_duration_unit;
+ }
/**
* Add a new line item.
@@ -1611,29 +1469,22 @@ class Cart implements \JsonSerializable {
*/
public function add_line_item($line_item) {
- if (!is_a($line_item, '\WP_Ultimo\Checkout\Line_Item')) {
-
+ if ( ! is_a($line_item, '\WP_Ultimo\Checkout\Line_Item')) {
return;
-
- } // end if;
+ }
if ($line_item->is_discountable()) {
-
$line_item = $this->apply_discounts_to_item($line_item);
-
- } // end if;
+ }
if ($line_item->is_taxable()) {
-
$line_item = $this->apply_taxes_to_item($line_item);
+ }
- } // end if;
-
- $this->line_items[$line_item->get_id()] = $line_item;
+ $this->line_items[ $line_item->get_id() ] = $line_item;
krsort($this->line_items);
-
- } // end add_line_item;
+ }
/**
* Adds a new product to the cart.
*
@@ -1646,52 +1497,43 @@ class Cart implements \JsonSerializable {
$product = is_numeric($product_id_or_slug) ? wu_get_product($product_id_or_slug) : wu_get_product_by_slug($product_id_or_slug);
- if (!$product) {
-
+ if ( ! $product) {
$message = __('The product you are trying to add does not exist.', 'wp-ultimo');
$this->errors->add('missing-product', $message);
return false;
-
- } // end if;
+ }
// Here we check if the product is recurring and if so, get the correct variation
- if ($product->is_recurring() && !empty($this->duration) && ($this->duration !== $product->get_duration() || $this->duration_unit !== $product->get_duration_unit())) {
-
+ if ($product->is_recurring() && ! empty($this->duration) && ($this->duration !== $product->get_duration() || $this->duration_unit !== $product->get_duration_unit())) {
$product = $product->get_as_variation($this->duration, $this->duration_unit);
- if (!$product) {
-
+ if ( ! $product) {
$message = __('The product you are trying to add does not exist for the selected duration.', 'wp-ultimo');
$this->errors->add('missing-price-variations', $message);
return false;
-
- } // end if;
-
- } // end if;
+ }
+ }
if ($product->get_type() === 'plan') {
/*
* If we already have a plan, we can't add
* another one. Bail.
*/
- if (!empty($this->plan_id)) {
-
+ if ( ! empty($this->plan_id)) {
$message = __('Theres already a plan in this membership.', 'wp-ultimo');
$this->errors->add('plan-already-added', $message);
return false;
-
- } // end if;
+ }
$this->plan_id = $product->get_id();
$this->billing_cycles = $product->get_billing_cycles();
-
- } // end if;
+ }
/*
* We only try to reset the duration and such if
@@ -1701,17 +1543,13 @@ class Cart implements \JsonSerializable {
* want access this to fetch price variations.
*/
if (empty($this->duration) || $product->is_recurring() === false) {
-
$this->duration = $product->get_duration();
$this->duration_unit = $product->get_duration_unit();
-
- } // end if;
+ }
if (empty($this->currency)) {
-
$this->currency = $product->get_currency();
-
- } // end if;
+ }
/*
* Set product amount in here, because
@@ -1733,19 +1571,15 @@ class Cart implements \JsonSerializable {
* the cart.
*/
if ($product->is_free() === false) {
-
if (absint($this->duration) !== $product->get_duration() || $this->duration_unit !== $product->get_duration_unit()) {
-
$price_variation = $product->get_price_variation($this->duration, $this->duration_unit);
if ($price_variation) {
-
$price_variation = (object) $price_variation;
$amount = $price_variation->amount;
$duration = $price_variation->duration;
$duration_unit = $price_variation->duration_unit;
-
} else {
/*
* This product does not have a valid
@@ -1757,28 +1591,30 @@ class Cart implements \JsonSerializable {
$this->errors->add('missing-price-variations', $message);
return false;
+ }
+ }
+ }
- } // end if;
-
- } // end if;
-
- } // end if;
-
- $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, $this);
+ $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,
+ $this
+ );
$this->products[] = $product;
if (empty($line_item_data)) {
-
return false;
-
- } // end if;
+ }
$line_item = new Line_Item($line_item_data);
@@ -1793,10 +1629,8 @@ class Cart implements \JsonSerializable {
* Signup Fees
*/
if (empty($product->get_setup_fee())) {
-
return true;
-
- } // end if;
+ }
$add_signup_fee = 'renewal' !== $this->get_cart_type();
@@ -1811,11 +1645,9 @@ class Cart implements \JsonSerializable {
*/
$add_signup_fee = apply_filters('wu_apply_signup_fee', $add_signup_fee, $product, $this); // @phpstan-ignore-line
- if (!$add_signup_fee) {
-
+ if ( ! $add_signup_fee) {
return true;
-
- } // end if;
+ }
// translators: placeholder is the product name.
$description = ($product->get_setup_fee() > 0) ? __('Signup Fee for %s', 'wp-ultimo') : __('Signup Credit for %s', 'wp-ultimo');
@@ -1832,24 +1664,28 @@ class Cart implements \JsonSerializable {
* @param \WP_Ultimo\Checkout\Cart $cart The cart object.
* @return array
*/
- $setup_fee_line_item = apply_filters('wu_add_product_setup_fee_line_item', array(
- 'product' => $product,
- 'type' => 'fee',
- 'description' => '--',
- 'title' => $description,
- 'taxable' => $product->is_taxable(),
- 'recurring' => false,
- 'unit_price' => $product->get_setup_fee(),
- 'quantity' => $quantity,
- ), $product, $this);
+ $setup_fee_line_item = apply_filters(
+ 'wu_add_product_setup_fee_line_item',
+ array(
+ 'product' => $product,
+ 'type' => 'fee',
+ 'description' => '--',
+ 'title' => $description,
+ 'taxable' => $product->is_taxable(),
+ 'recurring' => false,
+ 'unit_price' => $product->get_setup_fee(),
+ 'quantity' => $quantity,
+ ),
+ $product,
+ $this
+ );
$setup_fee_line_item = new Line_Item($setup_fee_line_item);
$this->add_line_item($setup_fee_line_item);
return true;
-
- } // end add_product;
+ }
/**
* Returns an array containing the subtotal per tax rate.
@@ -1864,24 +1700,19 @@ class Cart implements \JsonSerializable {
$tax_brackets = array();
foreach ($line_items as $line_item) {
-
$tax_bracket = $line_item->get_tax_rate();
- if (isset($tax_brackets[$tax_bracket])) {
-
- $tax_brackets[$tax_bracket] += $line_item->get_tax_total();
+ if (isset($tax_brackets[ $tax_bracket ])) {
+ $tax_brackets[ $tax_bracket ] += $line_item->get_tax_total();
continue;
+ }
- } // end if;
-
- $tax_brackets[$tax_bracket] = $line_item->get_tax_total();
-
- } // end foreach;
+ $tax_brackets[ $tax_bracket ] = $line_item->get_tax_total();
+ }
return $tax_brackets;
-
- } // end get_tax_breakthrough;
+ }
/**
* Determine whether or not the level being registered for has a trial that the current user is eligible
@@ -1896,39 +1727,30 @@ class Cart implements \JsonSerializable {
$products = $this->get_all_products();
if (empty($products)) {
-
return false;
-
- } // end if;
+ }
$is_trial = $this->get_billing_start_date();
- if (!$is_trial) {
-
+ if ( ! $is_trial) {
return false;
-
- } // end if;
+ }
// There is a trial, but let's check eligibility.
$customer = wu_get_current_customer();
// No customer, which means they're brand new, which means they're eligible.
if (empty($customer)) {
-
return true;
-
- } // end if;
+ }
// Check if this is the initial membership payment with trial
if ($this->membership && $this->payment && $this->membership->is_trialing()) {
-
return empty($this->payment->get_total());
+ }
- } // end if;
-
- return !$customer->has_trialed();
-
- } // end has_trial;
+ return ! $customer->has_trialed();
+ }
/**
* Get the recovered payment object.
@@ -1939,8 +1761,7 @@ class Cart implements \JsonSerializable {
public function get_recovered_payment() {
return $this->recovered_payment;
-
- } // end get_recovered_payment;
+ }
/**
* Add discount to the order.
*
@@ -1951,37 +1772,31 @@ class Cart implements \JsonSerializable {
public function add_discount_code($code): bool {
if (is_a($code, \WP_Ultimo\Models\Discount_Code::class)) {
-
$this->discount_code = $code;
return true;
-
- } // end if;
+ }
$discount_code = wu_get_discount_code_by_code($code);
- if (!$discount_code) {
-
+ if ( ! $discount_code) {
return false;
-
- } // end if;
+ }
$this->discount_code = $discount_code;
return true;
-
- } // end add_discount_code;
- /**
- * Get registration discounts.
- *
- * @since 2.5
- * @return mixed[]|bool
- */
- public function get_discounts() {
+ }
+ /**
+ * Get registration discounts.
+ *
+ * @since 2.5
+ * @return mixed[]|bool
+ */
+ public function get_discounts() {
return $this->get_line_items_by_type('discount');
-
- } // end get_discounts;
+ }
/**
* Checks if the cart has any discounts applied.
@@ -1992,8 +1807,7 @@ class Cart implements \JsonSerializable {
public function has_discount() {
return $this->get_total_discounts() > 0;
-
- } // end has_discount;
+ }
/**
* Returns a list of line items based on the line item type.
@@ -2011,26 +1825,27 @@ class Cart implements \JsonSerializable {
// 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,
- ));
+ $line_items = Array_Search::find(
+ $line_items,
+ array(
+ 'where' => $where_clauses,
+ )
+ );
$ids = array_keys($line_items);
return array_filter($this->line_items, fn($id) => in_array($id, $ids, true), ARRAY_FILTER_USE_KEY);
-
- } // end get_line_items_by_type;
- /**
- * Get registration fees.
- *
- * @since 2.0.0
- * @return mixed[]|bool
- */
- public function get_fees() {
+ }
+ /**
+ * Get registration fees.
+ *
+ * @since 2.0.0
+ * @return mixed[]|bool
+ */
+ public function get_fees() {
return $this->get_line_items_by_type('fees');
-
- } // end get_fees;
+ }
/**
* Calculates the total tax amount.
@@ -2044,14 +1859,11 @@ class Cart implements \JsonSerializable {
$total_taxes = 0;
foreach ($this->line_items as $line_item) {
-
$total_taxes += $line_item->get_tax_total();
-
- } // end foreach;
+ }
return $total_taxes;
-
- } // end get_total_taxes;
+ }
/**
* Get the total number of fees.
@@ -2067,37 +1879,28 @@ class Cart implements \JsonSerializable {
$line_items = $this->get_fees();
- if (!$line_items) {
-
+ if ( ! $line_items) {
return 0;
-
- } // end if;
+ }
$fees = 0;
foreach ($line_items as $fee) {
-
- if ($only_recurring && !$fee->is_recurring()) {
-
+ if ($only_recurring && ! $fee->is_recurring()) {
continue;
-
- } // end if;
+ }
$fees += $fee->get_total();
-
- } // end foreach;
+ }
// if total is present, make sure that any negative fees are not
// greater than the total.
if ($total && ($fees + $total) < 0) {
-
$fees = -1 * $total;
-
- } // end if;
+ }
return apply_filters('wu_cart_get_total_fees', (float) $fees, $total, $only_recurring, $this);
-
- } // end get_total_fees;
+ }
/**
* Get the total proration amount.
@@ -2109,29 +1912,22 @@ class Cart implements \JsonSerializable {
*/
public function get_proration_credits() {
- if (!$this->get_fees()) {
-
+ if ( ! $this->get_fees()) {
return 0;
-
- } // end if;
+ }
$proration = 0;
foreach ($this->get_fees() as $fee) {
-
- if (!$fee['proration']) {
-
+ if ( ! $fee['proration']) {
continue;
-
- } // end if;
+ }
$proration += $fee['amount'];
-
- } // end foreach;
+ }
return apply_filters('wu_cart_get_proration_fees', (float) $proration, $this);
-
- } // end get_proration_credits;
+ }
/**
* Get the total discounts.
@@ -2144,16 +1940,13 @@ class Cart implements \JsonSerializable {
$total_discount = 0;
foreach ($this->line_items as $line_item) {
-
$total_discount -= $line_item->get_discount_total();
-
- } // end foreach;
+ }
$total_discount = round($total_discount, wu_currency_decimal_filter());
return apply_filters('wu_cart_get_total_discounts', $total_discount, $this);
-
- } // end get_total_discounts;
+ }
/**
* Gets the subtotal value of the cart.
@@ -2171,22 +1964,16 @@ class Cart implements \JsonSerializable {
);
foreach ($this->line_items as $line_item) {
-
if (in_array($line_item->get_type(), $exclude_types, true)) {
-
continue;
-
- } // end if;
+ }
$subtotal += $line_item->get_subtotal();
-
- } // end foreach;
+ }
if (0 > $subtotal) {
-
$subtotal = 0;
-
- } // end if;
+ }
$subtotal = round($subtotal, wu_currency_decimal_filter());
@@ -2197,8 +1984,7 @@ class Cart implements \JsonSerializable {
* @param \WP_Ultimo\Checkout\Cart $this Cart object.
*/
return apply_filters('wu_cart_get_subtotal', floatval($subtotal), $this); // @phpstan-ignore-line
-
- } // end get_subtotal;
+ }
/**
* Get the registration total due today.
@@ -2211,16 +1997,12 @@ class Cart implements \JsonSerializable {
$total = 0;
foreach ($this->line_items as $line_item) {
-
$total += $line_item->get_total();
-
- } // end foreach;
+ }
if (0 > $total) {
-
$total = 0;
-
- } // end if;
+ }
$total = round($total, wu_currency_decimal_filter());
@@ -2231,8 +2013,7 @@ class Cart implements \JsonSerializable {
* @param \WP_Ultimo\Checkout\Cart $this Cart object.
*/
return apply_filters('wu_cart_get_total', floatval($total), $this); // @phpstan-ignore-line
-
- } // end get_total;
+ }
/**
* Get the registration recurring total.
@@ -2245,43 +2026,35 @@ class Cart implements \JsonSerializable {
$total = 0;
foreach ($this->line_items as $line_item) {
-
- if (!$line_item->is_recurring()) {
-
+ if ( ! $line_item->is_recurring()) {
continue;
-
- } // end if;
+ }
/*
* Check for coupon codes
*/
- if ($line_item->get_discount_total() > 0 && !$line_item->should_apply_discount_to_renewals()) {
-
+ if ($line_item->get_discount_total() > 0 && ! $line_item->should_apply_discount_to_renewals()) {
$new_line_item = clone $line_item;
- $new_line_item->attributes(array(
- 'discount_rate' => 0,
- ));
+ $new_line_item->attributes(
+ array(
+ 'discount_rate' => 0,
+ )
+ );
$new_line_item->recalculate_totals();
$amount = $new_line_item->get_total();
-
} else {
-
$amount = $line_item->get_total();
-
- } // end if;
+ }
$total += $amount;
-
- } // end foreach;
+ }
if (0 > $total) {
-
$total = 0;
-
- } // end if;
+ }
$total = round($total, wu_currency_decimal_filter());
@@ -2292,8 +2065,7 @@ class Cart implements \JsonSerializable {
* @param \WP_Ultimo\Checkout\Cart $this Cart object.
*/
return apply_filters('wu_cart_get_recurring_total', floatval($total), $this); // @phpstan-ignore-line
-
- } // end get_recurring_total;
+ }
/**
* Gets the recurring subtotal, before taxes.
@@ -2306,22 +2078,16 @@ class Cart implements \JsonSerializable {
$subtotal = 0;
foreach ($this->line_items as $line_item) {
-
- if (!$line_item->is_recurring()) {
-
+ if ( ! $line_item->is_recurring()) {
continue;
-
- } // end if;
+ }
$subtotal += $line_item->get_subtotal();
-
- } // end foreach;
+ }
if (0 > $subtotal) {
-
$subtotal = 0;
-
- } // end if;
+ }
$subtotal = round($subtotal, wu_currency_decimal_filter());
@@ -2332,8 +2098,7 @@ class Cart implements \JsonSerializable {
* @param \WP_Ultimo\Checkout\Cart $this Cart object.
*/
return apply_filters('wu_cart_get_recurring_total', floatval($subtotal), $this); // @phpstan-ignore-line
-
- } // end get_recurring_subtotal;
+ }
/**
* Returns the timestamp of the end of the trial period.
@@ -2343,11 +2108,9 @@ class Cart implements \JsonSerializable {
*/
public function get_billing_start_date() {
- if ($this->is_free() && !$this->has_recurring()) {
-
+ if ($this->is_free() && ! $this->has_recurring()) {
return null;
-
- } // end if;
+ }
/*
* Set extremely high value at first to prevent any change of errors.
@@ -2355,67 +2118,51 @@ class Cart implements \JsonSerializable {
$smallest_trial = 300 * YEAR_IN_SECONDS;
foreach ($this->get_all_products() as $product) {
-
- if (!$product->has_trial()) {
-
+ if ( ! $product->has_trial()) {
$smallest_trial = 0;
-
- } // end if;
+ }
$duration = $product->get_trial_duration();
$duration_unit = $product->get_trial_duration_unit();
if ($duration && $duration_unit) {
-
$trial_period = strtotime("+$duration $duration_unit");
if ($trial_period < $smallest_trial) {
-
$smallest_trial = $trial_period;
-
- } // end if;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
+ }
return $smallest_trial;
-
- } // end get_billing_start_date;
- /**
- * Returns the timestamp of the next charge, if recurring.
- *
- * @since 2.0.0
- * @return string|false
- */
- public function get_billing_next_charge_date() {
+ }
+ /**
+ * Returns the timestamp of the next charge, if recurring.
+ *
+ * @since 2.0.0
+ * @return string|false
+ */
+ public function get_billing_next_charge_date() {
/*
* Set extremely high value at first to prevent any chance of errors.
*/
$smallest_next_charge = 300 * YEAR_IN_SECONDS;
if ($this->get_cart_type() === 'downgrade') {
-
$membership = $this->membership;
if ($membership->is_active() || $membership->get_status() === Membership_Status::TRIALING) {
-
$next_charge = strtotime($membership->get_date_expiration());
return $next_charge;
-
- } // end if;
-
- } // end if;
+ }
+ }
foreach ($this->get_all_products() as $product) {
-
- if (!$product->is_recurring() || ($product->has_trial() && $this->has_trial())) {
-
+ if ( ! $product->is_recurring() || ($product->has_trial() && $this->has_trial())) {
continue;
-
- } // end if;
+ }
$duration = $product->get_duration();
@@ -2424,16 +2171,12 @@ class Cart implements \JsonSerializable {
$next_charge = strtotime("+$duration $duration_unit");
if ($next_charge < $smallest_next_charge) {
-
$smallest_next_charge = $next_charge;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
return $smallest_next_charge;
-
- } // end get_billing_next_charge_date;
+ }
/**
* Checks if the order is recurring or not.
@@ -2444,8 +2187,7 @@ class Cart implements \JsonSerializable {
public function has_recurring() {
return $this->get_recurring_total() > 0;
-
- } // end has_recurring;
+ }
/**
* Returns an array with all types of line-items of the cart.
@@ -2456,8 +2198,7 @@ class Cart implements \JsonSerializable {
public function get_line_items() {
return $this->line_items;
-
- } // end get_line_items;
+ }
/**
* Apply discounts to a line item.
@@ -2472,52 +2213,45 @@ class Cart implements \JsonSerializable {
/**
* Product is not taxable, bail.
*/
- if (!$line_item->is_discountable() || !$this->discount_code) {
-
+ if ( ! $line_item->is_discountable() || ! $this->discount_code) {
return $line_item;
-
- } // end if;
+ }
if (is_wp_error($this->discount_code->is_valid($line_item->get_product_id()))) {
-
return $line_item;
-
- } // end if;
+ }
/**
* Should apply to fees?
*/
if ($line_item->get_type() === 'fee') {
-
if ($this->discount_code->get_setup_fee_value() <= 0) {
-
return $line_item;
+ }
- } // end if;
-
- $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()),
- ));
-
+ $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()),
- ));
-
- } // end if;
+ $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()),
+ )
+ );
+ }
$line_item->recalculate_totals();
return $line_item;
-
- } // end apply_discounts_to_item;
+ }
/**
* Apply taxes to a line item.
@@ -2532,63 +2266,54 @@ class Cart implements \JsonSerializable {
/**
* Tax collection is not enabled
*/
- if (!wu_should_collect_taxes()) {
-
+ if ( ! wu_should_collect_taxes()) {
return $line_item;
-
- } // end if;
+ }
/**
* Product is not taxable, bail.
*/
- if (!$line_item->is_taxable()) {
-
+ if ( ! $line_item->is_taxable()) {
return $line_item;
-
- } // end if;
+ }
$tax_category = $line_item->get_tax_category();
/**
* No tax category, bail.
*/
- if (!$tax_category) {
-
+ if ( ! $tax_category) {
return $line_item;
-
- } // end if;
+ }
$tax_rates = apply_filters('wu_cart_applicable_tax_rates', wu_get_applicable_tax_rates($this->country, $tax_category, $this->state, $this->city), $this->country, $tax_category, $this);
if (empty($tax_rates)) {
-
return $line_item;
-
- } // end if;
+ }
foreach ($tax_rates as $applicable_tax_rate) {
-
$tax_type = 'percentage';
$tax_rate = $applicable_tax_rate['tax_rate'];
$tax_label = $applicable_tax_rate['title'];
continue;
+ }
- } // end foreach;
-
- $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->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();
return $line_item;
-
- } // end apply_taxes_to_item;
+ }
/**
* Calculates the totals of the cart and return them.
@@ -2609,8 +2334,7 @@ class Cart implements \JsonSerializable {
'total_discounts' => $this->get_total_discounts(),
'total' => $this->get_total(),
);
-
- } // end calculate_totals;
+ }
/**
* Used for serialization purposes.
@@ -2621,8 +2345,7 @@ class Cart implements \JsonSerializable {
public function jsonSerialize(): string {
return json_encode($this->done());
-
- } // end jsonSerialize;
+ }
/**
* Get the list of extra parameters.
@@ -2635,14 +2358,11 @@ class Cart implements \JsonSerializable {
$extra_params = array();
foreach ($this->extra as $key) {
-
- $extra_params[$key] = $this->get_param($key);
-
- } // end foreach;
+ $extra_params[ $key ] = $this->get_param($key);
+ }
return apply_filters('wu_cart_get_extra_params', $extra_params, $this);
-
- } // end get_extra_params;
+ }
/**
* Implements our on json_decode version of this object. Useful for use in vue.js.
@@ -2657,21 +2377,15 @@ class Cart implements \JsonSerializable {
$errors = array();
if ($this->errors->has_errors()) {
-
foreach ($this->errors as $code => $messages) {
-
foreach ($messages as $message) {
-
$errors[] = array(
'code' => $code,
'message' => $message,
);
-
- } // end foreach;
-
- } // end foreach;
-
- } // end if;
+ }
+ }
+ }
return (object) array(
@@ -2699,8 +2413,7 @@ class Cart implements \JsonSerializable {
),
);
-
- } // end done;
+ }
/**
* Converts the current cart to an array of membership elements.
@@ -2712,36 +2425,38 @@ class Cart implements \JsonSerializable {
$membership_data = array();
- $all_additional_products = $this->get_line_items_by_type('product', array(
- array('product_id', '!=', $this->get_plan_id()),
- ));
+ $all_additional_products = $this->get_line_items_by_type(
+ 'product',
+ array(
+ array('product_id', '!=', $this->get_plan_id()),
+ )
+ );
$addon_list = array();
foreach ($all_additional_products as $line_item) {
+ $addon_list[ $line_item->get_product_id() ] = $line_item->get_quantity();
+ }
- $addon_list[$line_item->get_product_id()] = $line_item->get_quantity();
-
- } // end foreach;
-
- $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(),
- 'addon_products' => $addon_list,
- 'currency' => $this->get_currency(),
- 'duration' => $this->get_duration(),
- 'duration_unit' => $this->get_duration_unit(),
- 'amount' => $this->get_recurring_total(),
- 'times_billed' => 0,
- 'billing_cycles' => $this->get_plan() ? $this->get_plan()->get_billing_cycles() : 0,
- 'auto_renew' => false, // @todo: revisit
- 'upgraded_from' => false, // @todo: revisit
- ));
+ $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(),
+ 'addon_products' => $addon_list,
+ 'currency' => $this->get_currency(),
+ 'duration' => $this->get_duration(),
+ 'duration_unit' => $this->get_duration_unit(),
+ 'amount' => $this->get_recurring_total(),
+ 'times_billed' => 0,
+ '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;
-
- } // end to_membership_data;
+ }
/**
* Converts the current cart to a payment data array.
@@ -2766,8 +2481,7 @@ class Cart implements \JsonSerializable {
);
return $payment_data;
-
- } // end to_payment_data;
+ }
/**
* Get the value of discount_code
@@ -2778,8 +2492,7 @@ class Cart implements \JsonSerializable {
public function get_discount_code() {
return $this->discount_code;
-
- } // end get_discount_code;
+ }
/**
* Get the value of plan_id
@@ -2790,8 +2503,7 @@ class Cart implements \JsonSerializable {
public function get_plan_id() {
return $this->plan_id;
-
- } // end get_plan_id;
+ }
/**
* Get the currency code.
@@ -2802,8 +2514,7 @@ class Cart implements \JsonSerializable {
public function get_currency() {
return $this->currency;
-
- } // end get_currency;
+ }
/**
* Set the currency.
@@ -2815,8 +2526,7 @@ class Cart implements \JsonSerializable {
public function set_currency($currency) {
$this->currency = $currency;
-
- } // end set_currency;
+ }
/**
* Get the cart membership.
@@ -2827,8 +2537,7 @@ class Cart implements \JsonSerializable {
public function get_membership() {
return $this->membership;
-
- } // end get_membership;
+ }
/**
* Get the cart payment.
@@ -2839,8 +2548,7 @@ class Cart implements \JsonSerializable {
public function get_payment() {
return $this->payment;
-
- } // end get_payment;
+ }
/**
* Get the cart customer.
@@ -2851,8 +2559,7 @@ class Cart implements \JsonSerializable {
public function get_customer() {
return $this->customer;
-
- } // end get_customer;
+ }
/**
* Set the cart membership.
@@ -2864,8 +2571,7 @@ class Cart implements \JsonSerializable {
public function set_membership($membership) {
$this->membership = $membership;
-
- } // end set_membership;
+ }
/**
* Set the cart customer.
@@ -2877,8 +2583,7 @@ class Cart implements \JsonSerializable {
public function set_customer($customer) {
$this->customer = $customer;
-
- } // end set_customer;
+ }
/**
* Set the cart payment.
@@ -2890,8 +2595,7 @@ class Cart implements \JsonSerializable {
public function set_payment($payment) {
$this->payment = $payment;
-
- } // end set_payment;
+ }
/**
* Get the value of auto_renew.
@@ -2902,8 +2606,7 @@ class Cart implements \JsonSerializable {
public function should_auto_renew() {
return $this->auto_renew === 'yes' || $this->auto_renew === true;
-
- } // end should_auto_renew;
+ }
/**
* Get the cart type.
@@ -2914,8 +2617,7 @@ class Cart implements \JsonSerializable {
public function get_cart_type() {
return $this->cart_type;
-
- } // end get_cart_type;
+ }
/**
* Get the country of the customer.
@@ -2926,8 +2628,7 @@ class Cart implements \JsonSerializable {
public function get_country() {
return $this->country;
-
- } // end get_country;
+ }
/**
* Set the country of the customer.
@@ -2939,8 +2640,7 @@ class Cart implements \JsonSerializable {
public function set_country($country) {
$this->country = $country;
-
- } // end set_country;
+ }
/**
* Builds a cart URL that we can use with the browser history APIs.
@@ -2955,41 +2655,32 @@ class Cart implements \JsonSerializable {
$plan = wu_get_product($this->plan_id);
if ($plan) {
-
$base_url .= $plan->get_slug();
-
- } // end if;
+ }
if ($this->duration && absint($this->duration) !== 1) {
-
$base_url .= "/{$this->duration}";
+ }
- } // end if;
-
- if ($this->duration_unit && $this->duration_unit !== 'month') {
-
+ if ($this->duration_unit && 'month' !== $this->duration_unit) {
$base_url .= "/{$this->duration_unit}";
-
- } // end if;
+ }
$all_products = $this->products;
$products_list = array();
foreach ($all_products as $product) {
-
if ($product->get_id() !== $this->plan_id) {
-
$products_list[] = $product->get_slug();
+ }
+ }
- } // end if;
-
- } // end foreach;
-
- return add_query_arg(array(
- 'products' => $products_list,
- ), $base_url);
-
- } // end get_cart_url;
-
-} // end class Cart;
+ return add_query_arg(
+ array(
+ 'products' => $products_list,
+ ),
+ $base_url
+ );
+ }
+}
diff --git a/inc/checkout/class-checkout-pages.php b/inc/checkout/class-checkout-pages.php
index 18d31e7..ea25e95 100644
--- a/inc/checkout/class-checkout-pages.php
+++ b/inc/checkout/class-checkout-pages.php
@@ -38,16 +38,13 @@ class Checkout_Pages {
add_filter('lostpassword_redirect', array($this, 'filter_lost_password_redirect'));
if (is_main_site()) {
-
add_action('before_signup_header', array($this, 'redirect_to_registration_page'));
$use_custom_login = wu_get_setting('enable_custom_login_page', false);
- if (!$use_custom_login) {
-
+ if ( ! $use_custom_login) {
return;
-
- } // end if;
+ }
add_filter('login_url', array($this, 'filter_login_url'), 10, 3);
@@ -73,10 +70,8 @@ class Checkout_Pages {
add_action('post_submitbox_misc_actions', array($this, 'render_compat_mode_setting'));
add_action('save_post', array($this, 'handle_compat_mode_setting'));
-
- } // end if;
-
- } // end init;
+ }
+ }
/**
* Filters the lost password redirect URL.
@@ -85,17 +80,14 @@ class Checkout_Pages {
*/
public function filter_lost_password_redirect(string $redirect_to): string {
- if (!empty($redirect_to)) {
-
+ if ( ! empty($redirect_to)) {
return $redirect_to;
-
- } // end if;
+ }
$redirect_to = add_query_arg('checkemail', 'confirm', wp_login_url());
return $redirect_to;
-
- } // end filter_lost_password_redirect;
+ }
/**
* Renders the compat mode option for pages and posts.
@@ -127,8 +119,7 @@ class Checkout_Pages {
post_name, $url);
-
- } // end if;
+ }
return $url;
-
- } // end maybe_change_wp_login_on_urls;
+ }
/**
* Get an error message.
@@ -215,11 +190,11 @@ class Checkout_Pages {
public function get_error_message($error_code, $username = '') {
$messages = array(
- 'incorrect_password' => sprintf(__( 'Error: The password you entered is incorrect.', 'wp-ultimo')),
+ 'incorrect_password' => sprintf(__('Error: 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.'),
'confirm' => sprintf(__('Check your email for the confirmation link, then visit the login page.'), wp_login_url()),
- 'registered' => sprintf(__( 'Registration complete. Please check your email, then visit the login page.' ), wp_login_url()),
+ 'registered' => sprintf(__('Registration complete. Please check your email, then visit the login page.'), wp_login_url()),
'loggedout' => __('You are now logged out.'),
'registerdisabled' => __('Error: User registration is currently not allowed.'),
'empty_username' => __('Error: The username field is empty.'),
@@ -243,8 +218,7 @@ class Checkout_Pages {
$messages = apply_filters('wu_checkout_pages_error_messages', $messages);
return wu_get_isset($messages, $error_code, __('Something went wrong', 'wp-ultimo'));
-
- } // end get_error_message;
+ }
/**
* Handle password reset errors.
@@ -260,20 +234,20 @@ class Checkout_Pages {
public function maybe_handle_password_reset_errors($errors) {
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());
+ $url = add_query_arg(
+ array(
+ 'action' => wu_request('action', ''),
+ 'user_login' => wu_request('user_login', ''),
+ 'error' => $errors->get_error_code(),
+ ),
+ wp_login_url()
+ );
wp_redirect($url);
exit;
-
- } // end if;
-
- } // end maybe_handle_password_reset_errors;
+ }
+ }
/**
* Maybe redirects users to the confirm screen.
@@ -289,14 +263,11 @@ class Checkout_Pages {
public function maybe_redirect_to_confirm_screen() {
if (wu_request('redirect_to')) {
-
wp_redirect(wu_request('redirect_to'));
exit;
-
- } // end if;
-
- } // end maybe_redirect_to_confirm_screen;
+ }
+ }
/**
* Replace the reset password link, if necessary.
@@ -311,11 +282,9 @@ class Checkout_Pages {
*/
public function replace_reset_password_link($message, $key, $user_login, $user_data) {
- if (!is_main_site()) {
-
+ if ( ! is_main_site()) {
return $message;
-
- } // end if;
+ }
$results = array();
@@ -330,28 +299,27 @@ 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());
+ $new_url = add_query_arg(
+ array(
+ 'action' => 'rp',
+ 'key' => $key,
+ 'login' => rawurlencode($user_login),
+ 'wp_lang' => $locale,
+ ),
+ wp_login_url()
+ );
$new_url = set_url_scheme($new_url, null);
$message = str_replace($results[0], $new_url, $message);
-
- } // end if;
+ }
if ($switched_locale) {
-
restore_previous_locale();
-
- } // end if;
+ }
return $message;
-
- } // end replace_reset_password_link;
+ }
/**
* Redirect logged users when they reach the login page.
@@ -363,25 +331,19 @@ class Checkout_Pages {
global $post;
- if (!is_user_logged_in()) {
-
+ if ( ! is_user_logged_in()) {
return;
-
- } // end if;
+ }
$custom_login_page = $this->get_signup_page('login');
if (empty($custom_login_page) || empty($post)) {
-
return;
-
- } // end if;
+ }
if ($custom_login_page->ID !== $post->ID) {
-
return;
-
- } // end if;
+ }
/**
* Create an exclusion list of parameters that prevent the auto-redirect.
@@ -392,24 +354,26 @@ class Checkout_Pages {
* @since 2.0.4
* @return array
*/
- $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);
+ $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
+ );
foreach ($exclusion_list as $exclusion_param) {
-
if (wu_request($exclusion_param, null) !== null) {
-
return;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
$user = wp_get_current_user();
@@ -418,34 +382,23 @@ class Checkout_Pages {
$redirect_to = $active_blog ? get_admin_url($active_blog->blog_id) : false;
if (isset($_GET['redirect_to'])) {
-
$redirect_to = $_GET['redirect_to'];
-
- } elseif (is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin($user->ID)) {
-
+ } elseif (is_multisite() && ! get_active_blog_for_user($user->ID) && ! is_super_admin($user->ID)) {
$redirect_to = user_admin_url();
-
- } elseif (is_multisite() && !$user->has_cap('read')) {
-
+ } elseif (is_multisite() && ! $user->has_cap('read')) {
$redirect_to = get_dashboard_url($user->ID);
-
- } elseif (!$user->has_cap('edit_posts')) {
-
+ } elseif ( ! $user->has_cap('edit_posts')) {
$redirect_to = $user->has_cap('read') ? admin_url('profile.php') : home_url();
+ }
- } // end if;
-
- if (!$redirect_to) {
-
+ if ( ! $redirect_to) {
return;
-
- } // end if;
+ }
wp_redirect($redirect_to);
exit;
-
- } // end maybe_redirect_to_admin_panel;
+ }
/**
* Adds the unverified email account error message.
@@ -460,7 +413,6 @@ class Checkout_Pages {
public function add_verify_email_notice($payment, $membership, $customer) {
if ($payment->get_total() == 0 && $customer->get_email_verification() === 'pending') {
-
$html = '
%s
';
$message = __('Your email address is not yet verified. Your site will only be activated after your email address is verified. Check your inbox and verify your email address.', 'wp-ultimo');
@@ -468,10 +420,8 @@ class Checkout_Pages {
$message .= sprintf(' %s', __('Resend verification email →', 'wp-ultimo'));
printf($html, $message);
-
- } // end if;
-
- } // end add_verify_email_notice;
+ }
+ }
/**
* Check if we should obfuscate the login URL.
@@ -483,44 +433,33 @@ class Checkout_Pages {
$use_custom_login = wu_get_setting('enable_custom_login_page', false);
- if (!$use_custom_login) {
-
+ if ( ! $use_custom_login) {
return;
-
- } // end if;
+ }
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
-
return;
-
- } // end if;
+ }
if (wu_request('interim-login')) {
-
return;
-
- } // end if;
+ }
if (wu_request('action') === 'logout') {
-
return;
-
- } // end if;
+ }
$new_login_url = $this->get_page_url('login');
- if (!$new_login_url) {
-
+ if ( ! $new_login_url) {
return;
-
- } // end if;
+ }
$should_obfuscate = wu_get_setting('obfuscate_original_login_url', 1);
$bypass_obfuscation = wu_request('wu_bypass_obfuscation');
- if ($should_obfuscate && !$bypass_obfuscation) {
-
+ if ($should_obfuscate && ! $bypass_obfuscation) {
status_header(404);
nocache_headers();
@@ -529,19 +468,15 @@ class Checkout_Pages {
$wp_query->set_404();
- include(get_404_template());
+ include get_404_template();
die;
-
} else {
-
wp_redirect($new_login_url);
exit;
-
- } // end if;
-
- } // end maybe_obfuscate_login_url;
+ }
+ }
/**
* Redirects the customers to the registration page, when one is used.
@@ -554,14 +489,11 @@ class Checkout_Pages {
$registration_url = $this->get_page_url('register');
if ($registration_url) {
-
wp_redirect($registration_url);
exit;
-
- } // end if;
-
- } // end redirect_to_registration_page;
+ }
+ }
/**
* Filters the login URL if necessary.
@@ -578,19 +510,15 @@ class Checkout_Pages {
/**
* Fix incompatibility with UIPress, making sure we only filter after wp_loaded ran.
*/
- if (!did_action('wp_loaded')) {
-
+ if ( ! did_action('wp_loaded')) {
return $login_url;
-
- } // end if;
+ }
$function_caller = wu_get_function_caller(5);
if ($function_caller === 'wp_auth_check_html') {
-
return $login_url;
-
- } // end if;
+ }
$params = array();
@@ -600,33 +528,24 @@ class Checkout_Pages {
$new_login_url = $this->get_page_url('login');
- if (!$new_login_url) {
-
+ if ( ! $new_login_url) {
return $login_url;
-
- } // end if;
+ }
if ($params) {
-
$new_login_url = add_query_arg($params, $new_login_url);
-
- } // end if;
+ }
if ($redirect) {
-
- $new_login_url = add_query_arg('redirect_to', urlencode( $redirect ), $new_login_url);
-
- } // end if;
+ $new_login_url = add_query_arg('redirect_to', urlencode($redirect), $new_login_url);
+ }
if ($force_reauth) {
-
$new_login_url = add_query_arg('reauth', 1, $new_login_url);
-
- } // end if;
+ }
return $new_login_url;
-
- } // end filter_login_url;
+ }
/**
* Returns the ID of the pages being used for each WP Multisite WaaS purpose.
@@ -643,52 +562,45 @@ class Checkout_Pages {
'block_frontend' => wu_get_setting('default_block_frontend_page', false),
'new_site' => wu_get_setting('default_new_site_page', false),
);
-
- } // end get_signup_pages;
- /**
- * Returns the WP_Post object for one of the pages.
- *
- * @since 2.0.0
- *
- * @param string $page The slug of the page to retrieve.
- * @return \WP_Post|false
- */
- public function get_signup_page($page) {
+ }
+ /**
+ * Returns the WP_Post object for one of the pages.
+ *
+ * @since 2.0.0
+ *
+ * @param string $page The slug of the page to retrieve.
+ * @return \WP_Post|false
+ */
+ public function get_signup_page($page) {
$pages = $this->get_signup_pages();
$page_id = wu_get_isset($pages, $page);
- if (!$page_id) {
-
+ if ( ! $page_id) {
return false;
-
- } // end if;
+ }
return get_blog_post(wu_get_main_site_id(), $page_id);
-
- } // end get_signup_page;
- /**
- * Returns the URL for a particular page type.
- *
- * @since 2.0.0
- *
- * @param string $page_slug The signup page to get.
- * @return string|false
- */
- public function get_page_url($page_slug = 'login') {
+ }
+ /**
+ * Returns the URL for a particular page type.
+ *
+ * @since 2.0.0
+ *
+ * @param string $page_slug The signup page to get.
+ * @return string|false
+ */
+ public function get_page_url($page_slug = 'login') {
$page = $this->get_signup_page($page_slug);
- if (!$page) {
-
+ if ( ! $page) {
return false;
-
- } // end if;
+ }
return wu_switch_blog_and_run(fn() => get_the_permalink($page));
-
- } // end get_page_url;
+ }
/**
* Tags the WP Multisite WaaS pages on the main site.
@@ -701,11 +613,9 @@ class Checkout_Pages {
*/
public function add_wp_ultimo_status_annotation($states, $post) {
- if (!is_main_site()) {
-
+ if ( ! is_main_site()) {
return $states;
-
- } // end if;
+ }
$labels = array(
'register' => __('WP Multisite WaaS - Register Page', 'wp-ultimo'),
@@ -718,16 +628,13 @@ class Checkout_Pages {
$pages = array_map('absint', $this->get_signup_pages());
if (in_array($post->ID, $pages, true)) {
-
$key = array_search($post->ID, $pages, true);
$states['wp_ultimo_page'] = wu_get_isset($labels, $key);
-
- } // end if;
+ }
return $states;
-
- } // end add_wp_ultimo_status_annotation;
+ }
/**
* Renders the confirmation page.
@@ -740,11 +647,12 @@ class Checkout_Pages {
*/
public function render_confirmation_page($atts, $content = null) {
- return wu_get_template_contents('checkout/confirmation', array(
- 'errors' => Checkout::get_instance()->errors,
- 'membership' => wu_get_membership_by_hash(wu_request('membership')),
- ));
-
- } // end render_confirmation_page;
-
-} // end 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')),
+ )
+ );
+ }
+}
diff --git a/inc/checkout/class-checkout.php b/inc/checkout/class-checkout.php
index 2b74f4c..98c439b 100644
--- a/inc/checkout/class-checkout.php
+++ b/inc/checkout/class-checkout.php
@@ -12,13 +12,13 @@ namespace WP_Ultimo\Checkout;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \Psr\Log\LogLevel;
-use \WP_Ultimo\Database\Sites\Site_Type;
-use \WP_Ultimo\Database\Payments\Payment_Status;
-use \WP_Ultimo\Database\Memberships\Membership_Status;
-use \WP_Ultimo\Checkout\Checkout_Pages;
-use \WP_Ultimo\Objects\Billing_Address;
-use \WP_Ultimo\Models\Site;
+use Psr\Log\LogLevel;
+use WP_Ultimo\Database\Sites\Site_Type;
+use WP_Ultimo\Database\Payments\Payment_Status;
+use WP_Ultimo\Database\Memberships\Membership_Status;
+use WP_Ultimo\Checkout\Checkout_Pages;
+use WP_Ultimo\Objects\Billing_Address;
+use WP_Ultimo\Models\Site;
/**
* Handles the processing of new membership purchases.
@@ -197,8 +197,7 @@ class Checkout {
* Errors
*/
add_action('wu_checkout_errors', array($this, 'maybe_display_checkout_errors'));
-
- } // end init;
+ }
/**
* Add checkout rewrite rules.
@@ -218,11 +217,9 @@ class Checkout {
$register = Checkout_Pages::get_instance()->get_signup_page('register');
- if (!is_a($register, '\WP_Post')) {
-
+ if ( ! is_a($register, '\WP_Post')) {
return;
-
- } // end if;
+ }
$register_slug = $register->post_name;
@@ -279,8 +276,7 @@ class Checkout {
'index.php?pagename=' . $register_slug . '&template_name=$matches[1]&wu_preselected=template_id',
'top'
);
-
- } // end add_rewrite_rules;
+ }
/**
* Filters the wu_request with the query vars.
@@ -293,21 +289,22 @@ class Checkout {
*/
public function get_checkout_from_query_vars($value, $key) {
- if (!did_action('wp')) {
-
+ if ( ! did_action('wp')) {
return $value;
-
- } // end if;
+ }
$from_query = get_query_var($key);
- $cart_arguments = apply_filters('wu_get_checkout_from_query_vars', array(
- 'products',
- 'duration',
- 'duration_unit',
- 'template_id',
- 'wu_preselected',
- ));
+ $cart_arguments = apply_filters(
+ 'wu_get_checkout_from_query_vars',
+ array(
+ 'products',
+ 'duration',
+ 'duration_unit',
+ 'template_id',
+ 'wu_preselected',
+ )
+ );
/**
* Deal with site templates in a specific manner.
@@ -315,11 +312,9 @@ class Checkout {
* @since 2.0.8
*/
if ($key === 'template_id') {
-
$template_name = get_query_var('template_name', null);
if ($template_name !== null) {
-
$d = wu_get_site_domain_and_path($template_name);
$wp_site = get_site_by_path($d->domain, $d->path);
@@ -327,28 +322,21 @@ class Checkout {
$site = $wp_site ? wu_get_site($wp_site->blog_id) : false;
if ($site && $site->get_type() === Site_Type::SITE_TEMPLATE) {
-
return $site->get_id();
-
- } // end if;
-
- } // end if;
-
- } // end if;
+ }
+ }
+ }
/*
* Otherwise, simply check for its existence
* on the query object.
*/
if (in_array($key, $cart_arguments, true) && $from_query) {
-
return $from_query;
-
- } // end if;
+ }
return $value;
-
- } // end get_checkout_from_query_vars;
+ }
/**
* Setups the necessary boilerplate code to have checkouts work.
@@ -360,39 +348,30 @@ class Checkout {
public function setup_checkout($element = null) {
if ($this->already_setup) {
-
return;
-
- } // end if;
+ }
$checkout_form_slug = wu_request('checkout_form');
if (wu_request('pre-flight')) {
-
$checkout_form_slug = false;
$_REQUEST['pre_selected'] = $_REQUEST;
+ }
- } // end if;
-
- if (!$checkout_form_slug && is_a($element, \WP_Ultimo\UI\Checkout_Element::class)) {
-
+ 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;
-
- } // end if;
+ }
$this->checkout_form = wu_get_checkout_form_by_slug($checkout_form_slug);
if ($this->session === null) {
-
$this->session = wu_get_session('signup');
-
- } // end if;
+ }
if ($this->checkout_form) {
-
$this->steps = $this->checkout_form->get_steps_to_show();
$first_step = current($this->steps);
@@ -408,20 +387,16 @@ class Checkout {
$this->auto_submittable_field = $this->contains_auto_submittable_field($this->step['fields']);
$this->step['fields'] = wu_create_checkout_fields($this->step['fields']);
-
- } // end if;
+ }
if (is_user_logged_in()) {
-
$_REQUEST['user_id'] = get_current_user_id();
-
- } // end if;
+ }
$this->already_setup = true;
wu_no_cache(); // Prevent the registration page from being cached.
-
- } // end setup_checkout;
+ }
/**
* Checks if a list of fields has an auto-submittable field.
@@ -440,45 +415,34 @@ class Checkout {
'products',
'submit_button',
'period_selection',
- 'steps'
+ 'steps',
);
// Extra check to prevent error messages from being displayed.
- if (!is_array($fields)) {
-
+ if ( ! is_array($fields)) {
$fields = array();
-
- } // end if;
+ }
foreach ($fields as $field) {
-
if (in_array($field['type'], $field_types_to_ignore, true)) {
-
continue;
-
- } // end if;
+ }
$relevant_fields[] = $field;
if (count($relevant_fields) > 1) {
-
return false;
+ }
+ }
- } // end if;
-
- } // end foreach;
-
- if (!$relevant_fields) {
-
+ if ( ! $relevant_fields) {
return false;
-
- } // end if;
+ }
$auto_submittable_field = $relevant_fields[0]['type'];
return wu_get_isset($this->get_auto_submittable_fields(), $auto_submittable_field, false);
-
- } // end contains_auto_submittable_field;
+ }
/**
* Returns a list of auto-submittable fields.
@@ -499,8 +463,7 @@ class Checkout {
);
return apply_filters('wu_checkout_get_auto_submittable_fields', $auto_submittable_fields, $this);
-
- } // end get_auto_submittable_fields;
+ }
/**
* Decides if we want to handle a step submission or a full checkout submission.
@@ -513,24 +476,17 @@ class Checkout {
$this->setup_checkout();
if ($this->is_last_step()) {
-
$this->handle_order_submission();
-
} else {
-
$validation = $this->validate();
if (is_wp_error($validation)) {
-
wp_send_json_error($validation);
-
- } // end if;
+ }
wp_send_json_success(array());
-
- } // end if;
-
- } // end maybe_handle_order_submission;
+ }
+ }
/**
* Validates the order submission, and then delegates the processing to the gateway.
@@ -571,28 +527,21 @@ class Checkout {
do_action('wu_after_handle_order_submission', $results, $this);
if (is_wp_error($results)) {
-
$this->errors = $results;
-
- } // end if;
-
+ }
} catch (\Throwable $e) {
-
wu_maybe_log_error($e);
$wpdb->query('ROLLBACK');
$this->errors = new \WP_Error('exception-order-submission', $e->getMessage(), $e->getTrace());
-
- } // end try;
+ }
if (is_wp_error($this->errors)) {
-
$wpdb->query('ROLLBACK');
wp_send_json_error($this->errors);
-
- } // end if;
+ }
$wpdb->query('COMMIT');
@@ -600,36 +549,35 @@ class Checkout {
$this->session->commit();
wp_send_json_success($results);
-
- } // end handle_order_submission;
- /**
- * Process an order.
- *
- * This method is responsible for
- * creating all the data elements we
- * need in order to actually process a
- * checkout.
- *
- * Those include:
- * - A customer;
- * - A pending payment;
- * - A membership.
- *
- * With those elements, we can then
- * delegate to the gateway to run their
- * own preparations (@see run_preflight).
- *
- * We then return everything to be added
- * to the front-end form. That data then
- * gets submitted with the rest of the form,
- * and eventually handled by process_checkout.
- *
- * @see process_checkout
- *
- * @since 2.0.0
- * @return mixed[]|\WP_Error
- */
- public function process_order() {
+ }
+ /**
+ * Process an order.
+ *
+ * This method is responsible for
+ * creating all the data elements we
+ * need in order to actually process a
+ * checkout.
+ *
+ * Those include:
+ * - A customer;
+ * - A pending payment;
+ * - A membership.
+ *
+ * With those elements, we can then
+ * delegate to the gateway to run their
+ * own preparations (@see run_preflight).
+ *
+ * We then return everything to be added
+ * to the front-end form. That data then
+ * gets submitted with the rest of the form,
+ * and eventually handled by process_checkout.
+ *
+ * @see process_checkout
+ *
+ * @since 2.0.0
+ * @return mixed[]|\WP_Error
+ */
+ public function process_order() {
global $current_site, $wpdb;
@@ -638,19 +586,25 @@ class Checkout {
* We need to take into consideration the date we receive from
* the form submission.
*/
- $cart = new Cart(apply_filters('wu_cart_parameters', array(
- 'products' => $this->request_or_session('products', array()),
- 'discount_code' => $this->request_or_session('discount_code'),
- 'country' => $this->request_or_session('billing_country'),
- 'state' => $this->request_or_session('billing_state'),
- 'city' => $this->request_or_session('billing_city'),
- 'membership_id' => $this->request_or_session('membership_id'),
- 'payment_id' => $this->request_or_session('payment_id'),
- 'auto_renew' => $this->request_or_session('auto_renew', false),
- 'duration' => $this->request_or_session('duration'),
- 'duration_unit' => $this->request_or_session('duration_unit'),
- 'cart_type' => $this->request_or_session('cart_type', 'new'),
- ), $this));
+ $cart = new Cart(
+ apply_filters(
+ 'wu_cart_parameters',
+ array(
+ 'products' => $this->request_or_session('products', array()),
+ 'discount_code' => $this->request_or_session('discount_code'),
+ 'country' => $this->request_or_session('billing_country'),
+ 'state' => $this->request_or_session('billing_state'),
+ 'city' => $this->request_or_session('billing_city'),
+ 'membership_id' => $this->request_or_session('membership_id'),
+ 'payment_id' => $this->request_or_session('payment_id'),
+ 'auto_renew' => $this->request_or_session('auto_renew', false),
+ 'duration' => $this->request_or_session('duration'),
+ 'duration_unit' => $this->request_or_session('duration_unit'),
+ 'cart_type' => $this->request_or_session('cart_type', 'new'),
+ ),
+ $this
+ )
+ );
/*
* Check if our order is valid.
@@ -659,10 +613,8 @@ class Checkout {
* cart setup issues, as well as
*/
if ($cart->is_valid() === false) {
-
return $cart->get_errors();
-
- } // end if;
+ }
/*
* Update the checkout type
@@ -690,30 +642,20 @@ class Checkout {
* That's what's we checking on the else case.
*/
if ($cart->should_collect_payment() === false) {
-
$gateway = wu_get_gateway('free');
+ } elseif ( ! $gateway || $gateway->get_id() === 'free') {
+ $this->errors = new \WP_Error('no-gateway', __('Payment gateway not registered.', 'wp-ultimo'));
- } else {
-
- if (!$gateway || $gateway->get_id() === 'free') {
-
- $this->errors = new \WP_Error('no-gateway', __('Payment gateway not registered.', 'wp-ultimo'));
-
- return false;
-
- } // end if;
-
- } // end if;
+ return false;
+ }
/*
* If we do not have a gateway object,
* we need to bail.
*/
- if (!$gateway) {
-
+ if ( ! $gateway) {
return new \WP_Error('no-gateway', __('Payment gateway not registered.', 'wp-ultimo'));
-
- } // end if;
+ }
$this->gateway_id = $gateway->get_id();
@@ -729,10 +671,8 @@ class Checkout {
* Bail on error.
*/
if (is_wp_error($validation)) {
-
return $validation;
-
- } // end if;
+ }
/*
* From now on, logic can be delegated to
@@ -760,10 +700,8 @@ class Checkout {
* a new customer or retrieve an existing one.
*/
if (is_wp_error($this->customer)) {
-
return $this->customer;
-
- } // end if;
+ }
/*
* Next, we need to create a membership.
@@ -780,10 +718,8 @@ class Checkout {
* a new membership or retrieve an existing one.
*/
if (is_wp_error($this->membership)) {
-
return $this->membership;
-
- } // end if;
+ }
/*
* Next step: maybe create a site.
@@ -799,10 +735,8 @@ class Checkout {
* in here for now but completeness dictates I add this.
*/
if (is_wp_error($this->pending_site)) {
-
return $this->pending_site;
-
- } // end if;
+ }
/*
* Next, we need to create a payment.
@@ -819,10 +753,8 @@ class Checkout {
* a new payment or retrieve an existing one.
*/
if (is_wp_error($this->payment)) {
-
return $this->payment;
-
- } // end if;
+ }
/**
* Keep the cart used in checkout for later reference.
@@ -847,15 +779,13 @@ class Checkout {
* let's check if the user is logged in,
* and if not, let's do that.
*/
- if (!is_user_logged_in()) {
-
+ if ( ! is_user_logged_in()) {
wp_clear_auth_cookie();
wp_set_current_user($this->customer->get_user_id());
wp_set_auth_cookie($this->customer->get_user_id());
-
- } // end if;
+ }
/*
* Action time.
@@ -868,15 +798,12 @@ class Checkout {
/*
* Checks for free memberships.
*/
- if ($this->order->is_free() && $this->order->get_recurring_total() === 0.0 && (!wu_get_setting('enable_email_verification', true) || $this->customer->get_email_verification() !== 'pending')) {
-
+ if ($this->order->is_free() && $this->order->get_recurring_total() === 0.0 && (! wu_get_setting('enable_email_verification', true) || $this->customer->get_email_verification() !== 'pending')) {
if ($this->order->get_plan_id() === $this->membership->get_plan_id()) {
-
$this->membership->set_status(Membership_Status::ACTIVE);
$this->membership->save();
-
- } // end if;
+ }
/**
* Trigger payment received manually.
@@ -884,21 +811,18 @@ class Checkout {
* @since 2.0.10
*/
$gateway->trigger_payment_processed($this->payment, $this->membership);
-
} elseif ($this->order->has_trial()) {
-
$this->membership->set_date_trial_end(gmdate('Y-m-d 23:59:59', $this->order->get_billing_start_date()));
$this->membership->set_date_expiration(gmdate('Y-m-d 23:59:59', $this->order->get_billing_start_date()));
- if (wu_get_setting('allow_trial_without_payment_method') && (!wu_get_setting('enable_email_verification', true) || $this->customer->get_email_verification() !== 'pending')) {
+ if (wu_get_setting('allow_trial_without_payment_method') && (! wu_get_setting('enable_email_verification', true) || $this->customer->get_email_verification() !== 'pending')) {
/*
* In this particular case, we need to set the status to trialing here as we will not update the membership after and then, publish the site.
*/
$this->membership->set_status(Membership_Status::TRIALING);
$this->membership->publish_pending_site_async();
-
- } // end if;
+ }
$this->membership->save();
@@ -908,8 +832,7 @@ class Checkout {
* @since 2.0.10
*/
$gateway->trigger_payment_processed($this->payment, $this->membership);
-
- } // end if;
+ }
$success_data = array(
'nonce' => wp_create_nonce('wp-ultimo-register-nonce'),
@@ -945,18 +868,13 @@ class Checkout {
* On error, bail.
*/
if (is_wp_error($result)) {
-
return $result;
-
- } // end if;
-
+ }
} catch (\Throwable $e) {
+ wu_maybe_log_error($e);
- wu_maybe_log_error($e);
-
- return new \WP_Error('exception', $e->getMessage(), $e->getTrace());
-
- } // end try;
+ return new \WP_Error('exception', $e->getMessage(), $e->getTrace());
+ }
/**
* Allow developers to triggers additional hooks.
@@ -973,15 +891,14 @@ class Checkout {
* All set!
*/
return $success_data;
-
- } // end process_order;
- /**
- * Checks if a customer exists, otherwise, creates a new one.
- *
- * @since 2.0.0
- * @return \WP_Ultimo\Models\Customer|\WP_Error
- */
- protected function maybe_create_customer() {
+ }
+ /**
+ * Checks if a customer exists, otherwise, creates a new one.
+ *
+ * @since 2.0.0
+ * @return \WP_Ultimo\Models\Customer|\WP_Error
+ */
+ protected function maybe_create_customer() {
/*
* Check if we have
* a customer for the current user.
@@ -1002,26 +919,21 @@ class Checkout {
* and that happens at the end of this method.
*/
if (empty($customer)) {
-
$username = $this->request_or_session('username');
/*
* Handles auto-generation based on the email address.
*/
if ($this->request_or_session('auto_generate_username') === 'email') {
-
$username = wu_username_from_email($this->request_or_session('email_address'));
/*
* Case where the site title is also auto-generated, based on the username.
*/
if ($this->request_or_session('auto_generate_site_title') && $this->request_or_session('site_title', '') === '') {
-
$_REQUEST['site_title'] = $username;
-
- } // end if;
-
- } // end if;
+ }
+ }
/*
* If we get to this point,
@@ -1043,17 +955,13 @@ class Checkout {
* we use the existing email address to create the customer.
*/
if ($this->is_existing_user()) {
-
$customer_data = array(
'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'));
-
- } // end if;
+ }
/*
* Tries to create it.
@@ -1064,12 +972,9 @@ class Checkout {
* Something failed, bail.
*/
if (is_wp_error($customer)) {
-
return $customer;
-
- } // end if;
-
- } // end if;
+ }
+ }
/*
* Updates IP, and country
@@ -1101,10 +1006,8 @@ class Checkout {
* bail with the errors.
*/
if (is_wp_error($valid_address)) {
-
return $valid_address;
-
- } // end if;
+ }
$customer->set_billing_address($billing_address);
@@ -1114,11 +1017,9 @@ class Checkout {
* This should rarely happen, but if something goes
* wrong with the customer update, we return a general error.
*/
- if (!$address_saved) {
-
+ if ( ! $address_saved) {
return new \WP_Error('address_failure', __('Something wrong happened while attempting to save the customer billing address', 'wp-ultimo'));
-
- } // end if;
+ }
/*
* Handle meta fields.
@@ -1145,8 +1046,7 @@ class Checkout {
* Otherwise, get the customer back.
*/
return $customer;
-
- } // end maybe_create_customer;
+ }
/**
* Save meta data related to customers.
@@ -1160,15 +1060,12 @@ class Checkout {
protected function handle_customer_meta_fields($customer, $form_slug) {
if (empty($form_slug) || $form_slug === 'none') {
-
return;
-
- } // end if;
+ }
$checkout_form = wu_get_checkout_form_by_slug($form_slug);
if ($checkout_form) {
-
$customer_meta_fields = $checkout_form->get_all_meta_fields('customer_meta');
$meta_repository = array();
@@ -1178,7 +1075,7 @@ class Checkout {
* Adds to the repository so we can save it again.
* in filters, if we need be.
*/
- $meta_repository[$customer_meta_field['id']] = $this->request_or_session($customer_meta_field['id']);
+ $meta_repository[ $customer_meta_field['id'] ] = $this->request_or_session($customer_meta_field['id']);
wu_update_customer_meta(
$customer->get_id(),
@@ -1187,8 +1084,7 @@ class Checkout {
$customer_meta_field['type'],
$customer_meta_field['name']
);
-
- } // end foreach;
+ }
/**
* Allow plugin developers to save meta
@@ -1217,11 +1113,10 @@ class Checkout {
* Adds to the repository so we can save it again.
* in filters, if we need be.
*/
- $user_meta_repository[$user_meta_field['id']] = $this->request_or_session($user_meta_field['id']);
+ $user_meta_repository[ $user_meta_field['id'] ] = $this->request_or_session($user_meta_field['id']);
update_user_meta($customer->get_user_id(), $user_meta_field['id'], $this->request_or_session($user_meta_field['id']));
-
- } // end foreach;
+ }
/**
* Allow plugin developers to save user meta
@@ -1234,26 +1129,22 @@ class Checkout {
* @param Checkout $this The checkout class.
*/
do_action('wu_handle_user_meta_fields', $user_meta_repository, $user, $customer, $this);
-
- } // end if;
-
- } // end handle_customer_meta_fields;
- /**
- * Checks if a membership exists, otherwise, creates a new one.
- *
- * @since 2.0.0
- * @return \WP_Ultimo\Models\Membership|\WP_Error
- */
- protected function maybe_create_membership() {
+ }
+ }
+ /**
+ * Checks if a membership exists, otherwise, creates a new one.
+ *
+ * @since 2.0.0
+ * @return \WP_Ultimo\Models\Membership|\WP_Error
+ */
+ protected function maybe_create_membership() {
/*
* The first thing we'll do is check the cart
* to see if a membership was passed.
*/
if ($this->order->get_membership()) {
-
return $this->order->get_membership();
-
- } // end if;
+ }
/*
* If that's not the case,
@@ -1284,22 +1175,19 @@ class Checkout {
$discount_code = $this->order->get_discount_code();
if ($discount_code) {
-
$membership->set_discount_code($discount_code);
$membership->save();
-
- } // end if;
+ }
return $membership;
-
- } // end maybe_create_membership;
- /**
- * Checks if a pending site exists, otherwise, creates a new one.
- *
- * @since 2.0.0
- * @return bool|\WP_Ultimo\Models\Site|\WP_Error
- */
- protected function maybe_create_site() {
+ }
+ /**
+ * Checks if a pending site exists, otherwise, creates a new one.
+ *
+ * @since 2.0.0
+ * @return bool|\WP_Ultimo\Models\Site|\WP_Error
+ */
+ protected function maybe_create_site() {
/*
* Let's get a list of membership sites.
* This list includes pending sites as well.
@@ -1317,28 +1205,25 @@ class Checkout {
* The get_sites method already includes pending sites,
* so we can safely rely on it.
*/
- if (!empty($sites)) {
+ if ( ! empty($sites)) {
/*
* Returns the first site on that list.
* This is not ideal, but since we'll usually only have
* one site here, it's ok. for now.
*/
return current($sites);
-
- } // end if;
+ }
$site_url = $this->request_or_session('site_url');
$site_title = $this->request_or_session('site_title');
- if (!$site_url && !$site_title) {
-
+ if ( ! $site_url && ! $site_title) {
return false;
-
- } // end if;
+ }
$auto_generate_url = $this->request_or_session('auto_generate_site_url');
- $site_title = !$site_title && !$auto_generate_url ? $site_url : $site_title;
+ $site_title = ! $site_title && ! $auto_generate_url ? $site_url : $site_title;
/*
* Let's handle auto-generation of site URLs.
@@ -1351,34 +1236,26 @@ class Checkout {
* check if it is already taken.
*/
if (empty($site_url) || $auto_generate_url === 'username') {
-
if ($auto_generate_url === 'username') {
-
$site_url = $this->customer->get_username();
$site_title = $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)))));
-
- } // end if;
+ }
$d = wu_get_site_domain_and_path($site_url, $this->request_or_session('site_domain'));
$n = 0;
while (domain_exists($d->domain, $d->path)) {
-
- $n++;
+ ++$n;
$site_url = $this->customer->get_username() . $n;
$d = wu_get_site_domain_and_path($site_url, $this->request_or_session('site_domain'));
-
- } // end while;
-
- } // end if;
+ }
+ }
$d = wu_get_site_domain_and_path($site_url, $this->request_or_session('site_domain'));
@@ -1388,10 +1265,8 @@ class Checkout {
$results = wpmu_validate_blog_signup($site_url, $site_title, $this->customer->get_user());
if ($results['errors']->has_errors()) {
-
return $results['errors'];
-
- } // end if;
+ }
/*
* Get the form slug to save with the customer.
@@ -1406,7 +1281,6 @@ class Checkout {
$transient = array();
if ($this->checkout_form) {
-
$site_meta_fields = $this->checkout_form->get_all_fields();
foreach ($site_meta_fields as $site_meta_field) {
@@ -1416,16 +1290,12 @@ class Checkout {
* on the database.
*/
if (strpos((string) $site_meta_field['id'], 'password') !== false ) {
-
continue;
+ }
- } // end if;
-
- $transient[$site_meta_field['id']] = $this->request_or_session($site_meta_field['id']);
-
- } // end foreach;
-
- } // end if;
+ $transient[ $site_meta_field['id'] ] = $this->request_or_session($site_meta_field['id']);
+ }
+ }
/*
* Gets the template id from the request.
@@ -1456,8 +1326,7 @@ class Checkout {
$pending_site = $this->membership->create_pending_site($site_data);
return $pending_site;
-
- } // end maybe_create_site;
+ }
/**
* Gets list of site meta data.
@@ -1471,37 +1340,30 @@ class Checkout {
protected function get_site_meta_fields($form_slug, $meta_type = 'site_meta') {
if (empty($form_slug) || $form_slug === 'none') {
-
return array();
-
- } // end if;
+ }
$checkout_form = wu_get_checkout_form_by_slug($form_slug);
$list = array();
if ($checkout_form) {
-
$site_meta_fields = $checkout_form->get_all_meta_fields($meta_type);
foreach ($site_meta_fields as $site_meta_field) {
-
- $list[$site_meta_field['id']] = $this->request_or_session($site_meta_field['id']);
-
- } // end foreach;
-
- } // end if;
+ $list[ $site_meta_field['id'] ] = $this->request_or_session($site_meta_field['id']);
+ }
+ }
return $list;
-
- } // end get_site_meta_fields;
- /**
- * Checks if a pending payment exists, otherwise, creates a new one.
- *
- * @since 2.0.0
- * @return \WP_Ultimo\Models\Payment|\WP_Error
- */
- protected function maybe_create_payment() {
+ }
+ /**
+ * Checks if a pending payment exists, otherwise, creates a new one.
+ *
+ * @since 2.0.0
+ * @return \WP_Ultimo\Models\Payment|\WP_Error
+ */
+ protected function maybe_create_payment() {
/*
* The first thing we'll do is check the cart
* to see if a payment was passed.
@@ -1513,15 +1375,12 @@ class Checkout {
* Set the gateway in existing payment
*/
if ($payment->get_gateway() !== $this->gateway_id) {
-
$payment->set_gateway($this->gateway_id);
$payment->save();
-
- } // end if;
+ }
return $this->order->get_payment();
-
- } // end if;
+ }
/*
* The membership might have a previous payment.
@@ -1537,7 +1396,6 @@ class Checkout {
);
if ($previous_payment && in_array($this->type, $cancel_types, true)) {
-
$previous_payment->set_status(Payment_Status::CANCELLED);
/*
@@ -1546,8 +1404,7 @@ class Checkout {
* were able to cancel the previous payment or not.
*/
$previous_payment->save();
-
- } // end if;
+ }
/*
* If that's not the case,
@@ -1572,11 +1429,9 @@ class Checkout {
* to handle the status here as the payment is not
* passed to process_checkout method in this case.
*/
- if (!$this->order->should_collect_payment() && $this->type === 'downgrade') {
-
+ if ( ! $this->order->should_collect_payment() && $this->type === 'downgrade') {
$payment_data['status'] = Payment_Status::COMPLETED;
-
- } // end if;
+ }
/*
* Create new payment.
@@ -1588,21 +1443,20 @@ class Checkout {
* we need to set the payment value to zero.
*/
if ($this->order->has_trial()) {
-
- $payment->attributes(array(
- 'tax_total' => 0,
- 'subtotal' => 0,
- 'refund_total' => 0,
- 'total' => 0,
- ));
+ $payment->attributes(
+ array(
+ 'tax_total' => 0,
+ 'subtotal' => 0,
+ 'refund_total' => 0,
+ 'total' => 0,
+ )
+ );
$payment->save();
-
- } // end if;
+ }
return $payment;
-
- } // end maybe_create_payment;
+ }
/**
* Validates the checkout form to see if it's valid por not.
@@ -1615,14 +1469,11 @@ class Checkout {
$validation = $this->validate();
if (is_wp_error($validation)) {
-
wp_send_json_error($validation);
-
- } // end if;
+ }
wp_send_json_success();
-
- } // end validate_form;
+ }
/**
* Creates an order object to display the order summary tables.
@@ -1635,23 +1486,29 @@ class Checkout {
$this->setup_checkout();
// Set billing address to be used on the order
- $country = !empty($this->request_or_session('country')) ? $this->request_or_session('country') : $this->request_or_session('billing_country', '');
- $state = !empty($this->request_or_session('state')) ? $this->request_or_session('state') : $this->request_or_session('billing_state', '');
- $city = !empty($this->request_or_session('city')) ? $this->request_or_session('city') : $this->request_or_session('billing_city', '');
+ $country = ! empty($this->request_or_session('country')) ? $this->request_or_session('country') : $this->request_or_session('billing_country', '');
+ $state = ! empty($this->request_or_session('state')) ? $this->request_or_session('state') : $this->request_or_session('billing_state', '');
+ $city = ! empty($this->request_or_session('city')) ? $this->request_or_session('city') : $this->request_or_session('billing_city', '');
- $cart = new Cart(apply_filters('wu_cart_parameters', array(
- 'products' => $this->request_or_session('products', array()),
- 'discount_code' => $this->request_or_session('discount_code'),
- 'country' => $country,
- 'state' => $state,
- 'city' => $city,
- 'membership_id' => $this->request_or_session('membership_id'),
- 'payment_id' => $this->request_or_session('payment_id'),
- 'auto_renew' => $this->request_or_session('auto_renew', false),
- 'duration' => $this->request_or_session('duration'),
- 'duration_unit' => $this->request_or_session('duration_unit'),
- 'cart_type' => $this->request_or_session('cart_type', 'new'),
- ), $this));
+ $cart = new Cart(
+ apply_filters(
+ 'wu_cart_parameters',
+ array(
+ 'products' => $this->request_or_session('products', array()),
+ 'discount_code' => $this->request_or_session('discount_code'),
+ 'country' => $country,
+ 'state' => $state,
+ 'city' => $city,
+ 'membership_id' => $this->request_or_session('membership_id'),
+ 'payment_id' => $this->request_or_session('payment_id'),
+ 'auto_renew' => $this->request_or_session('auto_renew', false),
+ 'duration' => $this->request_or_session('duration'),
+ 'duration_unit' => $this->request_or_session('duration_unit'),
+ 'cart_type' => $this->request_or_session('cart_type', 'new'),
+ ),
+ $this
+ )
+ );
/**
* Calculate state and city options, if necessary.
@@ -1660,17 +1517,18 @@ 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(
- 'state_field' => $country_data->get_administrative_division_name(null, true),
- 'city_field' => $country_data->get_municipality_name(null, true),
- ),
- ));
-
- } // end create_order;
+ 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(
+ 'state_field' => $country_data->get_administrative_division_name(null, true),
+ 'city_field' => $country_data->get_municipality_name(null, true),
+ ),
+ )
+ );
+ }
/**
* Returns the checkout variables.
@@ -1705,31 +1563,21 @@ class Checkout {
// If duration is not set we check for a previous period_selection field in form to use;
if (empty($duration) && $this->steps) {
-
foreach ($this->steps as $step) {
-
foreach ($step['fields'] as $field) {
-
if ($field['type'] === 'period_selection') {
-
$duration = $field['period_options'][0]['duration'];
$duration_unit = $field['period_options'][0]['duration_unit'];
break;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
if ($duration) {
-
break;
-
- } // end if;
-
- } // end foreach;
-
- } // end if;
+ }
+ }
+ }
$products = array_merge($this->request_or_session('products', array()), wu_request('products', array()));
@@ -1776,10 +1624,8 @@ class Checkout {
* a retry.
*/
if ($payment_id) {
-
$variables['payment_id'] = $payment_id;
-
- } // end if;
+ }
/*
* The next case we need to take care of
@@ -1802,10 +1648,8 @@ class Checkout {
* a retry.
*/
if ($membership_id) {
-
$variables['membership_id'] = $membership_id;
-
- } // end if;
+ }
list($plan, $other_products) = wu_segregate_products($variables['products']);
@@ -1835,8 +1679,7 @@ class Checkout {
* @return array The new variables array.
*/
return apply_filters('wu_get_checkout_variables', $variables, $this);
-
- } // end get_checkout_variables;
+ }
/**
* Returns the validation rules for the fields.
@@ -1880,12 +1723,10 @@ class Checkout {
// char limit according https://datatracker.ietf.org/doc/html/rfc1034#section-3.1
$rules['site_title'] = 'min:4';
$rules['site_url'] = 'min:3|max:63|lowercase|unique_site';
-
- } // end if;
+ }
return apply_filters('wu_checkout_validation_rules', $rules, $this);
-
- } // end validation_rules;
+ }
/**
* Returns the list of validation rules.
@@ -1904,29 +1745,23 @@ class Checkout {
$validation_rules = $this->validation_rules();
if (wu_request('pre-flight') || wu_request('checkout_form') === 'wu-finish-checkout') {
-
$validation_rules = array();
return $validation_rules;
-
- } // end if;
+ }
if ($this->step_name && $this->is_last_step() === false) {
-
$fields_available = array_column($this->step['fields'], 'id');
/*
* Re-adds the template id check
*/
if (wu_request('template_id', null) !== null) {
-
$fields_available[] = 'template_id';
-
- } // end if;
+ }
$validation_rules = array_filter($validation_rules, fn($rule) => in_array($rule, $fields_available, true), ARRAY_FILTER_USE_KEY);
-
- } // end if;
+ }
// We'll use this to validate product fields
$product_fields = array(
@@ -1942,29 +1777,20 @@ class Checkout {
* General required fields
*/
if (wu_get_isset($field, 'required') && wu_get_isset($field, 'id')) {
-
- if (isset($validation_rules[$field['id']])) {
-
- $validation_rules[$field['id']] .= '|required';
-
+ if (isset($validation_rules[ $field['id'] ])) {
+ $validation_rules[ $field['id'] ] .= '|required';
} else {
-
- $validation_rules[$field['id']] = 'required';
-
- } // end if;
-
- } // end if;
+ $validation_rules[ $field['id'] ] = 'required';
+ }
+ }
/*
* Product fields
*/
if (wu_get_isset($field, 'id') && in_array($field['id'], $product_fields, true)) {
-
$validation_rules['products'] = 'products|required';
-
- } // end if;
-
- } // end foreach;
+ }
+ }
/**
* Allow plugin developers to filter the validation rules.
@@ -1974,8 +1800,7 @@ class Checkout {
* @param Checkout $this The checkout class.
*/
return apply_filters('wu_checkout_validation_rules', $validation_rules, $this);
-
- } // end get_validation_rules;
+ }
/**
* Validates the rules and make sure we only save models when necessary.
@@ -1986,23 +1811,19 @@ class Checkout {
*/
public function validate($rules = null) {
- $validator = new \WP_Ultimo\Helpers\Validator;
+ $validator = new \WP_Ultimo\Helpers\Validator();
$session = $this->session->get('signup');
$stack = $_REQUEST;
if (is_array($session)) {
-
$stack = array_merge($session, $_REQUEST);
-
- } // end if;
+ }
if ($rules === null) {
-
$rules = $this->get_validation_rules();
-
- } // end if;
+ }
$base_aliases = array();
@@ -2010,26 +1831,25 @@ class Checkout {
// Add current form fields
foreach ($checkout_form_fields as $field) {
-
- $base_aliases[$field['id']] = wu_get_isset($field, 'name', '');
-
- } // end foreach;
+ $base_aliases[ $field['id'] ] = wu_get_isset($field, 'name', '');
+ }
// Add Billing Address fields
foreach (Billing_Address::fields() as $field_key => $field) {
-
- $base_aliases[$field_key] = wu_get_isset($field, 'title', '');
-
- } // end foreach;
+ $base_aliases[ $field_key ] = wu_get_isset($field, 'title', '');
+ }
// 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);
+ $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
+ );
/**
* Allow plugin developers to add custom aliases in form validator.
@@ -2043,18 +1863,15 @@ class Checkout {
$validator->validate($stack, $rules, $validation_aliases);
if ($validator->fails()) {
-
$errors = $validator->get_errors();
$errors->remove('valid_password');
return $errors;
-
- } // end if;
+ }
return true;
-
- } // end validate;
+ }
/**
* Decides if we are to process a checkout.
@@ -2080,11 +1897,9 @@ class Checkout {
* We can only process a checkout
* if certain conditions are met.
*/
- if (!$this->should_process_checkout()) {
-
+ if ( ! $this->should_process_checkout()) {
return;
-
- } // end if;
+ }
/*
* Checks if we are in the last step.
@@ -2112,7 +1927,6 @@ class Checkout {
* arg so the customer can try again.
*/
if (is_wp_error($results)) {
-
$redirect_url = wu_get_current_url();
$this->session->set('errors', $results);
@@ -2129,13 +1943,14 @@ class Checkout {
* to a try again page.
*/
if ($payment) {
-
- $redirect_url = add_query_arg(array(
- 'payment' => $payment->get_hash(),
- 'status' => 'error',
- ), $redirect_url);
-
- } // end if;
+ $redirect_url = add_query_arg(
+ array(
+ 'payment' => $payment->get_hash(),
+ 'status' => 'error',
+ ),
+ $redirect_url
+ );
+ }
/*
* Redirect go burrr!
@@ -2143,14 +1958,13 @@ class Checkout {
wp_redirect($redirect_url);
exit;
+ }
- } // end if;
-
- /*
- * This is not the final step,
- * so we just clean the data and save it
- * for later.
- */
+ /*
+ * This is not the final step,
+ * so we just clean the data and save it
+ * for later.
+ */
} else {
/*
* Cleans data and add it to the session.
@@ -2162,11 +1976,9 @@ class Checkout {
$to_save = array_filter($_POST, fn($item) => strncmp((string) $item, 'checkout_', strlen('checkout_')) !== 0 && strncmp((string) $item, '_', strlen('_')) !== 0, 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));
-
- } // end if;
+ }
/*
* Append the cleaned date to the
@@ -2179,7 +1991,7 @@ class Checkout {
* Whether we should advance to the next step.
* This prevents breaking the checkout flow when triggered from a shortcode page.
*/
- if (!wu_request('pre-flight')) {
+ if ( ! wu_request('pre-flight')) {
/*
* Go to the next step.
*/
@@ -2188,12 +2000,9 @@ class Checkout {
wp_redirect(add_query_arg('step', $next_step));
exit;
-
- } // end if;
-
- } // end if;
-
- } // end maybe_process_checkout;
+ }
+ }
+ }
/**
* Runs pre-checks to see if we should process the checkout.
@@ -2203,9 +2012,8 @@ class Checkout {
*/
public function should_process_checkout() {
- return wu_request('checkout_action') === 'wu_checkout' && !wp_doing_ajax();
-
- } // end should_process_checkout;
+ return wu_request('checkout_action') === 'wu_checkout' && ! wp_doing_ajax();
+ }
/**
* Handles the checkout submission.
@@ -2251,32 +2059,20 @@ class Checkout {
* That's what's we checking on the else case.
*/
if ($payment->get_status() === Payment_Status::COMPLETED) {
-
$gateway = wu_get_gateway($payment->get_gateway());
-
} elseif ($this->order->should_collect_payment() === false) {
-
$gateway = wu_get_gateway('free');
-
- } else {
-
- if ($gateway->get_id() === 'free') {
-
+ } elseif ($gateway->get_id() === 'free') {
$this->errors = new \WP_Error('no-gateway', __('Payment gateway not registered.', 'wp-ultimo'));
return false;
+ }
- } // end if;
-
- } // end if;
-
- if (!$gateway) {
-
+ if ( ! $gateway) {
$this->errors = new \WP_Error('no-gateway', __('Payment gateway not registered.', 'wp-ultimo'));
return false;
-
- } // end if;
+ }
/*
* Set the gateway data.
@@ -2307,10 +2103,8 @@ class Checkout {
* In that case, we simply return.
*/
if ($status === false) {
-
return;
-
- } // end if;
+ }
/*
* Run after every checkout processing.
@@ -2323,7 +2117,6 @@ class Checkout {
* Deprecated hook for registration.
*/
if (has_action('wp_ultimo_registration')) {
-
$_payment = wu_get_payment($payment->get_id());
$args = array(
@@ -2338,8 +2131,7 @@ class Checkout {
do_action_deprecated('wp_ultimo_registration', $args, '2.0.0');
ob_flush();
-
- } // end if;
+ }
/*
* Otherwise, we redirect
@@ -2348,7 +2140,7 @@ class Checkout {
*/
$redirect_url = $gateway->get_return_url();
- if (!is_admin()) {
+ if ( ! is_admin()) {
/**
* Set the redirect URL.
*
@@ -2359,19 +2151,19 @@ 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);
-
- } // end if;
+ $redirect_url = add_query_arg(
+ array(
+ 'payment' => $payment ? $payment->get_hash() : 'none',
+ 'status' => 'done',
+ ),
+ $redirect_url
+ );
+ }
wp_redirect($redirect_url);
exit;
-
} catch (\Throwable $e) {
-
$membership_id = $this->order->get_membership() ? $this->order->get_membership()->get_id() : 'unknown';
$log_message = sprintf(__('Checkout failed for customer %s: ', 'wp-ultimo'), $membership_id);
@@ -2379,14 +2171,16 @@ class Checkout {
wu_log_add('checkout', $log_message, LogLevel::ERROR);
- return new \WP_Error('error', $e->getMessage(), array(
- 'trace' => $e->getTrace(),
- 'payment' => $payment,
- ));
-
- } // end try;
-
- } // end process_checkout;
+ return new \WP_Error(
+ 'error',
+ $e->getMessage(),
+ array(
+ 'trace' => $e->getTrace(),
+ 'payment' => $payment,
+ )
+ );
+ }
+ }
/**
* Handle user display names, if first and last names are available.
@@ -2403,14 +2197,11 @@ class Checkout {
$last_name = $this->request_or_session('last_name', '');
if ($first_name || $last_name) {
-
$display_name = trim("$first_name $last_name");
-
- } // end if;
+ }
return $display_name;
-
- } // end handle_display_name;
+ }
/*
* Helper methods
@@ -2429,8 +2220,7 @@ class Checkout {
public function get_thank_you_page() {
return wu_get_current_url();
-
- } // end get_thank_you_page;
+ }
/**
* Checks if the user already exists.
@@ -2441,8 +2231,7 @@ class Checkout {
public function is_existing_user() {
return is_user_logged_in();
-
- } // end is_existing_user;
+ }
/**
* Returns the customer email verification status we want to use depending on the type of checkout.
@@ -2455,8 +2244,7 @@ class Checkout {
$should_confirm_email = wu_get_setting('enable_email_verification', true);
return $this->order->should_collect_payment() === false && $should_confirm_email ? 'pending' : 'none';
-
- } // end get_customer_email_verification_status;
+ }
/**
* Adds the checkout scripts.
@@ -2481,8 +2269,7 @@ class Checkout {
wp_localize_script('wu-checkout', 'wu_checkout', $this->get_checkout_variables());
wp_enqueue_script('wu-checkout');
-
- } // end register_scripts;
+ }
/**
* Gets the info either from the request or session.
@@ -2502,22 +2289,17 @@ class Checkout {
$value = $default;
if ($this->session !== null) {
-
$session = $this->session->get('signup');
- if (isset($session[$key])) {
-
- $value = $session[$key];
-
- } // end if;
-
- } // end if;
+ if (isset($session[ $key ])) {
+ $value = $session[ $key ];
+ }
+ }
$value = wu_request($key, $value);
return $value;
-
- } // end request_or_session;
+ }
/**
* Returns the name of the next step on the flow.
@@ -2539,16 +2321,13 @@ class Checkout {
* so we need to set it to the first.
*/
if ($current_step_index === false) {
-
$current_step_index = 0;
-
- } // end if;
+ }
$index = $current_step_index + 1;
- return isset($keys[$index]) ? $keys[$index] : $keys[$current_step_index];
-
- } // end get_next_step_name;
+ return isset($keys[ $index ]) ? $keys[ $index ] : $keys[ $current_step_index ];
+ }
/**
* Checks if we are in the first step of the signup.
@@ -2561,14 +2340,11 @@ class Checkout {
$step_names = array_column($this->steps, 'id');
if (empty($step_names)) {
-
return true;
-
- } // end if;
+ }
return $this->step_name === array_shift($step_names);
-
- } // end is_first_step;
+ }
/**
* Checks if we are in the last step of the signup.
@@ -2596,22 +2372,17 @@ class Checkout {
* you need to add the ?pre-flight to the action URL.
*/
if (wu_request('pre-flight')) {
-
return false;
-
- } // end if;
+ }
$step_names = array_column($this->steps, 'id');
if (empty($step_names)) {
-
return true;
-
- } // end if;
+ }
return $this->step_name === array_pop($step_names);
-
- } // end is_last_step;
+ }
/**
* Decides if we should display errors on the checkout screen.
@@ -2622,11 +2393,7 @@ class Checkout {
public function maybe_display_checkout_errors() {
if (wu_request('status') !== 'error') {
-
return;
-
- } // end if;
-
- } // end maybe_display_checkout_errors;
-
-} // end class Checkout;
+ }
+ }
+}
diff --git a/inc/checkout/class-legacy-checkout.php b/inc/checkout/class-legacy-checkout.php
index 2f01fc3..20f48c8 100644
--- a/inc/checkout/class-legacy-checkout.php
+++ b/inc/checkout/class-legacy-checkout.php
@@ -111,7 +111,7 @@ class Legacy_Checkout {
// template assigned and return it's path
add_filter('template_include', array($this, 'view_legacy_template'));
- } // end init;
+ }
/**
* Adds our page templates to the page template dropdown.
@@ -127,11 +127,11 @@ class Legacy_Checkout {
$posts_templates = array_merge($posts_templates, $this->templates);
- } // end if;
+ }
return $posts_templates;
- } // end add_new_template;
+ }
/**
* Adds our template to the pages cache in order to trick WordPress
@@ -155,7 +155,7 @@ class Legacy_Checkout {
$templates = array();
- } // end if;
+ }
// New cache, therefore remove the old one
wp_cache_delete($cache_key, 'themes');
@@ -170,7 +170,7 @@ class Legacy_Checkout {
return $atts;
- } // end register_legacy_templates;
+ }
/**
* Checks if our custom template is assigned to the page and display it.
@@ -187,7 +187,7 @@ class Legacy_Checkout {
return $template;
- } // end if;
+ }
// Get global post
global $post, $signup;
@@ -197,7 +197,7 @@ class Legacy_Checkout {
return $template;
- } // end if;
+ }
$template_slug = get_post_meta($post->ID, '_wp_page_template', true);
@@ -206,7 +206,7 @@ class Legacy_Checkout {
return $template;
- } // end if;
+ }
$file = wu_path("views/legacy/signup/$template_slug");
@@ -215,12 +215,12 @@ class Legacy_Checkout {
return $file;
- } // end if;
+ }
// Return template
return $template;
- } // end view_legacy_template;
+ }
/**
* Loads the necessary scripts.
@@ -251,11 +251,11 @@ class Legacy_Checkout {
wp_enqueue_style('login');
- } // end if;
+ }
wp_enqueue_style('common');
- } // end register_scripts;
+ }
/**
* Adds the additional dynamic styles.
@@ -298,8 +298,7 @@ class Legacy_Checkout {
// phpcs:enable
return ob_get_clean();
-
- } // end get_legacy_dynamic_styles;
+ }
/**
* Checks if we should pre-fill checkout fields based on the request.
@@ -319,7 +318,6 @@ class Legacy_Checkout {
$page_name = isset($request['pagename']) ? $request['pagename'] : '';
if (strncmp((string) $page_name, $checkout_page_slug, strlen($checkout_page_slug)) === 0) {
-
$page = explode('/', (string) $page_name);
/**
@@ -328,24 +326,20 @@ class Legacy_Checkout {
* @todo needs to check for frequency and unit.
*/
if (isset($page[1])) {
-
$product_slug = $page[1];
$product = wu_get_product_by_slug($product_slug);
$this->product = $product;
-
- } // end if;
+ }
$request['pagename'] = $checkout_page_slug;
return $this->legacy_signup();
-
- } // end if;
+ }
return $request;
-
- } // end maybe_render_legacy_signup;
+ }
/**
* Renders the legacy checkout.
@@ -369,13 +363,15 @@ class Legacy_Checkout {
$this->handle_post();
- wu_get_template('legacy/signup/signup-main', array(
- 'signup' => $this,
- ));
+ wu_get_template(
+ 'legacy/signup/signup-main',
+ array(
+ 'signup' => $this,
+ )
+ );
exit;
-
- } // end legacy_signup;
+ }
/**
* Check Geolocation
@@ -391,16 +387,11 @@ class Legacy_Checkout {
$allowed_countries = wu_get_setting('allowed_countries');
if (isset($location['country']) && $location['country'] && $allowed_countries) {
-
- if (!in_array($location['country'], $allowed_countries, true)) {
-
+ if ( ! in_array($location['country'], $allowed_countries, true)) {
wp_die(apply_filters('wu_geolocation_error_message', __('Sorry. Our service is not allowed in your country.', 'wp-ultimo')));
-
- } // end if;
-
- } // end if;
-
- } // end check_geolocation;
+ }
+ }
+ }
/**
* Gets the info for the current step.
@@ -410,9 +401,8 @@ class Legacy_Checkout {
*/
protected function get_current_step_info() {
- return $this->steps[$this->step];
-
- } // end get_current_step_info;
+ return $this->steps[ $this->step ];
+ }
/**
* Handles a post submission.
@@ -433,23 +423,17 @@ class Legacy_Checkout {
/** Checks if the view has a handler of its own */
if (isset($current_step['handler']) && $current_step['handler']) {
-
$handler_function = $current_step['handler'];
-
} else {
-
$handler_function = array($this, 'default_save');
-
- } // end if;
+ }
/** Allows for handler rewrite */
$handler_function = apply_filters("wu_signup_step_handler_$this->step", $handler_function);
call_user_func($handler_function);
-
- } // end if;
-
- } // end handle_post;
+ }
+ }
/**
* The first invisible step, handles the creation of the transient saver
@@ -479,19 +463,16 @@ class Legacy_Checkout {
// Adds to the payload
$content['coupon'] = $_REQUEST['coupon'];
-
- } // end if;
+ }
/**
* Check if user came from a pricing select table
*/
if (isset($_REQUEST['plan_id']) && isset($_REQUEST['plan_freq']) && WU_Gateway::check_frequency($_REQUEST['plan_freq'])) {
-
$content['plan_id'] = $_REQUEST['plan_id'];
$content['plan_freq'] = $_REQUEST['plan_freq'];
$content['skip_plan'] = true;
-
- } // end if;
+ }
/**
* Check if we only have one plan and the skip_plan enabled
@@ -500,7 +481,6 @@ class Legacy_Checkout {
$plans = wu_get_plans();
if (wu_get_setting('skip_plan', false) && count($plans) === 1) {
-
$billing_frequency = wu_get_setting('default_pricing_option', 1);
$plan = reset($plans);
@@ -511,34 +491,29 @@ class Legacy_Checkout {
$content['skip_plan'] = true;
$_REQUEST['skip_plan'] = 1;
-
- } // end if;
+ }
/**
* Check if we are settings the template via the URL
- *
+ *
* @since 1.7.3
*/
if (isset($_REQUEST['template_id']) && wu_get_setting('allow_template')) {
// Check if the template is valid
- $site = new WU_Site_Template( $_REQUEST['template_id'] );
+ $site = new WU_Site_Template($_REQUEST['template_id']);
if ($site->is_template) {
-
$content['template'] = $_REQUEST['template_id'];
$content['skip_template_selection'] = true;
-
- } // end if;
-
- } // end if;
+ }
+ }
$this->session->set('form', $content);
/** Go to the next step */
$this->next_step();
-
- } // end begin_signup;
+ }
/**
* Check if the current page is a customizer page.
*/
@@ -547,18 +522,13 @@ class Legacy_Checkout {
$exclude_list = apply_filters('wu_replace_signup_urls_exclude', array('wu-signup-customizer-preview'));
foreach ($exclude_list as $replace_word) {
-
- if (isset($_GET[$replace_word])) {
-
+ if (isset($_GET[ $replace_word ])) {
return true;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
return false;
-
- } // end is_customizer;
+ }
/**
* Returns the first step of the signup process
@@ -570,16 +540,11 @@ class Legacy_Checkout {
$keys = array_keys($this->get_steps());
if (isset($keys[1])) {
-
return $keys[1];
-
} else {
-
return false;
-
- } // end if;
-
- } // end get_first_step;
+ }
+ }
/**
* Get the current step
@@ -592,14 +557,11 @@ class Legacy_Checkout {
// Always get the first step for the customizer //
if ($this->is_customizer()) {
-
$current_step = $this->get_first_step();
-
- } // end if;
+ }
return apply_filters('wu_current_step', $current_step);
-
- } // end get_current_step;
+ }
/**
* Includes the template for that particular step; If none is set (false), includes the default template
@@ -616,16 +578,12 @@ class Legacy_Checkout {
* Set the errors
*/
if ($this->results === null) {
-
- $this->results = array('errors' => new \WP_Error);
-
- } // end if;
+ $this->results = array('errors' => new \WP_Error());
+ }
if (empty($_POST)) {
-
$this->results = array_merge($this->results, $transient);
-
- } // end if;
+ }
/**
* Builds the array containing the available elements inside the template
@@ -633,37 +591,28 @@ class Legacy_Checkout {
$args = array(
'signup' => $this,
'transient' => $transient,
- 'fields' => isset($this->steps[$step]['fields']) ? $this->steps[$step]['fields'] : array(),
+ 'fields' => isset($this->steps[ $step ]['fields']) ? $this->steps[ $step ]['fields'] : array(),
'results' => $this->results,
);
/**
* Checks if anything is passed to the view element
*/
- if (isset($this->steps[$step]['view']) && $this->steps[$step]['view']) {
-
- wu_get_template('legacy/signup/steps/' . $this->steps[$step]['view'], $args);
-
+ if (isset($this->steps[ $step ]['view']) && $this->steps[ $step ]['view']) {
+ wu_get_template('legacy/signup/steps/' . $this->steps[ $step ]['view'], $args);
} else {
-
$found = locate_template("wp-ultimo/signup/steps/step-$step.php");
/**
* Let's try to locate a custom template on the user's theme. If it's there, we use it instead
*/
if ($found) {
-
wu_get_template("legacy/signup/steps/step-$step", $args);
-
} else {
-
wu_get_template('legacy/signup/steps/step-default', $args);
-
- } // end if;
-
- } // end if;
-
- } // end get_step_view;
+ }
+ }
+ }
/**
* Set and return the steps and fields of each step.
@@ -696,7 +645,6 @@ class Legacy_Checkout {
// We add template selection if this has template
if ($site_templates) {
-
$steps['template'] = array(
'name' => __('Template Selection', 'wp-ultimo'),
'desc' => __('Select the base template of your new site.', 'wp-ultimo'),
@@ -705,8 +653,7 @@ class Legacy_Checkout {
'handler' => false,
'core' => true,
);
-
- } // end if;
+ }
// Domain registering
$steps['domain'] = array(
@@ -716,40 +663,43 @@ class Legacy_Checkout {
'view' => false,
'order' => 30,
'core' => true,
- 'fields' => apply_filters('wu_signup_fields_domain', array(
- 'blog_title' => array(
- 'order' => 10,
- 'name' => apply_filters('wu_signup_site_title_label', __('Site Title', 'wp-ultimo')),
- 'type' => 'text',
- 'default' => '',
- 'placeholder' => '',
- '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(
- 'order' => 20,
- 'name' => apply_filters('wu_signup_site_url_label', __('URL', 'wp-ultimo')),
- 'type' => 'text',
- 'default' => '',
- 'placeholder' => '',
- '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(
- 'order' => 30,
- 'name' => __('Site URL Preview', 'wp-ultimo'),
- 'type' => 'html',
- 'content' => wu_get_template_contents('legacy/signup/steps/step-domain-url-preview'),
- ),
- 'submit' => array(
- 'order' => 100,
- 'type' => 'submit',
- 'name' => __('Continue to the next step', 'wp-ultimo'),
- 'core' => true,
- ),
- )),
+ 'fields' => apply_filters(
+ 'wu_signup_fields_domain',
+ array(
+ 'blog_title' => array(
+ 'order' => 10,
+ 'name' => apply_filters('wu_signup_site_title_label', __('Site Title', 'wp-ultimo')),
+ 'type' => 'text',
+ 'default' => '',
+ 'placeholder' => '',
+ '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(
+ 'order' => 20,
+ 'name' => apply_filters('wu_signup_site_url_label', __('URL', 'wp-ultimo')),
+ 'type' => 'text',
+ 'default' => '',
+ 'placeholder' => '',
+ '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(
+ 'order' => 30,
+ 'name' => __('Site URL Preview', 'wp-ultimo'),
+ 'type' => 'html',
+ 'content' => wu_get_template_contents('legacy/signup/steps/step-domain-url-preview'),
+ ),
+ 'submit' => array(
+ 'order' => 100,
+ 'type' => 'submit',
+ 'name' => __('Continue to the next step', 'wp-ultimo'),
+ 'core' => true,
+ ),
+ )
+ ),
);
/**
@@ -818,14 +768,14 @@ class Legacy_Checkout {
),
'attributes' => array(
'autocomplete' => 'nope',
- )
+ ),
),
- ); // end first account fields;
+ );
/**
* Check and Add Coupon Code Fields
- *
+ *
* @since 1.4.0
*/
// if (wu_get_setting('enable_coupon_codes', 'url_and_field') == 'url_and_field') {
@@ -851,7 +801,7 @@ class Legacy_Checkout {
// 'requires' => array('has_coupon' => true),
// 'core' => true,
// );
- // } // end if;
+ // }
// /**
// * Check and Add the Terms field
// * @since 1.0.4
@@ -864,7 +814,7 @@ class Legacy_Checkout {
// 'name' => sprintf(__('I agree with the Terms of Service', 'wp-ultimo'), $this->get_terms_url()),
// 'core' => true,
// );
- // } // end if;
+ // }
/**
* Submit Field
@@ -896,23 +846,23 @@ class Legacy_Checkout {
// Sorts each of the fields block
foreach ($steps as &$step) {
-
- $step = wp_parse_args($step, array(
- 'hidden' => false,
- ));
+ $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'));
-
- } // end if;
-
- } // end foreach;
+ }
+ }
/**
* Adds the hidden step now responsible for validating data entry and the actual account creation
- *
+ *
* @since 1.4.0
*/
$begin_signup = array(
@@ -928,7 +878,7 @@ class Legacy_Checkout {
/**
* Adds the hidden step now responsible for validating data entry and the actual account creation
- *
+ *
* @since 1.4.0
*/
$create_account = array(
@@ -949,25 +899,20 @@ class Legacy_Checkout {
/**
* Filter the hidden ones, if we need to...
- *
+ *
* @var array
*/
- if (!$include_hidden) {
-
- $steps = array_filter($steps, fn($step) => !(isset($step['hidden']) && $step['hidden']));
-
- } // end if;
+ if ( ! $include_hidden) {
+ $steps = array_filter($steps, fn($step) => ! (isset($step['hidden']) && $step['hidden']));
+ }
// If we need to add that
- if (!$this->has_plan_step()) {
-
+ if ( ! $this->has_plan_step()) {
unset($steps['plan']);
-
- } // end if;
+ }
return $steps;
-
- } // end get_steps;
+ }
/**
* Check the transient, and if it does not exists, throw fatal
@@ -978,32 +923,24 @@ class Legacy_Checkout {
public static function get_transient($die = true) {
if (self::is_customizer()) {
-
$transient = array(
'not-empty' => '',
);
-
} else {
-
$transient = wu_get_session('signup')->get('form');
-
- } // end if;
+ }
if ($die && empty($transient)) {
// wp_die(__('Try again', 'wp-ultimo'));
-
- } // end if;
+ }
if (is_null($transient)) {
-
return array();
-
- } // end if;
+ }
return $transient;
-
- } // end get_transient;
+ }
/**
* Update the transient data in out database
@@ -1015,8 +952,7 @@ class Legacy_Checkout {
$this->session->set('form', $transient);
$this->session->commit();
-
- } // end update_transient;
+ }
/**
* Checks transient data to see if the plan step is necessary
*/
@@ -1025,14 +961,11 @@ class Legacy_Checkout {
$transient = $this->get_transient();
if (isset($transient['skip_plan']) && isset($transient['plan_id']) && isset($transient['plan_freq'])) {
-
return false;
-
- } // end if;
+ }
return true;
-
- } // end has_plan_step;
+ }
/**
* Get the link for the next step
@@ -1044,57 +977,42 @@ class Legacy_Checkout {
// Add CS
if (isset($_GET['cs'])) {
-
$params['cs'] = $_GET['cs'];
-
- } // end if;
+ }
if (isset($_REQUEST['customized'])) {
-
$params['customized'] = $_REQUEST['customized'];
-
- } // end if;
+ }
if (isset($_REQUEST['skip_plan']) && $_REQUEST['skip_plan'] == 1) {
-
unset($this->steps['plan']);
unset($params['skip_plan']);
-
- } // end if;
+ }
if (isset($_REQUEST['template_id'])) {
-
$plan = false;
if (isset($_REQUEST['plan_id'])) {
-
$plan = wu_get_plan($_REQUEST['plan_id']);
-
- } // end if;
+ }
$templates = array_keys((array) wu_get_setting('templates'));
if ( ($plan && $plan->is_template_available($_REQUEST['template_id'])) || in_array($_REQUEST['template_id'], $templates)) {
-
unset($this->steps['template']);
unset($params['skip_template_selection']);
-
- } // end if;
-
- } // end if;
+ }
+ }
$keys = array_keys($this->steps);
$url = add_query_arg('step', $keys[ array_search($this->step, array_keys($this->steps)) + 1 ]);
foreach ($params as $param => $value) {
-
$url = add_query_arg($param, $value, $url);
-
- } // end foreach;
+ }
return $url;
-
- } // end get_next_step_link;
+ }
/**
* Redirects the user to the next step on the signup flow
@@ -1105,12 +1023,11 @@ class Legacy_Checkout {
public function next_step($args = array()) {
/** Redirect the user to the next step */
- wp_redirect(esc_url_raw($this->get_next_step_link( $args )));
+ wp_redirect(esc_url_raw($this->get_next_step_link($args)));
/** Kill the execution after the redirect */
exit;
-
- } // end next_step;
+ }
/**
* Get the link for the previous step
@@ -1122,38 +1039,29 @@ class Legacy_Checkout {
// Add CS
if (isset($_GET['cs'])) {
-
$params['cs'] = $_GET['cs'];
-
- } // end if;
+ }
if (isset($_REQUEST['customized'])) {
-
$params['customized'] = $_REQUEST['customized'];
-
- } // end if;
+ }
$keys = array_keys($this->steps);
$search_key = array_search($this->step, array_keys($this->steps)) - 1 >= 0 ? array_search($this->step, array_keys($this->steps)) - 1 : false;
- $key = $search_key === false ? '' : $keys[$search_key];
-
- if (!$key || $key == 'begin-signup') {
+ $key = $search_key === false ? '' : $keys[ $search_key ];
+ if ( ! $key || $key == 'begin-signup') {
return false;
-
- } // end if;
+ }
$url = add_query_arg('step', $key);
foreach ($params as $param => $value) {
-
$url = add_query_arg($param, $value, $url);
-
- } // end foreach;
+ }
return $url;
-
- } // end get_prev_step_link;
+ }
/**
* Sorts the steps.
@@ -1169,8 +1077,7 @@ class Legacy_Checkout {
$b['order'] = isset($b['order']) ? (int) $b['order'] : 50;
return $a['order'] - $b['order'];
-
- } // end sort_steps_and_fields;
+ }
/**
* Display the necessary fields for the plan template
@@ -1191,11 +1098,11 @@ class Legacy_Checkout {
-
-
+
+
@@ -1205,13 +1112,12 @@ class Legacy_Checkout {
-
+
-domain;
if (wu_get_setting('enable_multiple_domains', false) && $domain_options) {
-
$domain = array_shift($domain_options);
-
- } // end if;
+ }
$domain = rtrim($domain . $site->path, '/');
@@ -1244,8 +1148,7 @@ class Legacy_Checkout {
* @return string New domain to be used
*/
return apply_filters('get_site_url_for_previewer', $domain, $domain_options); // phpcs:ignore
-
- } // end get_site_url_for_previewer;
+ }
/**
* We pass the following info
@@ -1259,19 +1162,19 @@ class Legacy_Checkout {
check_admin_referer('signup_form_1', '_signup_form');
// Errors
- $this->results['errors'] = new \WP_Error;
+ $this->results['errors'] = new \WP_Error();
// We need now to check for plan
- if (!isset($_POST['plan_id'])) {
+ if ( ! isset($_POST['plan_id'])) {
$this->results['errors']->add('plan_id', __('You don\'t have any plan selected.', 'wp-ultimo'));
} else {
// We need now to check if the plan exists
$plan = wu_get_product($_POST['plan_id']);
- if (!$plan->exists()) {
+ if ( ! $plan->exists()) {
$this->results['errors']->add('plan_id', __('The plan you\'ve selected doesn\'t exist.', 'wp-ultimo'));
- } // end if;
- } // end if;
+ }
+ }
$transient = apply_filters('wp_ultimo_registration_step_plans_save_transient', $transient);
@@ -1281,7 +1184,7 @@ class Legacy_Checkout {
// Stay on the form if we get any errors
if ($this->results['errors']->get_error_code()) {
return;
- } // end if;
+ }
/** Update Transient Content */
$transient['plan_freq'] = $_POST['plan_freq'];
@@ -1292,8 +1195,7 @@ class Legacy_Checkout {
/** Go to the next step */
$this->next_step();
-
- } // end plans_save;
+ }
/**
* Personal Info Settings.
@@ -1324,20 +1226,17 @@ class Legacy_Checkout {
// Stay on the form if we get any errors
if ($this->results['errors']->get_error_code()) {
-
$this->results = array_merge($this->results, $_POST);
return;
-
- } // end if;
+ }
// Re-saves the transient
$this->update_transient($transient);
/** Go to the next step */
$this->next_step();
-
- } // end domain_save;
+ }
/**
* Filters the input variables and sanitizes its contents
@@ -1351,14 +1250,13 @@ class Legacy_Checkout {
$exclude_list = $exclude_list ? $exclude_list : array('_signup_form', '_wp_http_referer');
/** Filter Array */
- $post = $this->array_filter_key($post, fn($element_key) => !in_array($element_key, $exclude_list, true));
+ $post = $this->array_filter_key($post, fn($element_key) => ! in_array($element_key, $exclude_list, true));
/** Sanitizes the input */
$post = array_map(fn($element) => sanitize_text_field($element), $post);
return $post;
-
- } // end filter_post_array;
+ }
/**
* Helper function to filter based on key.
*
@@ -1369,11 +1267,10 @@ 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 === null ? fn($v, $k): bool => ! empty($v) : $callback, $callback === null ? ARRAY_FILTER_USE_BOTH : 0);
return array_intersect_key($array, array_flip($matched_keys));
-
- } // end array_filter_key;
+ }
/**
* Get the active until + trial days, to allow for putting subscription on hold
*
@@ -1388,8 +1285,7 @@ class Legacy_Checkout {
$active_until->add(new \DateInterval('P' . $trial_days . 'D'));
return $active_until->format('Y-m-d H:i:s');
-
- } // end get_active_until_with_trial;
+ }
/**
* Adds a new Step to the sign-up flow
@@ -1402,21 +1298,22 @@ class Legacy_Checkout {
*/
public function add_signup_step($id, $order, $step) {
- add_filter('wp_ultimo_registration_steps', function($steps) use ($id, $order, $step) {
+ add_filter(
+ 'wp_ultimo_registration_steps',
+ function ($steps) use ($id, $order, $step) {
- // Save new order
- $step['order'] = $order;
+ // Save new order
+ $step['order'] = $order;
- // mark as not core
- $step['core'] = false;
+ // mark as not core
+ $step['core'] = false;
- $steps[$id] = $step;
+ $steps[ $id ] = $step;
- return $steps;
-
- });
-
- } // end add_signup_step;
+ return $steps;
+ }
+ );
+ }
/**
* Adds a new field to a step the sign-up flow
@@ -1430,27 +1327,25 @@ class Legacy_Checkout {
*/
public function add_signup_field($step, $id, $order, $field) {
- add_filter('wp_ultimo_registration_steps', function($steps) use ($step, $id, $order, $field) {
+ add_filter(
+ 'wp_ultimo_registration_steps',
+ function ($steps) use ($step, $id, $order, $field) {
- // Checks for honey-trap id
- if ($id === 'site_url') {
+ // Checks for honey-trap id
+ if ($id === 'site_url') {
+ wp_die(__('Please, do not use the "site_url" as one of your custom fields\' ids. We use it as a honeytrap field to prevent spam registration. Consider alternatives such as "url" or "website".', 'wp-ultimo'));
+ }
- wp_die(__('Please, do not use the "site_url" as one of your custom fields\' ids. We use it as a honeytrap field to prevent spam registration. Consider alternatives such as "url" or "website".', 'wp-ultimo'));
+ // Saves the order
+ $field['order'] = $order;
- } // end if;
+ // mark as not core
+ $field['core'] = false;
- // Saves the order
- $field['order'] = $order;
+ $steps[ $step ]['fields'][ $id ] = $field;
- // mark as not core
- $field['core'] = false;
-
- $steps[$step]['fields'][$id] = $field;
-
- return $steps;
-
- });
-
- } // end add_signup_field;
-
-} // end class Legacy_Checkout;
+ return $steps;
+ }
+ );
+ }
+}
diff --git a/inc/checkout/class-line-item.php b/inc/checkout/class-line-item.php
index 46163db..e7487f4 100644
--- a/inc/checkout/class-line-item.php
+++ b/inc/checkout/class-line-item.php
@@ -12,8 +12,8 @@ namespace WP_Ultimo\Checkout;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Database\Payments\Payment_Status;
-use \WP_Ultimo\Models\Product;
+use WP_Ultimo\Database\Payments\Payment_Status;
+use WP_Ultimo\Models\Product;
/**
* Creates an cart with the parameters of the purchase being placed.
@@ -291,12 +291,11 @@ class Line_Item implements \JsonSerializable {
$this->attributes($atts);
- /*
- * Refresh totals.
- */
+ /*
+ * Refresh totals.
+ */
$this->recalculate_totals();
-
- } // end __construct;
+ }
/**
* Loops through allowed fields and loads them.
@@ -308,44 +307,35 @@ class Line_Item implements \JsonSerializable {
*/
public function attributes($data) {
/*
- * Set type first to allow for overriding the other parameters.
- */
+ * Set type first to allow for overriding the other parameters.
+ */
$type = wu_get_isset($data, 'type');
if ($type) {
-
$this->set_type($data['type']);
+ }
- } // end if;
-
- /*
- * Set product first to allow for overriding the other parameters.
- */
+ /*
+ * Set product first to allow for overriding the other parameters.
+ */
$product = wu_get_isset($data, 'product');
if ($product) {
-
$this->set_product($data['product']);
unset($data['product']);
-
- } // end if;
+ }
$allowed_attributes = array_keys(get_object_vars($this));
foreach ($data as $key => $value) {
-
if (in_array($key, $allowed_attributes, true)) {
-
$this->{$key} = $value;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
$this->id = 'LN_' . strtoupper($this->type) . '_' . $this->hash;
-
- } // end attributes;
+ }
/**
* Get the value of id
@@ -356,8 +346,7 @@ class Line_Item implements \JsonSerializable {
public function get_id() {
return $this->id;
-
- } // end get_id;
+ }
/**
* Get the value of type
@@ -368,8 +357,7 @@ class Line_Item implements \JsonSerializable {
public function get_type() {
return $this->type;
-
- } // end get_type;
+ }
/**
* Set the value of type.
@@ -383,42 +371,34 @@ class Line_Item implements \JsonSerializable {
public function set_type($type) {
$this->type = $type;
-
- } // end set_type;
- /**
- * Get product associated with this line item.
- *
- * @since 2.0.0
- * @return \WP_Ultimo\Models\Product|false
- */
- public function get_product() {
+ }
+ /**
+ * Get product associated with this line item.
+ *
+ * @since 2.0.0
+ * @return \WP_Ultimo\Models\Product|false
+ */
+ public function get_product() {
$product = wu_get_product($this->product_id);
- if (!$product) {
-
+ if ( ! $product) {
return false;
-
- } // end if;
+ }
if ($product->is_recurring() && ($this->duration_unit !== $product->get_duration_unit() || $this->duration !== $product->get_duration())) {
-
$product_variation = $product->get_as_variation($this->duration, $this->duration_unit);
/*
* Checks if the variation exists before re-setting the product.
*/
if ($product_variation) {
-
$product = $product_variation;
-
- } // end if;
-
- } // end if;
+ }
+ }
return $product;
-
- } // end get_product;
+ }
/**
* Set product associated with this line item.
@@ -452,8 +432,7 @@ class Line_Item implements \JsonSerializable {
$this->tax_category = $product->get_tax_category();
$this->discountable = true;
-
- } // end set_product;
+ }
/**
* Calculate the taxes value based on the tax_amount and tax_type.
@@ -465,8 +444,7 @@ class Line_Item implements \JsonSerializable {
public function calculate_taxes($sub_total) {
return wu_get_tax_amount($sub_total, $this->get_tax_rate(), $this->get_tax_type(), false, $this->get_tax_inclusive());
-
- } // end calculate_taxes;
+ }
/**
* Calculate the discounts value based on the discount_amount and discount_type.
@@ -478,8 +456,7 @@ class Line_Item implements \JsonSerializable {
public function calculate_discounts($sub_total) {
return wu_get_tax_amount($sub_total, $this->get_discount_rate(), $this->get_discount_type(), false);
-
- } // end calculate_discounts;
+ }
/**
* Recalculate payment totals.
@@ -496,30 +473,23 @@ class Line_Item implements \JsonSerializable {
$discounted_subtotal = $sub_total - $discounts;
if ($sub_total > 0 && $discounted_subtotal < 0) {
-
$discounted_subtotal = 0;
$discounts = $sub_total;
-
- } // end if;
+ }
$taxes = $this->calculate_taxes($discounted_subtotal);
if ($this->get_tax_inclusive()) {
-
$total = $this->is_tax_exempt() ? $discounted_subtotal - $taxes : $discounted_subtotal;
-
} else {
-
$total = $this->is_tax_exempt() ? $discounted_subtotal : $discounted_subtotal + $taxes; // tax exclusive
- } // end if;
+ }
if ($this->is_tax_exempt()) {
-
$taxes = 0;
-
- } // end if;
+ }
$totals = array(
'subtotal' => $sub_total,
@@ -531,8 +501,7 @@ class Line_Item implements \JsonSerializable {
$this->attributes($totals);
return $this;
-
- } // end recalculate_totals;
+ }
/**
* Get quantity of the given product.
@@ -543,8 +512,7 @@ class Line_Item implements \JsonSerializable {
public function get_quantity() {
return $this->quantity;
-
- } // end get_quantity;
+ }
/**
* Set quantity of the given product.
@@ -556,8 +524,7 @@ class Line_Item implements \JsonSerializable {
public function set_quantity($quantity) {
$this->quantity = $quantity;
-
- } // end set_quantity;
+ }
/**
* Get unit price of the product.
@@ -568,8 +535,7 @@ class Line_Item implements \JsonSerializable {
public function get_unit_price() {
return $this->unit_price;
-
- } // end get_unit_price;
+ }
/**
* Set unit price of the product.
@@ -581,8 +547,7 @@ class Line_Item implements \JsonSerializable {
public function set_unit_price($unit_price) {
$this->unit_price = $unit_price;
-
- } // end set_unit_price;
+ }
/**
* Get tax amount, absolute or percentage.
@@ -593,8 +558,7 @@ class Line_Item implements \JsonSerializable {
public function get_tax_rate() {
return $this->tax_rate;
-
- } // end get_tax_rate;
+ }
/**
* Set tax amount, absolute or percentage.
@@ -606,8 +570,7 @@ class Line_Item implements \JsonSerializable {
public function set_tax_rate($tax_rate) {
$this->tax_rate = $tax_rate;
-
- } // end set_tax_rate;
+ }
/**
* Get type of the tax, percentage or absolute.
@@ -618,8 +581,7 @@ class Line_Item implements \JsonSerializable {
public function get_tax_type() {
return $this->tax_type;
-
- } // end get_tax_type;
+ }
/**
* Set type of the tax, percentage or absolute.
@@ -631,8 +593,7 @@ class Line_Item implements \JsonSerializable {
public function set_tax_type($tax_type) {
$this->tax_type = $tax_type;
-
- } // end set_tax_type;
+ }
/**
* Get if tax are included in the price or not.
@@ -643,8 +604,7 @@ class Line_Item implements \JsonSerializable {
public function get_tax_inclusive() {
return (bool) $this->tax_inclusive;
-
- } // end get_tax_inclusive;
+ }
/**
* Set if tax are included in the price or not.
@@ -656,8 +616,7 @@ class Line_Item implements \JsonSerializable {
public function set_tax_inclusive($tax_inclusive) {
$this->tax_inclusive = $tax_inclusive;
-
- } // end set_tax_inclusive;
+ }
/**
* Get if the line item is tax exempt ot not.
@@ -668,8 +627,7 @@ class Line_Item implements \JsonSerializable {
public function is_tax_exempt() {
return $this->tax_exempt;
-
- } // end is_tax_exempt;
+ }
/**
* Set if the line item is tax exempt ot not.
@@ -681,8 +639,7 @@ class Line_Item implements \JsonSerializable {
public function set_tax_exempt($tax_exempt) {
$this->tax_exempt = $tax_exempt;
-
- } // end set_tax_exempt;
+ }
/**
* Get the amount, in currency, of the tax.
@@ -693,8 +650,7 @@ class Line_Item implements \JsonSerializable {
public function get_tax_total() {
return $this->tax_total;
-
- } // end get_tax_total;
+ }
/**
* Set the amount, in currency, of the tax.
@@ -706,8 +662,7 @@ class Line_Item implements \JsonSerializable {
public function set_tax_total($tax_total) {
$this->tax_total = $tax_total;
-
- } // end set_tax_total;
+ }
/**
* Get the value of total
@@ -718,8 +673,7 @@ class Line_Item implements \JsonSerializable {
public function get_total() {
return $this->total;
-
- } // end get_total;
+ }
/**
* Set the value of total.
@@ -731,8 +685,7 @@ class Line_Item implements \JsonSerializable {
public function set_total($total) {
$this->total = $total;
-
- } // end set_total;
+ }
/**
* Get the value of recurring.
@@ -743,8 +696,7 @@ class Line_Item implements \JsonSerializable {
public function is_recurring() {
return $this->recurring;
-
- } // end is_recurring;
+ }
/**
* Set the value of recurring.
@@ -756,8 +708,7 @@ class Line_Item implements \JsonSerializable {
public function set_recurring($recurring) {
$this->recurring = $recurring;
-
- } // end set_recurring;
+ }
/**
* Get value before taxes, discounts, fees and etc.
@@ -768,8 +719,7 @@ class Line_Item implements \JsonSerializable {
public function get_subtotal() {
return $this->subtotal;
-
- } // end get_subtotal;
+ }
/**
* Set value before taxes, discounts, fees and etc.
@@ -781,8 +731,7 @@ class Line_Item implements \JsonSerializable {
public function set_subtotal($subtotal) {
$this->subtotal = $subtotal;
-
- } // end set_subtotal;
+ }
/**
* Get the value of duration
@@ -793,8 +742,7 @@ class Line_Item implements \JsonSerializable {
public function get_duration() {
return $this->duration;
-
- } // end get_duration;
+ }
/**
* Set the value of duration.
@@ -806,8 +754,7 @@ class Line_Item implements \JsonSerializable {
public function set_duration($duration) {
$this->duration = $duration;
-
- } // end set_duration;
+ }
/**
* Get the value of duration_unit.
@@ -818,8 +765,7 @@ class Line_Item implements \JsonSerializable {
public function get_duration_unit() {
return $this->duration_unit;
-
- } // end get_duration_unit;
+ }
/**
* Set the value of duration_unit.
@@ -831,8 +777,7 @@ class Line_Item implements \JsonSerializable {
public function set_duration_unit($duration_unit) {
$this->duration_unit = $duration_unit;
-
- } // end set_duration_unit;
+ }
/**
* Get the value of billing_cycles.
@@ -843,8 +788,7 @@ class Line_Item implements \JsonSerializable {
public function get_billing_cycles() {
return $this->billing_cycles;
-
- } // end get_billing_cycles;
+ }
/**
* Set the value of billing_cycles.
@@ -856,8 +800,7 @@ class Line_Item implements \JsonSerializable {
public function set_billing_cycles($billing_cycles) {
$this->billing_cycles = $billing_cycles;
-
- } // end set_billing_cycles;
+ }
/**
* Get the value of discount_total.
@@ -868,8 +811,7 @@ class Line_Item implements \JsonSerializable {
public function get_discount_total() {
return $this->discount_total;
-
- } // end get_discount_total;
+ }
/**
* Set the value of discount_total.
@@ -881,8 +823,7 @@ class Line_Item implements \JsonSerializable {
public function set_discount_total($discount_total) {
$this->discount_total = $discount_total;
-
- } // end set_discount_total;
+ }
/**
* Get the value of tax_category.
@@ -893,8 +834,7 @@ class Line_Item implements \JsonSerializable {
public function get_tax_category() {
return $this->tax_category;
-
- } // end get_tax_category;
+ }
/**
* Set the value of tax_category.
@@ -906,8 +846,7 @@ class Line_Item implements \JsonSerializable {
public function set_tax_category($tax_category) {
$this->tax_category = $tax_category;
-
- } // end set_tax_category;
+ }
/**
* Get the value of discountable.
@@ -918,8 +857,7 @@ class Line_Item implements \JsonSerializable {
public function is_discountable() {
return $this->discountable;
-
- } // end is_discountable;
+ }
/**
* Set the value of discountable.
@@ -931,8 +869,7 @@ class Line_Item implements \JsonSerializable {
public function set_discountable($discountable) {
$this->discountable = $discountable;
-
- } // end set_discountable;
+ }
/**
* Get the value of taxable.
@@ -943,8 +880,7 @@ class Line_Item implements \JsonSerializable {
public function is_taxable() {
return $this->taxable;
-
- } // end is_taxable;
+ }
/**
* Set the value of taxable.
@@ -956,8 +892,7 @@ class Line_Item implements \JsonSerializable {
public function set_taxable($taxable) {
$this->taxable = $taxable;
-
- } // end set_taxable;
+ }
/**
* Get the value of discount_rate.
@@ -968,8 +903,7 @@ class Line_Item implements \JsonSerializable {
public function get_discount_rate() {
return $this->discount_rate;
-
- } // end get_discount_rate;
+ }
/**
* Set the value of discount_rate.
@@ -981,8 +915,7 @@ class Line_Item implements \JsonSerializable {
public function set_discount_rate($discount_rate) {
$this->discount_rate = $discount_rate;
-
- } // end set_discount_rate;
+ }
/**
* Get the value of discount_type.
@@ -993,8 +926,7 @@ class Line_Item implements \JsonSerializable {
public function get_discount_type() {
return $this->discount_type;
-
- } // end get_discount_type;
+ }
/**
* Set the value of discount_type.
@@ -1006,8 +938,7 @@ class Line_Item implements \JsonSerializable {
public function set_discount_type($discount_type) {
$this->discount_type = $discount_type;
-
- } // end set_discount_type;
+ }
/**
* Get discount Label.
@@ -1018,8 +949,7 @@ class Line_Item implements \JsonSerializable {
public function get_discount_label() {
return $this->discount_label;
-
- } // end get_discount_label;
+ }
/**
* Set discount Label.
@@ -1031,8 +961,7 @@ class Line_Item implements \JsonSerializable {
public function set_discount_label($discount_label) {
$this->discount_label = $discount_label;
-
- } // end set_discount_label;
+ }
/**
* Get if we should apply discount to renewals.
@@ -1043,8 +972,7 @@ class Line_Item implements \JsonSerializable {
public function should_apply_discount_to_renewals() {
return $this->apply_discount_to_renewals;
-
- } // end should_apply_discount_to_renewals;
+ }
/**
* Set if we should apply discount to renewals.
@@ -1056,8 +984,7 @@ class Line_Item implements \JsonSerializable {
public function set_apply_discount_to_renewals($apply_discount_to_renewals) {
$this->apply_discount_to_renewals = $apply_discount_to_renewals;
-
- } // end set_apply_discount_to_renewals;
+ }
/**
* Get the value of product_id.
@@ -1068,8 +995,7 @@ class Line_Item implements \JsonSerializable {
public function get_product_id() {
return $this->product_id;
-
- } // end get_product_id;
+ }
/**
* Set the value of product_id.
@@ -1081,8 +1007,7 @@ class Line_Item implements \JsonSerializable {
public function set_product_id($product_id) {
$this->product_id = $product_id;
-
- } // end set_product_id;
+ }
/**
* Get the value of title
@@ -1093,8 +1018,7 @@ class Line_Item implements \JsonSerializable {
public function get_title() {
return $this->title;
-
- } // end get_title;
+ }
/**
* Set the value of title.
@@ -1106,8 +1030,7 @@ class Line_Item implements \JsonSerializable {
public function set_title($title) {
$this->title = $title;
-
- } // end set_title;
+ }
/**
* Get the value of description.
@@ -1118,8 +1041,7 @@ class Line_Item implements \JsonSerializable {
public function get_description() {
return $this->description;
-
- } // end get_description;
+ }
/**
* Set the value of description.
@@ -1131,8 +1053,7 @@ class Line_Item implements \JsonSerializable {
public function set_description($description) {
$this->description = $description;
-
- } // end set_description;
+ }
/**
* Get label of the tax applied.
@@ -1143,8 +1064,7 @@ class Line_Item implements \JsonSerializable {
public function get_tax_label() {
return $this->tax_label;
-
- } // end get_tax_label;
+ }
/**
* Set label of the tax applied.
@@ -1156,8 +1076,7 @@ class Line_Item implements \JsonSerializable {
public function set_tax_label($tax_label) {
$this->tax_label = $tax_label;
-
- } // end set_tax_label;
+ }
/**
* Returns the amount recurring in a human-friendly way.
@@ -1167,11 +1086,9 @@ class Line_Item implements \JsonSerializable {
*/
public function get_recurring_description() {
- if (!$this->is_recurring()) {
-
+ if ( ! $this->is_recurring()) {
return '';
-
- } // end if;
+ }
$description = sprintf(
// translators: %1$s the duration, and %2$s the duration unit (day, week, month, etc)
@@ -1181,8 +1098,7 @@ class Line_Item implements \JsonSerializable {
);
return $description;
-
- } // end get_recurring_description;
+ }
/**
* Converts the line item to an array.
@@ -1197,8 +1113,7 @@ class Line_Item implements \JsonSerializable {
$array['recurring_description'] = $this->get_recurring_description();
return $array;
-
- } // end to_array;
+ }
/**
* Implements our on json_decode version of this object. Useful for use in vue.js.
@@ -1210,8 +1125,7 @@ class Line_Item implements \JsonSerializable {
public function jsonSerialize() {
return $this->to_array();
-
- } // end jsonSerialize;
+ }
/**
* Queries the database for Line Items across payments.
@@ -1225,11 +1139,14 @@ class Line_Item implements \JsonSerializable {
global $wpdb;
- $query = wp_parse_args($query, array(
- 'number' => 100,
- 'date_query' => array(),
- 'payment_status' => false,
- ));
+ $query = wp_parse_args(
+ $query,
+ array(
+ 'number' => 100,
+ 'date_query' => array(),
+ 'payment_status' => false,
+ )
+ );
$query['date_query']['column'] = 'p.date_created';
@@ -1241,11 +1158,9 @@ class Line_Item implements \JsonSerializable {
$status_query_sql = '';
- if ($query['payment_status'] && (new Payment_Status)->is_valid($query['payment_status'])) {
-
+ if ($query['payment_status'] && (new Payment_Status())->is_valid($query['payment_status'])) {
$status_query_sql = "AND p.status = '{$query['payment_status']}'";
-
- } // end if;
+ }
// phpcs:disable;
$query = $wpdb->prepare("
@@ -1266,26 +1181,25 @@ class Line_Item implements \JsonSerializable {
$results = $wpdb->get_results($query); // phpcs:ignore
foreach ($results as &$ln) {
-
$copy = $ln;
$line_items = $ln->line_items;
$ln = maybe_unserialize($line_items);
- $ln = array_map(function($_ln) use ($copy) {
+ $ln = array_map(
+ function ($_ln) use ($copy) {
- $_ln->date_created = $copy->date_created;
+ $_ln->date_created = $copy->date_created;
- return $_ln;
-
- }, $ln);
-
- } // end foreach;
+ return $_ln;
+ },
+ $ln
+ );
+ }
return $results;
-
- } // end get_line_items;
+ }
/**
* Get the product slug, if any.
@@ -1296,8 +1210,7 @@ class Line_Item implements \JsonSerializable {
public function get_product_slug() {
return $this->product_slug;
-
- } // end get_product_slug;
+ }
/**
* Set the product slug.
@@ -1309,7 +1222,5 @@ class Line_Item implements \JsonSerializable {
public function set_product_slug($product_slug) {
$this->product_slug = $product_slug;
-
- } // end set_product_slug;
-
-} // end class Line_Item;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-base-signup-field.php b/inc/checkout/signup-fields/class-base-signup-field.php
index 1eca1ad..738d2f5 100644
--- a/inc/checkout/signup-fields/class-base-signup-field.php
+++ b/inc/checkout/signup-fields/class-base-signup-field.php
@@ -112,8 +112,7 @@ abstract class Base_Signup_Field {
public function is_hidden() {
return false;
-
- } // end is_hidden;
+ }
/**
* Defines if this field/element is related to site creation or not.
@@ -124,8 +123,7 @@ abstract class Base_Signup_Field {
public function is_site_field() {
return false;
-
- } // end is_site_field;
+ }
/**
* Defines if this field/element is related to user/customer creation or not.
@@ -136,8 +134,7 @@ abstract class Base_Signup_Field {
public function is_user_field() {
return false;
-
- } // end is_user_field;
+ }
/**
* Returns the field as an array that the form builder can understand.
@@ -159,8 +156,7 @@ abstract class Base_Signup_Field {
'all_attributes' => $this->get_all_attributes(),
'fields' => array($this, 'get_editor_fields'),
);
-
- } // end get_field_as_type_option;
+ }
/**
* Modifies the HTML attr array before sending it over to the form.
@@ -174,8 +170,7 @@ abstract class Base_Signup_Field {
public function get_editor_fields_html_attr($html_attr, $field_name) {
return $html_attr;
-
- } // end get_editor_fields_html_attr;
+ }
/**
* Get the tabs available for this field.
@@ -189,8 +184,7 @@ abstract class Base_Signup_Field {
'content',
'style',
);
-
- } // end get_tabs;
+ }
/**
* Gets the pre-filled value for the field.
@@ -207,20 +201,15 @@ abstract class Base_Signup_Field {
$value_session = wu_get_isset($session->get('signup'), $this->attributes['id']);
if ($value_session) {
-
$value = $value_session;
-
- } // end if;
+ }
if (wu_get_isset($this->attributes, 'from_request') && wu_get_isset($this->attributes, 'id')) {
-
$value = wu_request($this->attributes['id'], '');
-
- } // end if;
+ }
return $value;
-
- } // end get_value;
+ }
/**
* Calculate the style attributes for the field.
@@ -235,24 +224,17 @@ abstract class Base_Signup_Field {
$width = (int) wu_get_isset($this->attributes, 'width');
if ($width) {
-
if ($width !== 100) {
-
$styles[] = 'float: left';
$styles[] = sprintf('width: %s%%', $width);
-
- } // end if;
-
+ }
} else {
-
$styles[] = 'clear: both';
-
- } // end if;
+ }
return implode('; ', $styles);
-
- } // end calculate_style_attr;
+ }
/**
* Sets the config values for the current field.
@@ -265,8 +247,7 @@ abstract class Base_Signup_Field {
public function set_attributes($attributes) {
$this->attributes = $attributes;
-
- } // end set_attributes;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -277,8 +258,7 @@ abstract class Base_Signup_Field {
public function force_attributes() {
return array();
-
- } // end force_attributes;
+ }
/**
* Default values for the editor fields.
@@ -289,8 +269,7 @@ abstract class Base_Signup_Field {
public function defaults() {
return array();
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -308,8 +287,7 @@ abstract class Base_Signup_Field {
'default',
'required',
);
-
- } // end default_fields;
+ }
/**
* Returns the editor fields.
@@ -327,32 +305,27 @@ 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() ] = array(
'type' => 'note',
'classes' => 'wu--mt-px',
'desc' => sprintf('
%s
', __('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,
);
-
- } // end if;
+ }
/*
* 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() ] = array(
'type' => 'note',
'classes' => 'wu--mt-px',
'desc' => sprintf('
%s
', __('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,
);
-
- } // end if;
+ }
foreach ($final_field_list as $key => &$field) {
-
$field['html_attr'] = wu_get_isset($field, 'html_attr', array());
$value = wu_get_isset($attributes, $key, null);
@@ -360,13 +333,10 @@ abstract class Base_Signup_Field {
$field['default'] = wu_get_isset($this->defaults(), $key, '');
if ($value === null) {
-
$value = $field['default'];
-
- } // end if;
+ }
if (wu_get_isset($field['html_attr'], 'data-model')) {
-
$model_name = wu_get_isset($field['html_attr'], 'data-model', 'product');
$models = explode(',', (string) $value);
@@ -374,34 +344,29 @@ abstract class Base_Signup_Field {
$func_name = "wu_get_{$model_name}";
if (function_exists($func_name)) {
+ $selected = array_map(
+ function ($id) use ($func_name) {
- $selected = array_map(function($id) use ($func_name) {
+ $model = call_user_func($func_name, absint($id));
- $model = call_user_func($func_name, absint($id));
+ if ( ! $model) {
+ return false;
+ }
- if (!$model) {
-
- return false;
-
- } // end if;
-
- return $model->to_search_results();
-
- }, $models);
+ return $model->to_search_results();
+ },
+ $models
+ );
$selected = array_filter($selected);
$field['html_attr']['data-selected'] = json_encode($selected);
+ }
+ }
- } // end if;
-
- } // end if;
-
- if (!is_null($value)) {
-
+ if ( ! is_null($value)) {
$field['value'] = $value;
-
- } // end if;
+ }
$field['html_attr'] = $this->get_editor_fields_html_attr($field['html_attr'], $field['type']);
@@ -411,23 +376,22 @@ abstract class Base_Signup_Field {
$show_reqs = false;
if (isset($field['wrapper_html_attr'])) {
-
$show_reqs = wu_get_isset($field['wrapper_html_attr'], 'v-show');
-
- } // end if;
+ }
$tab = wu_get_isset($field, 'tab', 'content');
- $field['wrapper_html_attr'] = array_merge(wu_get_isset($field, 'wrapper_html_attr', array()), array(
- 'v-cloak' => 1,
- 'v-show' => sprintf('require("type", "%s") && require("tab", "%s")', $this->get_type(), $tab) . ($show_reqs ? " && $show_reqs" : ''),
- ));
-
- } // end foreach;
+ $field['wrapper_html_attr'] = array_merge(
+ wu_get_isset($field, 'wrapper_html_attr', array()),
+ array(
+ 'v-cloak' => 1,
+ 'v-show' => sprintf('require("type", "%s") && require("tab", "%s")', $this->get_type(), $tab) . ($show_reqs ? " && $show_reqs" : ''),
+ )
+ );
+ }
return $final_field_list;
-
- } // end get_editor_fields;
+ }
/**
* Returns a list of all the attributes.
@@ -449,8 +413,7 @@ abstract class Base_Signup_Field {
$field_keys = array_keys($this->get_fields());
return array_merge($this->default_fields(), $field_keys, $styles);
-
- } // end get_all_attributes;
+ }
/**
* Treat the attributes array to avoid reaching the input var limits.
@@ -463,8 +426,7 @@ abstract class Base_Signup_Field {
public function reduce_attributes($attributes) {
return $attributes;
-
- } // end reduce_attributes;
+ }
/**
* List of all the default fields available.
@@ -608,7 +570,5 @@ abstract class Base_Signup_Field {
);
return $fields;
-
- } // end fields_list;
-
-} // end class Base_Signup_Field;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-billing-address.php b/inc/checkout/signup-fields/class-signup-field-billing-address.php
index cfc8b03..c80c161 100644
--- a/inc/checkout/signup-fields/class-signup-field-billing-address.php
+++ b/inc/checkout/signup-fields/class-signup-field-billing-address.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -32,8 +32,7 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
public function get_type() {
return 'billing_address';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
@@ -44,8 +43,7 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
public function is_required() {
return false;
-
- } // end is_required;
+ }
/**
* Is this a user-related field?
@@ -59,8 +57,7 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
public function is_user_field() {
return true;
-
- } // end is_user_field;
+ }
/**
* Requires the title of the field/element type.
@@ -73,8 +70,7 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
public function get_title() {
return __('Address', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -87,8 +83,7 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
public function get_description() {
return __('Adds billing address fields such as country, zip code.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -101,8 +96,7 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds billing address fields such as country, zip code.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
@@ -115,8 +109,7 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
public function get_icon() {
return 'dashicons-wu-map1';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -132,8 +125,7 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
return array(
'zip_and_country' => true,
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -146,8 +138,7 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
return array(
'name',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -161,8 +152,7 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
'id' => 'billing_address',
'required' => true,
);
-
- } // end force_attributes;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -180,8 +170,7 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
'value' => true,
),
);
-
- } // end get_fields;
+ }
/**
* Build a filed alternative.
@@ -199,9 +188,12 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
$field = $base_field;
- $option_template = sprintf('', $data_key_name);
+ ',
+ $data_key_name
+ );
$field['type'] = 'select';
$field['options_template'] = $option_template;
@@ -214,8 +206,7 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
$field['title'] = sprintf('%s', "labels.$label_key_field", $field['title']);
return $field;
-
- } // end build_select_alternative;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -235,29 +226,21 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
* Checks for an existing customer
*/
if ($customer) {
-
$fields = $customer->get_billing_address()->get_fields($zip_only);
-
} else {
-
$checkout_form = \WP_Ultimo\Checkout\Checkout::get_instance()->checkout_form;
$fields = \WP_Ultimo\Objects\Billing_Address::fields($zip_only, $checkout_form);
-
- } // end if;
+ }
if (isset($fields['billing_country'])) {
-
$fields['billing_country']['html_attr'] = array(
'v-model' => 'country',
);
+ }
- } // end if;
-
- if (!$zip_only) {
-
+ if ( ! $zip_only) {
if (isset($fields['billing_state'])) {
-
$fields['billing_state']['html_attr'] = array(
'v-model.lazy' => 'state',
);
@@ -268,11 +251,9 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
* @since 2.0.11
*/
$fields['billing_state_select'] = $this->build_select_alternative($fields['billing_state'], 'state_list', 'state_field');
-
- } // end if;
+ }
if (isset($fields['billing_city'])) {
-
$fields['billing_city']['html_attr'] = array(
'v-model.lazy' => 'city',
);
@@ -283,21 +264,15 @@ class Signup_Field_Billing_Address extends Base_Signup_Field {
* @since 2.0.11
*/
$fields['billing_city_select'] = $this->build_select_alternative($fields['billing_city'], 'city_list', 'city_field');
-
- } // end if;
-
- } // end if;
+ }
+ }
foreach ($fields as &$field) {
-
$field['wrapper_classes'] = trim(wu_get_isset($field, 'wrapper_classes', '') . ' ' . $attributes['element_classes']);
-
- } // end foreach;
+ }
uasort($fields, 'wu_sort_by_order');
return $fields;
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Billing_Address;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-checkbox.php b/inc/checkout/signup-fields/class-signup-field-checkbox.php
index 5477929..ef12f82 100644
--- a/inc/checkout/signup-fields/class-signup-field-checkbox.php
+++ b/inc/checkout/signup-fields/class-signup-field-checkbox.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -32,8 +32,7 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
public function get_type() {
return 'checkbox';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
@@ -44,8 +43,7 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
public function is_required() {
return false;
-
- } // end is_required;
+ }
/**
* Is this a user-related field?
@@ -59,8 +57,7 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
public function is_user_field() {
return false;
-
- } // end is_user_field;
+ }
/**
* Requires the title of the field/element type.
@@ -73,8 +70,7 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
public function get_title() {
return __('Checkbox', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -87,8 +83,7 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
public function get_description() {
return __('Adds a checkout box that can be checked by the customer.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -101,8 +96,7 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds a checkout box that can be checked by the customer.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
@@ -115,8 +109,7 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
public function get_icon() {
return 'dashicons-wu-check-square';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -130,10 +123,9 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
public function defaults() {
return array(
- ''
+ '',
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -150,8 +142,7 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
'save_as',
'required',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -162,8 +153,7 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
public function force_attributes() {
return array();
-
- } // end force_attributes;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -182,8 +172,7 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
'order' => 12,
),
);
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -197,7 +186,7 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
$checkout_fields = array();
- $checkout_fields[$attributes['id']] = array(
+ $checkout_fields[ $attributes['id'] ] = array(
'type' => 'checkbox',
'id' => $attributes['id'],
'name' => $attributes['name'],
@@ -207,21 +196,15 @@ class Signup_Field_Checkbox extends Base_Signup_Field {
);
if ($attributes['default_state']) {
-
- $checkout_fields[$attributes['id']]['html_attr']['checked'] = 'checked';
-
- } // end if;
+ $checkout_fields[ $attributes['id'] ]['html_attr']['checked'] = 'checked';
+ }
$value = $this->get_value();
if ($value !== '' && (bool) $value === true) {
-
- $checkout_fields[$attributes['id']]['html_attr']['checked'] = 'checked';
-
- } // end if;
+ $checkout_fields[ $attributes['id'] ]['html_attr']['checked'] = 'checked';
+ }
return $checkout_fields;
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Checkbox;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-color.php b/inc/checkout/signup-fields/class-signup-field-color.php
index 5283942..d2e4ffb 100644
--- a/inc/checkout/signup-fields/class-signup-field-color.php
+++ b/inc/checkout/signup-fields/class-signup-field-color.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -32,8 +32,7 @@ class Signup_Field_Color extends Base_Signup_Field {
public function get_type() {
return 'color_picker';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
@@ -44,8 +43,7 @@ class Signup_Field_Color extends Base_Signup_Field {
public function is_required() {
return false;
-
- } // end is_required;
+ }
/**
* Requires the title of the field/element type.
@@ -58,8 +56,7 @@ class Signup_Field_Color extends Base_Signup_Field {
public function get_title() {
return __('Color', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -72,8 +69,7 @@ class Signup_Field_Color extends Base_Signup_Field {
public function get_description() {
return __('Adds a color picker field.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -86,8 +82,7 @@ class Signup_Field_Color extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds a color picker field.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
@@ -100,8 +95,7 @@ class Signup_Field_Color extends Base_Signup_Field {
public function get_icon() {
return 'dashicons-wu-droplet';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -115,10 +109,9 @@ class Signup_Field_Color extends Base_Signup_Field {
public function defaults() {
return array(
- ''
+ '',
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -136,8 +129,7 @@ class Signup_Field_Color extends Base_Signup_Field {
'required',
'save_as',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -148,8 +140,7 @@ class Signup_Field_Color extends Base_Signup_Field {
public function force_attributes() {
return array();
-
- } // end force_attributes;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -167,8 +158,7 @@ class Signup_Field_Color extends Base_Signup_Field {
'desc' => __('Set the default value for this color field.', 'wp-ultimo'),
),
);
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -197,7 +187,5 @@ class Signup_Field_Color extends Base_Signup_Field {
),
),
);
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Color;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-discount-code.php b/inc/checkout/signup-fields/class-signup-field-discount-code.php
index db400d7..1e7a623 100644
--- a/inc/checkout/signup-fields/class-signup-field-discount-code.php
+++ b/inc/checkout/signup-fields/class-signup-field-discount-code.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -32,8 +32,7 @@ class Signup_Field_Discount_Code extends Base_Signup_Field {
public function get_type() {
return 'discount_code';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
@@ -44,8 +43,7 @@ class Signup_Field_Discount_Code extends Base_Signup_Field {
public function is_required() {
return false;
-
- } // end is_required;
+ }
/**
* Requires the title of the field/element type.
@@ -58,8 +56,7 @@ class Signup_Field_Discount_Code extends Base_Signup_Field {
public function get_title() {
return __('Coupon Code', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -72,8 +69,7 @@ class Signup_Field_Discount_Code extends Base_Signup_Field {
public function get_description() {
return __('Adds an additional field to apply a discount code.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -86,8 +82,7 @@ class Signup_Field_Discount_Code extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds an additional field to apply a discount code.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
@@ -100,8 +95,7 @@ class Signup_Field_Discount_Code extends Base_Signup_Field {
public function get_icon() {
return 'dashicons-wu-tag1';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -118,8 +112,7 @@ class Signup_Field_Discount_Code extends Base_Signup_Field {
'placeholder' => '',
'default' => '',
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -134,8 +127,7 @@ class Signup_Field_Discount_Code extends Base_Signup_Field {
'placeholder',
'tooltip',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -148,8 +140,7 @@ class Signup_Field_Discount_Code extends Base_Signup_Field {
return array(
'id' => 'discount_code',
);
-
- } // end force_attributes;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -160,8 +151,7 @@ class Signup_Field_Discount_Code extends Base_Signup_Field {
public function get_fields() {
return array();
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -201,12 +191,10 @@ class Signup_Field_Discount_Code extends Base_Signup_Field {
'html_attr' => array(
'v-model.lazy' => 'discount_code',
'v-init:discount_code' => "'{$this->get_value()}'",
- 'v-init:toggle_discount_code' => !empty($this->get_value()),
+ 'v-init:toggle_discount_code' => ! empty($this->get_value()),
),
);
return $checkout_fields;
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Discount_Code;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-email.php b/inc/checkout/signup-fields/class-signup-field-email.php
index c0b6922..59d01b1 100644
--- a/inc/checkout/signup-fields/class-signup-field-email.php
+++ b/inc/checkout/signup-fields/class-signup-field-email.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -24,15 +24,14 @@ defined('ABSPATH') || exit;
class Signup_Field_Email extends Base_Signup_Field {
/**
- * Returns the type of the field.
- *
- * @since 2.0.0
- */
+ * Returns the type of the field.
+ *
+ * @since 2.0.0
+ */
public function get_type(): string {
return 'email';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
*
@@ -41,8 +40,7 @@ class Signup_Field_Email extends Base_Signup_Field {
public function is_required(): bool {
return true;
-
- } // end is_required;
+ }
/**
* Is this a user-related field?
*
@@ -54,8 +52,7 @@ class Signup_Field_Email extends Base_Signup_Field {
public function is_user_field(): bool {
return false;
-
- } // end is_user_field;
+ }
/**
* Requires the title of the field/element type.
@@ -68,8 +65,7 @@ class Signup_Field_Email extends Base_Signup_Field {
public function get_title() {
return __('Email', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -82,8 +78,7 @@ class Signup_Field_Email extends Base_Signup_Field {
public function get_description() {
return __('Adds a email address field. This email address will be used to create the WordPress user.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -96,8 +91,7 @@ class Signup_Field_Email extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds a email address field. This email address will be used to create the WordPress user.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
*
@@ -108,8 +102,7 @@ class Signup_Field_Email extends Base_Signup_Field {
public function get_icon(): string {
return 'dashicons-wu-at-sign';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -125,8 +118,7 @@ class Signup_Field_Email extends Base_Signup_Field {
return array(
'display_notices' => true,
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -141,8 +133,7 @@ class Signup_Field_Email extends Base_Signup_Field {
'placeholder',
'tooltip',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -156,8 +147,7 @@ class Signup_Field_Email extends Base_Signup_Field {
'id' => 'email_address',
'required' => true,
);
-
- } // end force_attributes;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -179,8 +169,7 @@ class Signup_Field_Email extends Base_Signup_Field {
),
),
);
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -195,9 +184,7 @@ class Signup_Field_Email extends Base_Signup_Field {
$checkout_fields = array();
if (is_user_logged_in()) {
-
if ($attributes['display_notices']) {
-
$checkout_fields['login_note'] = array(
'type' => 'note',
'title' => __('Not you?', 'wp-ultimo'),
@@ -207,13 +194,9 @@ class Signup_Field_Email extends Base_Signup_Field {
'style' => $this->calculate_style_attr(),
),
);
-
- } // end if;
-
+ }
} else {
-
if ($attributes['display_notices']) {
-
$checkout_fields['login_note'] = array(
'type' => 'note',
'title' => __('Existing customer?', 'wp-ultimo'),
@@ -223,8 +206,7 @@ class Signup_Field_Email extends Base_Signup_Field {
'style' => $this->calculate_style_attr(),
),
);
-
- } // end if;
+ }
$checkout_fields['email_address'] = array(
'type' => 'text',
@@ -240,12 +222,10 @@ class Signup_Field_Email extends Base_Signup_Field {
'style' => $this->calculate_style_attr(),
),
);
-
- } // end if;
+ }
return $checkout_fields;
-
- } // end to_fields_array;
+ }
/**
* Renders the login message for users that are not logged in.
@@ -273,8 +253,7 @@ class Signup_Field_Email extends Base_Signup_Field {
true,
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -132,8 +125,7 @@ class Signup_Field_Hidden extends Base_Signup_Field {
'id',
'save_as',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -144,8 +136,7 @@ class Signup_Field_Hidden extends Base_Signup_Field {
public function force_attributes() {
return array();
-
- } // end force_attributes;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -166,8 +157,7 @@ class Signup_Field_Hidden extends Base_Signup_Field {
'value' => '',
),
);
-
- } // end get_fields;
+ }
/**
* Gets the pre-filled value for the field.
@@ -180,14 +170,11 @@ class Signup_Field_Hidden extends Base_Signup_Field {
$value = parent::get_value();
if (empty($value)) {
-
$value = $this->attributes['fixed_value'];
-
- } // end if;
+ }
return $value;
-
- } // end get_value;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -207,7 +194,5 @@ class Signup_Field_Hidden extends Base_Signup_Field {
'value' => $this->get_value(),
),
);
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Hidden;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-order-bump.php b/inc/checkout/signup-fields/class-signup-field-order-bump.php
index dabe24a..44ef87a 100644
--- a/inc/checkout/signup-fields/class-signup-field-order-bump.php
+++ b/inc/checkout/signup-fields/class-signup-field-order-bump.php
@@ -9,8 +9,8 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
-use \WP_Ultimo\Managers\Field_Templates_Manager;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Managers\Field_Templates_Manager;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -33,8 +33,7 @@ class Signup_Field_Order_Bump extends Base_Signup_Field {
public function get_type() {
return 'order_bump';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
@@ -45,8 +44,7 @@ class Signup_Field_Order_Bump extends Base_Signup_Field {
public function is_required() {
return false;
-
- } // end is_required;
+ }
/**
* Requires the title of the field/element type.
@@ -59,8 +57,7 @@ class Signup_Field_Order_Bump extends Base_Signup_Field {
public function get_title() {
return __('Order Bump', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -73,8 +70,7 @@ class Signup_Field_Order_Bump extends Base_Signup_Field {
public function get_description() {
return __('Adds a product offer that the customer can click to add to the current cart.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -87,8 +83,7 @@ class Signup_Field_Order_Bump extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds a product offer that the customer can click to add to the current cart.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
@@ -101,8 +96,7 @@ class Signup_Field_Order_Bump extends Base_Signup_Field {
public function get_icon() {
return 'dashicons-wu-gift';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -119,8 +113,7 @@ class Signup_Field_Order_Bump extends Base_Signup_Field {
'order_bump_template' => 'simple',
'display_product_description' => 0,
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -134,8 +127,7 @@ class Signup_Field_Order_Bump extends Base_Signup_Field {
// 'id',
'name',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -148,8 +140,7 @@ class Signup_Field_Order_Bump extends Base_Signup_Field {
return array(
'order_bump_template' => 'simple',
);
-
- } // end force_attributes;
+ }
/**
* Returns the list of available pricing table templates.
@@ -162,8 +153,7 @@ class Signup_Field_Order_Bump extends Base_Signup_Field {
$available_templates = Field_Templates_Manager::get_instance()->get_templates_as_options('order_bump');
return $available_templates;
-
- } // end get_templates;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -233,8 +223,7 @@ class Signup_Field_Order_Bump extends Base_Signup_Field {
// );
return $editor_fields;
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -250,11 +239,9 @@ 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) {
-
+ if ( ! $product) {
return array();
-
- } // end if;
+ }
$attributes['product'] = $product;
@@ -269,7 +256,5 @@ class Signup_Field_Order_Bump extends Base_Signup_Field {
'wrapper_classes' => $attributes['element_classes'],
),
);
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Order_Bump;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-order-summary.php b/inc/checkout/signup-fields/class-signup-field-order-summary.php
index 0f18672..dc16bc8 100644
--- a/inc/checkout/signup-fields/class-signup-field-order-summary.php
+++ b/inc/checkout/signup-fields/class-signup-field-order-summary.php
@@ -9,8 +9,8 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
-use \WP_Ultimo\Managers\Field_Templates_Manager;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Managers\Field_Templates_Manager;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -25,15 +25,14 @@ defined('ABSPATH') || exit;
class Signup_Field_Order_Summary extends Base_Signup_Field {
/**
- * Returns the type of the field.
- *
- * @since 2.0.0
- */
+ * Returns the type of the field.
+ *
+ * @since 2.0.0
+ */
public function get_type(): string {
return 'order_summary';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
*
@@ -42,8 +41,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
public function is_required(): bool {
return true;
-
- } // end is_required;
+ }
/**
* Requires the title of the field/element type.
@@ -56,8 +54,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
public function get_title() {
return __('Order Summary', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -70,8 +67,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
public function get_description() {
return __('Adds a summary table with prices, key subscription dates, discounts, and taxes.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -84,8 +80,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds a summary table with prices, key subscription dates, discounts, and taxes.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
*
@@ -96,8 +91,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
public function get_icon(): string {
return 'dashicons-wu-dollar-sign';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -114,8 +108,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
'order_summary_template' => 'clean',
'table_columns' => 'simple',
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -128,8 +121,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
return array(
'name',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -142,8 +134,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
return array(
'id' => 'order_summary',
);
-
- } // end force_attributes;
+ }
/**
* Returns the list of available pricing table templates.
@@ -156,8 +147,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
$available_templates = Field_Templates_Manager::get_instance()->get_templates_as_options('order_summary');
return $available_templates;
-
- } // end get_templates;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -176,7 +166,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
'options' => array(
'simple' => __('Simplified', 'wp-ultimo'),
'full' => __('Display All', 'wp-ultimo'),
- )
+ ),
);
$editor_fields['order_summary_template'] = array(
@@ -206,8 +196,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
// );
return $editor_fields;
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -225,16 +214,14 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
* Backwards compatibility with previous betas
*/
if ($attributes['order_summary_template'] === 'simple') {
-
$attributes['order_summary_template'] = 'clean';
-
- } // end if;
+ }
$template_class = Field_Templates_Manager::get_instance()->get_template_class('order_summary', $attributes['order_summary_template']);
$content = $template_class ? $template_class->render_container($attributes) : __('Template does not exist.', 'wp-ultimo');
- $checkout_fields[$attributes['id']] = array(
+ $checkout_fields[ $attributes['id'] ] = array(
'type' => 'note',
'desc' => $content,
'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''),
@@ -245,7 +232,5 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
);
return $checkout_fields;
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Order_Summary;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-password.php b/inc/checkout/signup-fields/class-signup-field-password.php
index 7a35bf2..f3d0c87 100644
--- a/inc/checkout/signup-fields/class-signup-field-password.php
+++ b/inc/checkout/signup-fields/class-signup-field-password.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -32,8 +32,7 @@ class Signup_Field_Password extends Base_Signup_Field {
public function get_type() {
return 'password';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
@@ -44,8 +43,7 @@ class Signup_Field_Password extends Base_Signup_Field {
public function is_required() {
return true;
-
- } // end is_required;
+ }
/**
* Is this a user-related field?
@@ -59,8 +57,7 @@ class Signup_Field_Password extends Base_Signup_Field {
public function is_user_field() {
return true;
-
- } // end is_user_field;
+ }
/**
* Requires the title of the field/element type.
@@ -73,8 +70,7 @@ class Signup_Field_Password extends Base_Signup_Field {
public function get_title() {
return __('Password', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -87,8 +83,7 @@ class Signup_Field_Password extends Base_Signup_Field {
public function get_description() {
return __('Adds a password field, with options for enforcing password strength and adding password confirmation field. This password is then used to create the WordPress user.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -101,8 +96,7 @@ class Signup_Field_Password extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds a password field, with options for enforcing password strength and adding password confirmation field. This password is then used to create the WordPress user.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
@@ -115,8 +109,7 @@ class Signup_Field_Password extends Base_Signup_Field {
public function get_icon() {
return 'dashicons-wu-lock1';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -133,8 +126,7 @@ class Signup_Field_Password extends Base_Signup_Field {
'password_confirm_field' => false,
'password_confirm_label' => __('Confirm Password', 'wp-ultimo'),
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -149,8 +141,7 @@ class Signup_Field_Password extends Base_Signup_Field {
'placeholder',
'tooltip',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -164,8 +155,7 @@ class Signup_Field_Password extends Base_Signup_Field {
'id' => 'password',
'required' => true,
);
-
- } // end force_attributes;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -189,8 +179,7 @@ class Signup_Field_Password extends Base_Signup_Field {
'value' => 1,
),
);
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -205,10 +194,8 @@ class Signup_Field_Password extends Base_Signup_Field {
* Logged in user, bail.
*/
if (is_user_logged_in()) {
-
return array();
-
- } // end if;
+ }
$checkout_fields = array();
@@ -231,7 +218,6 @@ class Signup_Field_Password extends Base_Signup_Field {
);
if ($attributes['password_confirm_field']) {
-
$checkout_fields['password_conf'] = array(
'type' => 'password',
'id' => 'password_conf',
@@ -249,11 +235,8 @@ class Signup_Field_Password extends Base_Signup_Field {
'style' => $this->calculate_style_attr(),
),
);
-
- } // end if;
+ }
return $checkout_fields;
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Password;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-payment.php b/inc/checkout/signup-fields/class-signup-field-payment.php
index 855dcd3..9f6fb48 100644
--- a/inc/checkout/signup-fields/class-signup-field-payment.php
+++ b/inc/checkout/signup-fields/class-signup-field-payment.php
@@ -9,8 +9,8 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
-use \WP_Ultimo\Managers\Gateway_Manager;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Managers\Gateway_Manager;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -33,8 +33,7 @@ class Signup_Field_Payment extends Base_Signup_Field {
public function get_type() {
return 'payment';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
@@ -45,8 +44,7 @@ class Signup_Field_Payment extends Base_Signup_Field {
public function is_required() {
return true;
-
- } // end is_required;
+ }
/**
* Requires the title of the field/element type.
@@ -59,8 +57,7 @@ class Signup_Field_Payment extends Base_Signup_Field {
public function get_title() {
return __('Payment', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -73,8 +70,7 @@ class Signup_Field_Payment extends Base_Signup_Field {
public function get_description() {
return __('Adds the payment options and the additional fields required to complete a purchase (e.g. credit card field).', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -87,8 +83,7 @@ class Signup_Field_Payment extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds the payment options and the additional fields required to complete a purchase (e.g. credit card field).', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
@@ -101,8 +96,7 @@ class Signup_Field_Payment extends Base_Signup_Field {
public function get_icon() {
return 'dashicons-wu-credit-card2';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -116,10 +110,9 @@ class Signup_Field_Payment extends Base_Signup_Field {
public function defaults() {
return array(
- ''
+ '',
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -132,8 +125,7 @@ class Signup_Field_Payment extends Base_Signup_Field {
return array(
'name',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -146,8 +138,7 @@ class Signup_Field_Payment extends Base_Signup_Field {
return array(
'id' => 'payment',
);
-
- } // end force_attributes;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -158,8 +149,7 @@ class Signup_Field_Payment extends Base_Signup_Field {
public function get_fields() {
return array();
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -194,8 +184,7 @@ class Signup_Field_Payment extends Base_Signup_Field {
* Checks if we need to add the
* auto renew field.
*/
- if (!wu_get_setting('force_auto_renew', 1)) {
-
+ if ( ! wu_get_setting('force_auto_renew', 1)) {
$auto_renewable_gateways = Gateway_Manager::get_instance()->get_auto_renewable_gateways();
$fields['auto_renew'] = array(
@@ -212,13 +201,10 @@ class Signup_Field_Payment extends Base_Signup_Field {
'wrapper_html_attr' => array(
'v-cloak' => 1,
'v-show' => sprintf('%s.includes(gateway) && order.should_collect_payment && order.has_recurring', json_encode($auto_renewable_gateways)),
- )
+ ),
);
-
- } // end if;
+ }
return $fields;
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Payment;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-period-selection.php b/inc/checkout/signup-fields/class-signup-field-period-selection.php
index ba49ba1..7ea5cca 100644
--- a/inc/checkout/signup-fields/class-signup-field-period-selection.php
+++ b/inc/checkout/signup-fields/class-signup-field-period-selection.php
@@ -9,8 +9,8 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
-use \WP_Ultimo\Managers\Field_Templates_Manager;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Managers\Field_Templates_Manager;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -25,15 +25,14 @@ defined('ABSPATH') || exit;
class Signup_Field_Period_Selection extends Base_Signup_Field {
/**
- * Returns the type of the field.
- *
- * @since 2.0.0
- */
+ * Returns the type of the field.
+ *
+ * @since 2.0.0
+ */
public function get_type(): string {
return 'period_selection';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
*
@@ -42,8 +41,7 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
public function is_required(): bool {
return false;
-
- } // end is_required;
+ }
/**
* Requires the title of the field/element type.
@@ -56,8 +54,7 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
public function get_title() {
return __('Period Select', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -70,8 +67,7 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
public function get_description() {
return __('Adds a period selector, that allows customers to switch between different billing periods.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -84,8 +80,7 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds a period selector, that allows customers to switch between different billing periods.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
*
@@ -96,8 +91,7 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
public function get_icon(): string {
return 'dashicons-wu dashicons-wu-toggle-right';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -113,8 +107,7 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
return array(
'period_selection_template' => 'clean',
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -127,8 +120,7 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
return array(
// 'name',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -143,8 +135,7 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
'name' => __('Plan Duration Switch', 'wp-ultimo'),
'required' => true,
);
-
- } // end force_attributes;
+ }
/**
* Returns the list of available pricing table templates.
@@ -157,8 +148,7 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
$available_templates = Field_Templates_Manager::get_instance()->get_templates_as_options('period_selection');
return $available_templates;
-
- } // end get_template_options;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -283,8 +273,7 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
);
return $editor_fields;
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -297,14 +286,12 @@ 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_enqueue_script('wu-legacy-signup');
wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), array('dashicons'), wu_get_version());
-
- } // end if;
+ }
$template_class = Field_Templates_Manager::get_instance()->get_template_class('period_selection', $attributes['period_selection_template']);
@@ -312,7 +299,7 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
$checkout_fields = array();
- $checkout_fields[$attributes['id']] = array(
+ $checkout_fields[ $attributes['id'] ] = array(
'type' => 'note',
'id' => $attributes['id'],
'wrapper_classes' => $attributes['element_classes'],
@@ -334,7 +321,5 @@ class Signup_Field_Period_Selection extends Base_Signup_Field {
);
return $checkout_fields;
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Period_Selection;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-pricing-table.php b/inc/checkout/signup-fields/class-signup-field-pricing-table.php
index e9ed328..e4c6817 100644
--- a/inc/checkout/signup-fields/class-signup-field-pricing-table.php
+++ b/inc/checkout/signup-fields/class-signup-field-pricing-table.php
@@ -9,8 +9,8 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
-use \WP_Ultimo\Managers\Field_Templates_Manager;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Managers\Field_Templates_Manager;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -25,15 +25,14 @@ defined('ABSPATH') || exit;
class Signup_Field_Pricing_Table extends Base_Signup_Field {
/**
- * Returns the type of the field.
- *
- * @since 2.0.0
- */
+ * Returns the type of the field.
+ *
+ * @since 2.0.0
+ */
public function get_type(): string {
return 'pricing_table';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
*
@@ -42,8 +41,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
public function is_required(): bool {
return false;
-
- } // end is_required;
+ }
/**
* Requires the title of the field/element type.
@@ -56,8 +54,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
public function get_title() {
return __('Pricing Table', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -70,8 +67,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
public function get_description() {
return __('Adds a pricing table section that customers can use to choose a plan to subscribe to.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -84,8 +80,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds a pricing table section that customers can use to choose a plan to subscribe to.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
*
@@ -96,8 +91,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
public function get_icon(): string {
return 'dashicons-wu dashicons-wu-columns';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -116,8 +110,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
'force_different_durations' => false,
'hide_pricing_table_when_pre_selected' => false,
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -130,8 +123,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
return array(
// 'name',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -146,8 +138,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
'name' => __('Plan Selection', 'wp-ultimo'),
'required' => true,
);
-
- } // end force_attributes;
+ }
/**
* Returns the list of available pricing table templates.
@@ -160,8 +151,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
$available_templates = Field_Templates_Manager::get_instance()->get_templates_as_options('pricing_table');
return $available_templates;
-
- } // end get_pricing_table_templates;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -242,8 +232,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
// );
return $editor_fields;
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -256,12 +245,10 @@ 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_add_inline_style('legacy-shortcodes', \WP_Ultimo\Checkout\Legacy_Checkout::get_instance()->get_legacy_dynamic_styles());
-
- } // end if;
+ }
$product_list = explode(',', (string) $attributes['pricing_table_products']);
@@ -276,10 +263,8 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
* Hide when pre-selected.
*/
if (wu_should_hide_form_field($attributes)) {
-
return array();
-
- } // end if;
+ }
$template_attributes = array(
'products' => $products,
@@ -294,7 +279,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
$checkout_fields = array();
- $checkout_fields[$attributes['id']] = array(
+ $checkout_fields[ $attributes['id'] ] = array(
'type' => 'note',
'id' => $attributes['id'],
'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''),
@@ -306,7 +291,5 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field {
);
return $checkout_fields;
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Pricing_Table;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-products.php b/inc/checkout/signup-fields/class-signup-field-products.php
index f5a8cc5..d4177ac 100644
--- a/inc/checkout/signup-fields/class-signup-field-products.php
+++ b/inc/checkout/signup-fields/class-signup-field-products.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -24,15 +24,14 @@ defined('ABSPATH') || exit;
class Signup_Field_Products extends Base_Signup_Field {
/**
- * Returns the type of the field.
- *
- * @since 2.0.0
- */
+ * Returns the type of the field.
+ *
+ * @since 2.0.0
+ */
public function get_type(): string {
return 'products';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
*
@@ -41,8 +40,7 @@ class Signup_Field_Products extends Base_Signup_Field {
public function is_required(): bool {
return false;
-
- } // end is_required;
+ }
/**
* Requires the title of the field/element type.
@@ -55,8 +53,7 @@ class Signup_Field_Products extends Base_Signup_Field {
public function get_title() {
return __('Product', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -69,8 +66,7 @@ class Signup_Field_Products extends Base_Signup_Field {
public function get_description() {
return __('Hidden field used 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 products manually.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -83,8 +79,7 @@ class Signup_Field_Products extends Base_Signup_Field {
public function get_tooltip() {
return __('Hidden field used 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 products manually.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
*
@@ -95,8 +90,7 @@ class Signup_Field_Products extends Base_Signup_Field {
public function get_icon(): string {
return 'dashicons-wu dashicons-wu-package';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -110,10 +104,9 @@ class Signup_Field_Products extends Base_Signup_Field {
public function defaults() {
return array(
- ''
+ '',
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -124,8 +117,7 @@ class Signup_Field_Products extends Base_Signup_Field {
public function default_fields() {
return array();
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -139,8 +131,7 @@ class Signup_Field_Products extends Base_Signup_Field {
'name' => __('Pre-selected Products', 'wp-ultimo'),
'id' => 'products',
);
-
- } // end force_attributes;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -166,8 +157,7 @@ class Signup_Field_Products extends Base_Signup_Field {
),
),
);
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -184,22 +174,19 @@ class Signup_Field_Products extends Base_Signup_Field {
$products = explode(',', (string) $attributes['products']);
foreach ($products as $product_id) {
-
- $checkout_fields["products[{$product_id}]"] = array(
+ $checkout_fields[ "products[{$product_id}]" ] = array(
'type' => 'hidden',
'value' => $product_id,
'html_attr' => array(
'v-bind:name' => "'products[]'",
),
);
-
- } // end foreach;
+ }
$this->insert_products_in_form($products);
return $checkout_fields;
-
- } // end to_fields_array;
+ }
/**
* Inserts the products in the form.
@@ -212,10 +199,8 @@ class Signup_Field_Products extends Base_Signup_Field {
static $added = false;
if ($added) {
-
return;
-
- } // end if;
+ }
$added = true;
@@ -224,24 +209,23 @@ class Signup_Field_Products extends Base_Signup_Field {
data.products.push(...%s);
data.products = data.products.map((value) => parseInt(value) || value);
data.products = [...new Set(data.products)];
- } // end if;
+ }
return data;
});";
if (did_action('wu-checkout')) {
-
wp_add_inline_script('wu-checkout', sprintf($script, json_encode($products)), 'before');
return;
+ }
- } // end if;
+ add_action(
+ 'wp_enqueue_scripts',
+ function () use ($script, $products) {
- add_action('wp_enqueue_scripts', function() use ($script, $products) {
-
- wp_add_inline_script('wu-checkout', sprintf($script, json_encode($products)), 'before');
-
- }, 11);
-
- } // end insert_products_in_form;
-
-} // end class Signup_Field_Products;
+ wp_add_inline_script('wu-checkout', sprintf($script, json_encode($products)), 'before');
+ },
+ 11
+ );
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-select.php b/inc/checkout/signup-fields/class-signup-field-select.php
index c8985cf..29fd1de 100644
--- a/inc/checkout/signup-fields/class-signup-field-select.php
+++ b/inc/checkout/signup-fields/class-signup-field-select.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -32,8 +32,7 @@ class Signup_Field_Select extends Base_Signup_Field {
public function get_type() {
return 'select';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
@@ -44,8 +43,7 @@ class Signup_Field_Select extends Base_Signup_Field {
public function is_required() {
return false;
-
- } // end is_required;
+ }
/**
* Requires the title of the field/element type.
@@ -58,8 +56,7 @@ class Signup_Field_Select extends Base_Signup_Field {
public function get_title() {
return __('Select', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -72,8 +69,7 @@ class Signup_Field_Select extends Base_Signup_Field {
public function get_description() {
return __('Adds a select field.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -86,8 +82,7 @@ class Signup_Field_Select extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds a select field.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
@@ -100,8 +95,7 @@ class Signup_Field_Select extends Base_Signup_Field {
public function get_icon() {
return 'dashicons-wu-list1';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -115,10 +109,9 @@ class Signup_Field_Select extends Base_Signup_Field {
public function defaults() {
return array(
- ''
+ '',
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -137,8 +130,7 @@ class Signup_Field_Select extends Base_Signup_Field {
'required',
'save_as',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -149,8 +141,7 @@ class Signup_Field_Select extends Base_Signup_Field {
public function force_attributes() {
return array();
-
- } // end force_attributes;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -237,8 +228,7 @@ class Signup_Field_Select extends Base_Signup_Field {
);
return $editor_fields;
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -253,10 +243,8 @@ class Signup_Field_Select extends Base_Signup_Field {
$options = array();
foreach ($attributes['options'] as $_option) {
-
- $options[$_option['key']] = $_option['label'];
-
- } // end foreach;
+ $options[ $_option['key'] ] = $_option['label'];
+ }
return array(
$attributes['id'] => array(
@@ -272,7 +260,5 @@ class Signup_Field_Select extends Base_Signup_Field {
'value' => $this->get_value(),
),
);
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Select;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-shortcode.php b/inc/checkout/signup-fields/class-signup-field-shortcode.php
index 1ac5906..49e497d 100644
--- a/inc/checkout/signup-fields/class-signup-field-shortcode.php
+++ b/inc/checkout/signup-fields/class-signup-field-shortcode.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -24,15 +24,14 @@ defined('ABSPATH') || exit;
class Signup_Field_Shortcode extends Base_Signup_Field {
/**
- * Returns the type of the field.
- *
- * @since 2.0.0
- */
+ * Returns the type of the field.
+ *
+ * @since 2.0.0
+ */
public function get_type(): string {
return 'shortcode';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
*
@@ -41,8 +40,7 @@ class Signup_Field_Shortcode extends Base_Signup_Field {
public function is_required(): bool {
return false;
-
- } // end is_required;
+ }
/**
* Requires the title of the field/element type.
@@ -55,8 +53,7 @@ class Signup_Field_Shortcode extends Base_Signup_Field {
public function get_title() {
return __('Shortcode', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -69,8 +66,7 @@ class Signup_Field_Shortcode extends Base_Signup_Field {
public function get_description() {
return __('Displays the content of a given WordPress shortcode. Can be useful to inset content from other plugins inside a WP Multisite WaaS checkout form.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -83,8 +79,7 @@ class Signup_Field_Shortcode extends Base_Signup_Field {
public function get_tooltip() {
return __('Displays the content of a given WordPress shortcode. Can be useful to insert content from other plugins inside a WP Multisite WaaS checkout form.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
*
@@ -95,8 +90,7 @@ class Signup_Field_Shortcode extends Base_Signup_Field {
public function get_icon(): string {
return 'dashicons-wu-terminal';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -110,10 +104,9 @@ class Signup_Field_Shortcode extends Base_Signup_Field {
public function defaults() {
return array(
- ''
+ '',
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -127,8 +120,7 @@ class Signup_Field_Shortcode extends Base_Signup_Field {
// 'id',
// 'name',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -141,8 +133,7 @@ class Signup_Field_Shortcode extends Base_Signup_Field {
return array(
'name' => __('Shortcode', 'wp-ultimo'),
);
-
- } // end force_attributes;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -160,8 +151,7 @@ class Signup_Field_Shortcode extends Base_Signup_Field {
'desc' => __('Please, enter the full shortcode, including [].', 'wp-ultimo'),
),
);
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -184,7 +174,5 @@ class Signup_Field_Shortcode extends Base_Signup_Field {
),
),
);
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Shortcode;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-site-title.php b/inc/checkout/signup-fields/class-signup-field-site-title.php
index 089a927..528f655 100644
--- a/inc/checkout/signup-fields/class-signup-field-site-title.php
+++ b/inc/checkout/signup-fields/class-signup-field-site-title.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -32,8 +32,7 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
public function get_type() {
return 'site_title';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
@@ -44,8 +43,7 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
public function is_required() {
return false;
-
- } // end is_required;
+ }
/**
* Defines if this field/element is related to site creation or not.
@@ -56,8 +54,7 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
public function is_site_field() {
return true;
-
- } // end is_site_field;
+ }
/**
* Requires the title of the field/element type.
@@ -70,8 +67,7 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
public function get_title() {
return __('Site Title', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -84,8 +80,7 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
public function get_description() {
return __('Adds a Site Title field. This value is used to set the site title for the site being created.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -98,8 +93,7 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds a Site Title field. This value is used to set the site title for the site being created.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
@@ -112,8 +106,7 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
public function get_icon() {
return 'dashicons-wu-type';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -129,8 +122,7 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
return array(
'auto_generate_site_title' => false,
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -145,8 +137,7 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
'placeholder',
'tooltip',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -160,8 +151,7 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
'id' => 'site_title',
'required' => true,
);
-
- } // end force_attributes;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -183,8 +173,7 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
),
),
);
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -199,7 +188,6 @@ 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(
'type' => 'hidden',
@@ -211,11 +199,10 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
'id' => 'site_title',
'html_attr' => array(
'v-bind:value' => 'username',
- )
+ ),
),
);
-
- } // end if;
+ }
return array(
'site_title' => array(
@@ -233,7 +220,5 @@ class Signup_Field_Site_Title extends Base_Signup_Field {
),
),
);
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Site_Title;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-site-url.php b/inc/checkout/signup-fields/class-signup-field-site-url.php
index a642571..a059668 100644
--- a/inc/checkout/signup-fields/class-signup-field-site-url.php
+++ b/inc/checkout/signup-fields/class-signup-field-site-url.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -24,15 +24,14 @@ defined('ABSPATH') || exit;
class Signup_Field_Site_Url extends Base_Signup_Field {
/**
- * Returns the type of the field.
- *
- * @since 2.0.0
- */
+ * Returns the type of the field.
+ *
+ * @since 2.0.0
+ */
public function get_type(): string {
return 'site_url';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
*
@@ -41,8 +40,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
public function is_required(): bool {
return false;
-
- } // end is_required;
+ }
/**
* Defines if this field/element is related to site creation or not.
*
@@ -51,8 +49,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
public function is_site_field(): bool {
return true;
-
- } // end is_site_field;
+ }
/**
* Requires the title of the field/element type.
@@ -65,8 +62,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
public function get_title() {
return __('Site URL', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -79,8 +75,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
public function get_description() {
return __('Adds a Site URL field. This is used to set the URL of the site being created.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -93,8 +88,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds a Site URL field. This is used to set the URL of the site being created.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
*
@@ -105,8 +99,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
public function get_icon(): string {
return 'dashicons-wu-globe1';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -128,8 +121,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
'display_field_attachments' => true,
'available_domains' => $current_site->domain . PHP_EOL,
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -144,8 +136,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
'placeholder',
'tooltip',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -159,8 +150,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
'id' => 'site_url',
'required' => true,
);
-
- } // end force_attributes;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -246,8 +236,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
),
),
);
-
- } // end get_fields;
+ }
/**
* Returns the list of available pricing table templates.
@@ -263,8 +252,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
);
return apply_filters('wu_get_pricing_table_templates', $templates);
-
- } // end get_url_preview_templates;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -279,7 +267,6 @@ 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(
'type' => 'hidden',
@@ -292,8 +279,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
'value' => uniqid(),
),
);
-
- } // end if;
+ }
$checkout_fields = array();
@@ -316,7 +302,6 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
);
if ($attributes['display_field_attachments']) {
-
$checkout_fields['site_url']['classes'] .= ' xs:wu-rounded-none';
$checkout_fields['site_url']['prefix'] = ' ';
@@ -337,11 +322,9 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
'v-cloak' => 1,
'v-show' => 'is_subdomain',
);
-
- } // end if;
+ }
if ($attributes['available_domains'] && $attributes['enable_domain_selection']) {
-
$options = $this->get_domain_options($attributes['available_domains']);
$checkout_fields['site_domain'] = array(
@@ -361,11 +344,9 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
'style' => $this->calculate_style_attr(),
),
);
-
- } // end if;
+ }
if ($attributes['display_url_preview']) {
-
$content = wu_get_template_contents('legacy/signup/steps/step-domain-url-preview');
$checkout_fields['site_url_preview'] = array(
@@ -377,12 +358,10 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
'style' => $this->calculate_style_attr(),
),
);
-
- } // end if;
+ }
return $checkout_fields;
-
- } // end to_fields_array;
+ }
/**
* Get the domain options.
*
@@ -397,7 +376,5 @@ class Signup_Field_Site_Url extends Base_Signup_Field {
$domains = array_map(fn($item) => trim((string) $item), $domains);
return array_combine($domains, $domains);
-
- } // end get_domain_options;
-
-} // end class Signup_Field_Site_Url;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-steps.php b/inc/checkout/signup-fields/class-signup-field-steps.php
index dfb14c3..374ce08 100644
--- a/inc/checkout/signup-fields/class-signup-field-steps.php
+++ b/inc/checkout/signup-fields/class-signup-field-steps.php
@@ -9,8 +9,8 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
-use \WP_Ultimo\Managers\Field_Templates_Manager;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Managers\Field_Templates_Manager;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -25,15 +25,14 @@ defined('ABSPATH') || exit;
class Signup_Field_Steps extends Base_Signup_Field {
/**
- * Returns the type of the field.
- *
- * @since 2.0.0
- */
+ * Returns the type of the field.
+ *
+ * @since 2.0.0
+ */
public function get_type(): string {
return 'steps';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
*
@@ -42,8 +41,7 @@ class Signup_Field_Steps extends Base_Signup_Field {
public function is_required(): bool {
return false;
-
- } // end is_required;
+ }
/**
* Requires the title of the field/element type.
@@ -56,8 +54,7 @@ class Signup_Field_Steps extends Base_Signup_Field {
public function get_title() {
return __('Steps', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -70,8 +67,7 @@ class Signup_Field_Steps extends Base_Signup_Field {
public function get_description() {
return __('Adds a list of the steps.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -84,8 +80,7 @@ class Signup_Field_Steps extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds a list of the steps.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
*
@@ -96,8 +91,7 @@ class Signup_Field_Steps extends Base_Signup_Field {
public function get_icon(): string {
return 'dashicons-wu-filter_1';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -113,8 +107,7 @@ class Signup_Field_Steps extends Base_Signup_Field {
return array(
'steps_template' => 'clean',
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -125,8 +118,7 @@ class Signup_Field_Steps extends Base_Signup_Field {
public function default_fields() {
return array();
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -139,8 +131,7 @@ class Signup_Field_Steps extends Base_Signup_Field {
return array(
'id' => 'steps',
);
-
- } // end force_attributes;
+ }
/**
* Returns the list of available pricing table templates.
@@ -153,8 +144,7 @@ class Signup_Field_Steps extends Base_Signup_Field {
$available_templates = Field_Templates_Manager::get_instance()->get_templates_as_options('steps');
return $available_templates;
-
- } // end get_templates;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -192,8 +182,7 @@ class Signup_Field_Steps extends Base_Signup_Field {
// );
return $editor_fields;
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -206,12 +195,10 @@ 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_add_inline_style('legacy-shortcodes', \WP_Ultimo\Checkout\Legacy_Checkout::get_instance()->get_legacy_dynamic_styles());
-
- } // end if;
+ }
$attributes['steps'] = \WP_Ultimo\Checkout\Checkout::get_instance()->steps;
$attributes['current_step'] = \WP_Ultimo\Checkout\Checkout::get_instance()->step_name;
@@ -227,7 +214,5 @@ class Signup_Field_Steps extends Base_Signup_Field {
'wrapper_classes' => $attributes['element_classes'],
),
);
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Steps;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-submit-button.php b/inc/checkout/signup-fields/class-signup-field-submit-button.php
index 96573c6..f4214c6 100644
--- a/inc/checkout/signup-fields/class-signup-field-submit-button.php
+++ b/inc/checkout/signup-fields/class-signup-field-submit-button.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -32,8 +32,7 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
public function get_type() {
return 'submit_button';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
@@ -44,8 +43,7 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
public function is_required() {
return true;
-
- } // end is_required;
+ }
/**
* Requires the title of the field/element type.
@@ -58,8 +56,7 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
public function get_title() {
return __('Submit Button', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -72,8 +69,7 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
public function get_description() {
return __('Adds a submit button. This is required to finalize single-step checkout forms or to navigate to the next step on multi-step checkout forms.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -86,8 +82,7 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds a submit button. This is required to finalize single-step checkout forms or to navigate to the next step on multi-step checkout forms.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
@@ -100,8 +95,7 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
public function get_icon() {
return 'dashicons-wu-zap';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -118,8 +112,7 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
'enable_go_back_button' => false,
'back_button_label' => __('← Go Back', 'wp-ultimo'),
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -133,8 +126,7 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
'id',
'name',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -145,8 +137,7 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
public function force_attributes() {
return array();
-
- } // end force_attributes;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -179,8 +170,7 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
),
),
);
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -196,7 +186,7 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
$fields = array();
- $fields[$attributes['id'] . '_errors'] = array(
+ $fields[ $attributes['id'] . '_errors' ] = array(
'type' => 'html',
'wrapper_classes' => 'wu_submit_button_errors wu-clear-both',
'content' => '',
@@ -205,7 +195,7 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
),
);
- $fields[$attributes['id'] . '_group'] = array(
+ $fields[ $attributes['id'] . '_group' ] = array(
'type' => 'group',
'raw' => true,
'default' => array(),
@@ -216,14 +206,12 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
$button_wrapper_classes = 'wu_submit_button';
if ($attributes['enable_go_back_button']) {
-
$steps = \WP_Ultimo\Checkout\Checkout::get_instance()->steps;
$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(
+ if ( ! $is_first_step) {
+ $fields[ $attributes['id'] . '_group' ]['fields'][ $attributes['id'] . '_go_back' ] = array(
'type' => 'html',
'wrapper_classes' => 'md:wu-w-1/2 wu-box-border wu-float-left wu--mt-4',
'id' => $attributes['id'] . '_go_back',
@@ -231,12 +219,10 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
);
$button_wrapper_classes .= ' md:wu-w-1/2 wu-box-border wu-float-left wu-text-right';
+ }
+ }
- } // end if;
-
- } // end if;
-
- $fields[$attributes['id'] . '_group']['fields'][$attributes['id']] = array(
+ $fields[ $attributes['id'] . '_group' ]['fields'][ $attributes['id'] ] = array(
'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', '')),
@@ -245,15 +231,11 @@ class Signup_Field_Submit_Button extends Base_Signup_Field {
);
if ($attributes['enable_go_back_button']) {
-
- $fields[$attributes['id'] . '_clear'] = array(
+ $fields[ $attributes['id'] . '_clear' ] = array(
'type' => 'clear',
);
-
- } // end if;
+ }
return $fields;
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Submit_Button;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-template-selection.php b/inc/checkout/signup-fields/class-signup-field-template-selection.php
index c6dacd7..0b2b054 100644
--- a/inc/checkout/signup-fields/class-signup-field-template-selection.php
+++ b/inc/checkout/signup-fields/class-signup-field-template-selection.php
@@ -9,9 +9,9 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
-use \WP_Ultimo\Managers\Field_Templates_Manager;
-use \WP_Ultimo\Models\Site;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Managers\Field_Templates_Manager;
+use WP_Ultimo\Models\Site;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -26,15 +26,14 @@ defined('ABSPATH') || exit;
class Signup_Field_Template_Selection extends Base_Signup_Field {
/**
- * Returns the type of the field.
- *
- * @since 2.0.0
- */
+ * Returns the type of the field.
+ *
+ * @since 2.0.0
+ */
public function get_type(): string {
return 'template_selection';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
*
@@ -43,8 +42,7 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
public function is_required(): bool {
return false;
-
- } // end is_required;
+ }
/**
* Requires the title of the field/element type.
@@ -57,8 +55,7 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
public function get_title() {
return __('Templates', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -71,8 +68,7 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
public function get_description() {
return __('Adds a template selection section. This allows the customer to choose a pre-built site to be used as a template for the site being currently created.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -85,8 +81,7 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds a template selection section. This allows the customer to choose a pre-built site to be used as a template for the site being currently created.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
*
@@ -97,8 +92,7 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
public function get_icon(): string {
return 'dashicons-wu-layout';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -118,8 +112,7 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
'cols' => 3,
'hide_template_selection_when_pre_selected' => false,
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -132,8 +125,7 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
return array(
// 'name',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -148,8 +140,7 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
'name' => __('Template Selection', 'wp-ultimo'),
'required' => true,
);
-
- } // end force_attributes;
+ }
/**
* Returns the list of available pricing table templates.
@@ -162,8 +153,7 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
$available_templates = Field_Templates_Manager::get_instance()->get_templates_as_options('template_selection');
return $available_templates;
-
- } // end get_template_selection_templates;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -223,9 +213,14 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
'data-label-field' => 'title',
'data-search-field' => 'title',
'data-max-items' => 999,
- 'data-include' => implode(',', wu_get_site_templates(array(
- 'fields' => 'blog_id',
- ))),
+ 'data-include' => implode(
+ ',',
+ wu_get_site_templates(
+ array(
+ 'fields' => 'blog_id',
+ )
+ )
+ ),
),
'wrapper_html_attr' => array(
'v-show' => 'template_selection_type === \'name\'',
@@ -272,8 +267,7 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
// );
return $editor_fields;
-
- } // end get_fields;
+ }
/**
* Treat the attributes array to avoid reaching the input var limits.
@@ -290,8 +284,7 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
$attributes['sites'] = array_values(array_column($array_sites, 'blog_id'));
return $attributes;
-
- } // end reduce_attributes;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -316,41 +309,33 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
* Hide when pre-selected.
*/
if (wu_should_hide_form_field($attributes)) {
-
return $checkout_fields;
-
- } // end if;
+ }
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_enqueue_script('wu-legacy-signup');
wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), array('dashicons'), wu_get_version());
-
- } // end if;
+ }
$site_list = $this->site_list($attributes);
$customer_sites = array();
if (wu_get_setting('allow_own_site_as_template')) {
-
$customer = wu_get_current_customer();
if ($customer) {
-
$customer_sites = $customer->get_sites(array('fields' => 'ids'));
$site_list = array_merge(
$customer_sites,
$site_list
);
-
- } // end if;
-
- } // end if;
+ }
+ }
$sites = array_map('wu_get_site', $site_list);
@@ -371,15 +356,14 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
$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'] ] = array(
'type' => 'note',
'desc' => $content,
'wrapper_classes' => $attributes['element_classes'],
);
return $checkout_fields;
-
- } // end to_fields_array;
+ }
/**
* Return site list according to selection type used.
@@ -392,19 +376,14 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
$selection_type = wu_get_isset($attributes, 'template_selection_type', 'name');
if ($selection_type === 'name') {
-
return explode(',', $attributes['template_selection_sites']);
-
- } // end if;
+ }
if ($selection_type === 'all') {
-
return wu_get_site_templates(array('fields' => 'blog_id'));
-
- } // end if;
+ }
if ($selection_type === 'categories') {
-
return array_column(
\WP_Ultimo\Models\Site::get_all_by_categories(
$attributes['template_selection_categories'],
@@ -414,12 +393,8 @@ class Signup_Field_Template_Selection extends Base_Signup_Field {
),
'blog_id'
);
-
- } // end if;
+ }
return explode(',', $attributes['template_selection_sites']);
-
- } // end site_list;
-
-
-} // end class Signup_Field_Template_Selection;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-terms-of-use.php b/inc/checkout/signup-fields/class-signup-field-terms-of-use.php
index d6ca43e..c0204e5 100644
--- a/inc/checkout/signup-fields/class-signup-field-terms-of-use.php
+++ b/inc/checkout/signup-fields/class-signup-field-terms-of-use.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -32,8 +32,7 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field {
public function get_type() {
return 'terms_of_use';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
@@ -44,8 +43,7 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field {
public function is_required() {
return false;
-
- } // end is_required;
+ }
/**
* Is this a user-related field?
@@ -59,8 +57,7 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field {
public function is_user_field() {
return false;
-
- } // end is_user_field;
+ }
/**
* Requires the title of the field/element type.
@@ -73,8 +70,7 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field {
public function get_title() {
return __('Terms of Use', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -87,8 +83,7 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field {
public function get_description() {
return __('Adds a terms and conditions checkbox that must be marked before the account/site can be created.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -101,8 +96,7 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds a terms and conditions checkbox that must be marked before the account/site can be created.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
@@ -115,8 +109,7 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field {
public function get_icon() {
return 'dashicons-wu-file-text';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -132,8 +125,7 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field {
return array(
'tou_name' => __('I agree with the terms of use.', 'wp-ultimo'),
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -144,8 +136,7 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field {
public function default_fields() {
return array();
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -159,8 +150,7 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field {
'id' => 'terms_of_use',
'name' => __('Terms of Use', 'wp-ultimo'),
);
-
- } // end force_attributes;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -185,8 +175,7 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field {
'placeholder' => __('e.g. https://yoursite.com/terms', 'wp-ultimo'),
),
);
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -212,7 +201,5 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field {
);
return $checkout_fields;
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Terms_Of_Use;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-text.php b/inc/checkout/signup-fields/class-signup-field-text.php
index 5e91b06..1ce3760 100644
--- a/inc/checkout/signup-fields/class-signup-field-text.php
+++ b/inc/checkout/signup-fields/class-signup-field-text.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -32,8 +32,7 @@ class Signup_Field_Text extends Base_Signup_Field {
public function get_type() {
return 'text';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
@@ -44,8 +43,7 @@ class Signup_Field_Text extends Base_Signup_Field {
public function is_required() {
return false;
-
- } // end is_required;
+ }
/**
* Requires the title of the field/element type.
@@ -58,8 +56,7 @@ class Signup_Field_Text extends Base_Signup_Field {
public function get_title() {
return __('Text', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -72,8 +69,7 @@ class Signup_Field_Text extends Base_Signup_Field {
public function get_description() {
return __('Adds a text field that the customer can fill with arbitrary data.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -86,8 +82,7 @@ class Signup_Field_Text extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds a text field that the customer can fill with arbitrary data.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
@@ -100,8 +95,7 @@ class Signup_Field_Text extends Base_Signup_Field {
public function get_icon() {
return 'dashicons-wu-edit-3';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -115,10 +109,9 @@ class Signup_Field_Text extends Base_Signup_Field {
public function defaults() {
return array(
- ''
+ '',
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -137,8 +130,7 @@ class Signup_Field_Text extends Base_Signup_Field {
'required',
'save_as',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -149,8 +141,7 @@ class Signup_Field_Text extends Base_Signup_Field {
public function force_attributes() {
return array();
-
- } // end force_attributes;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -161,8 +152,7 @@ class Signup_Field_Text extends Base_Signup_Field {
public function get_fields() {
return array();
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -188,7 +178,5 @@ class Signup_Field_Text extends Base_Signup_Field {
);
return $fields;
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Text;
+ }
+}
diff --git a/inc/checkout/signup-fields/class-signup-field-username.php b/inc/checkout/signup-fields/class-signup-field-username.php
index 70703fe..ac0e4cc 100644
--- a/inc/checkout/signup-fields/class-signup-field-username.php
+++ b/inc/checkout/signup-fields/class-signup-field-username.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\Checkout\Signup_Fields;
-use \WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
+use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -32,8 +32,7 @@ class Signup_Field_Username extends Base_Signup_Field {
public function get_type() {
return 'username';
-
- } // end get_type;
+ }
/**
* Returns if this field should be present on the checkout flow or not.
@@ -44,8 +43,7 @@ class Signup_Field_Username extends Base_Signup_Field {
public function is_required() {
return true;
-
- } // end is_required;
+ }
/**
* Is this a user-related field?
@@ -59,8 +57,7 @@ class Signup_Field_Username extends Base_Signup_Field {
public function is_user_field() {
return true;
-
- } // end is_user_field;
+ }
/**
* Requires the title of the field/element type.
@@ -73,8 +70,7 @@ class Signup_Field_Username extends Base_Signup_Field {
public function get_title() {
return __('Username', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* Returns the description of the field/element.
@@ -87,8 +83,7 @@ class Signup_Field_Username extends Base_Signup_Field {
public function get_description() {
return __('Adds an username field. This username will be used to create the WordPress user.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* Returns the tooltip of the field/element.
@@ -101,8 +96,7 @@ class Signup_Field_Username extends Base_Signup_Field {
public function get_tooltip() {
return __('Adds an username field. This username will be used to create the WordPress user.', 'wp-ultimo');
-
- } // end get_tooltip;
+ }
/**
* Returns the icon to be used on the selector.
@@ -115,8 +109,7 @@ class Signup_Field_Username extends Base_Signup_Field {
public function get_icon() {
return 'dashicons-wu-user1';
-
- } // end get_icon;
+ }
/**
* Returns the default values for the field-elements.
@@ -132,8 +125,7 @@ class Signup_Field_Username extends Base_Signup_Field {
return array(
'auto_generate_username' => false,
);
-
- } // end defaults;
+ }
/**
* List of keys of the default fields we want to display on the builder.
@@ -148,8 +140,7 @@ class Signup_Field_Username extends Base_Signup_Field {
'placeholder',
'tooltip',
);
-
- } // end default_fields;
+ }
/**
* If you want to force a particular attribute to a value, declare it here.
@@ -163,8 +154,7 @@ class Signup_Field_Username extends Base_Signup_Field {
'id' => 'username',
'required' => true,
);
-
- } // end force_attributes;
+ }
/**
* Returns the list of additional fields specific to this type.
@@ -186,8 +176,7 @@ class Signup_Field_Username extends Base_Signup_Field {
),
),
);
-
- } // end get_fields;
+ }
/**
* Returns the field/element actual field array to be used on the checkout form.
@@ -202,13 +191,10 @@ class Signup_Field_Username extends Base_Signup_Field {
* Logged in user, bail.
*/
if (is_user_logged_in()) {
-
return array();
-
- } // end if;
+ }
if (isset($attributes['auto_generate_username']) && $attributes['auto_generate_username']) {
-
return array(
'auto_generate_username' => array(
'type' => 'hidden',
@@ -221,8 +207,7 @@ class Signup_Field_Username extends Base_Signup_Field {
'value' => uniqid(),
),
);
-
- } // end if;
+ }
return array(
'username' => array(
@@ -245,7 +230,5 @@ class Signup_Field_Username extends Base_Signup_Field {
),
),
);
-
- } // end to_fields_array;
-
-} // end class Signup_Field_Username;
+ }
+}
diff --git a/inc/checkout/signup-fields/field-templates/class-base-field-template.php b/inc/checkout/signup-fields/field-templates/class-base-field-template.php
index f498630..eb8207b 100644
--- a/inc/checkout/signup-fields/field-templates/class-base-field-template.php
+++ b/inc/checkout/signup-fields/field-templates/class-base-field-template.php
@@ -29,10 +29,10 @@ class Base_Field_Template {
* @var string
*/
protected $id;
- /**
- * @var array
- */
- protected $attributes = array();
+ /**
+ * @var array
+ */
+ protected $attributes = array();
/**
* Field Template Constructor
@@ -41,10 +41,9 @@ class Base_Field_Template {
*
* @param array $attributes The attributes passed to the field.
*/
- public function __construct($attributes = array())
- {
- $this->attributes = $attributes;
- } // end __construct;
+ public function __construct($attributes = array()) {
+ $this->attributes = $attributes;
+ }
/**
* The render type for the template.
@@ -66,8 +65,7 @@ class Base_Field_Template {
public function get_render_type(): string {
return 'ajax';
-
- } // end get_render_type;
+ }
/**
* The title of the field template.
@@ -80,8 +78,7 @@ class Base_Field_Template {
public function get_title() {
return __('Field Template', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* The description of the field template.
@@ -94,8 +91,7 @@ class Base_Field_Template {
public function get_description() {
return __('Description', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* The preview image of the field template.
*
@@ -106,8 +102,7 @@ class Base_Field_Template {
public function get_preview(): string {
return '';
-
- } // end get_preview;
+ }
/**
* The content of the template.
@@ -117,7 +112,7 @@ class Base_Field_Template {
* @param array $attributes The field template attributes.
* @return void
*/
- public function output($attributes) {} // end output;
+ public function output($attributes) {}
/**
* Renders the content.
@@ -136,8 +131,7 @@ class Base_Field_Template {
$this->output($attributes);
return ob_get_clean();
-
- } // end render;
+ }
/**
* Displays the content on the checkout form as a wrapper.
@@ -153,23 +147,15 @@ class Base_Field_Template {
public function render_container($attributes, $signup_field = false) {
if ($this->get_render_type() === 'ajax') {
-
if ($signup_field) {
-
$attributes = $signup_field->reduce_attributes($attributes);
-
- } // end if;
+ }
$markup = sprintf('', esc_js($this->id), esc_attr(json_encode($attributes)));
-
} else {
-
$markup = $this->render($attributes);
-
- } // end if;
+ }
return $markup;
-
- } // end render_container;
-
-} // end class Base_Field_Template;
+ }
+}
diff --git a/inc/checkout/signup-fields/field-templates/order-bump/class-simple-order-bump-field-template.php b/inc/checkout/signup-fields/field-templates/order-bump/class-simple-order-bump-field-template.php
index 6882ba4..80d8590 100644
--- a/inc/checkout/signup-fields/field-templates/order-bump/class-simple-order-bump-field-template.php
+++ b/inc/checkout/signup-fields/field-templates/order-bump/class-simple-order-bump-field-template.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Order_Bump;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
+use WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
/**
* Template Selection Simple
@@ -52,8 +52,7 @@ class Simple_Order_Bump_Field_Template extends Base_Field_Template {
public function get_render_type(): string {
return 'ajax';
-
- } // end get_render_type;
+ }
/**
* The title of the field template.
@@ -66,8 +65,7 @@ class Simple_Order_Bump_Field_Template extends Base_Field_Template {
public function get_title() {
return __('Simple', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* The description of the field template.
@@ -80,8 +78,7 @@ class Simple_Order_Bump_Field_Template extends Base_Field_Template {
public function get_description() {
return __('A simple layout with minimal styling, just enough to make it usable out-of-the-box.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* The preview of the field template.
@@ -92,8 +89,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');
-
- } // end get_preview;
+ }
/**
* The content of the template.
@@ -106,10 +102,8 @@ class Simple_Order_Bump_Field_Template extends Base_Field_Template {
public function output($attributes) {
/**
- * Loads the actual order-bump template
- */
+ * Loads the actual order-bump template
+ */
wu_get_template('checkout/templates/order-bump/simple', $attributes);
-
- } // end output;
-
-} // end class Simple_Order_Bump_Field_Template;
+ }
+}
diff --git a/inc/checkout/signup-fields/field-templates/order-summary/class-clean-order-summary-field-template.php b/inc/checkout/signup-fields/field-templates/order-summary/class-clean-order-summary-field-template.php
index bfd85d2..34e411d 100644
--- a/inc/checkout/signup-fields/field-templates/order-summary/class-clean-order-summary-field-template.php
+++ b/inc/checkout/signup-fields/field-templates/order-summary/class-clean-order-summary-field-template.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Order_Summary;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
+use WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
/**
* Order Summary Clean
@@ -52,8 +52,7 @@ class Clean_Order_Summary_Field_Template extends Base_Field_Template {
public function get_render_type(): string {
return 'dynamic';
-
- } // end get_render_type;
+ }
/**
* The title of the field template.
@@ -66,8 +65,7 @@ class Clean_Order_Summary_Field_Template extends Base_Field_Template {
public function get_title() {
return __('Clean', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* The description of the field template.
@@ -80,8 +78,7 @@ class Clean_Order_Summary_Field_Template extends Base_Field_Template {
public function get_description() {
return __('A simple layout with minimal styling, just enough to make it usable out-of-the-box.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* The preview of the field template.
@@ -92,8 +89,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');
-
- } // end get_preview;
+ }
/**
* The content of the template.
@@ -106,10 +102,8 @@ class Clean_Order_Summary_Field_Template extends Base_Field_Template {
public function output($attributes) {
/**
- * Loads the actual order-summary template
- */
+ * Loads the actual order-summary template
+ */
wu_get_template('checkout/templates/order-summary/simple', $attributes);
-
- } // end output;
-
-} // end class Clean_Order_Summary_Field_Template;
+ }
+}
diff --git a/inc/checkout/signup-fields/field-templates/period-selection/class-clean-period-selection-field-template.php b/inc/checkout/signup-fields/field-templates/period-selection/class-clean-period-selection-field-template.php
index 4bdf6a9..b2ec553 100644
--- a/inc/checkout/signup-fields/field-templates/period-selection/class-clean-period-selection-field-template.php
+++ b/inc/checkout/signup-fields/field-templates/period-selection/class-clean-period-selection-field-template.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Period_Selection;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
+use WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
/**
* Template Selection Clean
@@ -52,8 +52,7 @@ class Clean_Period_Selection_Field_Template extends Base_Field_Template {
public function get_render_type(): string {
return 'dynamic';
-
- } // end get_render_type;
+ }
/**
* The title of the field template.
@@ -66,8 +65,7 @@ class Clean_Period_Selection_Field_Template extends Base_Field_Template {
public function get_title() {
return __('Clean', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* The description of the field template.
@@ -80,8 +78,7 @@ class Clean_Period_Selection_Field_Template extends Base_Field_Template {
public function get_description() {
return __('A simple template with clean markup and no styling, ready to be customized with custom CSS.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* The preview image of the field template.
@@ -94,8 +91,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');
-
- } // end get_preview;
+ }
/**
* The content of the template.
@@ -108,7 +104,5 @@ class Clean_Period_Selection_Field_Template extends Base_Field_Template {
public function output($attributes) {
wu_get_template('checkout/templates/period-selection/clean', $attributes);
-
- } // end output;
-
-} // end class Clean_Period_Selection_Field_Template;
+ }
+}
diff --git a/inc/checkout/signup-fields/field-templates/period-selection/class-legacy-period-selection-field-template.php b/inc/checkout/signup-fields/field-templates/period-selection/class-legacy-period-selection-field-template.php
index 946fbc9..77441b9 100644
--- a/inc/checkout/signup-fields/field-templates/period-selection/class-legacy-period-selection-field-template.php
+++ b/inc/checkout/signup-fields/field-templates/period-selection/class-legacy-period-selection-field-template.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Period_Selection;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
+use WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
/**
* Template Selection Clean
@@ -52,8 +52,7 @@ class Legacy_Period_Selection_Field_Template extends Base_Field_Template {
public function get_render_type(): string {
return 'dynamic';
-
- } // end get_render_type;
+ }
/**
* The title of the field template.
@@ -66,8 +65,7 @@ class Legacy_Period_Selection_Field_Template extends Base_Field_Template {
public function get_title() {
return __('Legacy', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* The description of the field template.
@@ -80,8 +78,7 @@ class Legacy_Period_Selection_Field_Template extends Base_Field_Template {
public function get_description() {
return __('Implementation of the layout that shipped with WP Multisite WaaS < 1.10.X.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* The preview image of the field template.
@@ -94,8 +91,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');
-
- } // end get_preview;
+ }
/**
* The content of the template.
@@ -108,7 +104,5 @@ class Legacy_Period_Selection_Field_Template extends Base_Field_Template {
public function output($attributes) {
wu_get_template('checkout/templates/period-selection/legacy', $attributes);
-
- } // end output;
-
-} // end class Legacy_Period_Selection_Field_Template;
+ }
+}
diff --git a/inc/checkout/signup-fields/field-templates/pricing-table/class-legacy-pricing-table-field-template.php b/inc/checkout/signup-fields/field-templates/pricing-table/class-legacy-pricing-table-field-template.php
index 682f202..3fddec6 100644
--- a/inc/checkout/signup-fields/field-templates/pricing-table/class-legacy-pricing-table-field-template.php
+++ b/inc/checkout/signup-fields/field-templates/pricing-table/class-legacy-pricing-table-field-template.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Pricing_Table;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
+use WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
/**
* Template Selection Clean
@@ -52,8 +52,7 @@ class Legacy_Pricing_Table_Field_Template extends Base_Field_Template {
public function get_render_type(): string {
return 'dynamic';
-
- } // end get_render_type;
+ }
/**
* The title of the field template.
@@ -66,8 +65,7 @@ class Legacy_Pricing_Table_Field_Template extends Base_Field_Template {
public function get_title() {
return __('Legacy', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* The description of the field template.
@@ -80,8 +78,7 @@ class Legacy_Pricing_Table_Field_Template extends Base_Field_Template {
public function get_description() {
return __('Implementation of the layout that shipped with WP Ultimo < 1.10.X.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* The preview image of the field template.
@@ -94,8 +91,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');
-
- } // end get_preview;
+ }
/**
* The content of the template.
@@ -108,7 +104,5 @@ class Legacy_Pricing_Table_Field_Template extends Base_Field_Template {
public function output($attributes) {
wu_get_template('checkout/templates/pricing-table/legacy', $attributes);
-
- } // end output;
-
-} // end class Legacy_Pricing_Table_Field_Template;
+ }
+}
diff --git a/inc/checkout/signup-fields/field-templates/pricing-table/class-list-pricing-table-field-template.php b/inc/checkout/signup-fields/field-templates/pricing-table/class-list-pricing-table-field-template.php
index c50b360..af5a121 100644
--- a/inc/checkout/signup-fields/field-templates/pricing-table/class-list-pricing-table-field-template.php
+++ b/inc/checkout/signup-fields/field-templates/pricing-table/class-list-pricing-table-field-template.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Pricing_Table;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
+use WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
/**
* Base Field Template
@@ -43,8 +43,7 @@ class List_Pricing_Table_Field_Template extends Base_Field_Template {
public function get_title() {
return __('Simple List', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* The description of the field template.
@@ -57,8 +56,7 @@ class List_Pricing_Table_Field_Template extends Base_Field_Template {
public function get_description() {
return __('Simple stylized list with price, recurrence, and the plan description.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* The preview image of the field template.
@@ -71,8 +69,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');
-
- } // end get_preview;
+ }
/**
* The content of the template.
@@ -85,7 +82,5 @@ class List_Pricing_Table_Field_Template extends Base_Field_Template {
public function output($attributes) {
wu_get_template('checkout/templates/pricing-table/list', $attributes);
-
- } // end output;
-
-} // end class List_Pricing_Table_Field_Template;
+ }
+}
diff --git a/inc/checkout/signup-fields/field-templates/steps/class-clean-steps-field-template.php b/inc/checkout/signup-fields/field-templates/steps/class-clean-steps-field-template.php
index 741580e..5eb2beb 100644
--- a/inc/checkout/signup-fields/field-templates/steps/class-clean-steps-field-template.php
+++ b/inc/checkout/signup-fields/field-templates/steps/class-clean-steps-field-template.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Steps;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
+use WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
/**
* Template Selection Clean
@@ -52,8 +52,7 @@ class Clean_Steps_Field_Template extends Base_Field_Template {
public function get_render_type(): string {
return 'dynamic';
-
- } // end get_render_type;
+ }
/**
* The title of the field template.
@@ -66,8 +65,7 @@ class Clean_Steps_Field_Template extends Base_Field_Template {
public function get_title() {
return __('Clean', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* The description of the field template.
@@ -80,8 +78,7 @@ class Clean_Steps_Field_Template extends Base_Field_Template {
public function get_description() {
return __('A simple layout with minimal styling, just enough to make it usable out-of-the-box.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* The preview of the field template.
@@ -92,8 +89,7 @@ class Clean_Steps_Field_Template extends Base_Field_Template {
public function get_preview(): string {
return wu_get_asset('checkout-forms/clean-steps.png');
-
- } // end get_preview;
+ }
/**
* The content of the template.
@@ -106,7 +102,5 @@ class Clean_Steps_Field_Template extends Base_Field_Template {
public function output($attributes) {
wu_get_template('checkout/templates/steps/clean', $attributes);
-
- } // end output;
-
-} // end class Clean_Steps_Field_Template;
+ }
+}
diff --git a/inc/checkout/signup-fields/field-templates/steps/class-legacy-steps-field-template.php b/inc/checkout/signup-fields/field-templates/steps/class-legacy-steps-field-template.php
index edd605b..fddfaf5 100644
--- a/inc/checkout/signup-fields/field-templates/steps/class-legacy-steps-field-template.php
+++ b/inc/checkout/signup-fields/field-templates/steps/class-legacy-steps-field-template.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Steps;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
+use WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
/**
* Template Selection Clean
@@ -52,8 +52,7 @@ class Legacy_Steps_Field_Template extends Base_Field_Template {
public function get_render_type(): string {
return 'dynamic';
-
- } // end get_render_type;
+ }
/**
* The title of the field template.
@@ -66,8 +65,7 @@ class Legacy_Steps_Field_Template extends Base_Field_Template {
public function get_title() {
return __('Legacy', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* The description of the field template.
@@ -80,8 +78,7 @@ class Legacy_Steps_Field_Template extends Base_Field_Template {
public function get_description() {
return __('Implementation of the layout that shipped with WP Ultimo < 1.10.X.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* The preview of the field template.
@@ -92,8 +89,7 @@ class Legacy_Steps_Field_Template extends Base_Field_Template {
public function get_preview(): string {
return wu_get_asset('checkout-forms/legacy-steps.png');
-
- } // end get_preview;
+ }
/**
* The content of the template.
@@ -106,7 +102,5 @@ class Legacy_Steps_Field_Template extends Base_Field_Template {
public function output($attributes) {
wu_get_template('checkout/templates/steps/legacy', $attributes);
-
- } // end output;
-
-} // end class Legacy_Steps_Field_Template;
+ }
+}
diff --git a/inc/checkout/signup-fields/field-templates/steps/class-minimal-steps-field-template.php b/inc/checkout/signup-fields/field-templates/steps/class-minimal-steps-field-template.php
index 5755a28..939b7cd 100644
--- a/inc/checkout/signup-fields/field-templates/steps/class-minimal-steps-field-template.php
+++ b/inc/checkout/signup-fields/field-templates/steps/class-minimal-steps-field-template.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Steps;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
+use WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
/**
* Template Selection Clean
@@ -52,8 +52,7 @@ class Minimal_Steps_Field_Template extends Base_Field_Template {
public function get_render_type(): string {
return 'dynamic';
-
- } // end get_render_type;
+ }
/**
* The title of the field template.
@@ -66,8 +65,7 @@ class Minimal_Steps_Field_Template extends Base_Field_Template {
public function get_title() {
return __('Minimal', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* The description of the field template.
@@ -80,8 +78,7 @@ class Minimal_Steps_Field_Template extends Base_Field_Template {
public function get_description() {
return __('A simple template with clean markup and no styling, ready to be customized with custom CSS.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* The preview of the field template.
@@ -92,8 +89,7 @@ class Minimal_Steps_Field_Template extends Base_Field_Template {
public function get_preview(): string {
return wu_get_asset('checkout-forms/minimal-steps.png');
-
- } // end get_preview;
+ }
/**
* The content of the template.
@@ -106,7 +102,5 @@ class Minimal_Steps_Field_Template extends Base_Field_Template {
public function output($attributes) {
wu_get_template('checkout/templates/steps/minimal', $attributes);
-
- } // end output;
-
-} // end class Minimal_Steps_Field_Template;
+ }
+}
diff --git a/inc/checkout/signup-fields/field-templates/template-selection/class-clean-template-selection-field-template.php b/inc/checkout/signup-fields/field-templates/template-selection/class-clean-template-selection-field-template.php
index 10eb475..d882a61 100644
--- a/inc/checkout/signup-fields/field-templates/template-selection/class-clean-template-selection-field-template.php
+++ b/inc/checkout/signup-fields/field-templates/template-selection/class-clean-template-selection-field-template.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Template_Selection;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
+use WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
/**
* Template Selection Clean
@@ -52,8 +52,7 @@ class Clean_Template_Selection_Field_Template extends Base_Field_Template {
public function get_render_type(): string {
return 'ajax';
-
- } // end get_render_type;
+ }
/**
* The title of the field template.
@@ -66,8 +65,7 @@ class Clean_Template_Selection_Field_Template extends Base_Field_Template {
public function get_title() {
return __('Clean', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* The description of the field template.
@@ -80,8 +78,7 @@ class Clean_Template_Selection_Field_Template extends Base_Field_Template {
public function get_description(): string {
return __('A simple layout with minimal styling, just enough to make it usable out-of-the-box.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* The preview of the field template.
@@ -92,8 +89,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');
-
- } // end get_preview;
+ }
/**
* The content of the template.
@@ -106,7 +102,5 @@ class Clean_Template_Selection_Field_Template extends Base_Field_Template {
public function output($attributes) {
wu_get_template('checkout/templates/template-selection/clean', $attributes);
-
- } // end output;
-
-} // end class Clean_Template_Selection_Field_Template;
+ }
+}
diff --git a/inc/checkout/signup-fields/field-templates/template-selection/class-legacy-template-selection-field-template.php b/inc/checkout/signup-fields/field-templates/template-selection/class-legacy-template-selection-field-template.php
index 9e21eeb..3623c2f 100644
--- a/inc/checkout/signup-fields/field-templates/template-selection/class-legacy-template-selection-field-template.php
+++ b/inc/checkout/signup-fields/field-templates/template-selection/class-legacy-template-selection-field-template.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Template_Selection;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
+use WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
/**
* Legacy Field Template Selector
@@ -41,8 +41,7 @@ class Legacy_Template_Selection_Field_Template extends Base_Field_Template {
public function get_render_type(): string {
return 'ajax';
-
- } // end get_render_type;
+ }
/**
* The title of the field template.
@@ -55,8 +54,7 @@ class Legacy_Template_Selection_Field_Template extends Base_Field_Template {
public function get_title() {
return __('Legacy', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* The description of the field template.
@@ -69,8 +67,7 @@ class Legacy_Template_Selection_Field_Template extends Base_Field_Template {
public function get_description() {
return __('Implementation of the layout that shipped with WP Ultimo < 1.10.X.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* The preview image of the field template.
@@ -83,8 +80,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');
-
- } // end get_preview;
+ }
/**
* The content of the template.
@@ -97,7 +93,5 @@ class Legacy_Template_Selection_Field_Template extends Base_Field_Template {
public function output($attributes) {
wu_get_template('checkout/templates/template-selection/legacy', $attributes);
-
- } // end output;
-
-} // end class Legacy_Template_Selection_Field_Template;
+ }
+}
diff --git a/inc/checkout/signup-fields/field-templates/template-selection/class-minimal-template-selection-field-template.php b/inc/checkout/signup-fields/field-templates/template-selection/class-minimal-template-selection-field-template.php
index fdf044b..bf47de5 100644
--- a/inc/checkout/signup-fields/field-templates/template-selection/class-minimal-template-selection-field-template.php
+++ b/inc/checkout/signup-fields/field-templates/template-selection/class-minimal-template-selection-field-template.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Template_Selection;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
+use WP_Ultimo\Checkout\Signup_Fields\Field_Templates\Base_Field_Template;
/**
* Template Selection Minimal
@@ -41,8 +41,7 @@ class Minimal_Template_Selection_Field_Template extends Base_Field_Template {
public function get_render_type(): string {
return 'ajax';
-
- } // end get_render_type;
+ }
/**
* The title of the field template.
@@ -55,8 +54,7 @@ class Minimal_Template_Selection_Field_Template extends Base_Field_Template {
public function get_title() {
return __('Minimal', 'wp-ultimo');
-
- } // end get_title;
+ }
/**
* The description of the field template.
@@ -69,8 +67,7 @@ class Minimal_Template_Selection_Field_Template extends Base_Field_Template {
public function get_description() {
return __('A simple template with clean markup and no styling, ready to be customized with custom CSS.', 'wp-ultimo');
-
- } // end get_description;
+ }
/**
* The preview of the field template.
@@ -81,8 +78,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');
-
- } // end get_preview;
+ }
/**
* The content of the template.
@@ -95,7 +91,5 @@ class Minimal_Template_Selection_Field_Template extends Base_Field_Template {
public function output($attributes) {
wu_get_template('checkout/templates/template-selection/minimal', $attributes);
-
- } // end output;
-
-} // end class Minimal_Template_Selection_Field_Template;
+ }
+}
diff --git a/inc/class-admin-notices.php b/inc/class-admin-notices.php
index 9086e07..bbdccae 100644
--- a/inc/class-admin-notices.php
+++ b/inc/class-admin-notices.php
@@ -45,8 +45,7 @@ class Admin_Notices {
add_action('in_admin_header', array($this, 'display_notices'));
add_action('wp_ajax_wu_dismiss_admin_notice', array($this, 'ajax_dismiss_admin_notices'));
-
- } // end init;
+ }
/**
* Get the notices the current user has dismissed
@@ -61,8 +60,7 @@ class Admin_Notices {
$dismissed = $dismissed ? $dismissed : array();
return $dismissed;
-
- } // end get_dismissed_notices;
+ }
/**
* Adds a new admin notice
@@ -83,14 +81,13 @@ class Admin_Notices {
$id = $dismissible_key ? $dismissible_key : md5($notice);
- $this->notices[$panel][$id] = array(
+ $this->notices[ $panel ][ $id ] = array(
'type' => $type,
'message' => $notice,
'dismissible_key' => is_string($dismissible_key) ? $dismissible_key : false,
'actions' => $actions,
);
-
- } // end add;
+ }
/**
* Returns the list of notices added for a particular panel.
@@ -103,15 +100,13 @@ class Admin_Notices {
*/
public function get_notices($panel = 'admin', $filter = true) {
- $notices = isset($this->notices[$panel]) ? $this->notices[$panel] : array();
+ $notices = isset($this->notices[ $panel ]) ? $this->notices[ $panel ] : array();
$dismissed_messages = $this->get_dismissed_notices();
if ($filter && $notices) {
-
- $notices = array_filter($notices, fn($notice) => !$notice['dismissible_key'] || !in_array($notice['dismissible_key'], $dismissed_messages, true));
-
- } // end if;
+ $notices = array_filter($notices, fn($notice) => ! $notice['dismissible_key'] || ! in_array($notice['dismissible_key'], $dismissed_messages, true));
+ }
/**
* Allow developers to filter admin notices added by WP Multisite WaaS.
@@ -123,11 +118,10 @@ class Admin_Notices {
* @param string $panel Panel to retrieve the notices.
* @param string $filter If the dismissable notices have been filtered out.
* @param array $dismissed_messages List of dismissed notice keys.
- * @return array
+ * @return array
*/
return apply_filters('wu_admin_notices', $notices, $this->notices, $panel, $filter, $dismissed_messages);
-
- } // end get_notices;
+ }
/**
* Enqueues the JavaScript code that sends the dismiss call to the ajax endpoint.
@@ -138,8 +132,7 @@ class Admin_Notices {
public function enqueue_scripts() {
wp_enqueue_script('wu-admin-notices', wu_get_asset('admin-notices.js', 'js'), array('jquery'), wu_get_version());
-
- } // end enqueue_scripts;
+ }
/**
* Gets the current panel the user is viewing
@@ -152,20 +145,15 @@ class Admin_Notices {
$panel = 'admin';
if (is_user_admin()) {
-
$panel = 'user';
-
- } // end if;
+ }
if (is_network_admin()) {
-
$panel = 'network-admin';
-
- } // end if;
+ }
return $panel;
-
- } // end get_current_panel;
+ }
/**
* Retrieves the admin notices for the current panel and displays them.
@@ -179,12 +167,14 @@ class Admin_Notices {
$notices = $this->get_notices($panel);
- wu_get_template('admin-notices', array(
- 'notices' => $notices,
- 'nonce' => wp_create_nonce('wu-dismiss-admin-notice'),
- ));
-
- } // end display_notices;
+ wu_get_template(
+ 'admin-notices',
+ array(
+ 'notices' => $notices,
+ 'nonce' => wp_create_nonce('wu-dismiss-admin-notice'),
+ )
+ );
+ }
/**
* Adds an ajax endpoint to dismiss admin notices
@@ -194,26 +184,20 @@ class Admin_Notices {
*/
public function ajax_dismiss_admin_notices() {
- if (!wp_verify_nonce($_POST['nonce'], 'wu-dismiss-admin-notice')) {
-
+ if ( ! wp_verify_nonce($_POST['nonce'], 'wu-dismiss-admin-notice')) {
die('-1');
-
- } // end if;
+ }
$dismissed = $this->get_dismissed_notices();
- if (!in_array($_POST['notice_id'], $dismissed, true)) {
-
+ if ( ! in_array($_POST['notice_id'], $dismissed, true)) {
$dismissed[] = $_POST['notice_id'];
update_user_meta(get_current_user_id(), 'wu_dismissed_admin_notices', $dismissed);
die('1');
-
- } // end if;
+ }
die('0');
-
- } // end ajax_dismiss_admin_notices;
-
-} // end class Admin_Notices;
+ }
+}
diff --git a/inc/class-admin-themes-compatibility.php b/inc/class-admin-themes-compatibility.php
index 7c62330..c683bdb 100644
--- a/inc/class-admin-themes-compatibility.php
+++ b/inc/class-admin-themes-compatibility.php
@@ -29,8 +29,7 @@ class Admin_Themes_Compatibility {
public function __construct() {
add_filter('admin_body_class', array($this, 'add_body_classes'));
-
- } // end __construct;
+ }
/**
* Body tag classes. Fired by `body_class` filter.
@@ -45,18 +44,13 @@ class Admin_Themes_Compatibility {
$prefix = 'wu-compat-admin-theme-';
foreach (self::get_admin_themes() as $key => $value) {
-
if ($value['activated']) {
-
$classes .= ' ' . $prefix . $key . ' ';
-
- } // end if;
-
- } // end foreach;
+ }
+ }
return $classes;
-
- } // end add_body_classes;
+ }
/**
* Get list of Admin Themes
@@ -66,27 +60,28 @@ class Admin_Themes_Compatibility {
*/
public static function get_admin_themes() {
- return apply_filters('wu_admin_themes_compatibility', array(
- 'material-wp' => array(
- 'activated' => class_exists('MaterialWP'),
- ),
- 'pro-theme' => array(
- 'activated' => class_exists('PROTheme'),
- ),
- 'admin-2020' => array(
- 'activated' => function_exists('run_admin_2020'),
- ),
- 'clientside' => array(
- 'activated' => class_exists('Clientside'),
- ),
- 'wphave' => array(
- 'activated' => class_exists('wphave_admin'),
- ),
- 'waaspro' => array(
- 'activated' => class_exists('AdminUIPRO') || class_exists('AdminUIPROflat'),
- ),
- ));
-
- } // end get_admin_themes;
-
-} // end class Admin_Themes_Compatibility;
+ return apply_filters(
+ 'wu_admin_themes_compatibility',
+ array(
+ 'material-wp' => array(
+ 'activated' => class_exists('MaterialWP'),
+ ),
+ 'pro-theme' => array(
+ 'activated' => class_exists('PROTheme'),
+ ),
+ 'admin-2020' => array(
+ 'activated' => function_exists('run_admin_2020'),
+ ),
+ 'clientside' => array(
+ 'activated' => class_exists('Clientside'),
+ ),
+ 'wphave' => array(
+ 'activated' => class_exists('wphave_admin'),
+ ),
+ 'waaspro' => array(
+ 'activated' => class_exists('AdminUIPRO') || class_exists('AdminUIPROflat'),
+ ),
+ )
+ );
+ }
+}
diff --git a/inc/class-ajax.php b/inc/class-ajax.php
index 4b81971..4b58f6e 100644
--- a/inc/class-ajax.php
+++ b/inc/class-ajax.php
@@ -41,8 +41,7 @@ class Ajax {
* Load search endpoints.
*/
add_action('wp_ajax_wu_list_table_fetch_ajax_results', array($this, 'refresh_list_table'));
-
- } // end __construct;
+ }
/**
* Reverts the name of the table being processed.
*
@@ -53,8 +52,7 @@ class Ajax {
private function get_table_class_name($table_id): string {
return str_replace(' ', '_', (ucwords(str_replace('_', ' ', $table_id))));
-
- } // end get_table_class_name;
+ }
/**
* Serves the pagination and search results of a list table ajax query.
@@ -71,16 +69,13 @@ class Ajax {
$full_class_name = "\\WP_Ultimo\\List_Tables\\{$class_name}";
if (class_exists($full_class_name)) {
-
$table = new $full_class_name();
$table->ajax_response();
-
- } // end if;
+ }
do_action('wu_list_table_fetch_ajax_results', $table_id);
-
- } // end refresh_list_table;
+ }
/**
* Search models using our ajax endpoint.
@@ -98,125 +93,102 @@ class Ajax {
do_action('wu_before_search_models');
if (wu_request('model') === 'all') {
-
$this->search_all_models();
return;
+ }
- } // end if;
+ $args = wp_parse_args(
+ $_REQUEST,
+ array(
+ 'model' => 'membership',
+ 'query' => array(),
+ 'exclude' => array(),
+ )
+ );
- $args = wp_parse_args($_REQUEST, array(
- 'model' => 'membership',
- 'query' => array(),
- 'exclude' => array()
- ));
-
- $query = array_merge($args['query'], array(
- 'number' => -1,
- ));
+ $query = array_merge(
+ $args['query'],
+ array(
+ 'number' => -1,
+ )
+ );
if ($args['exclude']) {
-
if (is_string($args['exclude'])) {
-
$args['exclude'] = explode(',', $args['exclude']);
$args['exclude'] = array_map('trim', $args['exclude']);
-
- } // end if;
+ }
$query['id__not_in'] = $args['exclude'];
-
- } // end if;
+ }
if (wu_get_isset($args, 'include')) {
-
if (is_string($args['include'])) {
-
$args['include'] = explode(',', $args['include']);
$args['include'] = array_map('trim', $args['include']);
-
- } // end if;
+ }
$query['id__in'] = $args['include'];
-
- } // end if;
+ }
/*
* Deal with site
*/
if ($args['model'] === 'site') {
-
if (wu_get_isset($query, 'id__in')) {
-
$query['blog_id__in'] = $query['id__in'];
unset($query['id__in']);
-
- } // end if;
+ }
if (wu_get_isset($query, 'id__not_in')) {
-
$query['blog_id__not_in'] = $query['id__not_in'];
unset($query['id__not_in']);
-
- } // end if;
-
- } // end if;
+ }
+ }
$results = array();
if ($args['model'] === 'user') {
-
$results = $this->search_wordpress_users($query);
-
} elseif ($args['model'] === 'page') {
-
- $results = get_posts(array(
- 'post_type' => 'page',
- 'post_status' => 'publish',
- 'numberposts' => -1,
- 'exclude' => isset($query['id__not_in']) ? $query['id__not_in'] : ''
- ));
-
+ $results = get_posts(
+ array(
+ 'post_type' => 'page',
+ 'post_status' => 'publish',
+ 'numberposts' => -1,
+ 'exclude' => isset($query['id__not_in']) ? $query['id__not_in'] : '',
+ )
+ );
} elseif ($args['model'] === 'setting') {
-
$results = $this->search_wp_ultimo_setting($query);
-
} else {
-
$model_func = 'wu_get_' . strtolower((string) $args['model']) . 's';
if (function_exists($model_func)) {
-
$results = $model_func($query);
-
- } // end if;
-
- } // end if;
+ }
+ }
// Try search by hash if do not have any result
if (empty($results)) {
-
$model_func = 'wu_get_' . strtolower((string) $args['model']) . '_by_hash';
if (function_exists($model_func)) {
-
$result = $model_func(trim((string) $query['search'], '*'));
$results = $result ? array($result) : array();
-
- } // end if;
-
- } // end if;
+ }
+ }
wp_send_json($results);
exit;
-
- } // end search_models;
+ }
/**
* Search all models for Jumper.
@@ -226,33 +198,40 @@ class Ajax {
*/
public function search_all_models() {
- $query = array_merge(wu_request('query', array()), array(
- 'number' => 10000,
- ));
+ $query = array_merge(
+ wu_request('query', array()),
+ array(
+ 'number' => 10000,
+ )
+ );
- $results_user = array_map(function($item) {
+ $results_user = array_map(
+ function ($item) {
- $item->model = 'user';
+ $item->model = 'user';
- $item->group = 'Users';
+ $item->group = 'Users';
- $item->value = network_admin_url("user-edit.php?user_id={$item->ID}");
+ $item->value = network_admin_url("user-edit.php?user_id={$item->ID}");
- return $item;
+ return $item;
+ },
+ $this->search_wordpress_users($query)
+ );
- }, $this->search_wordpress_users($query));
+ $results_settings = array_map(
+ function ($item) {
- $results_settings = array_map(function($item) {
+ $item['model'] = 'setting';
- $item['model'] = 'setting';
+ $item['group'] = 'Settings';
- $item['group'] = 'Settings';
+ $item['value'] = $item['url'];
- $item['value'] = $item['url'];
-
- return $item;
-
- }, $this->search_wp_ultimo_setting($query));
+ return $item;
+ },
+ $this->search_wp_ultimo_setting($query)
+ );
$data = array_merge($results_user, $results_settings);
@@ -261,57 +240,67 @@ class Ajax {
*
* @since 2.0.0
*/
- $data_sources = apply_filters('wu_search_models_functions', array(
- 'wu_get_customers',
- 'wu_get_products',
- 'wu_get_plans',
- 'wu_get_domains',
- 'wu_get_sites',
- 'wu_get_memberships',
- 'wu_get_payments',
- 'wu_get_broadcasts',
- 'wu_get_checkout_forms',
- ));
+ $data_sources = apply_filters(
+ 'wu_search_models_functions',
+ array(
+ 'wu_get_customers',
+ 'wu_get_products',
+ 'wu_get_plans',
+ 'wu_get_domains',
+ 'wu_get_sites',
+ 'wu_get_memberships',
+ 'wu_get_payments',
+ 'wu_get_broadcasts',
+ 'wu_get_checkout_forms',
+ )
+ );
foreach ($data_sources as $function) {
-
$results = call_user_func($function, $query);
- array_map(function($item) {
+ array_map(
+ function ($item) {
- $url = str_replace('_', '-', (string) $item->model);
+ $url = str_replace('_', '-', (string) $item->model);
- $item->value = wu_network_admin_url("wp-ultimo-edit-{$url}", array(
- 'id' => $item->get_id(),
- ));
+ $item->value = wu_network_admin_url(
+ "wp-ultimo-edit-{$url}",
+ array(
+ 'id' => $item->get_id(),
+ )
+ );
- $item->group = ucwords((string) $item->model) . 's';
+ $item->group = ucwords((string) $item->model) . 's';
- return $item;
+ return $item;
+ },
+ $results
+ );
- }, $results);
+ $discount_codes = array_map(
+ function ($item) {
- $discount_codes = array_map(function($item) {
+ $discount = $item->to_array();
- $discount = $item->to_array();
+ $discount['value'] = wu_network_admin_url(
+ 'wp-ultimo-edit-discount-code',
+ array(
+ 'id' => $discount['id'],
+ )
+ );
- $discount['value'] = wu_network_admin_url('wp-ultimo-edit-discount-code', array(
- 'id' => $discount['id'],
- ));
+ $discount['group'] = 'Discount Codes';
- $discount['group'] = 'Discount Codes';
-
- return $discount;
-
- }, wu_get_discount_codes($query));
+ return $discount;
+ },
+ wu_get_discount_codes($query)
+ );
$data = array_merge($data, $results, $discount_codes);
-
- } // end foreach;
+ }
wp_send_json($data);
-
- } // end search_all_models;
+ }
/**
* Search for WP Multisite WaaS settings to help customers find them.
*
@@ -326,36 +315,41 @@ class Ajax {
$all_fields = array();
foreach ($sections as $section_slug => $section) {
+ $section['fields'] = array_map(
+ function ($item) use ($section, $section_slug) {
- $section['fields'] = array_map(function($item) use ($section, $section_slug) {
+ $item['section'] = $section_slug;
- $item['section'] = $section_slug;
+ $item['section_title'] = wu_get_isset($section, 'title', '');
- $item['section_title'] = wu_get_isset($section, 'title', '');
+ $item['url'] = wu_network_admin_url(
+ 'wp-ultimo-settings',
+ array(
+ 'tab' => $section_slug,
+ )
+ ) . '#' . $item['setting_id'];
- $item['url'] = wu_network_admin_url('wp-ultimo-settings', array(
- 'tab' => $section_slug,
- )) . '#' . $item['setting_id'];
-
- return $item;
-
- }, $section['fields']);
+ return $item;
+ },
+ $section['fields']
+ );
$all_fields = array_merge($all_fields, $section['fields']);
+ }
- } // end foreach;
-
- $_settings = \Arrch\Arrch::find($all_fields, array(
- 'sort_key' => 'title',
- 'where' => array(
- array('setting_id', '~', trim((string) $query['search'], '*')),
- array('type', '!=', 'header'),
- ),
- ));
+ $_settings = \Arrch\Arrch::find(
+ $all_fields,
+ array(
+ 'sort_key' => 'title',
+ 'where' => array(
+ array('setting_id', '~', trim((string) $query['search'], '*')),
+ array('type', '!=', 'header'),
+ ),
+ )
+ );
return array_values($_settings);
-
- } // end search_wp_ultimo_setting;
+ }
/**
* Handles the special case of searching native WP users.
@@ -367,30 +361,44 @@ class Ajax {
*/
public function search_wordpress_users($query) {
- $results = get_users(array(
- 'blog_id' => 0,
- 'search' => '*' . $query['search'] . '*',
- 'search_columns' => array(
- 'ID', 'user_login', 'user_email', 'user_url', 'user_nicename', 'display_name',
- ),
- ));
+ $results = get_users(
+ array(
+ 'blog_id' => 0,
+ 'search' => '*' . $query['search'] . '*',
+ 'search_columns' => array(
+ 'ID',
+ 'user_login',
+ 'user_email',
+ 'user_url',
+ 'user_nicename',
+ 'display_name',
+ ),
+ )
+ );
- $results = array_map(function($item) {
+ $results = array_map(
+ function ($item) {
- $item->data->user_pass = '';
+ $item->data->user_pass = '';
- $item->data->avatar = get_avatar($item->data->user_email, 40, 'identicon', '', array(
- 'force_display' => true,
- 'class' => 'wu-rounded-full wu-mr-3',
- ));
+ $item->data->avatar = get_avatar(
+ $item->data->user_email,
+ 40,
+ 'identicon',
+ '',
+ array(
+ 'force_display' => true,
+ 'class' => 'wu-rounded-full wu-mr-3',
+ )
+ );
- return $item->data;
-
- }, $results);
+ return $item->data;
+ },
+ $results
+ );
return $results;
-
- } // end search_wordpress_users;
+ }
/**
* Adds the selectize templates to the admin footer.
@@ -401,11 +409,7 @@ class Ajax {
public function render_selectize_templates() {
if (current_user_can('manage_network')) {
-
wu_get_template('ui/selectize-templates');
-
- } // end if;
-
- } // end render_selectize_templates;
-
-} // end class Ajax;
+ }
+ }
+}
diff --git a/inc/class-api.php b/inc/class-api.php
index ad04e27..9a16487 100644
--- a/inc/class-api.php
+++ b/inc/class-api.php
@@ -22,19 +22,19 @@ class API {
use \WP_Ultimo\Traits\Singleton;
/**
- * Namespace of our API endpoints
- *
- * @since 1.7.4
- * @var string
- */
+ * Namespace of our API endpoints
+ *
+ * @since 1.7.4
+ * @var string
+ */
private string $namespace = 'wu';
/**
- * Version fo the API, this is used to build the API URL
- *
- * @since 1.7.4
- * @var string
- */
+ * Version fo the API, this is used to build the API URL
+ *
+ * @since 1.7.4
+ * @var string
+ */
private string $api_version = 'v2';
/**
@@ -61,7 +61,7 @@ class API {
/**
* Register the routes
- *
+ *
* @since 1.7.4
*/
add_action('rest_api_init', array($this, 'register_routes'));
@@ -79,8 +79,7 @@ class API {
* @since 2.1.2
*/
add_filter('rest_authentication_errors', array($this, 'maybe_bypass_wp_auth'), 1);
-
- } // end __construct;
+ }
/**
* Maybe bypass the WP Core auth errors in our routes so we can use our api keys.
@@ -94,10 +93,8 @@ class API {
// Another plugin already bypass this request
if ($result === true) {
-
return $result;
-
- } // end if;
+ }
$current_route = $_SERVER['REQUEST_URI'];
@@ -105,14 +102,11 @@ class API {
$rest_path = rtrim(parse_url($rest_url, PHP_URL_PATH), '/');
if (strncmp((string) $current_route, $rest_path . '/' . $this->get_namespace(), strlen($rest_path . '/' . $this->get_namespace())) !== 0) {
-
return $result;
-
- } // end if;
+ }
return true;
-
- } // end maybe_bypass_wp_auth;
+ }
/**
* Allow admins to refresh their API credentials.
@@ -123,7 +117,6 @@ class API {
public function refresh_API_credentials() { // phpcs:ignore
if (wu_request('submit_button') === 'refresh_api_credentials') {
-
wu_save_setting('api_url', network_site_url());
wu_save_setting('api_key', wp_generate_password(24, false));
@@ -133,10 +126,8 @@ class API {
wp_safe_redirect(network_admin_url('admin.php?page=wp-ultimo-settings&tab=api&api=refreshed&updated=1'));
exit;
-
- } // end if;
-
- } // end refresh_API_credentials;
+ }
+ }
/**
* Add the admin interface to create new webhooks
@@ -144,119 +135,159 @@ class API {
* @since 1.7.4
*/
public function add_settings() {
- /*
+ /*
* API & Webhooks
* This section holds the API settings of the WP Multisite WaaS Plugin.
*/
- wu_register_settings_section('api', array(
- 'title' => __('API & Webhooks', 'wp-ultimo'),
- 'desc' => __('API & Webhooks', 'wp-ultimo'),
- 'icon' => 'dashicons-wu-paper-plane',
- 'order' => 95,
- ));
+ wu_register_settings_section(
+ 'api',
+ array(
+ 'title' => __('API & Webhooks', 'wp-ultimo'),
+ 'desc' => __('API & Webhooks', 'wp-ultimo'),
+ 'icon' => 'dashicons-wu-paper-plane',
+ 'order' => 95,
+ )
+ );
- wu_register_settings_field('api', 'api_header', array(
- 'title' => __('API Settings', 'wp-ultimo'),
- 'desc' => __('Options related to WP Multisite WaaS API endpoints.', 'wp-ultimo'),
- 'type' => 'header',
- ));
+ wu_register_settings_field(
+ 'api',
+ 'api_header',
+ array(
+ 'title' => __('API Settings', 'wp-ultimo'),
+ 'desc' => __('Options related to WP Multisite WaaS API endpoints.', 'wp-ultimo'),
+ 'type' => 'header',
+ )
+ );
- wu_register_settings_field('api', 'enable_api', array(
- 'title' => __('Enable API', 'wp-ultimo'),
- 'desc' => __('Tick this box if you want WP Multisite WaaS to add its own endpoints to the WordPress REST API. This is required for some integrations to work, most notabily, Zapier.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 1,
- ));
+ wu_register_settings_field(
+ 'api',
+ 'enable_api',
+ array(
+ 'title' => __('Enable API', 'wp-ultimo'),
+ 'desc' => __('Tick this box if you want WP Multisite WaaS to add its own endpoints to the WordPress REST API. This is required for some integrations to work, most notabily, Zapier.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 1,
+ )
+ );
$refreshed_tag = '';
if (wu_request('updated') && wu_request('api') === 'refreshed') {
-
$refreshed_tag = sprintf('%s', __('Credentials Refreshed', 'wp-ultimo'));
+ }
- } // end if;
+ wu_register_settings_field(
+ 'api',
+ 'api_url',
+ array(
+ 'title' => __('API URL', 'wp-ultimo'),
+ 'desc' => '',
+ 'tooltip' => '',
+ 'copy' => true,
+ 'type' => 'text-display',
+ 'default' => network_site_url(),
+ 'require' => array(
+ 'enable_api' => true,
+ ),
+ )
+ );
- wu_register_settings_field('api', 'api_url', array(
- 'title' => __('API URL', 'wp-ultimo'),
- 'desc' => '',
- 'tooltip' => '',
- 'copy' => true,
- 'type' => 'text-display',
- 'default' => network_site_url(),
- 'require' => array(
- 'enable_api' => true,
- ),
- ));
+ wu_register_settings_field(
+ 'api',
+ 'api_key',
+ array(
+ 'title' => __('API Key', 'wp-ultimo') . $refreshed_tag,
+ 'desc' => '',
+ 'tooltip' => '',
+ 'type' => 'text-display',
+ 'copy' => true,
+ 'default' => wp_generate_password(24, false),
+ 'wrapper_classes' => 'sm:wu-w-1/2 wu-float-left',
+ 'require' => array(
+ 'enable_api' => true,
+ ),
+ )
+ );
- wu_register_settings_field('api', 'api_key', array(
- 'title' => __('API Key', 'wp-ultimo') . $refreshed_tag,
- 'desc' => '',
- 'tooltip' => '',
- 'type' => 'text-display',
- 'copy' => true,
- 'default' => wp_generate_password(24, false),
- 'wrapper_classes' => 'sm:wu-w-1/2 wu-float-left',
- 'require' => array(
- 'enable_api' => true,
- ),
- ));
+ wu_register_settings_field(
+ 'api',
+ 'api_secret',
+ array(
+ 'title' => __('API Secret', 'wp-ultimo') . $refreshed_tag,
+ 'tooltip' => '',
+ 'type' => 'text-display',
+ 'copy' => true,
+ 'default' => wp_generate_password(24, false),
+ 'wrapper_classes' => 'sm:wu-border-l-0 sm:wu-w-1/2 wu-float-left',
+ 'require' => array(
+ 'enable_api' => 1,
+ ),
+ )
+ );
- wu_register_settings_field('api', 'api_secret', array(
- 'title' => __('API Secret', 'wp-ultimo') . $refreshed_tag,
- 'tooltip' => '',
- 'type' => 'text-display',
- 'copy' => true,
- 'default' => wp_generate_password(24, false),
- 'wrapper_classes' => 'sm:wu-border-l-0 sm:wu-w-1/2 wu-float-left',
- 'require' => array(
- 'enable_api' => 1,
- ),
- ));
+ wu_register_settings_field(
+ 'api',
+ 'api_note',
+ array(
+ 'desc' => __('This is your API Key. You cannot change it directly. To reset the API key and secret, use the button "Refresh API credentials" below.', 'wp-ultimo'),
+ 'type' => 'note',
+ 'classes' => 'wu-text-gray-700 wu-text-xs',
+ 'wrapper_classes' => 'wu-bg-white sm:wu-border-t-0 sm:wu-mt-0 sm:wu-pt-0',
+ 'require' => array(
+ 'enable_api' => 1,
+ ),
+ )
+ );
- wu_register_settings_field('api', 'api_note', array(
- 'desc' => __('This is your API Key. You cannot change it directly. To reset the API key and secret, use the button "Refresh API credentials" below.', 'wp-ultimo'),
- 'type' => 'note',
- 'classes' => 'wu-text-gray-700 wu-text-xs',
- 'wrapper_classes' => 'wu-bg-white sm:wu-border-t-0 sm:wu-mt-0 sm:wu-pt-0',
- 'require' => array(
- 'enable_api' => 1,
- ),
- ));
+ wu_register_settings_field(
+ 'api',
+ 'refresh_api_credentials',
+ array(
+ 'title' => __('Refresh API Credentials', 'wp-ultimo'),
+ 'type' => 'submit',
+ 'classes' => 'button wu-ml-auto',
+ 'wrapper_classes' => 'wu-bg-white sm:wu-border-t-0 sm:wu-mt-0 sm:wu-pt-0',
+ 'require' => array(
+ 'enable_api' => 1,
+ ),
+ )
+ );
- wu_register_settings_field('api', 'refresh_api_credentials', array(
- 'title' => __('Refresh API Credentials', 'wp-ultimo'),
- 'type' => 'submit',
- 'classes' => 'button wu-ml-auto',
- 'wrapper_classes' => 'wu-bg-white sm:wu-border-t-0 sm:wu-mt-0 sm:wu-pt-0',
- 'require' => array(
- 'enable_api' => 1,
- ),
- ));
+ wu_register_settings_field(
+ 'api',
+ 'api_log_calls',
+ array(
+ 'title' => __('Log API calls (Advanced)', 'wp-ultimo'),
+ 'desc' => __('Tick this box if you want to log all calls received via WP Multisite WaaS API endpoints. You can access the logs on WP Multisite WaaS → System Info → Logs.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 0,
+ 'require' => array(
+ 'enable_api' => 1,
+ ),
+ )
+ );
- wu_register_settings_field('api', 'api_log_calls', array(
- 'title' => __('Log API calls (Advanced)', 'wp-ultimo'),
- 'desc' => __('Tick this box if you want to log all calls received via WP Multisite WaaS API endpoints. You can access the logs on WP Multisite WaaS → System Info → Logs.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 0,
- 'require' => array(
- 'enable_api' => 1,
- ),
- ));
+ wu_register_settings_field(
+ 'api',
+ 'webhook_header',
+ array(
+ 'title' => __('Webhook Settings', 'wp-ultimo'),
+ 'desc' => __('Options related to WP Multisite WaaS API webhooks.', 'wp-ultimo'),
+ 'type' => 'header',
+ )
+ );
- wu_register_settings_field('api', 'webhook_header', array(
- 'title' => __('Webhook Settings', 'wp-ultimo'),
- 'desc' => __('Options related to WP Multisite WaaS API webhooks.', 'wp-ultimo'),
- 'type' => 'header',
- ));
-
- wu_register_settings_field('api', 'webhook_calls_blocking', array(
- 'title' => __('Wait for Response (Advanced)', 'wp-ultimo'),
- 'desc' => __('Tick this box if you want the WP Multisite WaaS\'s webhook calls to wait for the remote server to respond. Keeping this option enabled can have huge effects on your network\'s performance, only enable it if you know what you are doing and need to debug webhook calls.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 0,
- ));
-
- } // end add_settings;
+ wu_register_settings_field(
+ 'api',
+ 'webhook_calls_blocking',
+ array(
+ 'title' => __('Wait for Response (Advanced)', 'wp-ultimo'),
+ 'desc' => __('Tick this box if you want the WP Multisite WaaS\'s webhook calls to wait for the remote server to respond. Keeping this option enabled can have huge effects on your network\'s performance, only enable it if you know what you are doing and need to debug webhook calls.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 0,
+ )
+ );
+ }
/**
* Returns the namespace of our API endpoints.
@@ -267,8 +298,7 @@ class API {
public function get_namespace() {
return "$this->namespace/$this->api_version";
-
- } // end get_namespace;
+ }
/**
* Returns the credentials.
@@ -282,8 +312,7 @@ class API {
'api_key' => wu_get_setting('api_key', 'prevent'),
'api_secret' => wu_get_setting('api_secret', 'prevent'),
);
-
- } // end get_auth;
+ }
/**
* Validate a pair of API credentials
@@ -296,8 +325,7 @@ class API {
public function validate_credentials($api_key, $api_secret) {
return compact('api_key', 'api_secret') === $this->get_auth(); // phpcs:ignore
-
- } // end validate_credentials;
+ }
/**
* Check if we can log api calls.
@@ -308,8 +336,7 @@ class API {
public function should_log_api_calls() {
return apply_filters('wu_should_log_api_calls', wu_get_setting('api_log_calls', false));
-
- } // end should_log_api_calls;
+ }
/**
* Checks if we should log api calls or not, and if we should, log them.
@@ -321,19 +348,16 @@ class API {
public function maybe_log_api_call($request) {
if ($this->should_log_api_calls()) {
-
$payload = array(
'route' => $request->get_route(),
'method' => $request->get_method(),
'url_params' => $request->get_url_params(),
- 'body_params' => $request->get_body()
+ 'body_params' => $request->get_body(),
);
wu_log_add('api-calls', json_encode($payload, JSON_PRETTY_PRINT));
-
- } // end if;
-
- } // end maybe_log_api_call;
+ }
+ }
/**
* Log api errors.
@@ -351,26 +375,22 @@ class API {
/*
* Log API call here if we didn't log it before.
*/
- if (!$this->should_log_api_calls()) {
-
+ if ( ! $this->should_log_api_calls()) {
$payload = array(
'route' => $request->get_route(),
'method' => $request->get_method(),
'url_params' => $request->get_url_params(),
- 'body_params' => $request->get_body()
+ 'body_params' => $request->get_body(),
);
wu_log_add('api-errors', json_encode($payload, JSON_PRETTY_PRINT));
-
- } // end if;
+ }
wu_log_add('api-errors', $result);
-
- } // end if;
+ }
return $result;
-
- } // end log_api_errors;
+ }
/**
* Tries to validate the API key and secret from the request
@@ -382,28 +402,21 @@ class API {
public function check_authorization($request) {
if (isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_USER']) {
-
$api_key = $_SERVER['PHP_AUTH_USER'];
$api_secret = $_SERVER['PHP_AUTH_PW'];
-
} else {
-
$params = $request->get_params();
$api_key = wu_get_isset($params, 'api_key', wu_get_isset($params, 'api-key'));
$api_secret = wu_get_isset($params, 'api_secret', wu_get_isset($params, 'api-secret'));
-
- } // end if;
+ }
if ($api_key === false) {
-
return false;
-
- } // end if;
+ }
return $this->validate_credentials($api_key, $api_secret);
-
- } // end check_authorization;
+ }
/**
* Checks if the API routes are available or not, via the settings.
@@ -420,8 +433,7 @@ class API {
* @return boolean
*/
return apply_filters('wu_is_api_enabled', wu_get_setting('enable_api', true));
-
- } // end is_api_enabled;
+ }
/**
* Register the API routes.
@@ -431,19 +443,21 @@ class API {
*/
public function register_routes() {
- if (!$this->is_api_enabled()) {
-
+ if ( ! $this->is_api_enabled()) {
return;
-
- } // end if;
+ }
$namespace = $this->get_namespace();
- register_rest_route($namespace, '/auth', array(
- 'methods' => 'GET',
- 'callback' => array($this, 'auth'),
- 'permission_callback' => array($this, 'check_authorization'),
- ));
+ register_rest_route(
+ $namespace,
+ '/auth',
+ array(
+ 'methods' => 'GET',
+ 'callback' => array($this, 'auth'),
+ 'permission_callback' => array($this, 'check_authorization'),
+ )
+ );
/**
* Allow additional routes to be registered.
@@ -454,8 +468,7 @@ class API {
* @param self $this The current API instance.
*/
do_action('wu_register_rest_routes', $this);
-
- } // end register_routes;
+ }
/**
* Dummy endpoint to low services to test the authentication method being used.
@@ -469,12 +482,12 @@ class API {
$current_site = get_current_site();
- wp_send_json(array(
- 'success' => true,
- 'label' => $current_site->site_name,
- 'message' => __('Welcome to our API', 'wp-ultimo'),
- ));
-
- } // end auth;
-
-} // end class API;
+ wp_send_json(
+ array(
+ 'success' => true,
+ 'label' => $current_site->site_name,
+ 'message' => __('Welcome to our API', 'wp-ultimo'),
+ )
+ );
+ }
+}
diff --git a/inc/class-async-calls.php b/inc/class-async-calls.php
index 7e0f094..1bc3e28 100644
--- a/inc/class-async-calls.php
+++ b/inc/class-async-calls.php
@@ -9,14 +9,14 @@
namespace WP_Ultimo;
-use \Amp\Iterator;
-use \Amp\Sync\LocalSemaphore;
-use \Amp\Sync\ConcurrentIterator;
-use \Amp\Http\Client\Request;
-use \Amp\Http\Client\Connection\DefaultConnectionPool;
-use \Amp\Socket\ClientTlsContext;
-use \Amp\Socket\ConnectContext;
-use \Amp\Http\Client\HttpClientBuilder;
+use Amp\Iterator;
+use Amp\Sync\LocalSemaphore;
+use Amp\Sync\ConcurrentIterator;
+use Amp\Http\Client\Request;
+use Amp\Http\Client\Connection\DefaultConnectionPool;
+use Amp\Socket\ClientTlsContext;
+use Amp\Socket\ConnectContext;
+use Amp\Http\Client\HttpClientBuilder;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -47,12 +47,11 @@ class Async_Calls {
*/
public static function register_listener($id, $callable, ...$args) {
- self::$registry[$id] = array(
+ self::$registry[ $id ] = array(
'callable' => $callable,
'args' => $args,
);
-
- } // end register_listener;
+ }
/**
* Install the registered listeners.
@@ -63,28 +62,23 @@ class Async_Calls {
public static function install_listeners() {
foreach (self::$registry as $id => $listener) {
+ add_action(
+ "wp_ajax_wu_async_call_listener_{$id}",
+ function () use ($listener) {
- add_action("wp_ajax_wu_async_call_listener_{$id}", function() use ($listener) {
+ try {
+ $results = call_user_func_array($listener['callable'], $listener['args']);
+ } catch (\Throwable $th) {
+ wp_send_json_error($th);
+ }
- try {
+ wp_send_json_success($results);
- $results = call_user_func_array($listener['callable'], $listener['args']);
-
- } catch (\Throwable $th) {
-
- wp_send_json_error($th);
-
- } // end try;
-
- wp_send_json_success($results);
-
- exit;
-
- });
-
- } // end foreach;
-
- } // end install_listeners;
+ exit;
+ }
+ );
+ }
+ }
/**
* Build the base URL for the listener calls.
@@ -98,8 +92,7 @@ class Async_Calls {
public static function build_base_url($id, $args) {
return add_query_arg($args, admin_url('admin-ajax.php'));
-
- } // end build_base_url;
+ }
/**
* Build the final URL to be called.
@@ -119,19 +112,22 @@ class Async_Calls {
$urls = array();
for ($i = 1; $i <= $pages; $i++) {
-
- $urls[] = self::build_base_url($id, array_merge($args, array(
- 'action' => "wu_async_call_listener_$id",
- 'parallel' => 1,
- 'page' => $i,
- 'per_page' => $chunk_size,
- )));
-
- } // end for;
+ $urls[] = self::build_base_url(
+ $id,
+ array_merge(
+ $args,
+ array(
+ 'action' => "wu_async_call_listener_$id",
+ 'parallel' => 1,
+ 'page' => $i,
+ 'per_page' => $chunk_size,
+ )
+ )
+ );
+ }
return $urls;
-
- } // end build_url_list;
+ }
/**
* Builds and returns the client that will handle the calls.
@@ -143,17 +139,16 @@ class Async_Calls {
$client_tls_context = new ClientTlsContext('');
- $connect_base_context = new ConnectContext;
+ $connect_base_context = new ConnectContext();
$tls_context = $client_tls_context->withoutPeerVerification();
$connect_context = $connect_base_context->withTlsContext($tls_context);
- $builder = new HttpClientBuilder;
+ $builder = new HttpClientBuilder();
return $builder->usingPool(new DefaultConnectionPool(null, $connect_context))->build();
-
- } // end get_client;
+ }
/**
* Run the parallel queue after everything is correctly enqueued.
@@ -173,49 +168,48 @@ class Async_Calls {
$urls = self::build_url_list($id, $total, $chunk_size, $args);
- $coroutine = \Amp\call(static function() use ($id, $total, $chunk_size, $parallel_threads, $client, $urls) {
+ $coroutine = \Amp\call(
+ static function () use ($id, $total, $chunk_size, $parallel_threads, $client, $urls) {
- $results = array();
+ $results = array();
- $chunker = new LocalSemaphore($parallel_threads);
+ $chunker = new LocalSemaphore($parallel_threads);
- yield ConcurrentIterator\each(Iterator\fromIterable($urls), $chunker, function($url) use (&$results, $client) {
+ yield ConcurrentIterator\each(
+ Iterator\fromIterable($urls),
+ $chunker,
+ function ($url) use (&$results, $client) {
- try {
+ try {
+ $request = new Request($url);
- $request = new Request($url);
+ $request->setTcpConnectTimeout(1000 * 1000);
- $request->setTcpConnectTimeout(1000 * 1000);
+ $request->setTlsHandshakeTimeout(1000 * 1000);
- $request->setTlsHandshakeTimeout(1000 * 1000);
+ $request->setTransferTimeout(1000 * 1000);
- $request->setTransferTimeout(1000 * 1000);
+ $request->setHeader('cookie', wu_get_isset($_SERVER, 'HTTP_COOKIE', ''));
- $request->setHeader('cookie', wu_get_isset($_SERVER, 'HTTP_COOKIE', ''));
+ $response = yield $client->request($request);
- $response = yield $client->request($request);
+ $body = yield $response->getBody()->buffer();
- $body = yield $response->getBody()->buffer();
-
- $results[$url] = json_decode($body);
-
- } catch (\Throwable $e) {
-
- throw $e;
-
- } // end try;
-
- });
+ $results[ $url ] = json_decode($body);
+ } catch (\Throwable $e) {
+ throw $e;
+ }
+ }
+ );
return self::condense_results($results); // phpcs:ignore
-
- });
+ }
+ );
$responses = \Amp\Promise\wait($coroutine);
return $responses;
-
- } // end run;
+ }
/**
* Condense multiple results into one single result.
@@ -228,19 +222,13 @@ class Async_Calls {
public static function condense_results($results) {
foreach ($results as $result) {
-
$status = wu_get_isset($result, 'success', false);
if ($status === false) {
-
return $result;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
return true;
-
- } // end condense_results;
-
-} // end class Async_Calls;
+ }
+}
diff --git a/inc/class-autoloader.php b/inc/class-autoloader.php
index 8a118f6..8210b75 100644
--- a/inc/class-autoloader.php
+++ b/inc/class-autoloader.php
@@ -31,7 +31,7 @@ class Autoloader {
/**
* Static-only class.
*/
- private function __construct() {} // end __construct;
+ private function __construct() {}
/**
* Initializes our custom autoloader
@@ -42,7 +42,7 @@ class Autoloader {
*/
public static function init() {
// do nothing now. Composer autoloader does the work.
- } // end init;
+ }
/**
* Checks for unit tests and WP_ULTIMO_DEBUG.
@@ -53,7 +53,5 @@ class Autoloader {
public static function is_debug() {
return false; // return wu_is_debug();
-
- } // end is_debug;
-
-} // end class Autoloader;
+ }
+}
diff --git a/inc/class-cron.php b/inc/class-cron.php
index ec93328..436b75d 100644
--- a/inc/class-cron.php
+++ b/inc/class-cron.php
@@ -13,8 +13,8 @@
namespace WP_Ultimo;
-use \WP_Ultimo\Database\Memberships\Membership_Status;
-use \WP_Ultimo\Database\Payments\Payment_Status;
+use WP_Ultimo\Database\Memberships\Membership_Status;
+use WP_Ultimo\Database\Payments\Payment_Status;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -66,8 +66,7 @@ class Cron {
add_action('wu_membership_check', array($this, 'membership_expired_check'), 20);
add_action('wu_async_mark_membership_as_expired', array($this, 'async_mark_membership_as_expired'), 10);
-
- } // end init;
+ }
/**
* Creates the recurring schedules for WP Multisite WaaS.
@@ -82,34 +81,27 @@ class Cron {
* Hourly check
*/
if (wu_next_scheduled_action('wu_hourly') === false) {
-
$next_hour = strtotime(gmdate('Y-m-d H:00:00', strtotime('+1 hour')));
wu_schedule_recurring_action($next_hour, HOUR_IN_SECONDS, 'wu_hourly', array(), 'wu_cron');
-
- } // end if;
+ }
/*
* Daily check
*/
if (wu_next_scheduled_action('wu_daily') === false) {
-
wu_schedule_recurring_action(strtotime('tomorrow'), DAY_IN_SECONDS, 'wu_daily', array(), 'wu_cron');
-
- } // end if;
+ }
/*
* Monthly check
*/
if (wu_next_scheduled_action('wu_monthly') === false) {
-
$next_month = strtotime(gmdate('Y-m-01 00:00:00', strtotime('+1 month')));
wu_schedule_recurring_action($next_month, MONTH_IN_SECONDS, 'wu_monthly', array(), 'wu_cron');
-
- } // end if;
-
- } // end create_schedules;
+ }
+ }
/**
* Creates the default membership checking schedule.
@@ -126,12 +118,9 @@ class Cron {
$interval = apply_filters('wu_schedule_membership_check_interval', 1 * HOUR_IN_SECONDS);
if (wu_next_scheduled_action('wu_membership_check') === false) {
-
wu_schedule_recurring_action(time(), $interval, 'wu_membership_check', array(), 'wu_cron');
-
- } // end if;
-
- } // end schedule_membership_check;
+ }
+ }
/**
* Checks if non-auto-renewable memberships need work.
@@ -144,23 +133,27 @@ class Cron {
*/
public function membership_renewal_check() {
/*
- * Define how many days before we need to
+ * Define how many days before we need to
* create pending payments.
*/
$days_before_expiring = apply_filters('wu_membership_renewal_days_before_expiring', 3);
- $query_params = apply_filters('wu_membership_renewal_check_query_params', array(
- 'auto_renew' => false,
- 'status__in' => array(
- Membership_Status::ACTIVE,
+ $query_params = apply_filters(
+ 'wu_membership_renewal_check_query_params',
+ array(
+ 'auto_renew' => false,
+ 'status__in' => array(
+ Membership_Status::ACTIVE,
+ ),
+ 'date_query' => array(
+ 'column' => 'date_expiration',
+ 'before' => "+{$days_before_expiring} days",
+ 'after' => 'yesterday',
+ 'inclusive' => true,
+ ),
),
- 'date_query' => array(
- 'column' => 'date_expiration',
- 'before' => "+{$days_before_expiring} days",
- 'after' => 'yesterday',
- 'inclusive' => true,
- ),
- ), $days_before_expiring);
+ $days_before_expiring
+ );
$memberships = wu_get_memberships($query_params);
@@ -169,14 +162,15 @@ class Cron {
* a new async call for each one.
*/
foreach ($memberships as $membership) {
-
- wu_enqueue_async_action('wu_async_create_renewal_payment', array(
- 'membership_id' => $membership->get_id(),
- ), 'wu_cron_check');
-
- } // end foreach;
-
- } // end membership_renewal_check;
+ wu_enqueue_async_action(
+ 'wu_async_create_renewal_payment',
+ array(
+ 'membership_id' => $membership->get_id(),
+ ),
+ 'wu_cron_check'
+ );
+ }
+ }
/**
* Checks if trialing memberships need work.
@@ -189,17 +183,20 @@ class Cron {
*/
public function membership_trial_check() {
- $query_params = apply_filters('wu_membership_trial_check_query_params', array(
- 'auto_renew' => false,
- 'status__in' => array(
- Membership_Status::TRIALING,
- ),
- 'date_query' => array(
- 'column' => 'date_trial_end',
- 'before' => '-3 hours',
- 'inclusive' => true,
- ),
- ));
+ $query_params = apply_filters(
+ 'wu_membership_trial_check_query_params',
+ array(
+ 'auto_renew' => false,
+ 'status__in' => array(
+ Membership_Status::TRIALING,
+ ),
+ 'date_query' => array(
+ 'column' => 'date_trial_end',
+ 'before' => '-3 hours',
+ 'inclusive' => true,
+ ),
+ )
+ );
$memberships = wu_get_memberships($query_params);
@@ -208,15 +205,16 @@ class Cron {
* a new async call for each one.
*/
foreach ($memberships as $membership) {
-
- wu_enqueue_async_action('wu_async_create_renewal_payment', array(
- 'membership_id' => $membership->get_id(),
- 'trial' => true,
- ), 'wu_cron_check');
-
- } // end foreach;
-
- } // end membership_trial_check;
+ wu_enqueue_async_action(
+ 'wu_async_create_renewal_payment',
+ array(
+ 'membership_id' => $membership->get_id(),
+ 'trial' => true,
+ ),
+ 'wu_cron_check'
+ );
+ }
+ }
/**
* Creates the pending payment for a renewing membership.
@@ -232,10 +230,8 @@ class Cron {
$membership = wu_get_membership($membership_id);
if (empty($membership)) {
-
return false;
-
- } // end if;
+ }
/*
* List of things to do:
@@ -249,8 +245,7 @@ class Cron {
$pending_payment = $membership->get_last_pending_payment();
if (empty($pending_payment)) {
-
- $new_payment = wu_membership_create_new_payment($membership, false, !$trial);
+ $new_payment = wu_membership_create_new_payment($membership, false, ! $trial);
/*
* Update the membership status.
@@ -259,9 +254,12 @@ class Cron {
$saved = $membership->save();
- $payment_url = add_query_arg(array(
- 'payment' => $new_payment->get_hash(),
- ), wu_get_registration_url());
+ $payment_url = add_query_arg(
+ array(
+ 'payment' => $new_payment->get_hash(),
+ ),
+ wu_get_registration_url()
+ );
$payload = array_merge(
array(
@@ -275,12 +273,10 @@ class Cron {
wu_do_event('renewal_payment_created', $payload);
return $saved;
-
- } // end if;
+ }
return true;
-
- } // end async_create_renewal_payment;
+ }
/**
* Checks if any memberships need to be marked as expired.
@@ -295,19 +291,23 @@ class Cron {
*/
$grace_period_days = apply_filters('wu_membership_grace_period_days', 3);
- $query_params = apply_filters('wu_membership_expired_check_query_params', array(
- 'auto_renew' => false,
- 'status__in' => array(
- Membership_Status::ACTIVE,
- Membership_Status::ON_HOLD,
+ $query_params = apply_filters(
+ 'wu_membership_expired_check_query_params',
+ array(
+ 'auto_renew' => false,
+ 'status__in' => array(
+ Membership_Status::ACTIVE,
+ Membership_Status::ON_HOLD,
+ ),
+ 'date_expiration__not_in' => array(null, '0000-00-00 00:00:00'),
+ 'date_query' => array(
+ 'column' => 'date_expiration',
+ 'before' => "-{$grace_period_days} days",
+ 'inclusive' => true,
+ ),
),
- 'date_expiration__not_in' => array(null, '0000-00-00 00:00:00'),
- 'date_query' => array(
- 'column' => 'date_expiration',
- 'before' => "-{$grace_period_days} days",
- 'inclusive' => true,
- ),
- ), $grace_period_days);
+ $grace_period_days
+ );
$memberships = wu_get_memberships($query_params);
@@ -316,14 +316,15 @@ class Cron {
* a new async call for each one.
*/
foreach ($memberships as $membership) {
-
- wu_enqueue_async_action('wu_async_mark_membership_as_expired', array(
- 'membership_id' => $membership->get_id(),
- ), 'wu_cron_check');
-
- } // end foreach;
-
- } // end membership_expired_check;
+ wu_enqueue_async_action(
+ 'wu_async_mark_membership_as_expired',
+ array(
+ 'membership_id' => $membership->get_id(),
+ ),
+ 'wu_cron_check'
+ );
+ }
+ }
/**
* Marks expired memberships as such.
@@ -338,10 +339,8 @@ class Cron {
$membership = wu_get_membership($membership_id);
if (empty($membership)) {
-
return false;
-
- } // end if;
+ }
/*
* Update the membership status.
@@ -356,7 +355,5 @@ class Cron {
$membership->set_skip_validation(true);
return $membership->save();
-
- } // end async_mark_membership_as_expired;
-
-} // end class Cron;
+ }
+}
diff --git a/inc/class-current.php b/inc/class-current.php
index d59de97..b9cc46d 100644
--- a/inc/class-current.php
+++ b/inc/class-current.php
@@ -90,8 +90,7 @@ class Current {
*/
add_action('init', array($this, 'load_currents'));
add_action('wp', array($this, 'load_currents'));
-
- } // end init;
+ }
/**
* Flush rewrite rules to make sure any newly added ones get installed on update.
@@ -102,8 +101,7 @@ class Current {
public function flush_rewrite_rules_on_update() {
flush_rewrite_rules();
-
- } // end flush_rewrite_rules_on_update;
+ }
/**
* Adds a new rewrite rule to allow for pretty links.
@@ -124,16 +122,13 @@ class Current {
);
if (is_subdomain_install() === false) {
-
add_rewrite_rule(
"blog/(.?.+?)/{$site_url_param}/([0-9a-zA-Z]+)/?$",
'index.php?name=$matches[1]&site_hash=$matches[2]',
'top'
);
-
- } // end if;
-
- } // end add_rewrite_rules;
+ }
+ }
/**
* Adds the necessary query vars to support pretty links.
@@ -153,8 +148,7 @@ class Current {
$query_vars[] = 'wu_preselected';
return $query_vars;
-
- } // end add_query_vars;
+ }
/**
* List of URL keys to set the current objects.
@@ -172,8 +166,7 @@ class Current {
);
return wu_get_isset($params, $type, $type);
-
- } // end param_key;
+ }
/**
* Returns the URL to manage a site/customer on the front-end or back end.
@@ -189,8 +182,7 @@ class Current {
// Uses hash instead of the ID.
$site_hash = \WP_Ultimo\Helpers\Hash::encode($id, $type);
- if (!is_admin()) {
-
+ if ( ! is_admin()) {
$current_url = rtrim((string) wu_get_current_url(), '/');
$url_param = self::param_key($type);
@@ -199,20 +191,15 @@ class Current {
* Check if the current URL already has a site parameter and remove it.
*/
if (strpos($current_url, '/' . $url_param . '/') !== false) {
-
$current_url = preg_replace('/\/' . $url_param . '\/(.+)/', '/', $current_url);
-
- } // end if;
+ }
$pretty_url = $current_url . '/' . $url_param . '/' . $site_hash;
$manage_site_url = get_option('permalink_structure') ? $pretty_url : add_query_arg($url_param, $site_hash);
-
} else {
-
$manage_site_url = get_admin_url($id);
-
- } // end if;
+ }
/**
* Allow developers to modify the manage site URL parameters.
@@ -225,8 +212,7 @@ class Current {
* @return string The modified manage URL.
*/
return apply_filters("wu_current_{$type}_get_manage_url", $manage_site_url, $id, $site_hash);
-
- } // end get_manage_url;
+ }
/**
* Loads the current site and makes it available.
@@ -241,7 +227,7 @@ class Current {
/**
* On the front-end, we need to check for url overrides.
*/
- if (!is_admin()) {
+ if ( ! is_admin()) {
/*
* By default, we'll use the `site` parameter.
*/
@@ -252,31 +238,24 @@ class Current {
$site_from_url = wu_get_site_by_hash($site_hash);
if ($site_from_url) {
-
$this->site_set_via_request = true;
$site = $site_from_url;
-
- } // end if;
-
+ }
} else {
-
$site = wu_get_current_site();
-
- } // end if;
+ }
if ($site) {
-
$this->set_site($site);
-
- } // end if;
+ }
$customer = wu_get_current_customer();
/**
* On the front-end, we need to check for url overrides.
*/
- if (!is_admin()) {
+ if ( ! is_admin()) {
/*
* By default, we'll use the `site` parameter.
*/
@@ -285,14 +264,11 @@ class Current {
$customer_from_url = wu_get_customer(wu_request($customer_url_param, 0));
if ($customer_from_url) {
-
$this->customer_set_via_request = true;
$customer = $customer_from_url;
-
- } // end if;
-
- } // end if;
+ }
+ }
$this->set_customer($customer);
@@ -306,28 +282,21 @@ class Current {
$membership_hash = wu_request($membership_url_param, get_query_var('membership_hash'));
if ($membership_hash) {
-
$this->membership_set_via_request = true;
$membership = wu_get_membership_by_hash($membership_hash);
-
} elseif ($site) {
-
$membership = $site->get_membership();
+ }
- } // end if;
-
- if ($customer && !$membership) {
-
+ if ($customer && ! $membership) {
$memberships = (array) $customer->get_memberships();
$membership = wu_get_isset($memberships, 0, false);
-
- } // end if;
+ }
$this->set_membership($membership);
-
- } // end load_currents;
+ }
/**
* Get the current site instance.
@@ -338,8 +307,7 @@ class Current {
public function get_site() {
return $this->site;
-
- } // end get_site;
+ }
/**
* Set the current site instance.
@@ -363,8 +331,7 @@ class Current {
$site = apply_filters('wu_current_set_site', $site, $this);
$this->site = $site;
-
- } // end set_site;
+ }
/**
* Get wether or not the site was set via request.
@@ -375,8 +342,7 @@ class Current {
public function is_site_set_via_request() {
return $this->site_set_via_request;
-
- } // end is_site_set_via_request;
+ }
/**
* Get the current customer instance.
@@ -387,8 +353,7 @@ class Current {
public function get_customer() {
return $this->customer;
-
- } // end get_customer;
+ }
/**
* Set the current customer instance.
@@ -412,8 +377,7 @@ class Current {
$customer = apply_filters('wu_current_set_customer', $customer, $this);
$this->customer = $customer;
-
- } // end set_customer;
+ }
/**
* Get the current membership instance.
@@ -424,8 +388,7 @@ class Current {
public function get_membership() {
return $this->membership;
-
- } // end get_membership;
+ }
/**
* Set the current membership instance.
@@ -449,8 +412,7 @@ class Current {
$membership = apply_filters('wu_current_set_membership', $membership, $this);
$this->membership = $membership;
-
- } // end set_membership;
+ }
/**
* Get wether or not the membership was set via request.
@@ -461,7 +423,5 @@ class Current {
public function is_membership_set_via_request() {
return $this->membership_set_via_request;
-
- } // end is_membership_set_via_request;
-
-} // end class Current;
+ }
+}
diff --git a/inc/class-dashboard-statistics.php b/inc/class-dashboard-statistics.php
index 4165377..289bc5b 100644
--- a/inc/class-dashboard-statistics.php
+++ b/inc/class-dashboard-statistics.php
@@ -11,9 +11,9 @@
namespace WP_Ultimo;
-use \WP_Ultimo\Models\Membership;
-use \WP_Ultimo\Models\Payment;
-use \WP_Ultimo\Database\Payments\Payment_Status;
+use WP_Ultimo\Models\Membership;
+use WP_Ultimo\Models\Payment;
+use WP_Ultimo\Database\Payments\Payment_Status;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -59,16 +59,13 @@ class Dashboard_Statistics {
public function __construct($args = array()) {
if ($args) {
-
$this->start_date = $args['start_date'];
$this->end_date = $args['end_date'];
$this->types = $args['types'];
-
- } // end if;
-
- } // end __construct;
+ }
+ }
/**
* Runs on singleton instantiation.
@@ -76,7 +73,7 @@ class Dashboard_Statistics {
* @since 2.0.0
* @return void.
*/
- public function init() {} // end init;
+ public function init() {}
/**
* Main function to call the get data functions based on the array of types.
@@ -89,16 +86,13 @@ class Dashboard_Statistics {
$data = array();
foreach ($this->types as $key => $type) {
-
$data_function = 'get_data_' . $type;
- $data[$key] = $this->$data_function();
-
- } // end foreach;
+ $data[ $key ] = $this->$data_function();
+ }
return $data;
-
- } // end statistics_data;
+ }
/**
* Get data of all completed and refunded payments to show in the main graph.
@@ -159,16 +153,18 @@ class Dashboard_Statistics {
),
);
- $memberships = wu_get_memberships(array(
- 'date_query' => array(
- 'column' => 'date_created',
- 'compare' => 'BETWEEN',
- 'relation' => '',
- array(
- 'year' => current_time('Y', true),
+ $memberships = wu_get_memberships(
+ array(
+ 'date_query' => array(
+ 'column' => 'date_created',
+ 'compare' => 'BETWEEN',
+ 'relation' => '',
+ array(
+ 'year' => current_time('Y', true),
+ ),
),
)
- ));
+ );
$mrr_status = array(
'active',
@@ -182,39 +178,29 @@ class Dashboard_Statistics {
);
foreach ($memberships as $membership) {
-
- if (!$membership->is_recurring()) {
-
+ if ( ! $membership->is_recurring()) {
continue;
-
- } // end if;
+ }
$status = $membership->get_status();
if (in_array($status, $mrr_status, true)) {
-
$data = getdate(strtotime($membership->get_date_created()));
$month = strtolower($data['month']);
- $payments_per_month[$month]['total'] += floatval($membership->get_normalized_amount());
-
- } // end if;
+ $payments_per_month[ $month ]['total'] += floatval($membership->get_normalized_amount());
+ }
if (in_array($status, $churn_status, true)) {
-
$data = getdate(strtotime((string) $membership->get_date_cancellation()));
$month = strtolower($data['month']);
- $payments_per_month[$month]['cancelled'] += floatval($membership->get_normalized_amount());
-
- } // end if;
-
- } // end foreach;
+ $payments_per_month[ $month ]['cancelled'] += floatval($membership->get_normalized_amount());
+ }
+ }
return $payments_per_month;
-
- } // end get_data_mrr_growth;
-
-} // end class Dashboard_Statistics;
+ }
+}
diff --git a/inc/class-dashboard-widgets.php b/inc/class-dashboard-widgets.php
index 14fe4cd..096d159 100644
--- a/inc/class-dashboard-widgets.php
+++ b/inc/class-dashboard-widgets.php
@@ -58,8 +58,7 @@ class Dashboard_Widgets {
add_action('wp_ajax_wu_fetch_activity', array($this, 'process_ajax_fetch_events'));
add_action('wp_ajax_wu_generate_csv', array($this, 'handle_table_csv'));
-
- } // end init;
+ }
/**
* Enqueues the JavaScript code that sends the dismiss call to the ajax endpoint.
@@ -71,17 +70,14 @@ class Dashboard_Widgets {
global $pagenow;
- if (!$pagenow || $pagenow !== 'index.php') {
-
+ if ( ! $pagenow || $pagenow !== 'index.php') {
return;
-
- } // end if;
+ }
wp_enqueue_script('wu-vue');
wp_enqueue_script('moment');
-
- } // end enqueue_scripts;
+ }
/**
* Register the widgets
@@ -97,40 +93,42 @@ class Dashboard_Widgets {
add_meta_box('wp-ultimo-activity-stream', __('WP Multisite WaaS - Activity Stream', 'wp-ultimo'), array($this, 'output_widget_activity_stream'), $this->screen_id, 'normal', 'high');
- \WP_Ultimo\UI\Tours::get_instance()->create_tour('dashboard', array(
+ \WP_Ultimo\UI\Tours::get_instance()->create_tour(
+ 'dashboard',
array(
- 'id' => 'welcome',
- 'title' => __('Welcome!', 'wp-ultimo'),
- 'text' => array(
- __('Welcome to your new network dashboard!', 'wp-ultimo'),
- __('You will notice that WP Multisite WaaS adds a couple of useful widgets here so you can keep an eye on how your network is doing.', 'wp-ultimo'),
+ array(
+ 'id' => 'welcome',
+ 'title' => __('Welcome!', 'wp-ultimo'),
+ 'text' => array(
+ __('Welcome to your new network dashboard!', 'wp-ultimo'),
+ __('You will notice that WP Multisite WaaS adds a couple of useful widgets here so you can keep an eye on how your network is doing.', 'wp-ultimo'),
+ ),
),
- ),
- array(
- 'id' => 'finish-your-setup',
- 'title' => __('Finish your setup', 'wp-ultimo'),
- 'text' => array(
- __('You still have a couple of things to do configuration-wise. Check the steps on this list and make sure you complete them all.', 'wp-ultimo'),
+ array(
+ 'id' => 'finish-your-setup',
+ 'title' => __('Finish your setup', 'wp-ultimo'),
+ 'text' => array(
+ __('You still have a couple of things to do configuration-wise. Check the steps on this list and make sure you complete them all.', 'wp-ultimo'),
+ ),
+ 'attachTo' => array(
+ 'element' => '#wp-ultimo-setup',
+ 'on' => 'left',
+ ),
),
- 'attachTo' => array(
- 'element' => '#wp-ultimo-setup',
- 'on' => 'left',
+ array(
+ 'id' => 'wp-ultimo-menu',
+ 'title' => __('Our home', 'wp-ultimo'),
+ 'text' => array(
+ __('You can always find WP Multisite WaaS settings and other pages under our menu item, here on the Network-level dashboard. 😃', 'wp-ultimo'),
+ ),
+ 'attachTo' => array(
+ 'element' => '.toplevel_page_wp-ultimo',
+ 'on' => 'left',
+ ),
),
- ),
- array(
- 'id' => 'wp-ultimo-menu',
- 'title' => __('Our home', 'wp-ultimo'),
- 'text' => array(
- __('You can always find WP Multisite WaaS settings and other pages under our menu item, here on the Network-level dashboard. 😃', 'wp-ultimo'),
- ),
- 'attachTo' => array(
- 'element' => '.toplevel_page_wp-ultimo',
- 'on' => 'left',
- ),
- ),
- ));
-
- } // end register_network_widgets;
+ )
+ );
+ }
/**
* Adds the customer's site's dashboard widgets.
@@ -143,10 +141,8 @@ class Dashboard_Widgets {
$screen = get_current_screen();
if (wu_get_current_site()->get_type() !== 'customer_owned') {
-
return;
-
- } // end if;
+ }
/*
* Account Summary
@@ -162,21 +158,16 @@ class Dashboard_Widgets {
* Maintenance Mode Widget
*/
if (wu_get_setting('maintenance_mode')) {
-
\WP_Ultimo\UI\Site_Maintenance_Element::get_instance()->as_metabox($screen->id, 'side');
-
- } // end if;
+ }
/*
* Domain Mapping Widget
*/
if (wu_get_setting('enable_domain_mapping') && wu_get_setting('custom_domains')) {
-
\WP_Ultimo\UI\Domain_Mapping_Element::get_instance()->as_metabox($screen->id, 'side');
-
- } // end if;
-
- } // end register_widgets;
+ }
+ }
/**
* Widget First Steps Output.
@@ -201,13 +192,16 @@ class Dashboard_Widgets {
'title' => __('Payment Method', 'wp-ultimo'),
'desc' => __('You will need to configure at least one payment gateway to be able to receive money from your customers.', 'wp-ultimo'),
'action_label' => __('Add a Payment Method', 'wp-ultimo'),
- 'action_link' => wu_network_admin_url('wp-ultimo-settings', array(
- 'tab' => 'payment-gateways',
- )),
- 'done' => !empty(wu_get_active_gateways()),
+ 'action_link' => wu_network_admin_url(
+ 'wp-ultimo-settings',
+ array(
+ 'tab' => 'payment-gateways',
+ )
+ ),
+ 'done' => ! empty(wu_get_active_gateways()),
),
'your-first-customer' => array(
- 'done' => !empty(wu_get_customers()),
+ 'done' => ! empty(wu_get_customers()),
'title' => __('Your First Customer', 'wp-ultimo'),
'desc' => __('Open the link below in an incognito tab and go through your newly created signup form.', 'wp-ultimo'),
'action_link' => wp_registration_url(),
@@ -215,19 +209,24 @@ class Dashboard_Widgets {
),
);
- $done = \Arrch\Arrch::find($steps, array(
- 'where' => array(
- array('done', true),
- ),
- ));
+ $done = \Arrch\Arrch::find(
+ $steps,
+ array(
+ 'where' => array(
+ array('done', true),
+ ),
+ )
+ );
- wu_get_template('dashboard-widgets/first-steps', array(
- 'steps' => $steps,
- 'percentage' => round(count($done) / count($steps) * 100),
- 'all_done' => count($done) === count($steps),
- ));
-
- } // end output_widget_first_steps;
+ wu_get_template(
+ 'dashboard-widgets/first-steps',
+ array(
+ 'steps' => $steps,
+ 'percentage' => round(count($done) / count($steps) * 100),
+ 'all_done' => count($done) === count($steps),
+ )
+ );
+ }
/**
* Widget Activity Stream Output.
@@ -239,8 +238,7 @@ class Dashboard_Widgets {
public function output_widget_activity_stream() {
wu_get_template('dashboard-widgets/activity-stream');
-
- } // end output_widget_activity_stream;
+ }
/**
* Widget Summary Output
@@ -253,22 +251,26 @@ class Dashboard_Widgets {
/*
* Get today's signups.
*/
- $signups = wu_get_customers(array(
- 'count' => true,
- 'date_query' => array(
- 'column' => 'date_registered',
- 'after' => 'today',
- 'inclusive' => true,
- ),
- ));
+ $signups = wu_get_customers(
+ array(
+ 'count' => true,
+ 'date_query' => array(
+ 'column' => 'date_registered',
+ 'after' => 'today',
+ 'inclusive' => true,
+ ),
+ )
+ );
- wu_get_template('dashboard-widgets/summary', array(
- 'signups' => $signups,
- 'mrr' => wu_calculate_mrr(),
- 'gross_revenue' => wu_calculate_revenue('today'),
- ));
-
- } // end output_widget_summary;
+ wu_get_template(
+ 'dashboard-widgets/summary',
+ array(
+ 'signups' => $signups,
+ 'mrr' => wu_calculate_mrr(),
+ 'gross_revenue' => wu_calculate_revenue('today'),
+ )
+ );
+ }
/**
* Process Ajax Filters for rss.
@@ -278,20 +280,22 @@ class Dashboard_Widgets {
*/
public function process_ajax_fetch_rss() {
- $atts = wp_parse_args($_GET, array(
- 'url' => 'https://community.wpultimo.com/topics/feed',
- 'title' => __('Forum Discussions', 'wp-ultimo'),
- 'items' => 3,
- 'show_summary' => 1,
- 'show_author' => 0,
- 'show_date' => 1,
- ));
+ $atts = wp_parse_args(
+ $_GET,
+ array(
+ 'url' => 'https://community.wpultimo.com/topics/feed',
+ 'title' => __('Forum Discussions', 'wp-ultimo'),
+ 'items' => 3,
+ 'show_summary' => 1,
+ 'show_author' => 0,
+ 'show_date' => 1,
+ )
+ );
wp_widget_rss_output($atts);
exit;
-
- } // end process_ajax_fetch_rss;
+ }
/**
* Process Ajax Filters for rss.
@@ -303,22 +307,27 @@ class Dashboard_Widgets {
check_ajax_referer('wu_activity_stream');
- $count = wu_get_events(array(
- 'count' => true,
- 'number' => -1,
- ));
+ $count = wu_get_events(
+ array(
+ 'count' => true,
+ 'number' => -1,
+ )
+ );
- $data = wu_get_events(array(
- 'offset' => (wu_request('page', 1) - 1) * 5,
- 'number' => 5,
- ));
+ $data = wu_get_events(
+ array(
+ 'offset' => (wu_request('page', 1) - 1) * 5,
+ 'number' => 5,
+ )
+ );
- wp_send_json_success(array(
- 'events' => $data,
- 'count' => $count,
- ));
-
- } // end process_ajax_fetch_events;
+ wp_send_json_success(
+ array(
+ 'events' => $data,
+ 'count' => $count,
+ )
+ );
+ }
/**
* Handle ajax endpoint to generate table CSV.
@@ -339,8 +348,7 @@ class Dashboard_Widgets {
wu_generate_csv($file_name, $data);
die;
-
- } // end handle_table_csv;
+ }
/**
* Get the registered widgets.
@@ -354,11 +362,9 @@ class Dashboard_Widgets {
ob_start();
- if (!function_exists('wp_add_dashboard_widget')) {
-
+ if ( ! function_exists('wp_add_dashboard_widget')) {
require_once ABSPATH . '/wp-admin/includes/dashboard.php';
-
- } // end if;
+ }
do_action('wp_network_dashboard_setup'); // phpcs:ignore
@@ -374,22 +380,20 @@ class Dashboard_Widgets {
);
foreach ($dashboard_widgets as $position => $priorities) {
-
foreach ($priorities as $priority => $widgets) {
-
foreach ($widgets as $widget_key => $widget) {
-
if (empty($widget) || wu_get_isset($widget, 'title') === false) {
-
continue;
+ }
- } // end if;
-
- $key = implode(':', array(
- $position,
- $priority,
- $widget_key,
- ));
+ $key = implode(
+ ':',
+ array(
+ $position,
+ $priority,
+ $widget_key,
+ )
+ );
/**
* For some odd reason, in some cases, $options
@@ -397,22 +401,15 @@ class Dashboard_Widgets {
* This checks prevents that error from happening.
* I don't know why $options would ever be a boolean here, though.
*/
- if (!is_array($options)) {
-
+ if ( ! is_array($options)) {
$options = array();
+ }
- } // end if;
-
- $options[$key] = $widget['title'];
-
- } // end foreach;
-
- } // end foreach;
-
- } // end foreach;
+ $options[ $key ] = $widget['title'];
+ }
+ }
+ }
return $options;
-
- } // end get_registered_dashboard_widgets;
-
-} // end class Dashboard_Widgets;
+ }
+}
diff --git a/inc/class-documentation.php b/inc/class-documentation.php
index dafe27c..c4a5ac0 100644
--- a/inc/class-documentation.php
+++ b/inc/class-documentation.php
@@ -84,8 +84,7 @@ class Documentation {
$links['multiple-accounts'] = 'https://help.wpultimo.com/article/303-accounts-taken-care-of-with-wp-ultimo-multiple-accounts';
$this->links = apply_filters('wu_documentation_links_list', $links);
-
- } // end init;
+ }
/**
* Checks if a link exists.
@@ -98,8 +97,7 @@ class Documentation {
public function has_link($slug) {
return (bool) $this->get_link($slug, false);
-
- } // end has_link;
+ }
/**
* Retrieves a link registered
@@ -125,8 +123,7 @@ class Documentation {
* @param string $default_link The default link registered
*/
return apply_filters('wu_documentation_get_link', $link, $slug, $this->default_link);
-
- } // end get_link;
+ }
/**
* Add a new link to the list of links available for reference
@@ -138,8 +135,6 @@ class Documentation {
*/
public function register_link($slug, $link) {
- $this->links[$slug] = $link;
-
- } // end register_link;
-
-} // end class Documentation;
+ $this->links[ $slug ] = $link;
+ }
+}
diff --git a/inc/class-domain-mapping.php b/inc/class-domain-mapping.php
index 850e5c6..e580c73 100644
--- a/inc/class-domain-mapping.php
+++ b/inc/class-domain-mapping.php
@@ -48,16 +48,11 @@ class Domain_Mapping {
public function init() {
if ($this->should_skip_checks()) {
-
$this->startup();
-
} else {
-
$this->maybe_startup();
-
- } // end if;
-
- } // end init;
+ }
+ }
/**
* Check if we should skip checks before running mapping functions.
@@ -68,8 +63,7 @@ class Domain_Mapping {
public static function should_skip_checks() {
return defined('WP_ULTIMO_DOMAIN_MAPPING_SKIP_CHECKS') && WP_ULTIMO_DOMAIN_MAPPING_SKIP_CHECKS;
-
- } // end should_skip_checks;
+ }
/**
* Run the checks to make sure the requirements for Domain mapping are in place and execute it.
@@ -82,34 +76,27 @@ class Domain_Mapping {
* Don't run during installation...
*/
if (defined('WP_INSTALLING') && $_SERVER['SCRIPT_NAME'] !== '/wp-activate.php') {
-
return;
-
- } // end if;
+ }
/*
* Make sure we got loaded in the sunrise stage.
*/
if (did_action('muplugins_loaded')) {
-
return;
-
- } // end if;
+ }
$is_enabled = (bool) wu_get_setting_early('enable_domain_mapping');
if ($is_enabled === false) {
-
return;
-
- } // end if;
+ }
/*
* Start the engines!
*/
$this->startup();
-
- } // end maybe_startup;
+ }
/**
* Actual handles domain mapping functionality.
@@ -122,12 +109,10 @@ class Domain_Mapping {
* Adds the necessary tables to the $wpdb global.
*/
if (empty($GLOBALS['wpdb']->wu_dmtable)) {
-
$GLOBALS['wpdb']->wu_dmtable = $GLOBALS['wpdb']->base_prefix . 'wu_domain_mappings';
$GLOBALS['wpdb']->ms_global_tables[] = 'wu_domain_mappings';
-
- } // end if;
+ }
// Ensure cache is shared
wp_cache_add_global_groups(array('domain_mappings', 'network_mappings'));
@@ -153,23 +138,27 @@ class Domain_Mapping {
* On WP Multisite WaaS 1.X builds we used Mercator. The Mercator actions and filters are now deprecated.
*/
if (has_action('mercator_load')) {
-
do_action_deprecated('mercator_load', array(), '2.0.0', 'wu_domain_mapping_load');
+ }
- } // end if;
+ add_action(
+ 'wu_sso_site_allowed_domains',
+ function ($list, $site_id): array {
- add_action('wu_sso_site_allowed_domains', function($list, $site_id): array {
+ $domains = wu_get_domains(
+ array(
+ 'active' => true,
+ 'blog_id' => $site_id,
+ 'stage__not_in' => \WP_Ultimo\Models\Domain::INACTIVE_STAGES,
+ 'fields' => 'domain',
+ )
+ );
- $domains = wu_get_domains(array(
- 'active' => true,
- 'blog_id' => $site_id,
- 'stage__not_in' => \WP_Ultimo\Models\Domain::INACTIVE_STAGES,
- 'fields' => 'domain',
- ));
-
- return array_merge($list, $domains);
-
- }, 10, 2);
+ return array_merge($list, $domains);
+ },
+ 10,
+ 2
+ );
/**
* Fired after our core Domain Mapping has been loaded
@@ -177,8 +166,7 @@ class Domain_Mapping {
* Hook into this to handle any add-on functionality.
*/
do_action('wu_domain_mapping_load');
-
- } // end startup;
+ }
/**
* Checks if an origin is a mapped domain.
@@ -192,31 +180,24 @@ class Domain_Mapping {
*/
public function add_mapped_domains_as_allowed_origins($origin) {
- if (!function_exists('wu_get_domain_by_domain')) {
-
+ if ( ! function_exists('wu_get_domain_by_domain')) {
return;
-
- } // end if;
+ }
if (empty($origin) && wp_doing_ajax()) {
-
$origin = wu_get_current_url();
-
- } // end if;
+ }
$the_domain = wp_parse_url($origin, PHP_URL_HOST);
$domain = wu_get_domain_by_domain($the_domain);
if ($domain) {
-
return $domain->get_domain();
-
- } // end if;
+ }
return $origin;
-
- } // end add_mapped_domains_as_allowed_origins;
+ }
/**
* Fixes the SSO target site in cases of domain mapping.
@@ -229,21 +210,16 @@ class Domain_Mapping {
*/
public function fix_sso_target_site($target_site, $domain) {
- if (!$target_site || !$target_site->blog_id) {
-
+ if ( ! $target_site || ! $target_site->blog_id) {
$mapping = \WP_Ultimo\Models\Domain::get_by_domain($domain);
if ($mapping) {
-
$target_site = get_site($mapping->get_site_id());
-
- } // end if;
-
- } // end if;
+ }
+ }
return $target_site;
-
- } // end fix_sso_target_site;
+ }
/**
* Returns both the naked and www. version of the given domain
@@ -256,62 +232,51 @@ class Domain_Mapping {
public function get_www_and_nowww_versions($domain) {
if (strncmp($domain, 'www.', strlen('www.')) === 0) {
-
$www = $domain;
$nowww = substr($domain, 4);
-
} else {
-
$nowww = $domain;
$www = 'www.' . $domain;
-
- } // end if;
+ }
return array($nowww, $www);
-
- } // end get_www_and_nowww_versions;
- /**
- * Checks if we have a site associated with the domain being accessed
- *
- * This method tries to find a site on the network that has a mapping related to the current
- * domain being accessed. This uses the default WordPress mapping functionality, added on 4.5.
- *
- * @since 2.0.0
- *
- * @param null|false|\WP_Site $site Site object being searched by path.
- * @param string $domain Domain to search for.
- * @return null|false|\WP_Site
- */
- public function check_domain_mapping($site, $domain) {
+ }
+ /**
+ * Checks if we have a site associated with the domain being accessed
+ *
+ * This method tries to find a site on the network that has a mapping related to the current
+ * domain being accessed. This uses the default WordPress mapping functionality, added on 4.5.
+ *
+ * @since 2.0.0
+ *
+ * @param null|false|\WP_Site $site Site object being searched by path.
+ * @param string $domain Domain to search for.
+ * @return null|false|\WP_Site
+ */
+ public function check_domain_mapping($site, $domain) {
// Have we already matched? (Allows other plugins to match first)
- if (!empty($site)) {
-
+ if ( ! empty($site)) {
return $site;
-
- } // end if;
+ }
$domains = $this->get_www_and_nowww_versions($domain);
$mapping = Domain::get_by_domain($domains);
if (empty($mapping) || is_wp_error($mapping)) {
-
return $site;
-
- } // end if;
+ }
if (has_filter('mercator.use_mapping')) {
-
$deprecated_args = array(
$mapping->is_active(),
$mapping,
- $domain
+ $domain,
);
$is_active = apply_filters_deprecated('mercator.use_mapping', $deprecated_args, '2.0.0', 'wu_use_domain_mapping');
-
- } // end if;
+ }
/**
* Determine whether a mapping should be used
@@ -327,20 +292,16 @@ class Domain_Mapping {
$is_active = apply_filters('wu_use_domain_mapping', $mapping->is_active(), $mapping, $domain);
// Ignore non-active mappings
- if (!$is_active) {
-
+ if ( ! $is_active) {
return $site;
-
- } // end if;
+ }
// Fetch the actual data for the site
$mapped_site = $mapping->get_site();
if (empty($mapped_site)) {
-
return $site;
-
- } // end if;
+ }
/*
* Note: This is only for backwards compatibility with WPMU Domain Mapping,
@@ -352,33 +313,26 @@ class Domain_Mapping {
* Decide if we use SSL
*/
if ($mapping->is_secure()) {
-
force_ssl_admin(true);
-
- } // end if;
+ }
$_site = $site;
if (is_a($mapped_site, '\WP_Site')) {
-
$this->original_url = $mapped_site->domain . $mapped_site->path;
$_site = $mapped_site;
-
} elseif (is_a($mapped_site, '\WP_Ultimo\Models\Site')) {
-
$this->original_url = $mapped_site->get_domain() . $mapped_site->get_path();
$_site = $mapped_site->to_wp_site();
-
- } // end if;
+ }
/*
* We found a site based on the mapped domain =)
*/
return $_site;
-
- } // end check_domain_mapping;
+ }
/**
* Clear mappings for a site when it's deleted
@@ -390,13 +344,10 @@ class Domain_Mapping {
$mappings = Domain::get_by_site($site->blog_id);
if (empty($mappings)) {
-
return;
-
- } // end if;
+ }
foreach ($mappings as $mapping) {
-
$error = $mapping->delete();
if (is_wp_error($error)) {
@@ -405,12 +356,9 @@ class Domain_Mapping {
$message = sprintf(__('Unable to delete mapping %1$d for site %2$d', 'wp-ultimo'), $mapping->get_id(), $site->blog_id);
trigger_error($message, E_USER_WARNING);
-
- } // end if;
-
- } // end foreach;
-
- } // end clear_mappings_on_delete;
+ }
+ }
+ }
/**
* Register filters for URLs, if we've mapped
@@ -422,11 +370,9 @@ class Domain_Mapping {
$current_site = $GLOBALS['current_blog'];
- if (!$current_site) {
-
+ if ( ! $current_site) {
return;
-
- } // end if;
+ }
$real_domain = $current_site->domain;
$domain = $_SERVER['HTTP_HOST'];
@@ -435,18 +381,15 @@ class Domain_Mapping {
// Domain hasn't been mapped
return;
-
- } // end if;
+ }
$domains = $this->get_www_and_nowww_versions($domain);
$mapping = Domain::get_by_domain($domains);
if (empty($mapping) || is_wp_error($mapping)) {
-
return;
-
- } // end if;
+ }
$this->current_mapping = $mapping;
@@ -465,11 +408,9 @@ class Domain_Mapping {
// If on network site, also filter network urls
if (is_main_site()) {
-
add_filter('network_site_url', array($this, 'mangle_url'), -10, 3);
add_filter('network_home_url', array($this, 'mangle_url'), -10, 3);
-
- } // end if;
+ }
add_filter('jetpack_sync_home_url', array($this, 'mangle_url'));
add_filter('jetpack_sync_site_url', array($this, 'mangle_url'));
@@ -491,8 +432,7 @@ class Domain_Mapping {
* @return void
*/
do_action('wu_domain_mapping_register_filters', array($this, 'mangle_url'), $this);
-
- } // end register_mapped_filters;
+ }
/**
* Apply the replace URL to URL filters provided by other plugins.
@@ -504,19 +444,18 @@ class Domain_Mapping {
*/
public static function apply_mapping_to_url($hooks) {
- add_action('wu_domain_mapping_register_filters', function($callback) use ($hooks) {
+ add_action(
+ 'wu_domain_mapping_register_filters',
+ function ($callback) use ($hooks) {
- $hooks = (array) $hooks;
+ $hooks = (array) $hooks;
- foreach ($hooks as $hook) {
-
- add_filter($hook, $callback);
-
- } // end foreach;
-
- });
-
- } // end apply_mapping_to_url;
+ foreach ($hooks as $hook) {
+ add_filter($hook, $callback);
+ }
+ }
+ );
+ }
/**
* Replaces the URL.
@@ -530,10 +469,8 @@ class Domain_Mapping {
public function replace_url($url, $current_mapping = null) {
if ($current_mapping === null) {
-
$current_mapping = $this->current_mapping;
-
- } // end if;
+ }
// Replace the domain
$domain_base = parse_url($url, PHP_URL_HOST);
@@ -545,18 +482,15 @@ class Domain_Mapping {
* Another try if we don't need to deal with subdirectory.
*/
if ($mangled === $url && $this->current_mapping !== $current_mapping) {
-
$domain = rtrim($domain_base, '/');
$regex = '#^(\w+://)' . preg_quote($domain, '#') . '#i';
$mangled = preg_replace($regex, '${1}' . $current_mapping->get_domain(), $url);
-
- } // end if;
+ }
$mangled = wu_replace_scheme($mangled, $current_mapping->is_secure() ? 'https://' : 'http://');
return $mangled;
-
- } // end replace_url;
+ }
/**
* Mangle the home URL to give our primary domain
@@ -570,22 +504,17 @@ class Domain_Mapping {
public function mangle_url($url, $path = '/', $orig_scheme = '', $site_id = 0) {
if (empty($site_id)) {
-
$site_id = get_current_blog_id();
-
- } // end if;
+ }
$current_mapping = $this->current_mapping;
if (empty($current_mapping) || $site_id !== $current_mapping->get_site_id()) {
-
return $url;
-
- } // end if;
+ }
return $this->replace_url($url);
-
- } // end mangle_url;
+ }
/**
* Adds a fix to the srcset URLs when we need that domain mapped
@@ -597,13 +526,9 @@ class Domain_Mapping {
public function fix_srcset($sources) {
foreach ($sources as &$source) {
-
- $sources[$source['value']]['url'] = $this->replace_url($sources[$source['value']]['url']);
-
- } // end foreach;
+ $sources[ $source['value'] ]['url'] = $this->replace_url($sources[ $source['value'] ]['url']);
+ }
return $sources;
-
- } // end fix_srcset;
-
-} // end class Domain_Mapping;
+ }
+}
diff --git a/inc/class-faker.php b/inc/class-faker.php
index 551f81d..e897d67 100644
--- a/inc/class-faker.php
+++ b/inc/class-faker.php
@@ -45,8 +45,7 @@ class Faker {
public function __construct() {
$this->faker = Lib_Faker\Factory::create();
-
- } // end __construct;
+ }
/**
* Get the faker generator.
@@ -57,8 +56,7 @@ class Faker {
private function get_faker() {
return $this->faker;
-
- } // end get_faker;
+ }
/**
* Get the faker generator.
@@ -69,8 +67,7 @@ class Faker {
public function generate() {
return $this->get_faker();
-
- } // end generate;
+ }
/**
* Get the fake data generated.
@@ -82,7 +79,6 @@ class Faker {
public function get_fake_data_generated($model = '') {
if (empty($this->fake_data_generated)) {
-
$this->fake_data_generated = array(
'customers' => array(),
'products' => array(),
@@ -97,25 +93,18 @@ class Faker {
'payments' => array(),
'sites' => array(),
);
-
- } // end if;
+ }
if (empty($model)) {
-
return $this->fake_data_generated;
+ }
- } // end if;
-
- if (isset($this->fake_data_generated[$model])) {
-
- return $this->fake_data_generated[$model];
-
+ if (isset($this->fake_data_generated[ $model ])) {
+ return $this->fake_data_generated[ $model ];
} else {
-
return array();
-
- } // end if;
- } // end get_fake_data_generated;
+ }
+ }
/**
* Set the fake data generated.
@@ -128,9 +117,8 @@ class Faker {
$this->get_fake_data_generated();
- $this->fake_data_generated[$model][] = $value;
-
- } // end set_fake_data_generated;
+ $this->fake_data_generated[ $model ][] = $value;
+ }
/**
* Get the option "debug_faker" with the data generated by faker.
@@ -140,22 +128,24 @@ class Faker {
*/
public function get_option_debug_faker() {
- return wu_get_option('debug_faker', array(
- 'customers' => array(),
- 'products' => array(),
- 'memberships' => array(),
- 'domains' => array(),
- 'events' => array(),
- 'discount_codes' => array(),
- 'checkout_forms' => array(),
- 'emails' => array(),
- 'broadcasts' => array(),
- 'webhooks' => array(),
- 'payments' => array(),
- 'sites' => array(),
- ));
-
- } // end get_option_debug_faker;
+ return wu_get_option(
+ 'debug_faker',
+ array(
+ 'customers' => array(),
+ 'products' => array(),
+ 'memberships' => array(),
+ 'domains' => array(),
+ 'events' => array(),
+ 'discount_codes' => array(),
+ 'checkout_forms' => array(),
+ 'emails' => array(),
+ 'broadcasts' => array(),
+ 'webhooks' => array(),
+ 'payments' => array(),
+ 'sites' => array(),
+ )
+ );
+ }
/**
* Get random data.
@@ -167,42 +157,31 @@ class Faker {
private function get_random_data($model) {
if ($model) {
-
$faker = $this->get_faker();
$data_saved = wu_get_isset($this->get_option_debug_faker(), $model, array());
$data_in_memory = $this->get_fake_data_generated($model);
- if (!empty($data_saved) && !empty($data_in_memory)) {
-
+ if ( ! empty($data_saved) && ! empty($data_in_memory)) {
$data_saved_or_in_memory = $faker->randomElement(array('data_saved', 'data_in_memory'));
$data_index = $faker->numberBetween(0, count(${$data_saved_or_in_memory}) - 1);
- return ${$data_saved_or_in_memory}[$data_index];
-
- } elseif (!empty($data_saved)) {
-
+ return ${$data_saved_or_in_memory}[ $data_index ];
+ } elseif ( ! empty($data_saved)) {
$data_index = $faker->numberBetween(0, count($data_saved) - 1);
- return $data_saved[$data_index];
-
- } elseif (!empty($data_in_memory)) {
-
+ return $data_saved[ $data_index ];
+ } elseif ( ! empty($data_in_memory)) {
$data_index = $faker->numberBetween(0, count($data_in_memory) - 1);
- return $data_in_memory[$data_index];
-
+ return $data_in_memory[ $data_index ];
} else {
-
return false;
-
- } // end if;
-
- } // end if;
-
- } // end get_random_data;
+ }
+ }
+ }
/**
* Get random customer.
@@ -217,32 +196,22 @@ class Faker {
$customer = $this->get_random_data('customers');
- if (!$customer) {
-
+ if ( ! $customer) {
if ($create_if_not_exist) {
-
$this->generate_fake_customers();
$customer = $this->get_random_data('customers');
-
} else {
-
return false;
-
- } // end if;
-
- } // end if;
+ }
+ }
if (is_object($customer)) {
-
return $customer;
-
} else {
-
return wu_get_customer($customer);
-
- } // end if;
- } // end get_random_customer;
+ }
+ }
/**
* Get random product.
@@ -257,33 +226,22 @@ class Faker {
$product = $this->get_random_data('products');
- if (!$product) {
-
+ if ( ! $product) {
if ($create_if_not_exist) {
-
$this->generate_fake_products();
$product = $this->get_random_data('products');
-
} else {
-
return false;
-
- } // end if;
-
- } // end if;
+ }
+ }
if (is_object($product)) {
-
return $product;
-
} else {
-
return wu_get_product($product);
-
- } // end if;
-
- } // end get_random_product;
+ }
+ }
/**
* Get random membership.
@@ -297,23 +255,16 @@ class Faker {
$membership = $this->get_random_data('memberships');
- if (!$membership) {
-
+ if ( ! $membership) {
return false;
-
- } // end if;
+ }
if (is_object($membership)) {
-
return $membership;
-
} else {
-
return wu_get_membership($membership);
-
- } // end if;
-
- } // end get_random_membership;
+ }
+ }
/**
* Get random site.
@@ -327,23 +278,16 @@ class Faker {
$site = $this->get_random_data('sites');
- if (!$site) {
-
+ if ( ! $site) {
return false;
-
- } // end if;
+ }
if (is_object($site)) {
-
return $site;
-
} else {
-
return wu_get_site($site);
-
- } // end if;
-
- } // end get_random_site;
+ }
+ }
/**
* Get random payment.
@@ -357,23 +301,16 @@ class Faker {
$payment = $this->get_random_data('payments');
- if (!$payment) {
-
+ if ( ! $payment) {
return false;
-
- } // end if;
+ }
if (is_object($payment)) {
-
return $payment;
-
} else {
-
return wu_get_payment($payment);
-
- } // end if;
-
- } // end get_random_payment;
+ }
+ }
/**
* Generate a faker customer.
@@ -385,47 +322,42 @@ class Faker {
public function generate_fake_customers($number = 1) {
for ($i = 0; $i < $number; $i++) {
-
$user_name = $this->get_faker()->userName;
$user_email = $this->get_faker()->safeEmail;
- if (!username_exists($user_name) && !email_exists($user_email)) {
-
- $password = wp_generate_password( 12, false );
+ if ( ! username_exists($user_name) && ! email_exists($user_email)) {
+ $password = wp_generate_password(12, false);
$user_id = wp_create_user($user_name, $password, $user_email);
remove_user_from_blog($user_id);
- $customer = wu_create_customer(array(
- 'user_id' => $user_id,
- 'vip' => $this->get_faker()->boolean,
- 'date_registered' => $this->get_faker()->dateTimeThisYear()->format('Y-m-d H:i:s'),
- 'email_verification' => $this->get_faker()->randomElement(array(
- 'none',
- 'pending',
- 'verified'
- )),
- 'meta' => array(
- 'ip_country' => $this->get_faker()->countryCode,
- ),
- ));
+ $customer = wu_create_customer(
+ array(
+ 'user_id' => $user_id,
+ 'vip' => $this->get_faker()->boolean,
+ 'date_registered' => $this->get_faker()->dateTimeThisYear()->format('Y-m-d H:i:s'),
+ 'email_verification' => $this->get_faker()->randomElement(
+ array(
+ 'none',
+ 'pending',
+ 'verified',
+ )
+ ),
+ 'meta' => array(
+ 'ip_country' => $this->get_faker()->countryCode,
+ ),
+ )
+ );
if (is_wp_error($customer)) {
-
throw new \Exception($customer->get_error_message());
-
} else {
-
$this->set_fake_data_generated('customers', $customer);
-
- } // end if;
-
- } // end if;
-
- } // end for;
-
- } // end generate_fake_customers;
+ }
+ }
+ }
+ }
/**
* Generate a faker product.
@@ -440,22 +372,21 @@ class Faker {
$product_type_options = array(
'plan',
'package',
- 'service'
+ 'service',
);
$pricing_type_options = array(
'paid',
'free',
- 'contact_us'
+ 'contact_us',
);
$duration_unit_options = array(
'day',
'week',
'month',
- 'year'
+ 'year',
);
for ($i = 0; $i < $number; $i++) {
-
$product_data = array();
$type = $faker->optional(0.5, $product_type_options[0])->randomElement($product_type_options);
@@ -480,18 +411,12 @@ class Faker {
$product = wu_create_product($product_data);
if (is_wp_error($product)) {
-
throw new \Exception($product->get_error_message());
-
} else {
-
$this->set_fake_data_generated('products', $product);
-
- } // end if;
-
- } // end for;
-
- } // end generate_fake_products;
+ }
+ }
+ }
/**
* Generate a faker membership.
@@ -505,7 +430,6 @@ class Faker {
$faker = $this->get_faker();
for ($i = 0; $i < $number; $i++) {
-
$customer = $this->get_random_customer(true);
$product = $this->get_random_product(true);
@@ -514,7 +438,7 @@ class Faker {
'active',
'on-hold',
'expired',
- 'cancelled'
+ 'cancelled',
);
$membership_data = array();
@@ -536,18 +460,12 @@ class Faker {
$membership = wu_create_membership($membership_data);
if (is_wp_error($membership)) {
-
throw new \Exception($membership->get_error_message());
-
} else {
-
$this->set_fake_data_generated('memberships', $membership);
-
- } // end if;
-
- } // end for;
-
- } // end generate_fake_memberships;
+ }
+ }
+ }
/**
* Generate a fake domain.
@@ -562,7 +480,7 @@ class Faker {
$stage_options = array(
'checking-dns',
'checking-ssl-cert',
- 'done'
+ 'done',
);
$stage_checking_dns = $stage_options[0];
@@ -570,31 +488,26 @@ class Faker {
$stage = $faker->optional(0.35, $stage_checking_dns)->randomElement($stage_options);
for ($i = 0; $i < $number; $i++) {
-
$site = $this->get_random_site();
- $domain = wu_create_domain(array(
- 'domain' => $faker->domainName, // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
+ $domain = wu_create_domain(
+ array(
+ 'domain' => $faker->domainName, // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
'stage' => $stage,
'blog_id' => $site ? $site->get_blog_id() : 0,
'primary_domain' => $faker->boolean(25),
'active' => $faker->boolean(75),
- 'secure' => $faker->boolean(25)
- ));
+ 'secure' => $faker->boolean(25),
+ )
+ );
if (is_wp_error($domain)) {
-
throw new \Exception($domain->get_error_message());
-
} else {
-
$this->set_fake_data_generated('domains', $domain);
-
- } // end if;
-
- } // end for;
-
- } // end generate_fake_domain;
+ }
+ }
+ }
/**
* Generate a fake event.
@@ -619,7 +532,6 @@ class Faker {
);
for ($i = 0; $i < $number; $i++) {
-
$membership = $this->get_random_membership(true);
$author_id = $membership->get_id();
@@ -638,18 +550,12 @@ class Faker {
$event_data = wu_create_event($event_data);
if (is_wp_error($event_data)) {
-
throw new \Exception($event_data->get_error_message());
-
} else {
-
$this->set_fake_data_generated('events', $event_data);
-
- } // end if;
-
- } // end for;
-
- } // end generate_fake_events;
+ }
+ }
+ }
/**
* Generate a fake discount code.
@@ -668,7 +574,6 @@ class Faker {
$type_options_percentage = $type_options[0];
for ($i = 0; $i < $number; $i++) {
-
$name = rtrim((string) $faker->sentence(2), '.');
$value = $faker->numberBetween(1, 25);
$code = strtoupper(substr(implode('', explode(' ', $name)), 0, 15)) . $value . 'OFF';
@@ -677,33 +582,29 @@ class Faker {
$start_date = $faker->dateTimeBetween('-1 weeks', 'now', 'UTC');
$expiration_date = $faker->dateTimeBetween('now', '+4 weeks', 'UTC');
- $discount_code = wu_create_discount_code(array(
- 'name' => $name,
- 'description' => $faker->sentence(),
- 'code' => $code,
- 'max_uses' => $faker->numberBetween(1, 50),
- 'type' => $type,
- 'value' => $value,
- 'setup_fee_type' => $setup_fee_type,
- 'setup_fee_value' => $faker->numberBetween(1, 20),
- 'date_start' => $start_date->format('Y-m-d H:i:s'),
- 'date_expiration' => $expiration_date->format('Y-m-d H:i:s'),
- 'active' => true
- ));
+ $discount_code = wu_create_discount_code(
+ array(
+ 'name' => $name,
+ 'description' => $faker->sentence(),
+ 'code' => $code,
+ 'max_uses' => $faker->numberBetween(1, 50),
+ 'type' => $type,
+ 'value' => $value,
+ 'setup_fee_type' => $setup_fee_type,
+ 'setup_fee_value' => $faker->numberBetween(1, 20),
+ 'date_start' => $start_date->format('Y-m-d H:i:s'),
+ 'date_expiration' => $expiration_date->format('Y-m-d H:i:s'),
+ 'active' => true,
+ )
+ );
if (is_wp_error($discount_code)) {
-
throw new \Exception($discount_code->get_error_message());
-
} else {
-
$this->set_fake_data_generated('discount_codes', $discount_code);
-
- } // end if;
-
- } // end for;
-
- } // end generate_fake_discount_code;
+ }
+ }
+ }
/**
* Generate a fake checkout form.
@@ -720,7 +621,6 @@ class Faker {
$checkout_form_slug = str_replace(' ', '-', $checkout_form_name);
for ($i = 0; $i < $number; $i++) {
-
$checkout_form_data = array(
'name' => $checkout_form_name,
'slug' => strtolower($checkout_form_slug),
@@ -735,18 +635,12 @@ class Faker {
$checkout_form = wu_create_checkout_form($checkout_form_data);
if (is_wp_error($checkout_form)) {
-
throw new \Exception($checkout_form->get_error_message());
-
} else {
-
$this->set_fake_data_generated('checkout_forms', $checkout_form);
-
- } // end if;
-
- } // end for;
-
- } // end generate_fake_checkout_form;
+ }
+ }
+ }
/**
* Generate a fake email.
@@ -770,7 +664,6 @@ class Faker {
);
for ($i = 0; $i < $number; $i++) {
-
$email_title = rtrim((string) $faker->sentence(2), '.');
$email_slug = strtolower(str_replace(' ', '-', $email_title));
$user_name = $this->get_faker()->userName;
@@ -798,18 +691,12 @@ class Faker {
$email = wu_create_email($email_data);
if (is_wp_error($email)) {
-
throw new \Exception($email->get_error_message());
-
} else {
-
$this->set_fake_data_generated('emails', $email);
-
- } // end if;
-
- } // end for;
-
- } // end generate_fake_email;
+ }
+ }
+ }
/**
* Generate a fake broadcast.
@@ -835,7 +722,6 @@ class Faker {
);
for ($i = 0; $i < $number; $i++) {
-
$broadcast_data = array(
'notice_type' => $faker->randomElement($notice_type_optinos),
'status' => 'publish',
@@ -848,18 +734,12 @@ class Faker {
$broadcast = wu_create_broadcast($broadcast_data);
if (is_wp_error($broadcast)) {
-
throw new \Exception($broadcast->get_error_message());
-
} else {
-
$this->set_fake_data_generated('broadcasts', $broadcast);
-
- } // end if;
-
- } // end for;
-
- } // end generate_fake_broadcast;
+ }
+ }
+ }
/**
* Generate a fake webhook.
@@ -883,7 +763,6 @@ class Faker {
);
for ($i = 0; $i < $number; $i++) {
-
$webhook_data = array(
'name' => rtrim((string) $faker->sentence(2), '.'),
'webhook_url' => 'https://' . $faker->domainName,
@@ -892,24 +771,18 @@ class Faker {
'active' => $faker->boolean(75),
'hidden' => 0,
'integration' => rtrim((string) $faker->sentence(3), '.'),
- 'date_last_failed' => ''
+ 'date_last_failed' => '',
);
$webhook = wu_create_webhook($webhook_data);
if (is_wp_error($webhook)) {
-
throw new \Exception($webhook->get_error_message());
-
} else {
-
$this->set_fake_data_generated('webhooks', $webhook);
-
- } // end if;
-
- } // end for;
-
- } // end generate_fake_webhook;
+ }
+ }
+ }
/**
* Generate a fake payment.
@@ -940,7 +813,6 @@ class Faker {
$memberships = $this->get_fake_data_generated('memberships');
for ($i = 0; $i < $number; $i++) {
-
$membership = $this->get_random_membership();
$payment_data = array(
@@ -967,20 +839,14 @@ class Faker {
$payment = wu_create_payment($payment_data);
if (is_wp_error($payment)) {
-
throw new \Exception($payment->get_error_message());
-
} else {
-
$payment->recalculate_totals()->save();
$this->set_fake_data_generated('payments', $payment);
-
- } // end if;
-
- } // end for;
-
- } // end generate_fake_payment;
+ }
+ }
+ }
/**
* Generate a faker site.
@@ -1015,31 +881,21 @@ class Faker {
$site_data['public'] = $faker->boolean(75);
if ($type_customer_owned === $type) {
-
$membership = $this->get_random_membership();
if ($membership) {
-
$site_data['customer_id'] = $membership->get_customer_id();
$site_data['membership_id'] = $membership->get_id();
-
- } // end if;
- } // end if;
+ }
+ }
$site = wu_create_site($site_data);
if (is_wp_error($site)) {
-
throw new \Exception($site->get_error_message());
-
} else {
-
$this->set_fake_data_generated('sites', $site);
-
- } // end if;
-
- } // end for;
-
- } // end generate_fake_site;
-
-} // end class Faker;
+ }
+ }
+ }
+}
diff --git a/inc/class-geolocation.php b/inc/class-geolocation.php
index 90aa597..a08df71 100644
--- a/inc/class-geolocation.php
+++ b/inc/class-geolocation.php
@@ -68,7 +68,7 @@ class Geolocation {
*/
private static function supports_geolite2(): bool {
return false; // version_compare( PHP_VERSION, '5.4.0', '>=' );
- } // end supports_geolite2;
+ }
/**
* Check if geolocation is enabled.
*
@@ -77,7 +77,7 @@ class Geolocation {
*/
private static function is_geolocation_enabled($current_settings ): bool {
return in_array( $current_settings, array( 'geolocation', 'geolocation_ajax' ), true );
- } // end is_geolocation_enabled;
+ }
/**
@@ -90,10 +90,10 @@ class Geolocation {
public static function disable_geolocation_on_legacy_php($default_customer_address ) {
if ( self::is_geolocation_enabled( $default_customer_address ) ) {
$default_customer_address = 'base';
- } // end if;
+ }
return $default_customer_address;
- } // end disable_geolocation_on_legacy_php;
+ }
/**
@@ -104,14 +104,14 @@ class Geolocation {
// Only download the database from MaxMind if the geolocation function is enabled, or a plugin specifically requests it.
if ( self::is_geolocation_enabled( get_option( 'wu_default_customer_address' ) ) || apply_filters( 'wu_geolocation_update_database_periodically', false ) ) {
add_action( 'wu_geoip_updater', array( __CLASS__, 'update_database' ) );
- } // end if;
+ }
// Trigger database update when settings are changed to enable geolocation.
add_filter( 'pre_update_option_wu_default_customer_address', array( __CLASS__, 'maybe_update_database' ), 10, 2 );
} else {
add_filter( 'pre_option_wu_default_customer_address', array( __CLASS__, 'disable_geolocation_on_legacy_php' ) );
- } // end if;
- } // end init;
+ }
+ }
/**
@@ -124,10 +124,10 @@ class Geolocation {
public static function maybe_update_database($new_value, $old_value ) {
if ( $new_value !== $old_value && self::is_geolocation_enabled( $new_value ) ) {
self::update_database();
- } // end if;
+ }
return $new_value;
- } // end maybe_update_database;
+ }
/**
* Get current user IP Address.
@@ -143,9 +143,9 @@ class Geolocation {
return (string) rest_is_ip_address( trim( (string) current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) ); // WPCS: input var ok, CSRF ok.
} elseif ( isset( $_SERVER['REMOTE_ADDR'] ) ) { // @codingStandardsIgnoreLine
return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ); // @codingStandardsIgnoreLine
- } // end if;
+ }
return '';
- } // end get_ip_address;
+ }
/**
@@ -161,7 +161,7 @@ class Geolocation {
if ( '' !== self::get_ip_address() ) {
$transient_name = 'external_ip_address_' . self::get_ip_address();
$external_ip_address = get_transient( $transient_name );
- } // end if;
+ }
if ( false === $external_ip_address ) {
$external_ip_address = '0.0.0.0';
@@ -176,14 +176,14 @@ class Geolocation {
if ( !is_wp_error( $response ) && rest_is_ip_address( $response['body'] ) ) {
$external_ip_address = apply_filters( 'wu_geolocation_ip_lookup_api_response', ( $response['body'] ), $service_name );
break;
- } // end if;
- } // end foreach;
+ }
+ }
set_transient( $transient_name, $external_ip_address, WEEK_IN_SECONDS );
- } // end if;
+ }
return $external_ip_address;
- } // end get_external_ip_address;
+ }
/**
@@ -218,21 +218,21 @@ class Geolocation {
$country_code = self::geolocate_via_api( $ip_address );
} else {
$country_code = '';
- } // end if;
+ }
if ( !$country_code && $fallback ) {
// May be a local environment - find external IP.
return self::geolocate_ip( self::get_external_ip_address(), false, $api_fallback );
- } // end if;
- } // end if;
- } // end if;
+ }
+ }
+ }
return array(
'ip' => $ip_address,
'country' => $country_code,
'state' => '',
);
- } // end geolocate_ip;
+ }
/**
@@ -243,7 +243,7 @@ class Geolocation {
*/
public static function get_local_database_path($deprecated = '2' ) {
return apply_filters( 'wu_geolocation_local_database_path', WP_CONTENT_DIR . '/uploads/GeoLite2-Country.mmdb', $deprecated );
- } // end get_local_database_path;
+ }
/**
@@ -257,7 +257,7 @@ class Geolocation {
if ( !self::supports_geolite2() ) {
$logger->notice( 'Requires PHP 5.4 to be able to download MaxMind GeoLite2 database', array( 'source' => 'geolocation' ) );
return;
- } // end if;
+ }
require_once ABSPATH . 'wp-admin/includes/file.php';
@@ -288,7 +288,7 @@ class Geolocation {
// Reschedule download of DB.
wp_clear_scheduled_hook( 'wu_geoip_updater' );
wp_schedule_event( strtotime( 'first tuesday of next month' ), 'monthly', 'wu_geoip_updater' );
- } // end try;
+ }
// Delete temp file regardless of success.
$wp_filesystem->delete( $tmp_database_path );
} else {
@@ -296,8 +296,8 @@ class Geolocation {
'Unable to download GeoIP Database: ' . $tmp_database_path->get_error_message(),
array( 'source' => 'geolocation' )
);
- } // end if;
- } // end update_database;
+ }
+ }
/**
@@ -310,12 +310,12 @@ class Geolocation {
private static function geolocate_via_db($ip_address, $database ) {
if ( !class_exists( 'WC_Geolite_Integration', false ) ) {
require_once WC_ABSPATH . 'includes/class-wc-geolite-integration.php';
- } // end if;
+ }
$geolite = new WC_Geolite_Integration( $database );
return $geolite->get_country_iso( $ip_address );
- } // end geolocate_via_db;
+ }
/**
@@ -338,7 +338,7 @@ class Geolocation {
if ( empty( $geoip_services ) ) {
return '';
- } // end if;
+ }
$geoip_services_keys = array_keys( $geoip_services );
@@ -361,21 +361,21 @@ class Geolocation {
default:
$country_code = apply_filters( 'wu_geolocation_geoip_response_' . $service_name, '', $response['body'] );
break;
- } // end switch;
+ }
$country_code = sanitize_text_field( strtoupper( (string) $country_code ) );
if ( $country_code ) {
break;
- } // end if;
- } // end if;
- } // end foreach;
+ }
+ }
+ }
set_transient( 'geoip_' . $ip_address, $country_code, WEEK_IN_SECONDS );
- } // end if;
+ }
return $country_code;
- } // end geolocate_via_api;
+ }
-} // end class Geolocation;
+}
diff --git a/inc/class-helper.php b/inc/class-helper.php
index a9995b7..de86a16 100644
--- a/inc/class-helper.php
+++ b/inc/class-helper.php
@@ -33,8 +33,7 @@ class Helper {
_deprecated_function(__METHOD__, '2.0.11', 'wu_path');
return wu_path($dir);
-
- } // end path;
+ }
/**
* Returns the URL to the plugin folder.
@@ -48,8 +47,7 @@ class Helper {
_deprecated_function(__METHOD__, '2.0.11', 'wu_url');
return wu_url($dir);
-
- } // end url;
+ }
/**
* Shorthand for url('assets/img'). Returns the URL for assets inside the assets folder.
@@ -65,8 +63,7 @@ class Helper {
_deprecated_function(__METHOD__, '2.0.11', 'wu_get_asset');
return wu_get_asset($asset, $assets_dir, $base_dir);
-
- } // end get_asset;
+ }
/**
* Renders a view file from the view folder.
@@ -82,8 +79,7 @@ class Helper {
_deprecated_function(__METHOD__, '2.0.11', 'wu_get_template');
wu_get_template($view, $vars, $default_view);
-
- } // end render;
+ }
/**
* This function return 'slugfied' options terms to be used as options ids.
@@ -99,8 +95,7 @@ class Helper {
_deprecated_function(__METHOD__, '2.0.11', 'wu_slugify');
return wu_slugify($term);
-
- } // end slugfy;
+ }
/**
* Get the value of a slugified network option
@@ -115,8 +110,7 @@ class Helper {
_deprecated_function(__METHOD__, '2.0.11', 'wu_get_option');
return wu_get_option($option_name, $default);
-
- } // end get_option;
+ }
/**
* Save slugified network option.
@@ -131,8 +125,7 @@ class Helper {
_deprecated_function(__METHOD__, '2.0.11', 'wu_save_option');
return wu_save_option($option_name, $value);
-
- } // end save_option;
+ }
/**
* Delete slugified network option
@@ -146,8 +139,7 @@ class Helper {
_deprecated_function(__METHOD__, '2.0.11', 'wu_delete_option');
return wu_delete_option($option_name);
-
- } // end delete_option;
+ }
/**
* Gets the URL for the folders created with maybe_create_folder().
@@ -163,8 +155,7 @@ class Helper {
_deprecated_function(__METHOD__, '2.0.11', 'wu_get_folder_url');
return wu_get_folder_url($folder);
-
- } // end get_folder_url;
+ }
/**
* Creates a WP Multisite WaaS folder inside the uploads folder. Returns the path to the folder.
@@ -180,8 +171,7 @@ class Helper {
_deprecated_function(__METHOD__, '2.0.11', 'wu_maybe_create_folder');
return wu_maybe_create_folder($folder);
-
- } // end maybe_create_folder;
+ }
/**
* Drop our custom tables.
@@ -196,7 +186,5 @@ class Helper {
_deprecated_function(__METHOD__, '2.0.11', 'wu_drop_tables');
wu_drop_tables();
-
- } // end drop_tables;
-
-} // end class Helper;
+ }
+}
diff --git a/inc/class-hooks.php b/inc/class-hooks.php
index d6f67b5..5f56eb5 100644
--- a/inc/class-hooks.php
+++ b/inc/class-hooks.php
@@ -22,7 +22,7 @@ class Hooks {
/**
* Static-only class.
*/
- private function __construct() {} // end __construct;
+ private function __construct() {}
/**
* Register the activation and deactivation hooks
@@ -46,8 +46,7 @@ class Hooks {
* Runs the activation hook.
*/
add_action('plugins_loaded', array('WP_Ultimo\Hooks', 'on_activation_do'), 1);
-
- } // end init;
+ }
/**
* Runs when WP Multisite WaaS is activated
@@ -63,8 +62,7 @@ class Hooks {
* Set the activation flag
*/
update_network_option(null, 'wu_activation', 'yes');
-
- } // end on_activation;
+ }
/**
* Runs whenever the activation flag is set.
@@ -91,10 +89,8 @@ class Hooks {
* @return void
*/
do_action('wu_activation');
-
- } // end if;
-
- } // end on_activation_do;
+ }
+ }
/**
* Runs when WP Multisite WaaS is deactivated
@@ -118,7 +114,5 @@ class Hooks {
* @return void
*/
do_action('wu_deactivation');
-
- } // end on_deactivation;
-
-} // end class Hooks;
+ }
+}
diff --git a/inc/class-license.php b/inc/class-license.php
index 6af00da..45d5c01 100644
--- a/inc/class-license.php
+++ b/inc/class-license.php
@@ -10,8 +10,7 @@ class License {
*
* @return null
*/
- public function get_license_key()
- {
+ public function get_license_key() {
return null;
}
-}
\ No newline at end of file
+}
diff --git a/inc/class-light-ajax.php b/inc/class-light-ajax.php
index 9be94fc..025afe5 100644
--- a/inc/class-light-ajax.php
+++ b/inc/class-light-ajax.php
@@ -32,16 +32,13 @@ class Light_Ajax {
public function __construct() {
if (isset($_REQUEST['wu-ajax'])) {
-
$action = $this->get_when_to_run();
wu_x_header("X-Ultimo-Ajax-When: $action");
add_action($action, array($this, 'process_light_ajax'), 20);
-
- } // end if;
-
- } // end __construct;
+ }
+ }
/**
* Actions that can ignore the referer check.
@@ -51,25 +48,27 @@ class Light_Ajax {
*/
protected function should_skip_referer_check(): bool {
- $allowed_actions = apply_filters('wu_light_ajax_should_skip_referer_check', array(
+ $allowed_actions = apply_filters(
+ 'wu_light_ajax_should_skip_referer_check',
+ array(
- /**
- * Checkout Form Actions
- *
- * They're here because in some cases,
- * the caching settings might prevent nonces from
- * being properly refreshed, which could cause 403
- * errors with the actions below.
- */
- 'wu_render_field_template',
- 'wu_create_order',
- 'wu_validate_form',
+ /**
+ * Checkout Form Actions
+ *
+ * They're here because in some cases,
+ * the caching settings might prevent nonces from
+ * being properly refreshed, which could cause 403
+ * errors with the actions below.
+ */
+ 'wu_render_field_template',
+ 'wu_create_order',
+ 'wu_validate_form',
- ));
+ )
+ );
return in_array(wu_request('action', 'no-action'), $allowed_actions, true);
-
- } // end should_skip_referer_check;
+ }
/**
* Gets the hook we should use to attach the light ajax runner to.
@@ -92,18 +91,20 @@ class Light_Ajax {
* @since 2.0.0
* @return array The hook list.
*/
- $allowed_list = apply_filters('wu_light_ajax_allowed_hooks', array(
- 'plugins_loaded',
- 'setup_theme',
- 'after_setup_theme',
- 'init',
- ));
+ $allowed_list = apply_filters(
+ 'wu_light_ajax_allowed_hooks',
+ array(
+ 'plugins_loaded',
+ 'setup_theme',
+ 'after_setup_theme',
+ 'init',
+ )
+ );
$action = isset($_REQUEST['wu-when']) ? base64_decode((string) $_REQUEST['wu-when']) : 'plugins_loaded';
return in_array($action, $allowed_list, true) ? $action : 'plugins_loaded';
-
- } // end get_when_to_run;
+ }
/**
* Adds an wu_ajax handler.
@@ -138,12 +139,10 @@ class Light_Ajax {
header('X-Robots-Tag: noindex');
if (empty($_REQUEST['action'])) {
-
status_header(400);
die('0');
-
- } // end if;
+ }
send_nosniff_header();
@@ -155,17 +154,11 @@ class Light_Ajax {
$action = esc_attr(trim((string) $_REQUEST['action']));
if (is_user_logged_in()) {
-
do_action('wu_ajax_' . $action); // phpcs:ignore
-
} else {
-
do_action('wu_ajax_nopriv_' . $action); // phpcs:ignore
-
- } // end if;
+ }
die('1');
-
- } // end process_light_ajax;
-
-} // end class Light_Ajax;
+ }
+}
diff --git a/inc/class-logger.php b/inc/class-logger.php
index 04180c6..8cf07d0 100644
--- a/inc/class-logger.php
+++ b/inc/class-logger.php
@@ -42,8 +42,7 @@ class Logger extends AbstractLogger {
public static function get_logs_folder() {
return wu_maybe_create_folder('wu-logs');
-
- } // end get_logs_folder;
+ }
/**
* Add a log entry to chosen file.
@@ -57,10 +56,8 @@ class Logger extends AbstractLogger {
$allowed_log_level = wu_get_setting('error_logging_level', 'default');
if ($allowed_log_level === 'disabled') {
-
return;
-
- } // end if;
+ }
if ($allowed_log_level === 'default') {
/**
@@ -91,42 +88,30 @@ class Logger extends AbstractLogger {
$current_log_levels = array();
foreach ($psr_log_levels as $php_level => $psr_level) {
-
if ($reporting_level & $php_level) {
-
$current_log_levels[] = $psr_level;
+ }
+ }
- } // end if;
-
- } // end foreach;
-
- if (!in_array($log_level, $current_log_levels, true) && ($reporting_level & ~E_ALL)) {
-
+ if ( ! in_array($log_level, $current_log_levels, true) && ($reporting_level & ~E_ALL)) {
return;
-
- } // end if;
-
+ }
} elseif ($allowed_log_level === 'errors' && $log_level !== LogLevel::ERROR && $log_level !== LogLevel::CRITICAL) {
-
return;
-
- } // end if;
+ }
$instance = self::get_instance();
$instance->set_log_file(self::get_logs_folder() . "/$handle.log");
if (is_wp_error($message)) {
-
$message = $message->get_error_message();
-
- } // end if;
+ }
$instance->log($log_level, $message);
do_action('wu_log_add', $handle, $message);
-
- } // end add;
+ }
/**
* Get the log contents
@@ -141,11 +126,9 @@ class Logger extends AbstractLogger {
$file = self::get_logs_folder() . "/$handle.log";
- if (!file_exists($file)) {
-
+ if ( ! file_exists($file)) {
return array();
-
- } // end if;
+ }
// read file
$content = file_get_contents($file);
@@ -155,15 +138,12 @@ class Logger extends AbstractLogger {
// remove last line if empty
if (empty(end($arr_content))) {
-
array_pop($arr_content);
-
- } // end if;
+ }
// return last lines
return array_slice($arr_content, -$lines);
-
- } // end read_lines;
+ }
/**
* Clear entries from chosen file.
@@ -176,14 +156,11 @@ class Logger extends AbstractLogger {
// Delete the file if it exists.
if (file_exists($file)) {
-
@unlink($file); // phpcs:ignore
-
- } // end if;
+ }
do_action('wu_log_clear', $handle);
-
- } // end clear;
+ }
/**
* Takes a callable as a parameter and logs how much time it took to execute it.
@@ -209,8 +186,7 @@ class Logger extends AbstractLogger {
self::add($handle, $message);
return $return;
-
- } // end track_time;
+ }
/**
* Set the log file path.
@@ -222,8 +198,7 @@ class Logger extends AbstractLogger {
public function set_log_file($log_file) {
$this->log_file = $log_file;
-
- } // end set_log_file;
+ }
/**
* Logs with an arbitrary level.
@@ -238,17 +213,14 @@ class Logger extends AbstractLogger {
*/
public function log($level, $message, array $context = array()) {
- if (!$this->is_valid_log_level($level) ) {
-
+ if ( ! $this->is_valid_log_level($level) ) {
return;
-
- } // end if;
+ }
$formatted_message = $this->format_message($level, $message, $context);
$this->write_to_file($formatted_message);
-
- } // end log;
+ }
/**
* Check if the log level is valid.
@@ -271,8 +243,7 @@ class Logger extends AbstractLogger {
);
return in_array($level, $valid_log_levels, true);
-
- } // end is_valid_log_level;
+ }
/**
* Format the message to be logged.
@@ -296,8 +267,7 @@ class Logger extends AbstractLogger {
);
return $formatted_message;
-
- } // end format_message;
+ }
/**
* Write the message to the log file.
@@ -309,20 +279,14 @@ class Logger extends AbstractLogger {
*/
protected function write_to_file($message) {
- if (!file_exists($this->log_file)) {
-
+ if ( ! file_exists($this->log_file)) {
touch($this->log_file);
+ }
- } // end if;
-
- if (!is_writable($this->log_file)) {
-
+ if ( ! is_writable($this->log_file)) {
return;
-
- } // end if;
+ }
file_put_contents($this->log_file, $message, FILE_APPEND | LOCK_EX);
-
- } // end write_to_file;
-
-} // end class Logger;
+ }
+}
diff --git a/inc/class-maintenance-mode.php b/inc/class-maintenance-mode.php
index 2632d87..9c464a6 100644
--- a/inc/class-maintenance-mode.php
+++ b/inc/class-maintenance-mode.php
@@ -33,12 +33,9 @@ class Maintenance_Mode {
add_action('wp_ultimo_load', array($this, 'add_settings'));
if (wu_get_setting('maintenance_mode')) {
-
$this->hooks();
-
- } // end if;
-
- } // end init;
+ }
+ }
/**
* Adds the additional hooks, when necessary.
@@ -50,35 +47,25 @@ class Maintenance_Mode {
add_action('wu_ajax_toggle_maintenance_mode', array($this, 'toggle_maintenance_mode'));
- if (!is_main_site()) {
-
+ if ( ! is_main_site()) {
add_action('admin_bar_menu', array($this, 'add_notice_to_admin_bar'), 15);
-
- } // end if;
+ }
if (self::check_maintenance_mode()) {
-
add_filter('pre_option_blog_public', '__return_true');
- if (!is_admin()) {
-
+ if ( ! is_admin()) {
add_action('wp', array($this, 'render_page'));
if (function_exists('wp_robots_no_robots')) {
-
add_filter('wp_robots', 'wp_robots_no_robots'); // WordPress 5.7+
} else {
-
add_action('wp_head', 'wp_no_robots', 20);
-
- } // end if;
-
- } // end if;
-
- } // end if;
-
- } // end hooks;
+ }
+ }
+ }
+ }
/**
* Add maintenance mode Notice to Admin Bar
@@ -89,14 +76,11 @@ class Maintenance_Mode {
*/
public function add_notice_to_admin_bar($wp_admin_bar) {
- if (!current_user_can('manage_options')) {
-
+ if ( ! current_user_can('manage_options')) {
return;
-
- } // end if;
+ }
if (is_admin() || self::check_maintenance_mode()) {
-
$args = array(
'id' => 'wu-maintenance-mode',
'parent' => 'top-secondary',
@@ -109,10 +93,8 @@ class Maintenance_Mode {
);
$wp_admin_bar->add_node($args);
-
- } // end if;
-
- } // end add_notice_to_admin_bar;
+ }
+ }
/**
* Render page - html filtrable
@@ -123,10 +105,8 @@ class Maintenance_Mode {
public function render_page() {
if (is_main_site() || current_user_can('read')) {
-
return;
-
- } // end if;
+ }
$text = apply_filters(
'wu_maintenance_mode_text',
@@ -139,8 +119,7 @@ class Maintenance_Mode {
);
wp_die($text, $title, 503);
-
- } // end render_page;
+ }
/**
* Check should display maintenance mode
@@ -151,8 +130,7 @@ class Maintenance_Mode {
public static function check_maintenance_mode() {
return get_site_meta(get_current_blog_id(), 'wu_maintenance_mode', true);
-
- } // end check_maintenance_mode;
+ }
/**
* Callback button admin toggle maintenance mode.
@@ -166,14 +144,14 @@ class Maintenance_Mode {
$site_id = \WP_Ultimo\Helpers\Hash::decode(wu_request('site_hash'), 'site');
- if (!current_user_can_for_blog($site_id, 'manage_options')) {
-
- return wp_send_json_error(array(
- 'message' => __('You do not have the necessary permissions to perform this option.', 'wp-ultimo'),
- 'value' => false,
- ));
-
- } // end if;
+ if ( ! current_user_can_for_blog($site_id, 'manage_options')) {
+ return wp_send_json_error(
+ array(
+ 'message' => __('You do not have the necessary permissions to perform this option.', 'wp-ultimo'),
+ 'value' => false,
+ )
+ );
+ }
$value = wu_request('maintenance_status', false);
@@ -190,8 +168,7 @@ class Maintenance_Mode {
Cache_Manager::get_instance()->flush_known_caches();
wp_send_json_success($return);
-
- } // end toggle_maintenance_mode;
+ }
/**
* Filter the WP Multisite WaaS settings to add Jumper options
@@ -201,14 +178,16 @@ class Maintenance_Mode {
*/
public function add_settings() {
- wu_register_settings_field('sites', 'maintenance_mode', array(
- 'title' => __('Site Maintenance Mode', 'wp-ultimo'),
- 'desc' => __('Allow your customers and super admins to quickly take sites offline via a toggle on the site dashboard.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 0,
- 'order' => 23,
- ));
-
- } // end add_settings;
-
-} // end class Maintenance_Mode;
+ wu_register_settings_field(
+ 'sites',
+ 'maintenance_mode',
+ array(
+ 'title' => __('Site Maintenance Mode', 'wp-ultimo'),
+ 'desc' => __('Allow your customers and super admins to quickly take sites offline via a toggle on the site dashboard.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 0,
+ 'order' => 23,
+ )
+ );
+ }
+}
diff --git a/inc/class-newsletter.php b/inc/class-newsletter.php
index b96c72c..a5ad983 100644
--- a/inc/class-newsletter.php
+++ b/inc/class-newsletter.php
@@ -10,17 +10,19 @@ class Newsletter {
public function init() {
add_action('wu_settings_login', array($this, 'add_settings'), 20);
add_filter('wu_pre_save_settings', array($this, 'maybe_update_newsletter_subscription'), 10, 3);
-
- } // end init;
+ }
public function add_settings() {
- wu_register_settings_field('general', self::SETTING_FIELD_SLUG, array(
- 'title' => __('Signup for WP Multisite WaaS Newsletter', 'wp-ultimo'),
- 'desc' => __('Be informed of new releases and all things related to running a WaaS Network.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'value' => '1',
- ),
- 45
+ wu_register_settings_field(
+ 'general',
+ self::SETTING_FIELD_SLUG,
+ array(
+ 'title' => __('Signup for WP Multisite WaaS Newsletter', 'wp-ultimo'),
+ 'desc' => __('Be informed of new releases and all things related to running a WaaS Network.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'value' => '1',
+ ),
+ 45
);
}
@@ -37,38 +39,46 @@ class Newsletter {
*/
public function maybe_update_newsletter_subscription($settings, $settings_to_save, $saved_settings) {
- if ( isset($settings_to_save[ self::SETTING_FIELD_SLUG ]) && $settings_to_save[ self::SETTING_FIELD_SLUG ] && $settings_to_save[ self::SETTING_FIELD_SLUG ] != $saved_settings[ self::SETTING_FIELD_SLUG ] ) {
-
- $response = wp_remote_post( 'https://wpmultisitewaas.org/wp-json/newsletter/v2/subscribers', [
- 'method' => 'PUT',
- 'body' => wp_json_encode( [
- 'email' => $settings['company_email'],
- 'status' => 'confirmed',
- 'first_name' => $settings['company_name'],
- 'country' => $settings['company_country'],
- ] ),
- 'headers' => [
- 'Accept' => 'application/json',
- 'Content-Type' => 'application/json',
- 'Authorization' => 'Basic ' . base64_encode( '30220d7fb4ec49a7410b3a309b9346c18410bd56:0407cd731d6f074cd0b96f2643b7619e89af1ed2' ),
- ],
- ] );
- } elseif( empty($settings_to_save[ self::SETTING_FIELD_SLUG ]) && ! empty( $saved_settings[ self::SETTING_FIELD_SLUG ] ) ) {
- $response = wp_remote_post( 'https://wpmultisitewaas.org/wp-json/newsletter/v2/subscribers', [
- 'method' => 'PUT',
- 'body' => wp_json_encode( [
- 'email' => $settings['company_email'],
- 'status' => 'unsubscribed',
- ] ),
- 'headers' => [
- 'Accept' => 'application/json',
- 'Content-Type' => 'application/json',
- 'Authorization' => 'Basic ' . base64_encode( '30220d7fb4ec49a7410b3a309b9346c18410bd56:0407cd731d6f074cd0b96f2643b7619e89af1ed2' ),
- ],
- ] );
+ if ( isset($settings_to_save[ self::SETTING_FIELD_SLUG ]) && $settings_to_save[ self::SETTING_FIELD_SLUG ] && $settings_to_save[ self::SETTING_FIELD_SLUG ] != $saved_settings[ self::SETTING_FIELD_SLUG ] ) {
+ $response = wp_remote_post(
+ 'https://wpmultisitewaas.org/wp-json/newsletter/v2/subscribers',
+ array(
+ 'method' => 'PUT',
+ 'body' => wp_json_encode(
+ array(
+ 'email' => $settings['company_email'],
+ 'status' => 'confirmed',
+ 'first_name' => $settings['company_name'],
+ 'country' => $settings['company_country'],
+ )
+ ),
+ 'headers' => array(
+ 'Accept' => 'application/json',
+ 'Content-Type' => 'application/json',
+ 'Authorization' => 'Basic ' . base64_encode('30220d7fb4ec49a7410b3a309b9346c18410bd56:0407cd731d6f074cd0b96f2643b7619e89af1ed2'),
+ ),
+ )
+ );
+ } elseif ( empty($settings_to_save[ self::SETTING_FIELD_SLUG ]) && ! empty($saved_settings[ self::SETTING_FIELD_SLUG ]) ) {
+ $response = wp_remote_post(
+ 'https://wpmultisitewaas.org/wp-json/newsletter/v2/subscribers',
+ array(
+ 'method' => 'PUT',
+ 'body' => wp_json_encode(
+ array(
+ 'email' => $settings['company_email'],
+ 'status' => 'unsubscribed',
+ )
+ ),
+ 'headers' => array(
+ 'Accept' => 'application/json',
+ 'Content-Type' => 'application/json',
+ 'Authorization' => 'Basic ' . base64_encode('30220d7fb4ec49a7410b3a309b9346c18410bd56:0407cd731d6f074cd0b96f2643b7619e89af1ed2'),
+ ),
+ )
+ );
}
return $settings;
-
- } // end fix_saving_settings;
+ }
}
diff --git a/inc/class-requirements.php b/inc/class-requirements.php
index c0879f7..97a8ee8 100644
--- a/inc/class-requirements.php
+++ b/inc/class-requirements.php
@@ -65,7 +65,7 @@ class Requirements {
/**
* Static-only class.
*/
- private function __construct() {} // end __construct;
+ private function __construct() {}
/**
* Check if the minimum pre-requisites to run WP Multisite WaaS are present.
@@ -80,20 +80,17 @@ class Requirements {
*/
public static function met() {
- if (self::$met === null) {
-
+ if (null === self::$met) {
self::$met = (
self::check_php_version()
&& self::check_wp_version()
&& self::is_multisite()
&& self::is_network_active()
);
-
- } // end if;
+ }
return self::$met;
-
- } // end met;
+ }
/**
* Checks if we have ran through the setup already.
@@ -106,26 +103,21 @@ class Requirements {
global $wpdb;
if (self::is_unit_test()) {
-
// phpcs:disable
$tables = wu_array_flatten($wpdb->get_results(sprintf('SHOW TABLES FROM %s;', DB_NAME), ARRAY_N));
// phpcs:enable
- if (!in_array("{$wpdb->prefix}wu_domain_mappings", $tables, true)) {
-
+ if (! in_array("{$wpdb->prefix}wu_domain_mappings", $tables, true)) {
Core_Installer::get_instance()->_install_database_tables();
-
- } // end if;
+ }
return true;
-
- } // end if;
+ }
return get_network_option(null, 'wu_setup_finished', false);
-
- } // end run_setup;
+ }
/**
* Checks for a test environment.
@@ -134,10 +126,8 @@ class Requirements {
* @return boolean
*/
public static function is_unit_test() {
-
return defined('WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE;
-
- } // end is_unit_test;
+ }
/**
* Check if the PHP version requirements are met
*
@@ -146,16 +136,13 @@ class Requirements {
public static function check_php_version(): bool {
if (version_compare(phpversion(), self::$php_version, '<')) {
-
add_action('network_admin_notices', array('WP_Ultimo\Requirements', 'notice_unsupported_php_version'));
return false;
-
- } // end if;
+ }
return true;
-
- } // end check_php_version;
+ }
/**
* Check if the WordPress version requirements are met
*
@@ -166,16 +153,13 @@ class Requirements {
global $wp_version;
if (version_compare($wp_version, self::$wp_version, '<')) {
-
add_action('network_admin_notices', array('WP_Ultimo\Requirements', 'notice_unsupported_wp_version'));
return false;
-
- } // end if;
+ }
return true;
-
- } // end check_wp_version;
+ }
/**
* Check Cron Status
@@ -195,50 +179,44 @@ class Requirements {
global $wp_version;
if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON) {
-
return false;
-
- } // end if;
+ }
if (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
-
return false;
-
- } // end if;
+ }
$cached_status = get_site_transient('wp-ultimo-cron-test-ok');
if ($cached_status) {
-
return true;
-
- } // end if;
+ }
$sslverify = version_compare($wp_version, 4.0, '<');
$doing_wp_cron = sprintf('%.22F', microtime(true));
- $cron_request = apply_filters('cron_request', array( // phpcs:ignore
- 'url' => site_url('wp-cron.php?doing_wp_cron=' . $doing_wp_cron),
- 'args' => array(
- 'timeout' => 3,
- 'blocking' => true,
- 'sslverify' => apply_filters('https_local_ssl_verify', $sslverify), // phpcs:ignore
- ),
- ));
+ $cron_request = apply_filters(
+ 'cron_request', // phpcs:ignore
+ array(
+ 'url' => site_url('wp-cron.php?doing_wp_cron=' . $doing_wp_cron),
+ 'args' => array(
+ 'timeout' => 3,
+ 'blocking' => true,
+ 'sslverify' => apply_filters('https_local_ssl_verify', $sslverify), // phpcs:ignore
+ ),
+ )
+ );
$result = wp_remote_post($cron_request['url'], $cron_request['args']);
if (wp_remote_retrieve_response_code($result) >= 300) {
-
return false;
-
- } // end if;
+ }
set_transient('wp-ultimo-cron-test-ok', 1, HOUR_IN_SECONDS);
return true;
-
- } // end check_wp_cron;
+ }
/**
* Check if the install is a Multisite install
*
@@ -246,17 +224,14 @@ class Requirements {
*/
public static function is_multisite(): bool {
- if (!is_multisite()) {
-
+ if (! is_multisite()) {
add_action('admin_notices', array('WP_Ultimo\Requirements', 'notice_not_multisite'));
return false;
-
- } // end if;
+ }
return true;
-
- } // end is_multisite;
+ }
/**
* Check if WP Multisite WaaS is network active.
*
@@ -277,28 +252,21 @@ class Requirements {
$skip_network_activation_check = apply_filters('wp_ultimo_skip_network_active_check', wu_is_must_use());
if ($skip_network_activation_check) {
-
return true;
+ }
- } // end if;
-
- if (!function_exists('is_plugin_active_for_network')) {
-
+ if (! function_exists('is_plugin_active_for_network')) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
+ }
- } // end if;
-
- if (!is_plugin_active_for_network(WP_ULTIMO_PLUGIN_BASENAME) && !self::is_unit_test()) {
-
+ if (! is_plugin_active_for_network(WP_ULTIMO_PLUGIN_BASENAME) && ! self::is_unit_test()) {
add_action('admin_notices', array('WP_Ultimo\Requirements', 'notice_not_network_active'));
return false;
-
- } // end if;
+ }
return true;
-
- } // end is_network_active;
+ }
/**
* Adds a network admin notice about the PHP requirements not being met
@@ -312,8 +280,7 @@ class Requirements {
$message = sprintf(__('WP Multisite WaaS requires at least PHP version %1$s to run. Your current PHP version is %2$s. Please, contact your hosting company support to upgrade your PHP version. If you want maximum performance consider upgrading your PHP to version 7.0 or later.', 'wp-ultimo'), self::$php_version, phpversion());
printf('
%s
', $message);
-
- } // end notice_unsupported_php_version;
+ }
/**
* Adds a network admin notice about the WordPress requirements not being met
@@ -329,8 +296,7 @@ class Requirements {
$message = sprintf(__('WP Multisite WaaS requires at least WordPress version %1$s to run. Your current WordPress version is %2$s.', 'wp-ultimo'), self::$wp_version, $wp_version);
printf('
%s
', $message);
-
- } // end notice_unsupported_wp_version;
+ }
/**
* Adds a network admin notice about the install not being a multisite install
@@ -343,8 +309,7 @@ class Requirements {
$message = __('WP Multisite WaaS requires a multisite install to run properly. To know more about WordPress Networks, visit this link: Create a Network →', 'wp-ultimo');
printf('
%s
', $message);
-
- } // end notice_not_multisite;
+ }
/**
* Adds a network admin notice about the WP Multisite WaaS not being network-active
@@ -358,7 +323,5 @@ class Requirements {
$message = sprintf(__('WP Multisite WaaS needs to be network active to run properly. You can "Network Activate" it here', 'wp-ultimo'), network_admin_url('plugins.php'));
printf('
%s
', $message);
-
- } // end notice_not_network_active;
-
-} // end class Requirements;
+ }
+}
diff --git a/inc/class-scripts.php b/inc/class-scripts.php
index ab89881..e6386c7 100644
--- a/inc/class-scripts.php
+++ b/inc/class-scripts.php
@@ -40,8 +40,7 @@ class Scripts {
add_action('wp_ajax_wu_toggle_container', array($this, 'update_use_container'));
add_filter('admin_body_class', array($this, 'add_body_class_container_boxed'));
-
- } // end init;
+ }
/**
* Wrapper for the register scripts function.
@@ -56,8 +55,7 @@ class Scripts {
public function register_script($handle, $src, $deps = array()) {
wp_register_script($handle, $src, $deps, wu_get_version());
-
- } // end register_script;
+ }
/**
* Wrapper for the register styles function.
@@ -72,8 +70,7 @@ class Scripts {
public function register_style($handle, $src, $deps = array()) {
wp_register_style($handle, $src, $deps, wu_get_version());
-
- } // end register_style;
+ }
/**
* Registers the default WP Multisite WaaS scripts.
@@ -138,16 +135,20 @@ class Scripts {
*/
$this->register_script('wu-functions', wu_get_asset('functions.js', 'js'), array('jquery-core', 'wu-tiptip', 'wu-flatpicker', 'wu-block-ui', 'wu-accounting', 'clipboard', 'wp-hooks'));
- wp_localize_script('wu-functions', 'wu_settings', array(
- 'currency' => wu_get_setting('currency_symbol', 'USD'),
- 'currency_symbol' => wu_get_currency_symbol(),
- 'currency_position' => wu_get_setting('currency_position'),
- 'decimal_separator' => wu_get_setting('decimal_separator'),
- 'thousand_separator' => wu_get_setting('thousand_separator'),
- 'precision' => wu_get_setting('precision', 2),
- 'use_container' => get_user_setting('wu_use_container', false),
- 'disable_image_zoom' => wu_get_setting('disable_image_zoom', false),
- ));
+ wp_localize_script(
+ 'wu-functions',
+ 'wu_settings',
+ array(
+ 'currency' => wu_get_setting('currency_symbol', 'USD'),
+ 'currency_symbol' => wu_get_currency_symbol(),
+ 'currency_position' => wu_get_setting('currency_position'),
+ 'decimal_separator' => wu_get_setting('decimal_separator'),
+ 'thousand_separator' => wu_get_setting('thousand_separator'),
+ 'precision' => wu_get_setting('precision', 2),
+ 'use_container' => get_user_setting('wu_use_container', false),
+ 'disable_image_zoom' => wu_get_setting('disable_image_zoom', false),
+ )
+ );
/*
* Adds Fields & Components
@@ -157,12 +158,16 @@ class Scripts {
/*
* Localize components
*/
- wp_localize_script('wu-fields', 'wu_fields', array(
- 'l10n' => array(
- 'image_picker_title' => __('Select an Image.', 'wp-ultimo'),
- 'image_picker_button_text' => __('Use this image', 'wp-ultimo'),
- ),
- ));
+ wp_localize_script(
+ 'wu-fields',
+ 'wu_fields',
+ array(
+ 'l10n' => array(
+ 'image_picker_title' => __('Select an Image.', 'wp-ultimo'),
+ 'image_picker_button_text' => __('Use this image', 'wp-ultimo'),
+ ),
+ )
+ );
/*
* Adds Admin Script
@@ -183,33 +188,45 @@ class Scripts {
/*
* Localize selectizer
*/
- wp_localize_script('wu-functions', 'wu_selectizer', array(
- 'ajaxurl' => wu_ajax_url(),
- ));
+ wp_localize_script(
+ 'wu-functions',
+ 'wu_selectizer',
+ array(
+ 'ajaxurl' => wu_ajax_url(),
+ )
+ );
/*
* Load variables to localized it
*/
- wp_localize_script('wu-functions', 'wu_ticker', array(
+ wp_localize_script(
+ 'wu-functions',
+ 'wu_ticker',
+ array(
'server_clock_offset' => (wu_get_current_time('timestamp') - time()) / 60 / 60, // phpcs:ignore
'moment_clock_timezone_name' => wp_date('e'),
'moment_clock_timezone_offset' => wp_date('Z'),
- ));
+ )
+ );
/*
* Adds our thickbox fork.
*/
$this->register_script('wubox', wu_get_asset('wubox.js', 'js'), array('wu-vue-apps'));
- wp_localize_script('wubox', 'wuboxL10n', array(
- 'next' => __('Next >'),
- 'prev' => __('< Prev'),
- 'image' => __('Image'),
- 'of' => __('of'),
- 'close' => __('Close'),
- 'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'),
- 'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'),
- ));
+ wp_localize_script(
+ 'wubox',
+ 'wuboxL10n',
+ array(
+ 'next' => __('Next >'),
+ 'prev' => __('< Prev'),
+ 'image' => __('Image'),
+ 'of' => __('of'),
+ 'close' => __('Close'),
+ 'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'),
+ 'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'),
+ )
+ );
/*
* WordPress localizes month names and all, but
@@ -217,8 +234,7 @@ class Scripts {
* times to be translated, so we need to do it ourselves.
*/
$this->localize_moment();
-
- } // end register_default_scripts;
+ }
/**
* Localize moment.js relative times.
@@ -231,15 +247,18 @@ class Scripts {
$time_format = get_option('time_format', __('g:i a'));
$date_format = get_option('date_format', __('F j, Y'));
- $long_date_formats = array_map('wu_convert_php_date_format_to_moment_js_format', array(
- 'LT' => $time_format,
- 'LTS' => str_replace(':i', ':i:s', (string) $time_format),
- /* translators: the day/month/year date format used by WP Multisite WaaS. You can changed it to localize this date format to your language. the default value is d/m/Y, which is the format 31/12/2021. */
- 'L' => __('d/m/Y', 'wp-ultimo'),
- 'LL' => $date_format,
- 'LLL' => sprintf('%s %s', $date_format, $time_format),
- 'LLLL' => sprintf('%s %s', $date_format, $time_format),
- ));
+ $long_date_formats = array_map(
+ 'wu_convert_php_date_format_to_moment_js_format',
+ array(
+ 'LT' => $time_format,
+ 'LTS' => str_replace(':i', ':i:s', (string) $time_format),
+ /* translators: the day/month/year date format used by WP Multisite WaaS. You can changed it to localize this date format to your language. the default value is d/m/Y, which is the format 31/12/2021. */
+ 'L' => __('d/m/Y', 'wp-ultimo'),
+ 'LL' => $date_format,
+ 'LLL' => sprintf('%s %s', $date_format, $time_format),
+ 'LLLL' => sprintf('%s %s', $date_format, $time_format),
+ )
+ );
// phpcs:disable
$strings = array(
@@ -268,8 +287,7 @@ class Scripts {
$inline_script = sprintf("moment.updateLocale( '%s', %s );", get_user_locale(), wp_json_encode($strings));
return did_action('init') && wp_add_inline_script('moment', $inline_script, 'after');
-
- } // end localize_moment;
+ }
/**
* Registers the default WP Multisite WaaS styles.
@@ -286,8 +304,7 @@ class Scripts {
$this->register_style('wu-checkout', wu_get_asset('checkout.css', 'css'), array(), wu_get_version());
$this->register_style('wu-flags', wu_get_asset('flags.css', 'css'), array(), wu_get_version());
-
- } // end register_default_styles;
+ }
/**
* Loads the default admin styles.
@@ -298,8 +315,7 @@ class Scripts {
public function enqueue_default_admin_styles() {
wp_enqueue_style('wu-admin');
-
- } // end enqueue_default_admin_styles;
+ }
/**
* Loads the default admin scripts.
@@ -310,8 +326,7 @@ class Scripts {
public function enqueue_default_admin_scripts() {
wp_enqueue_script('wu-admin');
-
- } // end enqueue_default_admin_scripts;
+ }
/**
* Update the use container setting.
@@ -323,13 +338,12 @@ class Scripts {
check_ajax_referer('wu_toggle_container', 'nonce');
- $new_value = (bool) !(get_user_setting('wu_use_container', false));
+ $new_value = (bool) ! (get_user_setting('wu_use_container', false));
set_user_setting('wu_use_container', $new_value);
wp_die();
-
- } // end update_use_container;
+ }
/**
* Add body classes of container boxed if user has setting.
@@ -342,13 +356,9 @@ class Scripts {
public function add_body_class_container_boxed($classes) {
if (get_user_setting('wu_use_container', false)) {
-
$classes .= ' has-wu-container ';
-
- } // end if;
+ }
return $classes;
-
- } // end add_body_class_container_boxed;
-
-} // end class Scripts;
+ }
+}
diff --git a/inc/class-session-cookie.php b/inc/class-session-cookie.php
index 2bfd66d..a3bd4e3 100644
--- a/inc/class-session-cookie.php
+++ b/inc/class-session-cookie.php
@@ -11,8 +11,8 @@
namespace WP_Ultimo;
-use \WP_Ultimo\Contracts\Session;
-use \Delight\Cookie\Cookie;
+use WP_Ultimo\Contracts\Session;
+use Delight\Cookie\Cookie;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -27,18 +27,18 @@ class Session_Cookie implements Session {
*
* @var array
*/
- protected $data = array();
+ protected $data = array();
/**
* If the session has already loaded
*
* @var boolean
*/
- protected $loaded = false;
- /**
- * @var string
- */
- protected $realm_name;
+ protected $loaded = false;
+ /**
+ * @var string
+ */
+ protected $realm_name;
/**
* Constructs the manager.
@@ -49,24 +49,21 @@ class Session_Cookie implements Session {
*/
public function __construct($realm_name) {
- $this->realm_name = $realm_name;
- if ($this->loaded === true) {
-
- return;
-
+ $this->realm_name = $realm_name;
+ if ($this->loaded === true) {
+ return;
}
- $cookie_name = $this->get_cookie_name();
+ $cookie_name = $this->get_cookie_name();
- $data_raw = Cookie::get($cookie_name, '{"new": true}');
- $data_raw = urldecode((string) $data_raw);
- $data_raw = stripslashes($data_raw);
+ $data_raw = Cookie::get($cookie_name, '{"new": true}');
+ $data_raw = urldecode((string) $data_raw);
+ $data_raw = stripslashes($data_raw);
- $this->data = json_decode($data_raw, true);
+ $this->data = json_decode($data_raw, true);
- $this->loaded = true;
-
- } // end __construct;
+ $this->loaded = true;
+ }
/**
* Get the name of current cookie.
@@ -76,8 +73,7 @@ class Session_Cookie implements Session {
protected function get_cookie_name() {
return "wu_session_{$this->realm_name}";
-
- } // end get_cookie_name;
+ }
/**
* Gets the value of a session key.
@@ -89,15 +85,12 @@ class Session_Cookie implements Session {
*/
public function get($key = null) {
- if (!$key) {
-
+ if ( ! $key) {
return $this->data;
+ }
- } // end if;
-
- return is_array($this->data) && isset($this->data[$key]) ? $this->data[$key] : null;
-
- } // end get;
+ return is_array($this->data) && isset($this->data[ $key ]) ? $this->data[ $key ] : null;
+ }
/**
* Set the value of a session key.
*
@@ -108,11 +101,10 @@ class Session_Cookie implements Session {
*/
public function set($key, $value): bool {
- $this->data[$key] = $value;
+ $this->data[ $key ] = $value;
- return true;
-
- } // end set;
+ return true;
+ }
/**
* Appends values to a given key, instead of replacing it.
*
@@ -123,13 +115,12 @@ class Session_Cookie implements Session {
*/
public function add_values($key, $values): bool {
- $old_values = isset($this->data[$key]) ? $this->data[$key] : array();
+ $old_values = isset($this->data[ $key ]) ? $this->data[ $key ] : array();
- $this->data[$key] = array_merge($old_values, $values);
+ $this->data[ $key ] = array_merge($old_values, $values);
return true;
-
- } // end add_values;
+ }
/**
* Writes to the session and closes the connection.
*
@@ -138,11 +129,9 @@ class Session_Cookie implements Session {
*/
public function commit($expire = null): bool {
- if ($expire === null) {
-
+ if ($expire === null) {
$expire = HOUR_IN_SECONDS;
-
- } // end if;
+ }
$value = json_encode($this->data, JSON_UNESCAPED_UNICODE);
@@ -158,11 +147,10 @@ class Session_Cookie implements Session {
$cookie->save();
// Set for current call
- $_COOKIE[$this->get_cookie_name()] = $value;
+ $_COOKIE[ $this->get_cookie_name() ] = $value;
return true;
-
- } // end commit;
+ }
/**
* Clears the current session.
@@ -171,9 +159,8 @@ class Session_Cookie implements Session {
*/
public function clear() {
- $this->data = array();
-
- } // end clear;
+ $this->data = array();
+ }
/**
* Destroys the session. Equivalent to session_destroy();
@@ -186,10 +173,8 @@ class Session_Cookie implements Session {
$name = $this->get_cookie_name();
// unset from current call
- unset($_COOKIE[$this->get_cookie_name()]);
+ unset($_COOKIE[ $this->get_cookie_name() ]);
return (new Cookie($name))->delete();
-
- } // end destroy;
-
-} // end class Session_Cookie;
+ }
+}
diff --git a/inc/class-settings.php b/inc/class-settings.php
index f29cdf1..0f42040 100644
--- a/inc/class-settings.php
+++ b/inc/class-settings.php
@@ -22,7 +22,8 @@ defined('ABSPATH') || exit;
*/
class Settings {
- use \WP_Ultimo\Traits\Singleton, \WP_Ultimo\Traits\WP_Ultimo_Settings_Deprecated;
+ use \WP_Ultimo\Traits\Singleton;
+ use \WP_Ultimo\Traits\WP_Ultimo_Settings_Deprecated;
/**
* Keeps the key used to access settings.
@@ -70,8 +71,7 @@ class Settings {
add_filter('pre_site_option_add_new_users', array($this, 'force_add_new_users'), 10, 3);
add_filter('pre_site_option_menu_items', array($this, 'force_plugins_menu'), 10, 3);
-
- } // end init;
+ }
/**
* Change the current status of the registration on WordPress MS.
@@ -88,16 +88,13 @@ class Settings {
global $current_site;
if ($network_id !== $current_site->id) {
-
return $status;
-
- } // end if;
+ }
$status = wu_get_setting('enable_registration') ? 'all' : $status;
return $status;
-
- } // end force_registration_status;
+ }
/**
* Change the current status of the add_new network option.
@@ -114,14 +111,11 @@ class Settings {
global $current_site;
if ($network_id !== $current_site->id) {
-
return $status;
-
- } // end if;
+ }
return wu_get_setting('add_new_users', true);
-
- } // end force_add_new_users;
+ }
/**
* Change the current status of the add_new network option.
@@ -138,16 +132,13 @@ class Settings {
global $current_site;
if ($network_id !== $current_site->id || is_bool($status)) {
-
return $status;
-
- } // end if;
+ }
$status['plugins'] = wu_get_setting('menu_items_plugin', true);
return $status;
-
- } // end force_plugins_menu;
+ }
/**
* Get all the settings from WP Multisite WaaS
@@ -159,26 +150,22 @@ class Settings {
// Get all the settings
if (null === $this->settings) {
-
- $this->settings = wu_get_option(Settings::KEY);
-
- } // end if;
+ $this->settings = wu_get_option(self::KEY);
+ }
if ($this->settings === false || empty($this->settings)) {
- if (! $this->saving) {
+ if ( ! $this->saving) {
$this->saving = true;
- $this->settings = $this->save_settings( array(), true );
+ $this->settings = $this->save_settings(array(), true);
} else {
return array();
}
-
- } // end if;
+ }
if ($check_caps) {} // phpcs:ignore;
return $this->settings;
-
- } // end get_all;
+ }
/**
* Get a specific settings from the plugin
@@ -195,16 +182,13 @@ class Settings {
$settings = $this->get_all();
if (strpos($setting, '-') !== false) {
-
_doing_it_wrong($setting, __('Dashes are no longer supported when registering a setting. You should change it to underscores in later versions.', 'wp-ultimo'), '2.0.0');
+ }
- } // end if;
-
- $setting_value = isset($settings[$setting]) ? $settings[$setting] : $default;
+ $setting_value = isset($settings[ $setting ]) ? $settings[ $setting ] : $default;
return apply_filters('wu_get_setting', $setting_value, $setting, $default, $settings);
-
- } // end get_setting;
+ }
/**
* Saves a specific setting into the database
@@ -220,20 +204,17 @@ class Settings {
$value = apply_filters('wu_save_setting', $value, $setting, $settings);
if (is_callable($value)) {
-
$value = call_user_func($value);
+ }
- } // end if;
+ $settings[ $setting ] = $value;
- $settings[$setting] = $value;
-
- $status = wu_save_option(Settings::KEY, $settings);
+ $status = wu_save_option(self::KEY, $settings);
$this->settings = $settings;
return $status;
-
- } // end save_setting;
+ }
/**
* Save WP Multisite WaaS Settings
@@ -253,44 +234,36 @@ class Settings {
$sections = $this->get_sections();
- $saved_settings = !$reset ? $this->get_all() : array();
+ $saved_settings = ! $reset ? $this->get_all() : array();
do_action('wu_before_save_settings', $settings_to_save);
foreach ($sections as $section_slug => $section) {
-
foreach ($section['fields'] as $field_slug => $field_atts) {
-
- $existing_value = isset($saved_settings[$field_slug]) ? $saved_settings[$field_slug] : false;
+ $existing_value = isset($saved_settings[ $field_slug ]) ? $saved_settings[ $field_slug ] : false;
$field = new Field($field_slug, $field_atts);
- $new_value = isset($settings_to_save[$field_slug]) ? $settings_to_save[$field_slug] : $existing_value;
+ $new_value = isset($settings_to_save[ $field_slug ]) ? $settings_to_save[ $field_slug ] : $existing_value;
/**
* For the current tab, we need to assume toggle fields.
*/
- if ($section_slug === wu_request('tab', 'general') && $field->type === 'toggle' && !isset($settings_to_save[$field_slug])) {
-
+ if ($section_slug === wu_request('tab', 'general') && $field->type === 'toggle' && ! isset($settings_to_save[ $field_slug ])) {
$new_value = false;
-
- } // end if;
+ }
$value = $reset ? $field->default : $new_value;
$field->set_value($value);
if ($field->get_value() !== null) {
-
- $settings[$field_slug] = $field->get_value();
-
- } // end if;
+ $settings[ $field_slug ] = $field->get_value();
+ }
do_action('wu_saving_setting', $field_slug, $field, $settings_to_save);
-
- } // end foreach;
-
- } // end foreach;
+ }
+ }
/**
* Allow developers to filter settings before save by WP Multisite WaaS.
@@ -303,15 +276,14 @@ class Settings {
*/
$settings = apply_filters('wu_pre_save_settings', $settings, $settings_to_save, $saved_settings);
- wu_save_option(Settings::KEY, $settings);
+ wu_save_option(self::KEY, $settings);
$this->settings = $settings;
do_action('wu_after_save_settings', $settings, $settings_to_save, $saved_settings);
return $settings;
-
- } // end save_settings;
+ }
/**
* Returns the list of sections and their respective fields.
@@ -327,24 +299,26 @@ class Settings {
return $this->sections;
}
$this->default_sections();
- $this->sections = apply_filters('wu_settings_get_sections', array(
+ $this->sections = apply_filters(
+ 'wu_settings_get_sections',
+ array(
- /*
- * Add a default invisible section that we can use
- * to register settings that will not have a control.
- */
- 'core' => array(
- 'invisible' => true,
- 'order' => 1_000_000,
- 'fields' => apply_filters('wu_settings_section_core_fields', array()),
- ),
- ));
+ /*
+ * Add a default invisible section that we can use
+ * to register settings that will not have a control.
+ */
+ 'core' => array(
+ 'invisible' => true,
+ 'order' => 1_000_000,
+ 'fields' => apply_filters('wu_settings_section_core_fields', array()),
+ ),
+ )
+ );
uasort($this->sections, 'wu_sort_by_order');
return $this->sections;
-
- } // end get_sections;
+ }
/**
* Returns a particular settings section.
@@ -358,11 +332,14 @@ class Settings {
$sections = $this->get_sections();
- return wu_get_isset($sections, $section_name, array(
- 'fields' => array(),
- ));
-
- } // end get_section;
+ return wu_get_isset(
+ $sections,
+ $section_name,
+ array(
+ 'fields' => array(),
+ )
+ );
+ }
/**
* Adds a new settings section.
@@ -379,25 +356,29 @@ class Settings {
*/
public function add_section($section_slug, $atts) {
- add_filter('wu_settings_get_sections', function($sections) use ($section_slug, $atts) {
+ add_filter(
+ 'wu_settings_get_sections',
+ function ($sections) use ($section_slug, $atts) {
- $default_order = (count($sections) + 1) * 10;
+ $default_order = (count($sections) + 1) * 10;
- $atts = wp_parse_args($atts, array(
- 'icon' => 'dashicons-wu-cog',
- 'order' => $default_order,
- 'capability' => 'manage_network',
- ));
+ $atts = wp_parse_args(
+ $atts,
+ array(
+ 'icon' => 'dashicons-wu-cog',
+ 'order' => $default_order,
+ 'capability' => 'manage_network',
+ )
+ );
- $atts['fields'] = apply_filters("wu_settings_section_{$section_slug}_fields", array());
+ $atts['fields'] = apply_filters("wu_settings_section_{$section_slug}_fields", array());
- $sections[$section_slug] = $atts;
+ $sections[ $section_slug ] = $atts;
- return $sections;
-
- });
-
- } // end add_section;
+ return $sections;
+ }
+ );
+ }
/**
* Adds a new field to a settings section.
@@ -416,132 +397,115 @@ class Settings {
/*
* Adds the field to the desired fields array.
*/
- add_filter("wu_settings_section_{$section_slug}_fields", function($fields) use ($field_slug, $atts) {
- /*
- * We no longer support settings with hyphens.
- */
- if (strpos($field_slug, '-') !== false) {
+ add_filter(
+ "wu_settings_section_{$section_slug}_fields",
+ function ($fields) use ($field_slug, $atts) {
+ /*
+ * We no longer support settings with hyphens.
+ */
+ if (strpos($field_slug, '-') !== false) {
+ _doing_it_wrong($field_slug, __('Dashes are no longer supported when registering a setting. You should change it to underscores in later versions.', 'wp-ultimo'), '2.0.0');
+ }
- _doing_it_wrong($field_slug, __('Dashes are no longer supported when registering a setting. You should change it to underscores in later versions.', 'wp-ultimo'), '2.0.0');
+ $default_order = (count($fields) + 1) * 10;
- } // end if;
+ $atts = wp_parse_args(
+ $atts,
+ array(
+ 'setting_id' => $field_slug,
+ 'title' => '',
+ 'desc' => '',
+ 'order' => $default_order,
+ 'default' => null,
+ 'capability' => 'manage_network',
+ 'wrapper_html_attr' => array(),
+ 'require' => array(),
+ 'html_attr' => array(),
+ 'value' => fn() => wu_get_setting($field_slug),
+ 'display_value' => fn() => wu_get_setting($field_slug),
+ 'img' => function () use ($field_slug) {
- $default_order = (count($fields) + 1) * 10;
+ $img_id = wu_get_setting($field_slug);
- $atts = wp_parse_args($atts, array(
- 'setting_id' => $field_slug,
- 'title' => '',
- 'desc' => '',
- 'order' => $default_order,
- 'default' => null,
- 'capability' => 'manage_network',
- 'wrapper_html_attr' => array(),
- 'require' => array(),
- 'html_attr' => array(),
- 'value' => fn() => wu_get_setting($field_slug),
- 'display_value' => fn() => wu_get_setting($field_slug),
- 'img' => function() use ($field_slug) {
+ if ( ! $img_id) {
+ return '';
+ }
- $img_id = wu_get_setting($field_slug);
+ $custom_logo_args = wp_get_attachment_image_src($img_id, 'full');
- if (!$img_id) {
+ return $custom_logo_args ? $custom_logo_args[0] : '';
+ },
+ )
+ );
- return '';
+ /**
+ * Adds v-model
+ */
+ if (wu_get_isset($atts, 'type') !== 'submit') {
+ $atts['html_attr']['v-model'] = wu_replace_dashes($field_slug);
+ $atts['html_attr']['true-value'] = '1';
+ $atts['html_attr']['false-value'] = '0';
+ }
- } // end if;
+ $atts['html_attr']['id'] = $field_slug;
- $custom_logo_args = wp_get_attachment_image_src($img_id, 'full');
+ /**
+ * Handle selectize.
+ */
+ $model_name = wu_get_isset($atts['html_attr'], 'data-model');
- return $custom_logo_args ? $custom_logo_args[0] : '';
+ if ($model_name) {
+ if (function_exists("wu_get_{$model_name}") || $model_name === 'page') {
+ $original_html_attr = $atts['html_attr'];
- },
- ));
+ $atts['html_attr'] = function () use ($field_slug, $model_name, $atts, $original_html_attr) {
- /**
- * Adds v-model
- */
- if (wu_get_isset($atts, 'type') !== 'submit') {
+ $value = wu_get_setting($field_slug);
- $atts['html_attr']['v-model'] = wu_replace_dashes($field_slug);
- $atts['html_attr']['true-value'] = '1';
- $atts['html_attr']['false-value'] = '0';
+ if ($model_name === 'page') {
+ $new_attrs['data-selected'] = get_post($value);
+ } else {
+ $data_selected = call_user_func("wu_get_{$model_name}", $value);
+ $new_attrs['data-selected'] = $data_selected->to_search_results();
+ }
- } // end if;
+ $new_attrs['data-selected'] = json_encode($new_attrs['data-selected']);
- $atts['html_attr']['id'] = $field_slug;
+ return array_merge($original_html_attr, $new_attrs);
+ };
+ }
+ }
- /**
- * Handle selectize.
- */
- $model_name = wu_get_isset($atts['html_attr'], 'data-model');
+ if ( ! empty($atts['require'])) {
+ $require_rules = array();
- if ($model_name) {
+ foreach ($atts['require'] as $attr => $value) {
+ $attr = str_replace('-', '_', $attr);
- if (function_exists("wu_get_{$model_name}") || $model_name === 'page') {
+ $value = json_encode($value);
- $original_html_attr = $atts['html_attr'];
+ $require_rules[] = "require('{$attr}', {$value})";
+ }
- $atts['html_attr'] = function() use ($field_slug, $model_name, $atts, $original_html_attr) {
+ $atts['wrapper_html_attr']['v-show'] = implode(' && ', $require_rules);
+ $atts['wrapper_html_attr']['v-cloak'] = 'v-cloak';
+ }
- $value = wu_get_setting($field_slug);
+ $fields[ $field_slug ] = $atts;
- if ($model_name === 'page') {
-
- $new_attrs['data-selected'] = get_post($value);
-
- } else {
-
- $data_selected = call_user_func("wu_get_{$model_name}", $value);
- $new_attrs['data-selected'] = $data_selected->to_search_results();
-
- } // end if;
-
- $new_attrs['data-selected'] = json_encode($new_attrs['data-selected']);
-
- return array_merge($original_html_attr, $new_attrs);
-
- };
-
- } // end if;
-
- } // end if;
-
- if (!empty($atts['require'])) {
-
- $require_rules = array();
-
- foreach ($atts['require'] as $attr => $value) {
-
- $attr = str_replace('-', '_', $attr);
-
- $value = json_encode($value);
-
- $require_rules[] = "require('{$attr}', {$value})";
-
- } // end foreach;
-
- $atts['wrapper_html_attr']['v-show'] = implode(' && ', $require_rules);
- $atts['wrapper_html_attr']['v-cloak'] = 'v-cloak';
-
- } // end if;
-
- $fields[$field_slug] = $atts;
-
- return $fields;
-
- }, $priority );
+ return $fields;
+ },
+ $priority
+ );
$settings = $this->get_all();
/*
* Makes sure we install the default value if it is not set yet.
*/
- if (isset($atts['default']) && $atts['default'] !== null && !isset($settings[$field_slug])) {
-
+ if (isset($atts['default']) && $atts['default'] !== null && ! isset($settings[ $field_slug ])) {
$this->save_setting($field_slug, $atts['default']);
-
- } // end if;
-
- } // end add_field;
+ }
+ }
/**
* Register the WP Multisite WaaS default sections and fields.
@@ -558,252 +522,358 @@ class Settings {
// Comma separated string of page ids that are already being used as default option
$filter_default_signup_pages = implode(',', array_filter(Checkout_Pages::get_instance()->get_signup_pages()));
- $this->add_section('general', array(
- 'title' => __('General', 'wp-ultimo'),
- 'desc' => __('General', 'wp-ultimo'),
- ));
-
- $this->add_field('general', 'company_header', array(
- 'title' => __('Your Business', 'wp-ultimo'),
- 'desc' => __('General information about your business..', 'wp-ultimo'),
- 'type' => 'header',
- ),
- 10
+ $this->add_section(
+ 'general',
+ array(
+ 'title' => __('General', 'wp-ultimo'),
+ 'desc' => __('General', 'wp-ultimo'),
+ )
);
- $this->add_field('general', 'company_name', array(
- 'title' => __('Company Name', 'wp-ultimo'),
- 'desc' => __('This name is used when generating invoices, for example.', 'wp-ultimo'),
- 'type' => 'text',
- 'default' => get_network_option(null, 'site_name'),
- ),
- 20
+ $this->add_field(
+ 'general',
+ 'company_header',
+ array(
+ 'title' => __('Your Business', 'wp-ultimo'),
+ 'desc' => __('General information about your business..', 'wp-ultimo'),
+ 'type' => 'header',
+ ),
+ 10
);
- $this->add_field('general', 'company_logo', array(
- 'title' => __('Upload Company Logo', 'wp-ultimo'),
- 'desc' => __('Add your company logo to be used on the login page and other places.', 'wp-ultimo'),
- 'type' => 'image',
- 'default' => '',
- ),
- 30
+ $this->add_field(
+ 'general',
+ 'company_name',
+ array(
+ 'title' => __('Company Name', 'wp-ultimo'),
+ 'desc' => __('This name is used when generating invoices, for example.', 'wp-ultimo'),
+ 'type' => 'text',
+ 'default' => get_network_option(null, 'site_name'),
+ ),
+ 20
);
- $this->add_field('general', 'company_email', array(
- 'title' => __('Company Email Address', 'wp-ultimo'),
- 'desc' => __('This email is used when generating invoices, for example.', 'wp-ultimo'),
- 'type' => 'text',
- 'default' => get_network_option(null, 'admin_email'),
- ),
+ $this->add_field(
+ 'general',
+ 'company_logo',
+ array(
+ 'title' => __('Upload Company Logo', 'wp-ultimo'),
+ 'desc' => __('Add your company logo to be used on the login page and other places.', 'wp-ultimo'),
+ 'type' => 'image',
+ 'default' => '',
+ ),
+ 30
+ );
+
+ $this->add_field(
+ 'general',
+ 'company_email',
+ array(
+ 'title' => __('Company Email Address', 'wp-ultimo'),
+ 'desc' => __('This email is used when generating invoices, for example.', 'wp-ultimo'),
+ 'type' => 'text',
+ 'default' => get_network_option(null, 'admin_email'),
+ ),
40
);
- $this->add_field('general', 'company_address', array(
- 'title' => __('Company Address', 'wp-ultimo'),
- 'desc' => __('This address is used when generating invoices.', 'wp-ultimo'),
- 'type' => 'textarea',
- 'placeholder' => "350 Fifth Avenue\nManhattan, \nNew York City, NY \n10118",
- 'default' => '',
- 'html_attr' => array(
- 'rows' => 5,
+ $this->add_field(
+ 'general',
+ 'company_address',
+ array(
+ 'title' => __('Company Address', 'wp-ultimo'),
+ 'desc' => __('This address is used when generating invoices.', 'wp-ultimo'),
+ 'type' => 'textarea',
+ 'placeholder' => "350 Fifth Avenue\nManhattan, \nNew York City, NY \n10118",
+ 'default' => '',
+ 'html_attr' => array(
+ 'rows' => 5,
+ ),
),
- ),
- 50);
-
- $this->add_field('general', 'company_country', array(
- 'title' => __('Company Country', 'wp-ultimo'),
- 'desc' => __('This info is used when generating invoices, as well as for calculating when taxes apply in some contexts.', 'wp-ultimo'),
- 'type' => 'select',
- 'options' => 'wu_get_countries',
- 'default' => array($this, 'get_default_company_country'),
- ), 60);
-
- $this->add_field('general', 'currency_header', array(
- 'title' => __('Currency Options', 'wp-ultimo'),
- 'desc' => __('The following options affect how prices are displayed on the frontend, the backend and in reports.', 'wp-ultimo'),
- 'type' => 'header',
- ), 70
+ 50
);
- $this->add_field('general', 'currency_symbol', array(
- 'title' => __('Currency', 'wp-ultimo'),
- 'desc' => __('Select the currency to be used in WP Multisite WaaS.', 'wp-ultimo'),
- 'type' => 'select',
- 'default' => 'USD',
- 'options' => 'wu_get_currencies',
- ), 80
+ $this->add_field(
+ 'general',
+ 'company_country',
+ array(
+ 'title' => __('Company Country', 'wp-ultimo'),
+ 'desc' => __('This info is used when generating invoices, as well as for calculating when taxes apply in some contexts.', 'wp-ultimo'),
+ 'type' => 'select',
+ 'options' => 'wu_get_countries',
+ 'default' => array($this, 'get_default_company_country'),
+ ),
+ 60
);
- $this->add_field('general', 'currency_position', array(
- 'title' => __('Currency Position', 'wp-ultimo'),
- 'desc' => __('This setting affects all prices displayed across the plugin elements.', 'wp-ultimo'),
- 'desc' => '',
- 'type' => 'select',
- 'default' => '%s %v',
- 'options' => array(
- '%s%v' => __('Left ($99.99)', 'wp-ultimo'),
- '%v%s' => __('Right (99.99$)', 'wp-ultimo'),
- '%s %v' => __('Left with space ($ 99.99)', 'wp-ultimo'),
- '%v %s' => __('Right with space (99.99 $)', 'wp-ultimo'),
- )
- ), 90
+ $this->add_field(
+ 'general',
+ 'currency_header',
+ array(
+ 'title' => __('Currency Options', 'wp-ultimo'),
+ 'desc' => __('The following options affect how prices are displayed on the frontend, the backend and in reports.', 'wp-ultimo'),
+ 'type' => 'header',
+ ),
+ 70
);
- $this->add_field('general', 'decimal_separator', array(
- 'title' => __('Decimal Separator', 'wp-ultimo'),
- 'desc' => __('This setting affects all prices displayed across the plugin elements.', 'wp-ultimo'),
- 'type' => 'text',
- 'default' => '.',
- ), 100);
+ $this->add_field(
+ 'general',
+ 'currency_symbol',
+ array(
+ 'title' => __('Currency', 'wp-ultimo'),
+ 'desc' => __('Select the currency to be used in WP Multisite WaaS.', 'wp-ultimo'),
+ 'type' => 'select',
+ 'default' => 'USD',
+ 'options' => 'wu_get_currencies',
+ ),
+ 80
+ );
- $this->add_field('general', 'thousand_separator', array(
- 'title' => __('Thousand Separator', 'wp-ultimo'),
- 'desc' => __('This setting affects all prices displayed across the plugin elements.', 'wp-ultimo'),
- 'type' => 'text',
- 'default' => ',',
- 'raw' => true
- ),110);
+ $this->add_field(
+ 'general',
+ 'currency_position',
+ array(
+ 'title' => __('Currency Position', 'wp-ultimo'),
+ 'desc' => __('This setting affects all prices displayed across the plugin elements.', 'wp-ultimo'),
+ 'desc' => '',
+ 'type' => 'select',
+ 'default' => '%s %v',
+ 'options' => array(
+ '%s%v' => __('Left ($99.99)', 'wp-ultimo'),
+ '%v%s' => __('Right (99.99$)', 'wp-ultimo'),
+ '%s %v' => __('Left with space ($ 99.99)', 'wp-ultimo'),
+ '%v %s' => __('Right with space (99.99 $)', 'wp-ultimo'),
+ ),
+ ),
+ 90
+ );
- $this->add_field('general', 'precision', array(
- 'title' => __('Number of Decimals', 'wp-ultimo'),
- 'desc' => __('This setting affects all prices displayed across the plugin elements.', 'wp-ultimo'),
- 'type' => 'number',
- 'default' => '2',
- 'min' => 0,
- ), 120);
+ $this->add_field(
+ 'general',
+ 'decimal_separator',
+ array(
+ 'title' => __('Decimal Separator', 'wp-ultimo'),
+ 'desc' => __('This setting affects all prices displayed across the plugin elements.', 'wp-ultimo'),
+ 'type' => 'text',
+ 'default' => '.',
+ ),
+ 100
+ );
+
+ $this->add_field(
+ 'general',
+ 'thousand_separator',
+ array(
+ 'title' => __('Thousand Separator', 'wp-ultimo'),
+ 'desc' => __('This setting affects all prices displayed across the plugin elements.', 'wp-ultimo'),
+ 'type' => 'text',
+ 'default' => ',',
+ 'raw' => true,
+ ),
+ 110
+ );
+
+ $this->add_field(
+ 'general',
+ 'precision',
+ array(
+ 'title' => __('Number of Decimals', 'wp-ultimo'),
+ 'desc' => __('This setting affects all prices displayed across the plugin elements.', 'wp-ultimo'),
+ 'type' => 'number',
+ 'default' => '2',
+ 'min' => 0,
+ ),
+ 120
+ );
/*
* Login & Registration
* This section holds the Login & Registration settings of the WP Multisite WaaS Plugin.
*/
- $this->add_section('login-and-registration', array(
- 'title' => __('Login & Registration', 'wp-ultimo'),
- 'desc' => __('Login & Registration', 'wp-ultimo'),
- 'icon' => 'dashicons-wu-key',
- ));
+ $this->add_section(
+ 'login-and-registration',
+ array(
+ 'title' => __('Login & Registration', 'wp-ultimo'),
+ 'desc' => __('Login & Registration', 'wp-ultimo'),
+ 'icon' => 'dashicons-wu-key',
+ )
+ );
- $this->add_field('login-and-registration', 'registration_header', array(
- 'title' => __('Login and Registration Options', 'wp-ultimo'),
- 'desc' => __('Options related to registration and login behavior.', 'wp-ultimo'),
- 'type' => 'header',
- ));
+ $this->add_field(
+ 'login-and-registration',
+ 'registration_header',
+ array(
+ 'title' => __('Login and Registration Options', 'wp-ultimo'),
+ 'desc' => __('Options related to registration and login behavior.', 'wp-ultimo'),
+ 'type' => 'header',
+ )
+ );
- $this->add_field('login-and-registration', 'enable_registration', array(
- 'title' => __('Enable Registration', 'wp-ultimo'),
- 'desc' => __('Turning this toggle off will disable registration in all checkout forms across the network.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 1,
- ));
+ $this->add_field(
+ 'login-and-registration',
+ 'enable_registration',
+ array(
+ 'title' => __('Enable Registration', 'wp-ultimo'),
+ 'desc' => __('Turning this toggle off will disable registration in all checkout forms across the network.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 1,
+ )
+ );
- $this->add_field('login-and-registration', 'enable_email_verification', array(
- 'title' => __('Enable email verification', 'wp-ultimo'),
- 'desc' => __('Enabling this option will require the customer to verify their email address when subscribing to a free plan or a plan with a trial period. Sites will not be created until the customer email verification status is changed to verified.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 1,
- ));
+ $this->add_field(
+ 'login-and-registration',
+ 'enable_email_verification',
+ array(
+ 'title' => __('Enable email verification', 'wp-ultimo'),
+ 'desc' => __('Enabling this option will require the customer to verify their email address when subscribing to a free plan or a plan with a trial period. Sites will not be created until the customer email verification status is changed to verified.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 1,
+ )
+ );
- $this->add_field('login-and-registration', 'default_registration_page', array(
- 'type' => 'model',
- 'title' => __('Default Registration Page', 'wp-ultimo'),
- 'placeholder' => __('Search pages on the main site...', 'wp-ultimo'),
- 'desc' => __('Only published pages on the main site are available for selection, and you need to make sure they contain a [wu_checkout] shortcode.', 'wp-ultimo'),
- 'tooltip' => '',
- 'html_attr' => array(
- 'data-base-link' => get_admin_url(wu_get_main_site_id(), 'post.php?action=edit&post'),
- 'data-model' => 'page',
- 'data-value-field' => 'ID',
- 'data-label-field' => 'post_title',
- 'data-search-field' => 'post_title',
- 'data-max-items' => 1,
- 'data-exclude' => $filter_default_signup_pages
- ),
- ));
+ $this->add_field(
+ 'login-and-registration',
+ 'default_registration_page',
+ array(
+ 'type' => 'model',
+ 'title' => __('Default Registration Page', 'wp-ultimo'),
+ 'placeholder' => __('Search pages on the main site...', 'wp-ultimo'),
+ 'desc' => __('Only published pages on the main site are available for selection, and you need to make sure they contain a [wu_checkout] shortcode.', 'wp-ultimo'),
+ 'tooltip' => '',
+ 'html_attr' => array(
+ 'data-base-link' => get_admin_url(wu_get_main_site_id(), 'post.php?action=edit&post'),
+ 'data-model' => 'page',
+ 'data-value-field' => 'ID',
+ 'data-label-field' => 'post_title',
+ 'data-search-field' => 'post_title',
+ 'data-max-items' => 1,
+ 'data-exclude' => $filter_default_signup_pages,
+ ),
+ )
+ );
- $this->add_field('login-and-registration', 'enable_custom_login_page', array(
- 'title' => __('Use Custom Login Page', 'wp-ultimo'),
- 'desc' => __('Turn this toggle on to select a custom page to be used as the login page.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 0,
- ));
+ $this->add_field(
+ 'login-and-registration',
+ 'enable_custom_login_page',
+ array(
+ 'title' => __('Use Custom Login Page', 'wp-ultimo'),
+ 'desc' => __('Turn this toggle on to select a custom page to be used as the login page.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 0,
+ )
+ );
- $this->add_field('login-and-registration', 'default_login_page', array(
- 'type' => 'model',
- 'title' => __('Default Login Page', 'wp-ultimo'),
- 'placeholder' => __('Search pages on the main site...', 'wp-ultimo'),
- 'desc' => __('Only published pages on the main site are available for selection, and you need to make sure they contain a [wu_login_form] shortcode.', 'wp-ultimo'),
- 'tooltip' => '',
- 'html_attr' => array(
- 'data-base-link' => get_admin_url(wu_get_main_site_id(), 'post.php?action=edit&post'),
- 'data-model' => 'page',
- 'data-value-field' => 'ID',
- 'data-label-field' => 'post_title',
- 'data-search-field' => 'post_title',
- 'data-max-items' => 1,
- ),
- 'require' => array(
- 'enable_custom_login_page' => true,
- ),
- ));
+ $this->add_field(
+ 'login-and-registration',
+ 'default_login_page',
+ array(
+ 'type' => 'model',
+ 'title' => __('Default Login Page', 'wp-ultimo'),
+ 'placeholder' => __('Search pages on the main site...', 'wp-ultimo'),
+ 'desc' => __('Only published pages on the main site are available for selection, and you need to make sure they contain a [wu_login_form] shortcode.', 'wp-ultimo'),
+ 'tooltip' => '',
+ 'html_attr' => array(
+ 'data-base-link' => get_admin_url(wu_get_main_site_id(), 'post.php?action=edit&post'),
+ 'data-model' => 'page',
+ 'data-value-field' => 'ID',
+ 'data-label-field' => 'post_title',
+ 'data-search-field' => 'post_title',
+ 'data-max-items' => 1,
+ ),
+ 'require' => array(
+ 'enable_custom_login_page' => true,
+ ),
+ )
+ );
- $this->add_field('login-and-registration', 'obfuscate_original_login_url', array(
- 'title' => __('Obfuscate the Original Login URL (wp-login.php)', 'wp-ultimo'),
- 'desc' => __('If this option is enabled, we will display a 404 error when a user tries to access the original wp-login.php link. This is useful to prevent brute-force attacks.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 0,
- 'require' => array(
- 'enable_custom_login_page' => 1,
- ),
- ));
+ $this->add_field(
+ 'login-and-registration',
+ 'obfuscate_original_login_url',
+ array(
+ 'title' => __('Obfuscate the Original Login URL (wp-login.php)', 'wp-ultimo'),
+ 'desc' => __('If this option is enabled, we will display a 404 error when a user tries to access the original wp-login.php link. This is useful to prevent brute-force attacks.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 0,
+ 'require' => array(
+ 'enable_custom_login_page' => 1,
+ ),
+ )
+ );
- $this->add_field('login-and-registration', 'subsite_custom_login_logo', array(
- 'title' => __('Use Sub-site logo on Login Page', 'wp-ultimo'),
- 'desc' => __('Toggle this option to replace the WordPress logo on the sub-site login page with the logo set for that sub-site. If unchecked, the network logo will be used instead.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 0,
- 'require' => array(
- 'enable_custom_login_page' => 0,
- ),
- ));
+ $this->add_field(
+ 'login-and-registration',
+ 'subsite_custom_login_logo',
+ array(
+ 'title' => __('Use Sub-site logo on Login Page', 'wp-ultimo'),
+ 'desc' => __('Toggle this option to replace the WordPress logo on the sub-site login page with the logo set for that sub-site. If unchecked, the network logo will be used instead.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 0,
+ 'require' => array(
+ 'enable_custom_login_page' => 0,
+ ),
+ )
+ );
- $this->add_field('login-and-registration', 'force_publish_sites_sync', array(
- 'title' => __('Force Synchronous Site Publication ', 'wp-ultimo'),
- 'desc' => __('By default, when a new pending site needs to be converted into a real network site, the publishing process happens via Job Queue, asynchronously. Enable this option to force the publication to happen in the same request as the signup. Be careful, as this can cause timeouts depending on the size of the site templates being copied.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 0,
- ));
+ $this->add_field(
+ 'login-and-registration',
+ 'force_publish_sites_sync',
+ array(
+ 'title' => __('Force Synchronous Site Publication ', 'wp-ultimo'),
+ 'desc' => __('By default, when a new pending site needs to be converted into a real network site, the publishing process happens via Job Queue, asynchronously. Enable this option to force the publication to happen in the same request as the signup. Be careful, as this can cause timeouts depending on the size of the site templates being copied.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 0,
+ )
+ );
- $this->add_field('login-and-registration', 'other_header', array(
- 'title' => __('Other Options', 'wp-ultimo'),
- 'desc' => __('Other registration-related options.', 'wp-ultimo'),
- 'type' => 'header',
- ));
+ $this->add_field(
+ 'login-and-registration',
+ 'other_header',
+ array(
+ 'title' => __('Other Options', 'wp-ultimo'),
+ 'desc' => __('Other registration-related options.', 'wp-ultimo'),
+ 'type' => 'header',
+ )
+ );
- $this->add_field('login-and-registration', 'default_role', array(
- 'title' => __('Default Role', 'wp-ultimo'),
- 'desc' => __('Set the role to be applied to the user during the signup process.', 'wp-ultimo'),
- 'type' => 'select',
- 'default' => 'administrator',
- 'options' => 'wu_get_roles_as_options',
- ));
+ $this->add_field(
+ 'login-and-registration',
+ 'default_role',
+ array(
+ 'title' => __('Default Role', 'wp-ultimo'),
+ 'desc' => __('Set the role to be applied to the user during the signup process.', 'wp-ultimo'),
+ 'type' => 'select',
+ 'default' => 'administrator',
+ 'options' => 'wu_get_roles_as_options',
+ )
+ );
- $this->add_field('login-and-registration', 'add_users_to_main_site', array(
- 'title' => __('Add Users to the Main Site as well?', 'wp-ultimo'),
- 'desc' => __('Enabling this option will also add the user to the main site of your network.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 0,
- ));
+ $this->add_field(
+ 'login-and-registration',
+ 'add_users_to_main_site',
+ array(
+ 'title' => __('Add Users to the Main Site as well?', 'wp-ultimo'),
+ 'desc' => __('Enabling this option will also add the user to the main site of your network.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 0,
+ )
+ );
- $this->add_field('login-and-registration', 'main_site_default_role', array(
- 'title' => __('Add to Main Site with Role...', 'wp-ultimo'),
- 'desc' => __('Select the role WP Multisite WaaS should use when adding the user to the main site of your network. Be careful.', 'wp-ultimo'),
- 'type' => 'select',
- 'default' => 'subscriber',
- 'options' => 'wu_get_roles_as_options',
- 'require' => array(
- 'add_users_to_main_site' => 1,
- ),
- ));
+ $this->add_field(
+ 'login-and-registration',
+ 'main_site_default_role',
+ array(
+ 'title' => __('Add to Main Site with Role...', 'wp-ultimo'),
+ 'desc' => __('Select the role WP Multisite WaaS should use when adding the user to the main site of your network. Be careful.', 'wp-ultimo'),
+ 'type' => 'select',
+ 'default' => 'subscriber',
+ 'options' => 'wu_get_roles_as_options',
+ 'require' => array(
+ 'add_users_to_main_site' => 1,
+ ),
+ )
+ );
do_action('wu_settings_login');
@@ -812,188 +882,243 @@ class Settings {
* This section holds the Membership settings of the WP Multisite WaaS Plugin.
*/
- $this->add_section('memberships', array(
- 'title' => __('Memberships', 'wp-ultimo'),
- 'desc' => __('Memberships', 'wp-ultimo'),
- 'icon' => 'dashicons-wu-infinity',
- ));
+ $this->add_section(
+ 'memberships',
+ array(
+ 'title' => __('Memberships', 'wp-ultimo'),
+ 'desc' => __('Memberships', 'wp-ultimo'),
+ 'icon' => 'dashicons-wu-infinity',
+ )
+ );
- $this->add_field('memberships', 'default_update_page', array(
- 'type' => 'model',
- 'title' => __('Default Membership Update Page', 'wp-ultimo'),
- 'placeholder' => __('Search pages on the main site...', 'wp-ultimo'),
- 'desc' => __('Only published pages on the main site are available for selection, and you need to make sure they contain a [wu_checkout] shortcode.', 'wp-ultimo'),
- 'tooltip' => '',
- 'html_attr' => array(
- 'data-base-link' => get_admin_url(wu_get_main_site_id(), 'post.php?action=edit&post'),
- 'data-model' => 'page',
- 'data-value-field' => 'ID',
- 'data-label-field' => 'post_title',
- 'data-search-field' => 'post_title',
- 'data-max-items' => 1,
- 'data-exclude' => $filter_default_signup_pages
- ),
- ));
-
- $this->add_field('memberships', 'block_frontend', array(
- 'title' => __('Block Frontend Access', 'wp-ultimo'),
- 'desc' => __('Block the frontend access of network sites after a membership is no longer active.', 'wp-ultimo'),
- 'tooltip' => __('By default, if a user does not pay and the account goes inactive, only the admin panel will be blocked, but the user\'s site will still be accessible on the frontend. If enabled, this option will also block frontend access in those cases.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 0,
- ));
-
- $this->add_field('memberships', 'block_frontend_grace_period', array(
- 'title' => __('Frontend Block Grace Period', 'wp-ultimo'),
- 'desc' => __('Select the number of days WP Multisite WaaS should wait after the membership goes inactive before blocking the frontend access. Leave 0 to block immediately after the membership becomes inactive.', 'wp-ultimo'),
- 'type' => 'number',
- 'default' => 0,
- 'min' => 0,
- 'require' => array(
- 'block_frontend' => 1,
- ),
- ));
-
- $this->add_field('memberships', 'default_block_frontend_page', array(
- 'title' => __('Frontend Block Page', 'wp-ultimo'),
- 'desc' => __('Select a page on the main site to redirect user if access is blocked', 'wp-ultimo'),
- 'tooltip' => '',
- 'html_attr' => array(
- 'data-base-link' => get_admin_url(wu_get_main_site_id(), 'post.php?action=edit&post'),
- 'data-model' => 'page',
- 'data-value-field' => 'ID',
- 'data-label-field' => 'post_title',
- 'data-search-field' => 'post_title',
- 'data-max-items' => 1,
- ),
- 'require' => array(
- 'block_frontend' => 1,
- ),
- ));
-
- $this->add_field('memberships', 'enable_multiple_memberships', array(
- 'title' => __('Enable Multiple Memberships per Customer', 'wp-ultimo'),
- 'desc' => __('Enabling this option will allow your users to create more than one membership.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 0,
- ));
-
- $this->add_field('memberships', 'enable_multiple_sites', array(
- 'title' => __('Enable Multiple Sites per Membership', 'wp-ultimo'),
- 'desc' => __('Enabling this option will allow your customers to create more than one site. You can limit how many sites your users can create in a per plan basis.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 0,
- ));
-
- $this->add_field('memberships', 'block_sites_on_downgrade', array(
- 'title' => __('Block Sites on Downgrade', 'wp-ultimo'),
- 'desc' => __('Choose how WP Multisite WaaS should handle client sites above their plan quota on downgrade.', 'wp-ultimo'),
- 'type' => 'select',
- 'default' => 'none',
- 'options' => array(
- 'none' => __('Keep sites as is (do nothing)', 'wp-ultimo'),
- 'block-frontend' => __('Block only frontend access', 'wp-ultimo'),
- 'block-backend' => __('Block only backend access', 'wp-ultimo'),
- 'block-both' => __('Block both frontend and backend access', 'wp-ultimo'),
- ),
- 'require' => array(
- 'enable_multiple_sites' => true,
- ),
- ));
-
- $this->add_field('memberships', 'move_posts_on_downgrade', array(
- 'title' => __('Move Posts on Downgrade', 'wp-ultimo'),
- 'desc' => __('Select how you want to handle the posts above the quota on downgrade. This will apply to all post types with quotas set.', 'wp-ultimo'),
- 'type' => 'select',
- 'default' => 'none',
- 'options' => array(
- 'none' => __('Keep posts as is (do nothing)', 'wp-ultimo'),
- 'trash' => __('Move posts above the new quota to the Trash', 'wp-ultimo'),
- 'draft' => __('Mark posts above the new quota as Drafts', 'wp-ultimo'),
- ),
- ));
-
- $this->add_field('memberships', 'emulated_post_types_header', array(
- 'type' => 'header',
- 'title' => __('Emulated Post Types', 'wp-ultimo'),
- 'desc' => __('Emulates the registering of a custom post type to be able to create limits for it without having to activate plugins on the main site.', 'wp-ultimo'),
- ));
-
- $this->add_field('memberships', 'emulated_post_types_explanation', array(
- 'type' => 'note',
- 'desc' => __('By default, WP Multisite WaaS only allows super admins to limit post types that are registered on the main site. This makes sense from a technical stand-point but it also forces you to have plugins network-activated in order to be able to set limitations for their custom post types. Using this option, you can emulate the registering of a post type. This will register them on the main site and allow you to create limits for them on your products.', 'wp-ultimo'),
- 'classes' => '',
- 'wrapper_classes' => '',
- ));
-
- $this->add_field('memberships', 'emulated_post_types_empty', array(
- 'type' => 'note',
- 'desc' => __('Add the first post type 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',
- 'wrapper_html_attr' => array(
- 'v-if' => 'emulated_post_types.length === 0',
- 'v-cloak' => '1',
- ),
- ));
-
- $this->add_field('memberships', 'emulated_post_types', array(
- 'type' => 'group',
- 'tooltip' => '',
- 'raw' => true,
- 'default' => array(),
- 'wrapper_classes' => 'wu-relative wu-bg-gray-100 wu-pb-2',
- 'wrapper_html_attr' => array(
- 'v-if' => 'emulated_post_types.length',
- 'v-for' => '(emulated_post_type, index) in emulated_post_types',
- 'v-cloak' => '1',
- ),
- 'fields' => array(
- 'emulated_post_types_remove' => array(
- 'type' => 'note',
- 'desc' => sprintf(' emulated_post_types.splice(index, 1)">', __('Remove', 'wp-ultimo')),
- 'wrapper_classes' => 'wu-absolute wu-top-0 wu-right-0',
+ $this->add_field(
+ 'memberships',
+ 'default_update_page',
+ array(
+ 'type' => 'model',
+ 'title' => __('Default Membership Update Page', 'wp-ultimo'),
+ 'placeholder' => __('Search pages on the main site...', 'wp-ultimo'),
+ 'desc' => __('Only published pages on the main site are available for selection, and you need to make sure they contain a [wu_checkout] shortcode.', 'wp-ultimo'),
+ 'tooltip' => '',
+ 'html_attr' => array(
+ 'data-base-link' => get_admin_url(wu_get_main_site_id(), 'post.php?action=edit&post'),
+ 'data-model' => 'page',
+ 'data-value-field' => 'ID',
+ 'data-label-field' => 'post_title',
+ 'data-search-field' => 'post_title',
+ 'data-max-items' => 1,
+ 'data-exclude' => $filter_default_signup_pages,
),
- 'emulated_post_types_slug' => array(
- 'type' => 'text',
- 'title' => __('Post Type Slug', 'wp-ultimo'),
- 'placeholder' => __('e.g. product', 'wp-ultimo'),
- 'wrapper_classes' => 'wu-w-5/12',
- 'html_attr' => array(
- 'v-model' => 'emulated_post_type.post_type',
- 'v-bind:name' => '"emulated_post_types[" + index + "][post_type]"',
+ )
+ );
+
+ $this->add_field(
+ 'memberships',
+ 'block_frontend',
+ array(
+ 'title' => __('Block Frontend Access', 'wp-ultimo'),
+ 'desc' => __('Block the frontend access of network sites after a membership is no longer active.', 'wp-ultimo'),
+ 'tooltip' => __('By default, if a user does not pay and the account goes inactive, only the admin panel will be blocked, but the user\'s site will still be accessible on the frontend. If enabled, this option will also block frontend access in those cases.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 0,
+ )
+ );
+
+ $this->add_field(
+ 'memberships',
+ 'block_frontend_grace_period',
+ array(
+ 'title' => __('Frontend Block Grace Period', 'wp-ultimo'),
+ 'desc' => __('Select the number of days WP Multisite WaaS should wait after the membership goes inactive before blocking the frontend access. Leave 0 to block immediately after the membership becomes inactive.', 'wp-ultimo'),
+ 'type' => 'number',
+ 'default' => 0,
+ 'min' => 0,
+ 'require' => array(
+ 'block_frontend' => 1,
+ ),
+ )
+ );
+
+ $this->add_field(
+ 'memberships',
+ 'default_block_frontend_page',
+ array(
+ 'title' => __('Frontend Block Page', 'wp-ultimo'),
+ 'desc' => __('Select a page on the main site to redirect user if access is blocked', 'wp-ultimo'),
+ 'tooltip' => '',
+ 'html_attr' => array(
+ 'data-base-link' => get_admin_url(wu_get_main_site_id(), 'post.php?action=edit&post'),
+ 'data-model' => 'page',
+ 'data-value-field' => 'ID',
+ 'data-label-field' => 'post_title',
+ 'data-search-field' => 'post_title',
+ 'data-max-items' => 1,
+ ),
+ 'require' => array(
+ 'block_frontend' => 1,
+ ),
+ )
+ );
+
+ $this->add_field(
+ 'memberships',
+ 'enable_multiple_memberships',
+ array(
+ 'title' => __('Enable Multiple Memberships per Customer', 'wp-ultimo'),
+ 'desc' => __('Enabling this option will allow your users to create more than one membership.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 0,
+ )
+ );
+
+ $this->add_field(
+ 'memberships',
+ 'enable_multiple_sites',
+ array(
+ 'title' => __('Enable Multiple Sites per Membership', 'wp-ultimo'),
+ 'desc' => __('Enabling this option will allow your customers to create more than one site. You can limit how many sites your users can create in a per plan basis.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 0,
+ )
+ );
+
+ $this->add_field(
+ 'memberships',
+ 'block_sites_on_downgrade',
+ array(
+ 'title' => __('Block Sites on Downgrade', 'wp-ultimo'),
+ 'desc' => __('Choose how WP Multisite WaaS should handle client sites above their plan quota on downgrade.', 'wp-ultimo'),
+ 'type' => 'select',
+ 'default' => 'none',
+ 'options' => array(
+ 'none' => __('Keep sites as is (do nothing)', 'wp-ultimo'),
+ 'block-frontend' => __('Block only frontend access', 'wp-ultimo'),
+ 'block-backend' => __('Block only backend access', 'wp-ultimo'),
+ 'block-both' => __('Block both frontend and backend access', 'wp-ultimo'),
+ ),
+ 'require' => array(
+ 'enable_multiple_sites' => true,
+ ),
+ )
+ );
+
+ $this->add_field(
+ 'memberships',
+ 'move_posts_on_downgrade',
+ array(
+ 'title' => __('Move Posts on Downgrade', 'wp-ultimo'),
+ 'desc' => __('Select how you want to handle the posts above the quota on downgrade. This will apply to all post types with quotas set.', 'wp-ultimo'),
+ 'type' => 'select',
+ 'default' => 'none',
+ 'options' => array(
+ 'none' => __('Keep posts as is (do nothing)', 'wp-ultimo'),
+ 'trash' => __('Move posts above the new quota to the Trash', 'wp-ultimo'),
+ 'draft' => __('Mark posts above the new quota as Drafts', 'wp-ultimo'),
+ ),
+ )
+ );
+
+ $this->add_field(
+ 'memberships',
+ 'emulated_post_types_header',
+ array(
+ 'type' => 'header',
+ 'title' => __('Emulated Post Types', 'wp-ultimo'),
+ 'desc' => __('Emulates the registering of a custom post type to be able to create limits for it without having to activate plugins on the main site.', 'wp-ultimo'),
+ )
+ );
+
+ $this->add_field(
+ 'memberships',
+ 'emulated_post_types_explanation',
+ array(
+ 'type' => 'note',
+ 'desc' => __('By default, WP Multisite WaaS only allows super admins to limit post types that are registered on the main site. This makes sense from a technical stand-point but it also forces you to have plugins network-activated in order to be able to set limitations for their custom post types. Using this option, you can emulate the registering of a post type. This will register them on the main site and allow you to create limits for them on your products.', 'wp-ultimo'),
+ 'classes' => '',
+ 'wrapper_classes' => '',
+ )
+ );
+
+ $this->add_field(
+ 'memberships',
+ 'emulated_post_types_empty',
+ array(
+ 'type' => 'note',
+ 'desc' => __('Add the first post type 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',
+ 'wrapper_html_attr' => array(
+ 'v-if' => 'emulated_post_types.length === 0',
+ 'v-cloak' => '1',
+ ),
+ )
+ );
+
+ $this->add_field(
+ 'memberships',
+ 'emulated_post_types',
+ array(
+ 'type' => 'group',
+ 'tooltip' => '',
+ 'raw' => true,
+ 'default' => array(),
+ 'wrapper_classes' => 'wu-relative wu-bg-gray-100 wu-pb-2',
+ 'wrapper_html_attr' => array(
+ 'v-if' => 'emulated_post_types.length',
+ 'v-for' => '(emulated_post_type, index) in emulated_post_types',
+ 'v-cloak' => '1',
+ ),
+ 'fields' => array(
+ 'emulated_post_types_remove' => array(
+ 'type' => 'note',
+ 'desc' => sprintf(' emulated_post_types.splice(index, 1)">', __('Remove', 'wp-ultimo')),
+ 'wrapper_classes' => 'wu-absolute wu-top-0 wu-right-0',
+ ),
+ 'emulated_post_types_slug' => array(
+ 'type' => 'text',
+ 'title' => __('Post Type Slug', 'wp-ultimo'),
+ 'placeholder' => __('e.g. product', 'wp-ultimo'),
+ 'wrapper_classes' => 'wu-w-5/12',
+ 'html_attr' => array(
+ 'v-model' => 'emulated_post_type.post_type',
+ 'v-bind:name' => '"emulated_post_types[" + index + "][post_type]"',
+ ),
+ ),
+ 'emulated_post_types_label' => array(
+ 'type' => 'text',
+ 'title' => __('Post Type Label', 'wp-ultimo'),
+ 'placeholder' => __('e.g. Products', 'wp-ultimo'),
+ 'wrapper_classes' => 'wu-w-7/12 wu-ml-2',
+ 'html_attr' => array(
+ 'v-model' => 'emulated_post_type.label',
+ 'v-bind:name' => '"emulated_post_types[" + index + "][label]"',
+ ),
),
),
- 'emulated_post_types_label' => array(
- 'type' => 'text',
- 'title' => __('Post Type Label', 'wp-ultimo'),
- 'placeholder' => __('e.g. Products', 'wp-ultimo'),
- 'wrapper_classes' => 'wu-w-7/12 wu-ml-2',
- 'html_attr' => array(
- 'v-model' => 'emulated_post_type.label',
- 'v-bind:name' => '"emulated_post_types[" + index + "][label]"',
- ),
- ),
- ),
- ));
+ )
+ );
- $this->add_field('memberships', 'emulated_post_types_repeat', array(
- 'type' => 'submit',
- 'title' => __('+ Add Post Type', '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(
- 'v-cloak' => '1',
- ),
- 'html_attr' => array(
- 'v-on:click.prevent' => '() => {
+ $this->add_field(
+ 'memberships',
+ 'emulated_post_types_repeat',
+ array(
+ 'type' => 'submit',
+ 'title' => __('+ Add Post Type', '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(
+ 'v-cloak' => '1',
+ ),
+ 'html_attr' => array(
+ 'v-on:click.prevent' => '() => {
emulated_post_types = Array.isArray(emulated_post_types) ? emulated_post_types : []; emulated_post_types.push({
post_type: "",
label: "",
})
}',
- ),
- ));
+ ),
+ )
+ );
do_action('wu_settings_memberships');
@@ -1002,107 +1127,158 @@ class Settings {
* This section holds the Site Templates settings of the WP Multisite WaaS Plugin.
*/
- $this->add_section('sites', array(
- 'title' => __('Sites', 'wp-ultimo'),
- 'desc' => __('Sites', 'wp-ultimo'),
- 'icon' => 'dashicons-wu-browser',
- ));
+ $this->add_section(
+ 'sites',
+ array(
+ 'title' => __('Sites', 'wp-ultimo'),
+ 'desc' => __('Sites', 'wp-ultimo'),
+ 'icon' => 'dashicons-wu-browser',
+ )
+ );
- $this->add_field('sites', 'sites_features_heading', array(
- 'title' => __('Site Options', 'wp-ultimo'),
- 'desc' => __('Configure certain aspects of how network Sites behave.', 'wp-ultimo'),
- 'type' => 'header',
- ));
+ $this->add_field(
+ 'sites',
+ 'sites_features_heading',
+ array(
+ 'title' => __('Site Options', 'wp-ultimo'),
+ 'desc' => __('Configure certain aspects of how network Sites behave.', 'wp-ultimo'),
+ 'type' => 'header',
+ )
+ );
- $this->add_field('sites', 'default_new_site_page', array(
- 'type' => 'model',
- 'title' => __('Default New Site Page', 'wp-ultimo'),
- 'placeholder' => __('Search pages on the main site...', 'wp-ultimo'),
- 'desc' => __('Only published pages on the main site are available for selection, and you need to make sure they contain a [wu_checkout] shortcode.', 'wp-ultimo'),
- 'tooltip' => '',
- 'html_attr' => array(
- 'data-base-link' => get_admin_url(wu_get_main_site_id(), 'post.php?action=edit&post'),
- 'data-model' => 'page',
- 'data-value-field' => 'ID',
- 'data-label-field' => 'post_title',
- 'data-search-field' => 'post_title',
- 'data-max-items' => 1,
- 'data-exclude' => $filter_default_signup_pages
- ),
- ));
+ $this->add_field(
+ 'sites',
+ 'default_new_site_page',
+ array(
+ 'type' => 'model',
+ 'title' => __('Default New Site Page', 'wp-ultimo'),
+ 'placeholder' => __('Search pages on the main site...', 'wp-ultimo'),
+ 'desc' => __('Only published pages on the main site are available for selection, and you need to make sure they contain a [wu_checkout] shortcode.', 'wp-ultimo'),
+ 'tooltip' => '',
+ 'html_attr' => array(
+ 'data-base-link' => get_admin_url(wu_get_main_site_id(), 'post.php?action=edit&post'),
+ 'data-model' => 'page',
+ 'data-value-field' => 'ID',
+ 'data-label-field' => 'post_title',
+ 'data-search-field' => 'post_title',
+ 'data-max-items' => 1,
+ 'data-exclude' => $filter_default_signup_pages,
+ ),
+ )
+ );
- $this->add_field('sites', 'enable_visits_limiting', array(
- 'title' => __('Enable Visits Limitation & Counting', 'wp-ultimo'),
- 'desc' => __('Enabling this option will add visits limitation settings to the plans and add the functionality necessary to count site visits on the front-end.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 1,
- ));
+ $this->add_field(
+ 'sites',
+ 'enable_visits_limiting',
+ array(
+ 'title' => __('Enable Visits Limitation & Counting', 'wp-ultimo'),
+ 'desc' => __('Enabling this option will add visits limitation settings to the plans and add the functionality necessary to count site visits on the front-end.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 1,
+ )
+ );
- $this->add_field('sites', 'enable_screenshot_generator', array(
- 'title' => __('Enable Screenshot Generator', 'wp-ultimo'),
- 'desc' => __('With this option is enabled, WP Multisite WaaS will take a screenshot for every newly created site on your network and set the resulting image as that site\'s featured image. This features requires a valid license key to work and it is not supported for local sites.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 1,
- ));
+ $this->add_field(
+ 'sites',
+ 'enable_screenshot_generator',
+ array(
+ 'title' => __('Enable Screenshot Generator', 'wp-ultimo'),
+ 'desc' => __('With this option is enabled, WP Multisite WaaS will take a screenshot for every newly created site on your network and set the resulting image as that site\'s featured image. This features requires a valid license key to work and it is not supported for local sites.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 1,
+ )
+ );
- $this->add_field('sites', 'wordpress_features_heading', array(
- 'title' => __('WordPress Features', 'wp-ultimo'),
- 'desc' => __('Override default WordPress settings for network Sites.', 'wp-ultimo'),
- 'type' => 'header',
- ));
+ $this->add_field(
+ 'sites',
+ 'wordpress_features_heading',
+ array(
+ 'title' => __('WordPress Features', 'wp-ultimo'),
+ 'desc' => __('Override default WordPress settings for network Sites.', 'wp-ultimo'),
+ 'type' => 'header',
+ )
+ );
- $this->add_field('sites', 'menu_items_plugin', array(
- 'title' => __('Enable Plugins Menu', 'wp-ultimo'),
- 'desc' => __('Do you want to let users on the network to have access to the Plugins page, activating plugins for their sites? If this option is disabled, the customer will not be able to manage the site plugins.', 'wp-ultimo'),
- 'tooltip' => __('You can select which plugins the user will be able to use for each plan.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 1,
- ));
+ $this->add_field(
+ 'sites',
+ 'menu_items_plugin',
+ array(
+ 'title' => __('Enable Plugins Menu', 'wp-ultimo'),
+ 'desc' => __('Do you want to let users on the network to have access to the Plugins page, activating plugins for their sites? If this option is disabled, the customer will not be able to manage the site plugins.', 'wp-ultimo'),
+ 'tooltip' => __('You can select which plugins the user will be able to use for each plan.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 1,
+ )
+ );
- $this->add_field('sites', 'add_new_users', array(
- 'title' => __('Add New Users', 'wp-ultimo'),
- 'desc' => __('Allow site administrators to add new users to their site via the "Users → Add New" page.', 'wp-ultimo'),
- 'tooltip' => __('You can limit the number of users allowed for each plan.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 1,
- ));
+ $this->add_field(
+ 'sites',
+ 'add_new_users',
+ array(
+ 'title' => __('Add New Users', 'wp-ultimo'),
+ 'desc' => __('Allow site administrators to add new users to their site via the "Users → Add New" page.', 'wp-ultimo'),
+ 'tooltip' => __('You can limit the number of users allowed for each plan.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 1,
+ )
+ );
- $this->add_field('sites', 'site_template_features_heading', array(
- 'title' => __('Site Template Options', 'wp-ultimo'),
- 'desc' => __('Configure certain aspects of how Site Templates behave.', 'wp-ultimo'),
- 'type' => 'header',
- ));
+ $this->add_field(
+ 'sites',
+ 'site_template_features_heading',
+ array(
+ 'title' => __('Site Template Options', 'wp-ultimo'),
+ 'desc' => __('Configure certain aspects of how Site Templates behave.', 'wp-ultimo'),
+ 'type' => 'header',
+ )
+ );
- $this->add_field('sites', 'allow_template_switching', array(
- 'title' => __('Allow Template Switching', 'wp-ultimo'),
- 'desc' => __("Enabling this option will add an option on your client's dashboard to switch their site template to another one available on the catalog of available templates. The data is lost after a switch as the data from the new template is copied over.", 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 1,
- ));
+ $this->add_field(
+ 'sites',
+ 'allow_template_switching',
+ array(
+ 'title' => __('Allow Template Switching', 'wp-ultimo'),
+ 'desc' => __("Enabling this option will add an option on your client's dashboard to switch their site template to another one available on the catalog of available templates. The data is lost after a switch as the data from the new template is copied over.", 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 1,
+ )
+ );
- $this->add_field('sites', 'allow_own_site_as_template', array(
- 'title' => __('Allow Users to use their own Sites as Templates', 'wp-ultimo'),
- 'desc' => __('Enabling this option will add the user own sites to the template screen, allowing them to create a new site based on the content and customizations they made previously.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 0,
- 'require' => array(
- 'allow_template_switching' => true,
- ),
- ));
+ $this->add_field(
+ 'sites',
+ 'allow_own_site_as_template',
+ array(
+ 'title' => __('Allow Users to use their own Sites as Templates', 'wp-ultimo'),
+ 'desc' => __('Enabling this option will add the user own sites to the template screen, allowing them to create a new site based on the content and customizations they made previously.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 0,
+ 'require' => array(
+ 'allow_template_switching' => true,
+ ),
+ )
+ );
- $this->add_field('sites', 'copy_media', array(
- 'title' => __('Copy Media on Template Duplication?', 'wp-ultimo'),
- 'desc' => __('Checking this option will copy the media uploaded on the template site to the newly created site. This can be overridden on each of the plans.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 1,
- ));
+ $this->add_field(
+ 'sites',
+ 'copy_media',
+ array(
+ 'title' => __('Copy Media on Template Duplication?', 'wp-ultimo'),
+ 'desc' => __('Checking this option will copy the media uploaded on the template site to the newly created site. This can be overridden on each of the plans.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 1,
+ )
+ );
- $this->add_field('sites', 'stop_template_indexing', array(
- 'title' => __('Prevent Search Engines from indexing Site Templates', 'wp-ultimo'),
- 'desc' => __('Checking this option will discourage search engines from indexing all the Site Templates on your network.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 0,
- ));
+ $this->add_field(
+ 'sites',
+ 'stop_template_indexing',
+ array(
+ 'title' => __('Prevent Search Engines from indexing Site Templates', 'wp-ultimo'),
+ 'desc' => __('Checking this option will discourage search engines from indexing all the Site Templates on your network.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 0,
+ )
+ );
do_action('wu_settings_site_templates');
@@ -1111,84 +1287,119 @@ class Settings {
* This section holds the Payment Gateways settings of the WP Multisite WaaS Plugin.
*/
- $this->add_section('payment-gateways', array(
- 'title' => __('Payments', 'wp-ultimo'),
- 'desc' => __('Payments', 'wp-ultimo'),
- 'icon' => 'dashicons-wu-credit-card',
- ));
+ $this->add_section(
+ 'payment-gateways',
+ array(
+ 'title' => __('Payments', 'wp-ultimo'),
+ 'desc' => __('Payments', 'wp-ultimo'),
+ 'icon' => 'dashicons-wu-credit-card',
+ )
+ );
- $this->add_field('payment-gateways', 'main_header', array(
- 'title' => __('Payment Settings', 'wp-ultimo'),
- 'desc' => __('The following options affect how prices are displayed on the frontend, the backend and in reports.', 'wp-ultimo'),
- 'type' => 'header',
- 'show_as_submenu' => true,
- ));
+ $this->add_field(
+ 'payment-gateways',
+ 'main_header',
+ array(
+ 'title' => __('Payment Settings', 'wp-ultimo'),
+ 'desc' => __('The following options affect how prices are displayed on the frontend, the backend and in reports.', 'wp-ultimo'),
+ 'type' => 'header',
+ 'show_as_submenu' => true,
+ )
+ );
- $this->add_field('payment-gateways', 'force_auto_renew', array(
- 'title' => __('Force Auto-Renew', 'wp-ultimo'),
- 'desc' => __('Enable this option if you want to make sure memberships are created with auto-renew activated whenever the selected gateway supports it. Disabling this option will show an auto-renew option during checkout.', 'wp-ultimo'),
- 'tooltip' => '',
- 'type' => 'toggle',
- 'default' => 1,
- ));
+ $this->add_field(
+ 'payment-gateways',
+ 'force_auto_renew',
+ array(
+ 'title' => __('Force Auto-Renew', 'wp-ultimo'),
+ 'desc' => __('Enable this option if you want to make sure memberships are created with auto-renew activated whenever the selected gateway supports it. Disabling this option will show an auto-renew option during checkout.', 'wp-ultimo'),
+ 'tooltip' => '',
+ 'type' => 'toggle',
+ 'default' => 1,
+ )
+ );
- $this->add_field('payment-gateways', 'allow_trial_without_payment_method', array(
- 'title' => __('Allow Trials without Payment Method', 'wp-ultimo'),
- 'desc' => __('By default, WP Multisite WaaS asks customers to add a payment method on sign-up even if a trial period is present. Enable this option to only ask for a payment method when the trial period is over.', 'wp-ultimo'),
- 'tooltip' => '',
- 'type' => 'toggle',
- 'default' => 0,
- ));
+ $this->add_field(
+ 'payment-gateways',
+ 'allow_trial_without_payment_method',
+ array(
+ 'title' => __('Allow Trials without Payment Method', 'wp-ultimo'),
+ 'desc' => __('By default, WP Multisite WaaS asks customers to add a payment method on sign-up even if a trial period is present. Enable this option to only ask for a payment method when the trial period is over.', 'wp-ultimo'),
+ 'tooltip' => '',
+ 'type' => 'toggle',
+ 'default' => 0,
+ )
+ );
- $this->add_field('payment-gateways', 'attach_invoice_pdf', array(
- 'title' => __('Send Invoice on Payment Confirmation', 'wp-ultimo'),
- 'desc' => __('Enabling this option will attach a PDF invoice (marked paid) with the payment confirmation email. This option does not apply to the Manual Gateway, which sends invoices regardless of this option.', 'wp-ultimo'),
- 'tooltip' => __('The invoice files will be saved on the wp-content/uploads/wu-invoices folder.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 1,
- ));
+ $this->add_field(
+ 'payment-gateways',
+ 'attach_invoice_pdf',
+ array(
+ 'title' => __('Send Invoice on Payment Confirmation', 'wp-ultimo'),
+ 'desc' => __('Enabling this option will attach a PDF invoice (marked paid) with the payment confirmation email. This option does not apply to the Manual Gateway, which sends invoices regardless of this option.', 'wp-ultimo'),
+ 'tooltip' => __('The invoice files will be saved on the wp-content/uploads/wu-invoices folder.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 1,
+ )
+ );
- $this->add_field('payment-gateways', 'invoice_numbering_scheme', array(
- 'title' => __('Invoice Numbering Scheme', 'wp-ultimo'),
- 'desc' => __('What should WP Multisite WaaS use as the invoice number?', 'wp-ultimo'),
- 'type' => 'select',
- 'default' => 'reference_code',
- 'tooltip' => '',
- 'options' => array(
- 'reference_code' => __('Payment Reference Code', 'wp-ultimo'),
- 'sequential_number' => __('Sequential Number', 'wp-ultimo'),
- ),
- ));
+ $this->add_field(
+ 'payment-gateways',
+ 'invoice_numbering_scheme',
+ array(
+ 'title' => __('Invoice Numbering Scheme', 'wp-ultimo'),
+ 'desc' => __('What should WP Multisite WaaS use as the invoice number?', 'wp-ultimo'),
+ 'type' => 'select',
+ 'default' => 'reference_code',
+ 'tooltip' => '',
+ 'options' => array(
+ 'reference_code' => __('Payment Reference Code', 'wp-ultimo'),
+ 'sequential_number' => __('Sequential Number', 'wp-ultimo'),
+ ),
+ )
+ );
- $this->add_field('payment-gateways', 'next_invoice_number', array(
- 'title' => __('Next Invoice Number', 'wp-ultimo'),
- 'desc' => __('This number will be used as the invoice number for the next invoice generated on the system. It is incremented by one every time a new invoice is created. You can change it and save it to reset the invoice sequential number to a specific value.', 'wp-ultimo'),
- 'type' => 'number',
- 'default' => '1',
- 'min' => 0,
- 'require' => array(
- 'invoice_numbering_scheme' => 'sequential_number',
- ),
- ));
+ $this->add_field(
+ 'payment-gateways',
+ 'next_invoice_number',
+ array(
+ 'title' => __('Next Invoice Number', 'wp-ultimo'),
+ 'desc' => __('This number will be used as the invoice number for the next invoice generated on the system. It is incremented by one every time a new invoice is created. You can change it and save it to reset the invoice sequential number to a specific value.', 'wp-ultimo'),
+ 'type' => 'number',
+ 'default' => '1',
+ 'min' => 0,
+ 'require' => array(
+ 'invoice_numbering_scheme' => 'sequential_number',
+ ),
+ )
+ );
- $this->add_field('payment-gateways', 'invoice_prefix', array(
- 'title' => __('Invoice Number Prefix', 'wp-ultimo'),
- 'placeholder' => __('INV00', 'wp-ultimo'),
+ $this->add_field(
+ 'payment-gateways',
+ 'invoice_prefix',
+ array(
+ 'title' => __('Invoice Number Prefix', 'wp-ultimo'),
+ 'placeholder' => __('INV00', 'wp-ultimo'),
'desc' => sprintf(__('Use %%YEAR%%, %%MONTH%%, and %%DAY%% to create a dynamic placeholder. E.g. %%YEAR%%-%%MONTH%%-INV will become %s.', 'wp-ultimo'), date('Y') . '-' . date('m') . '-INV'), // phpcs:ignore
- 'default' => '',
- 'type' => 'text',
- 'raw' => true, // Necessary to prevent the removal of the %% tags.
- 'require' => array(
+ 'default' => '',
+ 'type' => 'text',
+ 'raw' => true, // Necessary to prevent the removal of the %% tags.
+ 'require' => array(
'invoice_numbering_scheme' => 'sequential_number',
),
- ));
+ )
+ );
- $this->add_field('payment-gateways', 'gateways_header', array(
- 'title' => __('Payment Gateways', 'wp-ultimo'),
- 'desc' => __('Activate and configure the installed payment gateways in this section.', 'wp-ultimo'),
- 'type' => 'header',
- 'show_as_submenu' => true,
- ));
+ $this->add_field(
+ 'payment-gateways',
+ 'gateways_header',
+ array(
+ 'title' => __('Payment Gateways', 'wp-ultimo'),
+ 'desc' => __('Activate and configure the installed payment gateways in this section.', 'wp-ultimo'),
+ 'type' => 'header',
+ 'show_as_submenu' => true,
+ )
+ );
do_action('wu_settings_payment_gateways');
@@ -1196,24 +1407,30 @@ class Settings {
* Emails
* This section holds the Email settings of the WP Multisite WaaS Plugin.
*/
- $this->add_section('emails', array(
- 'title' => __('Emails', 'wp-ultimo'),
- 'desc' => __('Emails', 'wp-ultimo'),
- 'icon' => 'dashicons-wu-email',
- ));
+ $this->add_section(
+ 'emails',
+ array(
+ 'title' => __('Emails', 'wp-ultimo'),
+ 'desc' => __('Emails', 'wp-ultimo'),
+ 'icon' => 'dashicons-wu-email',
+ )
+ );
do_action('wu_settings_emails');
- /*
+ /*
* Domain Mapping
* This section holds the Domain Mapping settings of the WP Multisite WaaS Plugin.
*/
- $this->add_section('domain-mapping', array(
- 'title' => __('Domain Mapping', 'wp-ultimo'),
- 'desc' => __('Domain Mapping', 'wp-ultimo'),
- 'icon' => 'dashicons-wu-link',
- ));
+ $this->add_section(
+ 'domain-mapping',
+ array(
+ 'title' => __('Domain Mapping', 'wp-ultimo'),
+ 'desc' => __('Domain Mapping', 'wp-ultimo'),
+ 'icon' => 'dashicons-wu-link',
+ )
+ );
do_action('wu_settings_domain_mapping');
@@ -1222,11 +1439,14 @@ class Settings {
* This section includes settings related to the single sign-on functionality
*/
- $this->add_section('sso', array(
- 'title' => __('Single Sign-On', 'wp-ultimo'),
- 'desc' => __('Single Sign-On', 'wp-ultimo'),
- 'icon' => 'dashicons-wu-add-user',
- ));
+ $this->add_section(
+ 'sso',
+ array(
+ 'title' => __('Single Sign-On', 'wp-ultimo'),
+ 'desc' => __('Single Sign-On', 'wp-ultimo'),
+ 'icon' => 'dashicons-wu-add-user',
+ )
+ );
do_action('wu_settings_sso');
@@ -1235,18 +1455,25 @@ class Settings {
* This section holds the Integrations settings of the WP Multisite WaaS Plugin.
*/
- $this->add_section('integrations', array(
- 'title' => __('Integrations', 'wp-ultimo'),
- 'desc' => __('Integrations', 'wp-ultimo'),
- 'icon' => 'dashicons-wu-power-plug',
- ));
+ $this->add_section(
+ 'integrations',
+ array(
+ 'title' => __('Integrations', 'wp-ultimo'),
+ 'desc' => __('Integrations', 'wp-ultimo'),
+ 'icon' => 'dashicons-wu-power-plug',
+ )
+ );
- $this->add_field('integrations', 'hosting_providers_header', array(
- 'title' => __('Hosting or Panel Providers', 'wp-ultimo'),
- 'desc' => __('Configure and manage the integration with your Hosting or Panel Provider.', 'wp-ultimo'),
- 'type' => 'header',
- 'show_as_submenu' => true,
- ));
+ $this->add_field(
+ 'integrations',
+ 'hosting_providers_header',
+ array(
+ 'title' => __('Hosting or Panel Providers', 'wp-ultimo'),
+ 'desc' => __('Configure and manage the integration with your Hosting or Panel Provider.', 'wp-ultimo'),
+ 'type' => 'header',
+ 'show_as_submenu' => true,
+ )
+ );
do_action('wu_settings_integrations');
@@ -1255,76 +1482,108 @@ class Settings {
* This section holds the Other Options settings of the WP Multisite WaaS Plugin.
*/
- $this->add_section('other', array(
- 'title' => __('Other Options', 'wp-ultimo'),
- 'desc' => __('Other Options', 'wp-ultimo'),
- 'icon' => 'dashicons-wu-switch',
- 'order' => 1000,
- ));
+ $this->add_section(
+ 'other',
+ array(
+ 'title' => __('Other Options', 'wp-ultimo'),
+ 'desc' => __('Other Options', 'wp-ultimo'),
+ 'icon' => 'dashicons-wu-switch',
+ 'order' => 1000,
+ )
+ );
- $this->add_field('other', 'Other_header', array(
- 'title' => __('Miscellaneous', 'wp-ultimo'),
- 'desc' => __('Other options that do not fit anywhere else.', 'wp-ultimo'),
- 'type' => 'header',
- ));
+ $this->add_field(
+ 'other',
+ 'Other_header',
+ array(
+ 'title' => __('Miscellaneous', 'wp-ultimo'),
+ 'desc' => __('Other options that do not fit anywhere else.', 'wp-ultimo'),
+ 'type' => 'header',
+ )
+ );
$preview_image = wu_preview_image(wu_get_asset('settings/settings-hide-ui-tours.png'));
- $this->add_field('other', 'hide_tours', array(
- 'title' => __('Hide UI Tours', 'wp-ultimo') . $preview_image,
- 'desc' => __('The UI tours showed by WP Multisite WaaS should permanently hide themselves after being seen but if they persist for whatever reason, toggle this option to force them into their viewed state - which will prevent them from showing up again.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 0,
- ));
+ $this->add_field(
+ 'other',
+ 'hide_tours',
+ array(
+ 'title' => __('Hide UI Tours', 'wp-ultimo') . $preview_image,
+ 'desc' => __('The UI tours showed by WP Multisite WaaS should permanently hide themselves after being seen but if they persist for whatever reason, toggle this option to force them into their viewed state - which will prevent them from showing up again.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 0,
+ )
+ );
$preview_image_2 = wu_preview_image(wu_get_asset('settings/settings-disable-hover-to-zoom.png'));
- $this->add_field('other', 'disable_image_zoom', array(
- 'title' => __('Disable "Hover to Zoom"', 'wp-ultimo') . $preview_image_2,
- 'desc' => __('By default, WP Multisite WaaS adds a "hover to zoom" feature, allowing network admins to see larger version of site screenshots and other images across the UI in full-size when hovering over them. You can disable that feature here. Preview tags like the above are not affected.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 0,
- ));
+ $this->add_field(
+ 'other',
+ 'disable_image_zoom',
+ array(
+ 'title' => __('Disable "Hover to Zoom"', 'wp-ultimo') . $preview_image_2,
+ 'desc' => __('By default, WP Multisite WaaS adds a "hover to zoom" feature, allowing network admins to see larger version of site screenshots and other images across the UI in full-size when hovering over them. You can disable that feature here. Preview tags like the above are not affected.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 0,
+ )
+ );
- $this->add_field('other', 'error_reporting_header', array(
- 'title' => __('Logging', 'wp-ultimo'),
- 'desc' => __('Log WP Multisite WaaS data. This is useful for debugging purposes.', 'wp-ultimo'),
- 'type' => 'header',
- ));
+ $this->add_field(
+ 'other',
+ 'error_reporting_header',
+ array(
+ 'title' => __('Logging', 'wp-ultimo'),
+ 'desc' => __('Log WP Multisite WaaS data. This is useful for debugging purposes.', 'wp-ultimo'),
+ 'type' => 'header',
+ )
+ );
- $this->add_field('other', 'error_logging_level', array(
- 'title' => __('Logging Level', 'wp-ultimo'),
- 'desc' => __('Select the level of logging you want to use.', 'wp-ultimo'),
- 'type' => 'select',
- 'default' => 'default',
- 'options' => array(
- 'default' => __('PHP Default', 'wp-ultimo'),
- 'disabled' => __('Disabled', 'wp-ultimo'),
- 'errors' => __('Errors Only', 'wp-ultimo'),
- 'all' => __('Everything', 'wp-ultimo'),
- ),
- ));
+ $this->add_field(
+ 'other',
+ 'error_logging_level',
+ array(
+ 'title' => __('Logging Level', 'wp-ultimo'),
+ 'desc' => __('Select the level of logging you want to use.', 'wp-ultimo'),
+ 'type' => 'select',
+ 'default' => 'default',
+ 'options' => array(
+ 'default' => __('PHP Default', 'wp-ultimo'),
+ 'disabled' => __('Disabled', 'wp-ultimo'),
+ 'errors' => __('Errors Only', 'wp-ultimo'),
+ 'all' => __('Everything', 'wp-ultimo'),
+ ),
+ )
+ );
- $this->add_field('other', 'enable_error_reporting', array(
- 'title' => __('Send Error Data to WP Multisite WaaS Developers', 'wp-ultimo'),
- 'desc' => __('With this option enabled, every time your installation runs into an error related to WP Multisite WaaS, that error data will be sent to us. No sensitive data gets collected, only environmental stuff (e.g. if this is this is a subdomain network, etc).', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 1,
- ));
+ $this->add_field(
+ 'other',
+ 'enable_error_reporting',
+ array(
+ 'title' => __('Send Error Data to WP Multisite WaaS Developers', 'wp-ultimo'),
+ 'desc' => __('With this option enabled, every time your installation runs into an error related to WP Multisite WaaS, that error data will be sent to us. No sensitive data gets collected, only environmental stuff (e.g. if this is this is a subdomain network, etc).', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 1,
+ )
+ );
- $this->add_field('other', 'advanced_header', array(
- 'title' => __('Advanced Options', 'wp-ultimo'),
- 'desc' => __('Change the plugin and wordpress behavior.', 'wp-ultimo'),
- 'type' => 'header',
- ));
+ $this->add_field(
+ 'other',
+ 'advanced_header',
+ array(
+ 'title' => __('Advanced Options', 'wp-ultimo'),
+ 'desc' => __('Change the plugin and wordpress behavior.', 'wp-ultimo'),
+ 'type' => 'header',
+ )
+ );
- $plans = get_posts(array(
- 'post_type' => 'wpultimo_plan',
- 'numberposts' => 1,
- ));
-
- if (!empty($plans)) {
+ $plans = get_posts(
+ array(
+ 'post_type' => 'wpultimo_plan',
+ 'numberposts' => 1,
+ )
+ );
+ if ( ! empty($plans)) {
$url = wu_network_admin_url('wp-ultimo-migration-alert');
$title = __('Run Migration Again', 'wp-ultimo') . sprintf(
@@ -1337,13 +1596,16 @@ class Settings {
$html = sprintf('%s', $url, __('Migrate', 'wp-ultimo'));
- $this->add_field('other', 'run_migration', array(
- 'title' => $title,
- 'type' => 'note',
- 'desc' => $html,
- ));
-
- } // end if;
+ $this->add_field(
+ 'other',
+ 'run_migration',
+ array(
+ 'title' => $title,
+ 'type' => 'note',
+ 'desc' => $html,
+ )
+ );
+ }
if (function_exists('wu_get_security_mode_key')) {
/**
@@ -1351,24 +1613,30 @@ class Settings {
*/
$security_mode_key = '?wu_secure=' . wu_get_security_mode_key();
- $this->add_field('other', 'security_mode', array(
- 'title' => __('Security Mode', 'wp-ultimo'),
- // Translators: Placeholder adds the security mode key and current site url with query string
- 'desc' => sprintf(__('Only WP Multisite WaaS and other must-use plugins will run on your WordPress install while this option is enabled.
Important: Copy the following URL to disable security mode if something goes wrong and this page becomes unavailable:%2$s
', 'wp-ultimo'), $security_mode_key, get_site_url() . $security_mode_key),
+ $this->add_field(
+ 'other',
+ 'security_mode',
+ array(
+ 'title' => __('Security Mode', 'wp-ultimo'),
+ // Translators: Placeholder adds the security mode key and current site url with query string
+ 'desc' => sprintf(__('Only WP Multisite WaaS and other must-use plugins will run on your WordPress install while this option is enabled.
Important: Copy the following URL to disable security mode if something goes wrong and this page becomes unavailable:%2$s
', 'wp-ultimo'), $security_mode_key, get_site_url() . $security_mode_key),
+ 'type' => 'toggle',
+ 'default' => 0,
+ )
+ );
+ }
+
+ $this->add_field(
+ 'other',
+ 'uninstall_wipe_tables',
+ array(
+ 'title' => __('Remove Data on Uninstall', 'wp-ultimo'),
+ 'desc' => __('Remove all saved data for WP Multisite WaaS when the plugin is uninstalled.', 'wp-ultimo'),
'type' => 'toggle',
'default' => 0,
- ));
-
- } // end if;
-
- $this->add_field('other', 'uninstall_wipe_tables', array(
- 'title' => __('Remove Data on Uninstall', 'wp-ultimo'),
- 'desc' => __('Remove all saved data for WP Multisite WaaS when the plugin is uninstalled.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 0,
- ));
-
- } // end default_sections;
+ )
+ );
+ }
/**
* Tries to determine the location of the company based on the admin IP.
@@ -1381,7 +1649,5 @@ class Settings {
$geolocation = \WP_Ultimo\Geolocation::geolocate_ip('', true);
return $geolocation['country'];
-
- } // end get_default_company_country;
-
-} // end class Settings;
+ }
+}
diff --git a/inc/class-sunrise.php b/inc/class-sunrise.php
index 6e51048..d85087b 100644
--- a/inc/class-sunrise.php
+++ b/inc/class-sunrise.php
@@ -60,7 +60,7 @@ class Sunrise {
* Domain mapping needs to be loaded
* before anything else.
*/
- \WP_Ultimo\Sunrise::load_domain_mapping();
+ self::load_domain_mapping();
/**
* Enqueue the main hooks that deal with Sunrise
@@ -73,8 +73,7 @@ class Sunrise {
add_action('init', array('\WP_Ultimo\Sunrise', 'maybe_tap_on_init'));
add_filter('wu_system_info_data', array('\WP_Ultimo\Sunrise', 'system_info'));
-
- } // end init;
+ }
/**
* Checks if all the requirements for sunrise loading are in place.
@@ -95,8 +94,7 @@ class Sunrise {
$should_load_sunrise = wu_should_load_sunrise();
return $setup_finished && $should_load_sunrise;
-
- } // end should_startup;
+ }
/**
* Load dependencies, if we need them somewhere.
@@ -139,9 +137,7 @@ class Sunrise {
require_once __DIR__ . '/class-settings.php';
require_once __DIR__ . '/limits/class-plugin-limits.php';
require_once __DIR__ . '/limits/class-theme-limits.php';
-
-
- } // end load_dependencies;
+ }
/**
* Loads domain mapping before anything else.
@@ -151,11 +147,10 @@ class Sunrise {
*/
public static function load_domain_mapping() {
- $should_startup = \WP_Ultimo\Sunrise::should_startup();
+ $should_startup = self::should_startup();
if ($should_startup) {
-
- \WP_Ultimo\Sunrise::load_dependencies();
+ self::load_dependencies();
/*
* Primary Domain capabilities
@@ -163,10 +158,8 @@ class Sunrise {
\WP_Ultimo\Domain_Mapping\Primary_Domain::get_instance();
\WP_Ultimo\Domain_Mapping::get_instance();
-
- } // end if;
-
- } // end load_domain_mapping;
+ }
+ }
/**
* Loads the Sunrise components, if needed.
@@ -176,7 +169,7 @@ class Sunrise {
*/
public static function load() {
- $should_startup = \WP_Ultimo\Sunrise::should_startup();
+ $should_startup = self::should_startup();
if ($should_startup) {
/**
@@ -202,7 +195,7 @@ class Sunrise {
/**
* Define the WP Multisite WaaS main debug constant.
*/
- !defined('WP_ULTIMO_DEBUG') && define('WP_ULTIMO_DEBUG', false);
+ ! defined('WP_ULTIMO_DEBUG') && define('WP_ULTIMO_DEBUG', false);
/**
* Check if we are using security mode.
@@ -210,11 +203,8 @@ class Sunrise {
$security_mode = (bool) (int) wu_get_setting_early('security_mode');
if ($security_mode) {
-
if (wu_get_isset($_GET, 'wu_secure') === wu_get_security_mode_key()) {
-
wu_save_setting_early('security_mode', false);
-
} else {
/**
* Disable all plugins except WP Multisite WaaS
@@ -222,14 +212,10 @@ class Sunrise {
add_filter('option_active_plugins', fn() => array());
add_filter('site_option_active_sitewide_plugins', fn($plugins) => array(basename(dirname(__DIR__)) . '/wp-ultimo.php' => 1));
-
- } // end if;
-
- } // end if;
-
- } // end if;
-
- } // end load;
+ }
+ }
+ }
+ }
/**
* Adds an additional hook that runs after ms_loaded.
@@ -246,8 +232,7 @@ class Sunrise {
public static function loaded() {
do_action('wu_sunrise_loaded');
-
- } // end loaded;
+ }
/**
* Checks if we need to upgrade the sunrise version on wp-content
@@ -262,12 +247,9 @@ class Sunrise {
$old_version = defined('WP_ULTIMO_SUNRISE_VERSION') ? WP_ULTIMO_SUNRISE_VERSION : '0.0.1';
if (version_compare($old_version, self::$version, '<')) {
-
- \WP_Ultimo\Sunrise::try_upgrade();
-
- } // end if;
-
- } // end manage_sunrise_updates;
+ self::try_upgrade();
+ }
+ }
/**
* Upgrades the sunrise file, if necessary.
@@ -290,49 +272,38 @@ class Sunrise {
$location = WP_CONTENT_DIR . '/sunrise.php';
foreach ($possible_sunrises as $new_file) {
-
- if (!file_exists($new_file)) {
-
+ if ( ! file_exists($new_file)) {
continue;
-
- } // end if;
+ }
$sunrise_found = true;
$copy_results = @copy($new_file, $location); // phpcs:ignore
- if (!$copy_results) {
-
+ if ( ! $copy_results) {
$error = error_get_last();
continue;
-
- } // end if;
+ }
wu_log_add('sunrise', __('Sunrise upgrade attempt succeeded.', 'wp-ultimo'));
return true;
-
- } // end foreach;
+ }
if ($sunrise_found === false) {
-
$error = array(
'message' => __('File not found.', 'wp-ultimo'),
);
+ }
- } // end if;
-
- if (!empty($error)) {
-
+ if ( ! empty($error)) {
wu_log_add('sunrise', $error['message'], LogLevel::ERROR);
/* translators: the placeholder is an error message */
return new \WP_Error('error', sprintf(__('Sunrise copy failed: %s', 'wp-ultimo'), $error['message']));
-
- } // end if;
-
- } // end try_upgrade;
+ }
+ }
/**
* Reads the sunrise meta file and loads it to the static cache.
@@ -345,27 +316,22 @@ class Sunrise {
*/
protected static function read_sunrise_meta() {
- if (is_array(\WP_Ultimo\Sunrise::$sunrise_meta)) {
-
- return \WP_Ultimo\Sunrise::$sunrise_meta;
-
- } // end if;
+ if (is_array(self::$sunrise_meta)) {
+ return self::$sunrise_meta;
+ }
$sunrise_meta = get_network_option(null, 'wu_sunrise_meta', null);
$existing = array();
if ($sunrise_meta) {
-
$existing = $sunrise_meta;
self::$sunrise_meta = $existing;
-
- } // end if;
+ }
return $existing;
-
- } // end read_sunrise_meta;
+ }
/**
* Method for imputing Sunrise data at wp-ultimo-system-info table.
@@ -376,9 +342,10 @@ class Sunrise {
*/
public static function system_info($sys_info) {
- $data = Sunrise::read_sunrise_meta();
+ $data = self::read_sunrise_meta();
- $sys_info = array_merge($sys_info,
+ $sys_info = array_merge(
+ $sys_info,
array(
'Sunrise Data' => array(
'sunrise-status' => array(
@@ -389,7 +356,7 @@ class Sunrise {
'sunrise-data' => array(
'tooltip' => '',
'title' => 'Version',
- 'value' => Sunrise::$version
+ 'value' => self::$version,
),
'sunrise-created' => array(
'tooltip' => '',
@@ -410,14 +377,13 @@ class Sunrise {
'tooltip' => '',
'title' => 'Last Modified',
'value' => gmdate('Y-m-d @ H:i:s', $data['last_modified']),
- )
+ ),
),
)
);
return $sys_info;
-
- } // end system_info;
+ }
/**
* Checks if the sunrise extra modules need to be loaded.
@@ -427,11 +393,10 @@ class Sunrise {
*/
public static function should_load_sunrise() {
- $meta = \WP_Ultimo\Sunrise::read_sunrise_meta();
+ $meta = self::read_sunrise_meta();
return wu_get_isset($meta, 'active', false);
-
- } // end should_load_sunrise;
+ }
/**
* Makes sure the meta file accurately reflects the state of the main plugin.
@@ -443,9 +408,8 @@ class Sunrise {
$state = function_exists('WP_Ultimo') && WP_Ultimo()->is_loaded();
- \WP_Ultimo\Sunrise::maybe_tap($state ? 'activating' : 'deactivating');
-
- } // end maybe_tap_on_init;
+ self::maybe_tap($state ? 'activating' : 'deactivating');
+ }
/**
* Updates the sunrise meta file, if an update is due.
@@ -457,23 +421,18 @@ class Sunrise {
*/
public static function maybe_tap($mode = 'activating') {
- $meta = \WP_Ultimo\Sunrise::read_sunrise_meta();
+ $meta = self::read_sunrise_meta();
$is_active = isset($meta['active']) && $meta['active'];
if ($is_active && $mode === 'activating') {
-
return false;
-
- } elseif (!$is_active && $mode === 'deactivating') {
-
+ } elseif ( ! $is_active && $mode === 'deactivating') {
return false;
+ }
- } // end if;
-
- return (bool) \WP_Ultimo\Sunrise::tap($mode, $meta);
-
- } // end maybe_tap;
+ return (bool) self::tap($mode, $meta);
+ }
/**
* Updates the sunrise meta file.
@@ -488,36 +447,31 @@ class Sunrise {
$now = gmdate('U');
- $to_save = wp_parse_args($existing, array(
- 'active' => false,
- 'created' => $now,
- 'last_activated' => 'unknown',
- 'last_deactivated' => 'unknown',
- ));
+ $to_save = wp_parse_args(
+ $existing,
+ array(
+ 'active' => false,
+ 'created' => $now,
+ 'last_activated' => 'unknown',
+ 'last_deactivated' => 'unknown',
+ )
+ );
if ($mode === 'activating') {
-
$to_save['active'] = true;
$to_save['last_activated'] = $now;
-
} elseif ($mode === 'deactivating') {
-
$to_save['active'] = false;
$to_save['last_deactivated'] = $now;
-
} else {
-
return false;
-
- } // end if;
+ }
$to_save['last_modified'] = $now;
return update_network_option(null, 'wu_sunrise_meta', $to_save);
-
- } // end tap;
+ }
// phpcs:ignore
- private function __construct() {} // end __construct;
-
-} // end class Sunrise;
+ private function __construct() {}
+}
diff --git a/inc/class-user-switching.php b/inc/class-user-switching.php
index d646649..e0fe985 100644
--- a/inc/class-user-switching.php
+++ b/inc/class-user-switching.php
@@ -29,8 +29,7 @@ class User_Switching {
public function __construct() {
add_action('plugins_loaded', array($this, 'register_forms'));
-
- } // end __construct;
+ }
/**
* Check if Plugin User Switching is activated
*
@@ -39,8 +38,7 @@ class User_Switching {
public function check_user_switching_is_activated(): bool {
return class_exists('user_switching');
-
- } // end check_user_switching_is_activated;
+ }
/**
* Register forms
@@ -51,11 +49,13 @@ class User_Switching {
*/
public function register_forms() {
- wu_register_form('install_user_switching', array(
- 'render' => array($this, 'render_install_user_switching'),
- ));
-
- } // end register_forms;
+ wu_register_form(
+ 'install_user_switching',
+ array(
+ 'render' => array($this, 'render_install_user_switching'),
+ )
+ );
+ }
/**
* Create Install Form of User Switching
@@ -79,26 +79,31 @@ class User_Switching {
'classes' => 'button button-primary wu-w-full',
'wrapper_classes' => 'wu-items-end wu-text-center wu-bg-gray-100',
'html_attr' => array(
- 'href' => add_query_arg(array(
- 's' => 'user-switching',
- 'tab' => 'search',
- 'type' => 'tag'
- ), network_admin_url('plugin-install.php')
+ 'href' => add_query_arg(
+ array(
+ 's' => 'user-switching',
+ 'tab' => 'search',
+ 'type' => 'tag',
+ ),
+ network_admin_url('plugin-install.php')
),
),
),
);
- $form = new \WP_Ultimo\UI\Form('install_user_switching', $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(),
- ));
+ $form = new \WP_Ultimo\UI\Form(
+ 'install_user_switching',
+ $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(),
+ )
+ );
$form->render();
-
- } // end render_install_user_switching;
+ }
/**
* This function return should return the correct url
@@ -113,18 +118,12 @@ class User_Switching {
$user = new \WP_User($user_id);
- if (!$this->check_user_switching_is_activated()) {
-
+ if ( ! $this->check_user_switching_is_activated()) {
return wu_get_form_url('install_user_switching');
-
} else {
-
$link = \user_switching::switch_to_url($user);
return $link;
-
- } // end if;
-
- } // end render;
-
-} // end class User_Switching;
+ }
+ }
+}
diff --git a/inc/class-views.php b/inc/class-views.php
index 3db02d8..3738a8d 100644
--- a/inc/class-views.php
+++ b/inc/class-views.php
@@ -29,8 +29,7 @@ class Views {
public function init() {
add_filter('wu_view_override', array($this, 'view_override'), 10, 3);
-
- } // end init;
+ }
/**
* Custom locate template function that allows us to retrieve user overridden templates.
@@ -57,44 +56,31 @@ class Views {
$located = '';
foreach ((array) $template_names as $template_name) {
-
- if (!$template_name) {
-
+ if ( ! $template_name) {
continue;
+ }
- } // end if;
-
- if (file_exists( $stylesheet_path . '/' . $template_name)) {
-
+ if (file_exists($stylesheet_path . '/' . $template_name)) {
$located = $stylesheet_path . '/' . $template_name;
break;
-
} elseif (file_exists(get_template_directory() . '/' . $template_name)) {
-
$located = get_template_directory() . '/' . $template_name;
break;
-
} elseif (file_exists(ABSPATH . WPINC . '/theme-compat/' . $template_name)) {
-
$located = ABSPATH . WPINC . '/theme-compat/' . $template_name;
break;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
if ($load && '' !== $located) {
-
load_template($located, $require_once);
-
- } // end if;
+ }
return $located;
-
- } // end custom_locate_template;
+ }
/**
* Check if an alternative view exists and override
@@ -108,7 +94,5 @@ class Views {
$found = $this->custom_locate_template("wp-ultimo/$view.php");
return $found ? $found : $original_path;
-
- } // end view_override;
-
-} // end class Views;
+ }
+}
diff --git a/inc/class-whitelabel.php b/inc/class-whitelabel.php
index 58e99ae..8433298 100644
--- a/inc/class-whitelabel.php
+++ b/inc/class-whitelabel.php
@@ -68,8 +68,7 @@ class Whitelabel {
add_action('init', array($this, 'hooks'));
add_filter('gettext', array($this, 'replace_text'), 10, 3);
-
- } // end init;
+ }
/**
* Add the necessary hooks when the feature is enabled.
@@ -80,7 +79,6 @@ class Whitelabel {
public function hooks() {
if (wu_get_setting('hide_wordpress_logo', true)) {
-
add_action('wp_before_admin_bar_render', array($this, 'wp_logo_admin_bar_remove'), 0);
add_action('wp_user_dashboard_setup', array($this, 'remove_dashboard_widgets'), 11);
@@ -90,16 +88,12 @@ class Whitelabel {
add_action('admin_enqueue_scripts', array($this, 'enqueue_styles'));
add_action('wp_enqueue_scripts', array($this, 'enqueue_styles'));
-
- } // end if;
+ }
if (wu_get_setting('hide_sites_menu', true)) {
-
add_action('network_admin_menu', array($this, 'remove_sites_admin_menu'));
-
- } // end if;
-
- } // end hooks;
+ }
+ }
/**
* Loads the custom css file.
@@ -112,8 +106,7 @@ class Whitelabel {
WP_Ultimo()->scripts->register_style('wu-whitelabel', wu_get_asset('whitelabel.css', 'css'));
wp_enqueue_style('wu-whitelabel');
-
- } // end enqueue_styles;
+ }
/**
* Replaces the terms on the translated strings.
@@ -128,19 +121,18 @@ class Whitelabel {
public function replace_text($translation, $text, $domain) {
if ($this->allowed_domains === null) {
+ $this->allowed_domains = apply_filters(
+ 'wu_replace_text_allowed_domains',
+ array(
+ 'default',
+ 'wp-ultimo',
+ )
+ );
+ }
- $this->allowed_domains = apply_filters('wu_replace_text_allowed_domains', array(
- 'default',
- 'wp-ultimo',
- ));
-
- } // end if;
-
- if (!in_array($domain, $this->allowed_domains, true)) {
-
+ if ( ! in_array($domain, $this->allowed_domains, true)) {
return $translation;
-
- } // end if;
+ }
/**
* Prevent replacement when dealing with URLs.
@@ -153,64 +145,49 @@ class Whitelabel {
* @since 2.1.0
*/
if (strncmp($translation, 'http', strlen('http')) === 0) {
-
return $translation;
-
- } // end if;
+ }
if ($this->init === false) {
-
$search_and_replace = array();
$site_plural = wu_get_setting('rename_site_plural');
if ($site_plural) {
-
$search_and_replace['sites'] = strtolower((string) $site_plural);
$search_and_replace['Sites'] = ucfirst((string) $site_plural);
-
- } // end if;
+ }
$site_singular = wu_get_setting('rename_site_singular');
if ($site_singular) {
-
$search_and_replace['site'] = strtolower((string) $site_singular);
$search_and_replace['Site'] = ucfirst((string) $site_singular);
-
- } // end if;
+ }
$wordpress = wu_get_setting('rename_wordpress');
if ($wordpress) {
-
$search_and_replace['wordpress'] = strtolower((string) $wordpress);
$search_and_replace['WordPress'] = ucfirst((string) $wordpress);
$search_and_replace['Wordpress'] = ucfirst((string) $wordpress);
$search_and_replace['wordPress'] = ucfirst((string) $wordpress);
-
- } // end if;
+ }
if ($search_and_replace) {
-
$this->search = array_keys($search_and_replace);
$this->replace = array_values($search_and_replace);
-
- } // end if;
+ }
$this->init = true;
+ }
- } // end if;
-
- if (!empty($this->search)) {
-
+ if ( ! empty($this->search)) {
return str_replace($this->search, $this->replace, $translation);
-
- } // end if;
+ }
return $translation;
-
- } // end replace_text;
+ }
/**
* Adds the whitelabel options.
@@ -221,61 +198,87 @@ class Whitelabel {
*/
public function add_settings() {
- wu_register_settings_section('whitelabel', array(
- 'title' => __('Whitelabel', 'wp-ultimo'),
- 'desc' => __('Basic Whitelabel', 'wp-ultimo'),
- 'icon' => 'dashicons-wu-eye',
- ));
+ wu_register_settings_section(
+ 'whitelabel',
+ array(
+ 'title' => __('Whitelabel', 'wp-ultimo'),
+ 'desc' => __('Basic Whitelabel', 'wp-ultimo'),
+ 'icon' => 'dashicons-wu-eye',
+ )
+ );
- wu_register_settings_field('whitelabel', 'whitelabel_header', array(
- 'title' => __('Whitelabel', 'wp-ultimo'),
- 'desc' => __('Hide a couple specific WordPress elements and rename others.', 'wp-ultimo'),
- 'type' => 'header',
- ));
+ wu_register_settings_field(
+ 'whitelabel',
+ 'whitelabel_header',
+ array(
+ 'title' => __('Whitelabel', 'wp-ultimo'),
+ 'desc' => __('Hide a couple specific WordPress elements and rename others.', 'wp-ultimo'),
+ 'type' => 'header',
+ )
+ );
$preview_image = wu_preview_image(wu_get_asset('settings/settings-hide-wp-logo-preview.png'));
- wu_register_settings_field('whitelabel', 'hide_wordpress_logo', array(
- 'title' => __('Hide WordPress Logo', 'wp-ultimo') . $preview_image,
- 'desc' => __('Hide the WordPress logo from the top-bar and replace the same logo on the My Sites top-bar item with a more generic icon.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 1,
- ));
+ wu_register_settings_field(
+ 'whitelabel',
+ 'hide_wordpress_logo',
+ array(
+ 'title' => __('Hide WordPress Logo', 'wp-ultimo') . $preview_image,
+ 'desc' => __('Hide the WordPress logo from the top-bar and replace the same logo on the My Sites top-bar item with a more generic icon.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 1,
+ )
+ );
- wu_register_settings_field('whitelabel', 'hide_sites_menu', array(
- 'title' => __('Hide Sites Admin Menu', 'wp-ultimo'),
- 'desc' => __('We recommend that you manage all of your sites using the WP Multisite WaaS → Sites page. To avoid confusion, you can hide the default "Sites" item from the WordPress admin menu by toggling this option.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 0,
- ));
+ wu_register_settings_field(
+ 'whitelabel',
+ 'hide_sites_menu',
+ array(
+ 'title' => __('Hide Sites Admin Menu', 'wp-ultimo'),
+ 'desc' => __('We recommend that you manage all of your sites using the WP Multisite WaaS → Sites page. To avoid confusion, you can hide the default "Sites" item from the WordPress admin menu by toggling this option.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 0,
+ )
+ );
- wu_register_settings_field('whitelabel', 'rename_wordpress', array(
- 'title' => __('Replace the word "WordPress"', 'wp-ultimo'),
- 'placeholder' => __('e.g. My App', 'wp-ultimo'),
- 'desc' => __('Replace all occurrences of the word "WordPress" with a different word.', 'wp-ultimo'),
- 'type' => 'text',
- 'default' => '',
- ));
+ wu_register_settings_field(
+ 'whitelabel',
+ 'rename_wordpress',
+ array(
+ 'title' => __('Replace the word "WordPress"', 'wp-ultimo'),
+ 'placeholder' => __('e.g. My App', 'wp-ultimo'),
+ 'desc' => __('Replace all occurrences of the word "WordPress" with a different word.', 'wp-ultimo'),
+ 'type' => 'text',
+ 'default' => '',
+ )
+ );
- wu_register_settings_field('whitelabel', 'rename_site_singular', array(
- 'title' => __('Replace the word "Site" (singular)', 'wp-ultimo'),
- 'placeholder' => __('e.g. App', 'wp-ultimo'),
- 'desc' => __('Replace all occurrences of the word "Site" with a different word.', 'wp-ultimo'),
- 'type' => 'text',
- 'default' => '',
- 'wrapper_classes' => 'wu-w-1/2',
- ));
+ wu_register_settings_field(
+ 'whitelabel',
+ 'rename_site_singular',
+ array(
+ 'title' => __('Replace the word "Site" (singular)', 'wp-ultimo'),
+ 'placeholder' => __('e.g. App', 'wp-ultimo'),
+ 'desc' => __('Replace all occurrences of the word "Site" with a different word.', 'wp-ultimo'),
+ 'type' => 'text',
+ 'default' => '',
+ 'wrapper_classes' => 'wu-w-1/2',
+ )
+ );
- wu_register_settings_field('whitelabel', 'rename_site_plural', array(
- 'title' => __('Replace the word "Sites" (plural)', 'wp-ultimo'),
- 'placeholder' => __('e.g. Apps', 'wp-ultimo'),
- 'desc' => __('Replace all occurrences of the word "Sites" with a different word.', 'wp-ultimo'),
- 'type' => 'text',
- 'default' => '',
- 'wrapper_classes' => 'wu-w-1/2',
- ));
-
- } // end add_settings;
+ wu_register_settings_field(
+ 'whitelabel',
+ 'rename_site_plural',
+ array(
+ 'title' => __('Replace the word "Sites" (plural)', 'wp-ultimo'),
+ 'placeholder' => __('e.g. Apps', 'wp-ultimo'),
+ 'desc' => __('Replace all occurrences of the word "Sites" with a different word.', 'wp-ultimo'),
+ 'type' => 'text',
+ 'default' => '',
+ 'wrapper_classes' => 'wu-w-1/2',
+ )
+ );
+ }
/**
* Removes the WordPress original logo from the top-bar.
@@ -288,8 +291,7 @@ class Whitelabel {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
-
- } // end wp_logo_admin_bar_remove;
+ }
/**
* Remove the default widgets from the user panel.
@@ -309,8 +311,7 @@ class Whitelabel {
unset($wp_meta_boxes['dashboard-user']['normal']['core']['dashboard_recent_comments']);
unset($wp_meta_boxes['dashboard-user']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard-user']['side']['core']['dashboard_secondary']);
-
- } // end remove_dashboard_widgets;
+ }
/**
* Removes the WordPress credits from the admin footer.
@@ -321,16 +322,13 @@ class Whitelabel {
public function clear_footer_texts() {
if (current_user_can('manage_network')) {
-
return;
-
- } // end if;
+ }
add_filter('admin_footer_text', '__return_empty_string', 11);
add_filter('update_footer', '__return_empty_string', 11);
-
- } // end clear_footer_texts;
+ }
/**
* Remove the sites admin menu, if the option is selected.
@@ -345,19 +343,13 @@ class Whitelabel {
$index = '';
foreach ($menu as $i => $menu_item) {
-
if ($menu_item[2] === 'sites.php') {
-
$index = $i;
continue;
+ }
+ }
- } // end if;
-
- } // end foreach;
-
- unset($menu[$index]);
-
- } // end remove_sites_admin_menu;
-
-} // end class Whitelabel;
+ unset($menu[ $index ]);
+ }
+}
diff --git a/inc/class-wp-ultimo.php b/inc/class-wp-ultimo.php
index ec7d14d..1b7f3c5 100644
--- a/inc/class-wp-ultimo.php
+++ b/inc/class-wp-ultimo.php
@@ -20,7 +20,8 @@ defined('ABSPATH') || exit;
*/
final class WP_Ultimo {
- use \WP_Ultimo\Traits\Singleton, \WP_Ultimo\Traits\WP_Ultimo_Deprecated;
+ use \WP_Ultimo\Traits\Singleton;
+ use \WP_Ultimo\Traits\WP_Ultimo_Deprecated;
/**
* Version of the Plugin.
@@ -154,10 +155,8 @@ final class WP_Ultimo {
* and have no dependencies outside of the classes loaded so far.
*/
if (WP_Ultimo\Requirements::met() === false || WP_Ultimo\Requirements::run_setup() === false) {
-
return;
-
- } // end if;
+ }
$this->loaded = true;
@@ -211,9 +210,7 @@ final class WP_Ultimo {
* @todo: move this to a manager in the future?
*/
$this->load_admin_pages();
-
-
- } // end init;
+ }
/**
* Returns true if all the requirements are met.
@@ -224,8 +221,7 @@ final class WP_Ultimo {
public function is_loaded() {
return $this->loaded;
-
- } // end is_loaded;
+ }
/**
* Setup the plugin text domain to be used in translations.
@@ -239,8 +235,7 @@ final class WP_Ultimo {
*/
load_plugin_textdomain('wp-ultimo', false, dirname((string) WP_ULTIMO_PLUGIN_BASENAME) . '/lang');
load_plugin_textdomain('wp-ultimo-locations', false, dirname((string) WP_ULTIMO_PLUGIN_BASENAME) . '/lang');
-
- } // end setup_textdomain;
+ }
/**
* Loads the table objects for our custom tables.
@@ -251,8 +246,7 @@ final class WP_Ultimo {
public function setup_tables() {
$this->tables = \WP_Ultimo\Loaders\Table_Loader::get_instance();
-
- } // end setup_tables;
+ }
/**
* Loads public apis that should be on the global scope
@@ -420,12 +414,9 @@ final class WP_Ultimo {
* Admin helper functions
*/
if (is_admin()) {
-
require_once wu_path('inc/functions/admin.php');
-
- } // end if;
-
- } // end load_public_apis;
+ }
+ }
/**
* Load extra the WP Multisite WaaS elements
@@ -562,9 +553,12 @@ final class WP_Ultimo {
\WP_Ultimo\Checkout\Checkout_Pages::get_instance();
- add_action('init', function() {
- \WP_Ultimo\Checkout\Legacy_Checkout::get_instance();
- });
+ add_action(
+ 'init',
+ function () {
+ \WP_Ultimo\Checkout\Legacy_Checkout::get_instance();
+ }
+ );
/*
* Dashboard Statistics
@@ -633,8 +627,7 @@ final class WP_Ultimo {
* Cron Schedules
*/
\WP_Ultimo\Cron::get_instance();
-
- } // end load_extra_components;
+ }
/**
* Load the WP Multisite WaaS Admin Pages.
@@ -798,8 +791,7 @@ final class WP_Ultimo {
new WP_Ultimo\Tax\Dashboard_Taxes_Tab();
do_action('wp_ultimo_admin_pages');
-
- } // end load_admin_pages;
+ }
/**
* Load extra the WP Multisite WaaS managers.
@@ -917,7 +909,5 @@ final class WP_Ultimo {
* Loads views overrides
*/
WP_Ultimo\Views::get_instance();
-
- } // end load_managers;
-
-} // end class WP_Ultimo;
+ }
+}
diff --git a/inc/compat/class-as-admin-view.php b/inc/compat/class-as-admin-view.php
index ef4212b..106d738 100644
--- a/inc/compat/class-as-admin-view.php
+++ b/inc/compat/class-as-admin-view.php
@@ -27,6 +27,5 @@ class AS_Admin_View {
* @since 2.0.0
* @return void
*/
- public function init() {} // end init;
-
-} // end class AS_Admin_View;
+ public function init() {}
+}
diff --git a/inc/compat/class-discount-code-compat.php b/inc/compat/class-discount-code-compat.php
index 8679726..a35c73f 100644
--- a/inc/compat/class-discount-code-compat.php
+++ b/inc/compat/class-discount-code-compat.php
@@ -32,8 +32,7 @@ class Discount_Code_Compat {
public function init() {
add_filter('update_post_metadata', array($this, 'check_update_coupon'), 10, 5);
-
- } // end init;
+ }
/**
* Saves meta data from old plugins on the new plugin.
@@ -51,22 +50,18 @@ class Discount_Code_Compat {
/*
* Check if we are in the main site of the network.
*/
- if (!is_main_site()) {
-
+ if ( ! is_main_site()) {
return;
-
- } // end if;
+ }
/*
* Check if we have a new entity with this ID.
*/
$migrated_discount_code = wu_get_discount_code($object_id);
- if (!$migrated_discount_code) {
-
+ if ( ! $migrated_discount_code) {
return;
-
- } // end if;
+ }
/*
* Prevent double prefixing.
@@ -83,7 +78,5 @@ class Discount_Code_Compat {
* returning anything else will prevent meta data from being saved.
*/
return null;
-
- } // end check_update_coupon;
-
-} // end class Discount_Code_Compat;
+ }
+}
diff --git a/inc/compat/class-domain-mapping-compat.php b/inc/compat/class-domain-mapping-compat.php
index 48ab705..60094fb 100644
--- a/inc/compat/class-domain-mapping-compat.php
+++ b/inc/compat/class-domain-mapping-compat.php
@@ -30,7 +30,5 @@ class Domain_Mapping_Compat {
* @return void
*/
public function init() {
-
- } // end init;
-
-} // end class Domain_Mapping_Compat;
+ }
+}
diff --git a/inc/compat/class-elementor-compat.php b/inc/compat/class-elementor-compat.php
index 9bc5e42..c4e1463 100644
--- a/inc/compat/class-elementor-compat.php
+++ b/inc/compat/class-elementor-compat.php
@@ -36,8 +36,7 @@ class Elementor_Compat {
add_filter('wu_should_redirect_to_primary_domain', array($this, 'maybe_prevent_redirection'));
add_action('elementor/widget/shortcode/skins_init', array($this, 'maybe_setup_preview'));
-
- } // end init;
+ }
/**
* Makes sure we force elementor to regenerate the styles when necessary.
@@ -48,31 +47,24 @@ class Elementor_Compat {
*/
public function regenerate_css($site) {
- if (!class_exists('\Elementor\Plugin')) {
-
+ if ( ! class_exists('\Elementor\Plugin')) {
return;
+ }
- } // end if;
-
- if (!isset($site['site_id'])) {
-
+ if ( ! isset($site['site_id'])) {
return;
-
- } // end if;
+ }
switch_to_blog($site['site_id']);
$file_manager = \Elementor\Plugin::$instance->files_manager; // phpcs:ignore
- if (!empty($file_manager)) {
-
+ if ( ! empty($file_manager)) {
$file_manager->clear_cache();
-
- } // end if;
+ }
restore_current_blog();
-
- } // end regenerate_css;
+ }
/**
* Prevents redirection to primary domain when in Elementor preview mode.
@@ -85,8 +77,7 @@ class Elementor_Compat {
public function maybe_prevent_redirection($should_redirect) {
return wu_request('elementor-preview', false) === false ? $should_redirect : false;
-
- } // end maybe_prevent_redirection;
+ }
/**
* Maybe adds the setup preview for elements inside elementor.
@@ -102,11 +93,7 @@ class Elementor_Compat {
);
if (in_array(wu_request('action'), $elementor_actions, true)) {
-
wu_element_setup_preview();
-
- } // end if;
-
- } // end maybe_setup_preview;
-
-} // end class Elementor_Compat;
+ }
+ }
+}
diff --git a/inc/compat/class-general-compat.php b/inc/compat/class-general-compat.php
index 5d2ac8e..4163bbb 100644
--- a/inc/compat/class-general-compat.php
+++ b/inc/compat/class-general-compat.php
@@ -35,14 +35,14 @@ class General_Compat {
* Woocommerce
*
* Removes the default woocommerce hook on switch_blog to another more performant
- *
+ *
* @see https://wordpress.org/plugins/woocommerce/
*/
add_action('woocommerce_loaded', array($this, 'replace_wc_wpdb_table_fix'));
/**
* WP Typography.
- *
+ *
* @see https://de.wordpress.org/plugins/wp-typography/
*/
add_action('load-settings_page_wp-typography', array($this, 'add_wp_typography_warning_message'));
@@ -67,7 +67,7 @@ class General_Compat {
/**
* WP Hide Pro
- *
+ *
* @see https://wp-hide.com/
*/
add_filter('wu_append_preview_parameter', array($this, 'fix_wp_hide_preview_url'));
@@ -142,15 +142,16 @@ class General_Compat {
* @since 2.0.0
* @see https://getkeypress.com/dns-manager/
*/
- add_action('wu_before_pending_site_published', function() {
+ add_action(
+ 'wu_before_pending_site_published',
+ function () {
- if (function_exists('KPDNS')) {
-
- KPDNS(); // phpcs:ignore
-
- } // end if;
-
- }, 5); // need to hook before 10
+ if (function_exists('KPDNS')) {
+ KPDNS(); // phpcs:ignore
+ }
+ },
+ 5
+ ); // need to hook before 10
/**
* Perfmatters.
@@ -167,17 +168,16 @@ class General_Compat {
*
* @since 2.0.5
*/
- add_action('wp', function() {
+ add_action(
+ 'wp',
+ function () {
- if (wu_request('et_pb_preview')) {
-
- wu_element_setup_preview();
-
- } // end if;
-
- });
-
- } // end init;
+ if (wu_request('et_pb_preview')) {
+ wu_element_setup_preview();
+ }
+ }
+ );
+ }
/**
* Fixes a performance problem with Woocommerce.
@@ -205,22 +205,20 @@ class General_Compat {
);
foreach ( $tables as $name => $table ) {
-
$wpdb->tables[] = $table;
+ }
- } // end foreach;
+ add_action(
+ 'switch_blog',
+ function () use ($wpdb, $tables) {
- add_action('switch_blog', function() use ($wpdb, $tables) {
-
- foreach ( $tables as $name => $table ) {
-
- $wpdb->$name = $wpdb->prefix . $table;
-
- } // end foreach;
-
- }, 0);
-
- } // end replace_wc_wpdb_table_fix;
+ foreach ( $tables as $name => $table ) {
+ $wpdb->$name = $wpdb->prefix . $table;
+ }
+ },
+ 0
+ );
+ }
/**
* Fixes incompatibility with the plugin WP Typography.
@@ -244,8 +242,7 @@ class General_Compat {
$settings['smartQuotes'] = false;
return $settings;
-
- } // end fix_wp_typography;
+ }
/**
* Adds a warning message to let customers know why smart quotes are not working.
@@ -256,8 +253,7 @@ class General_Compat {
public function add_wp_typography_warning_message() {
WP_Ultimo()->notices->add(__('WP Typography "Smart Quotes" replacement is not compatible with WP Multisite WaaS and will be automatically disabled.', 'wp-ultimo'), 'warning');
-
- } // end add_wp_typography_warning_message;
+ }
/**
* Fixes brizy media URLs while on Ultimo's template preview
@@ -278,8 +274,7 @@ class General_Compat {
public function fix_brizy_preview_url($value) {
return class_exists('Brizy_Editor') ? false : $value;
-
- } // end fix_brizy_preview_url;
+ }
/**
* Fix the Brizy editor with domain mapping.
@@ -292,20 +287,15 @@ class General_Compat {
public function fix_brizy_editor_screen($should_redirect) {
if (class_exists('\Brizy_Editor')) {
-
$key = \Brizy_Editor::prefix('-edit-iframe');
if (wu_request($key, null) !== null) {
-
return false;
-
- } // end if;
-
- } // end if;
+ }
+ }
return $should_redirect;
-
- } // end fix_brizy_editor_screen;
+ }
/**
* Fix the Divi editor with domain mapping.
@@ -318,14 +308,11 @@ class General_Compat {
public function fix_divi_editor_screen(bool $should_redirect): bool {
if (isset($_GET['et_fb']) && (bool) $_GET['et_fb']) {
-
return false;
-
- } // end if;
+ }
return $should_redirect;
-
- } // end fix_divi_editor_screen;
+ }
/**
* Fixes WP Hide Pro URLs while on Ultimo's template preview
@@ -337,8 +324,7 @@ class General_Compat {
public function fix_wp_hide_preview_url($value) {
return class_exists('WPH') ? false : $value;
-
- } // end fix_wp_hide_preview_url;
+ }
/**
* Fix the load URL for WP Frontend Admin.
@@ -353,8 +339,7 @@ class General_Compat {
public function fix_frontend_admin_loading_url($final_url, $page_path_only, $blog_id) {
return wu_restore_original_url($final_url, $blog_id);
-
- } // end fix_frontend_admin_loading_url;
+ }
/**
* Oxygen renders things very strangely, so we need to handle it separately.
@@ -369,10 +354,8 @@ class General_Compat {
public function maybe_parse_oxygen_content($should_enqueue, $post, $shortcode_tag) {
if (function_exists('oxygen_vsb_current_user_can_access') === false) {
-
return $should_enqueue;
-
- } // end if;
+ }
$shortcode_content = get_post_meta($post->ID, 'ct_builder_shortcodes', true);
@@ -382,17 +365,14 @@ class General_Compat {
* Oxygen now base64 encodes shortcodes for some reason...
* Supporting third-party page builders is such a pain.
*/
- if (!$has_shortcode) {
-
+ if ( ! $has_shortcode) {
$base64 = base64_encode("[$shortcode_tag]");
$has_shortcode = strpos((string) $shortcode_content, $base64);
-
- } // end if;
+ }
return $has_shortcode;
-
- } // end maybe_parse_oxygen_content;
+ }
/**
* Prevent Oxygen from removing the real wp_head hook from the template
@@ -403,13 +383,15 @@ class General_Compat {
*/
public function prevent_oxygen_cleanup_on_template_previewer() {
- add_action('wp_head', function() {
+ add_action(
+ 'wp_head',
+ function () {
- remove_action('wp_head', 'oxy_print_cached_css', 999999);
-
- }, 10);
-
- } // end prevent_oxygen_cleanup_on_template_previewer;
+ remove_action('wp_head', 'oxy_print_cached_css', 999999);
+ },
+ 10
+ );
+ }
/**
* Adds SSO to WP Maintenance Mode.
@@ -422,8 +404,7 @@ class General_Compat {
public function add_sso_to_maintenance_mode($sso) {
add_action('wpmm_head', array($sso, 'enqueue_script'));
-
- } // end add_sso_to_maintenance_mode;
+ }
/**
* Run wp action on template previewer to prevent some errors like
@@ -434,12 +415,11 @@ class General_Compat {
public function run_wp_on_template_previewer() {
if (class_exists('Avada')) {
-
do_action('wp'); //phpcs:disable
- } // end if;
+ }
- } // end run_wp_on_template_previewer;
+ }
/**
* Run wp action on template previewer to prevent some errors like
@@ -467,13 +447,13 @@ class General_Compat {
fusion_reset_all_caches();
- } // end if;
+ }
- } // end if;
+ }
restore_current_blog();
- } // end clear_avada_cache;
+ }
/**
* Fix the FluentCRM Pro on site duplication due to fc_meta table not exist
@@ -491,9 +471,9 @@ class General_Compat {
// Here we use this function due FluentCrm($class_name) returns an instance not working with remove_action
$this->hard_remove_action('set_user_role', array($class_name, 'maybeAutoAlterTags'), 11);
- } // end if;
+ }
- } // end fix_fluent_pro_site_duplication;
+ }
/**
* Removes RankMath and RankMath Pro Installer::wpmu_new_blog action
@@ -517,11 +497,11 @@ class General_Compat {
$this->hard_remove_action('wpmu_new_blog', array($class_name, 'activate_blog'), 10);
$this->hard_remove_action('wp_initialize_site', array($class_name, 'initialize_site'), 10);
- } // end if;
+ }
- } // end foreach;
+ }
- } // end fix_rank_math_site_creation;
+ }
/**
* Removes WP E-Signature and WP E-Signature Business add-ons
@@ -545,11 +525,11 @@ class General_Compat {
// WP E-Signature does not provide a instance of the activation class
$this->hard_remove_action('wpmu_new_blog', array($class_name, 'activate_new_site'), 10);
- } // end if;
+ }
- } // end foreach;
+ }
- } // end fix_wp_e_signature_site_creation;
+ }
/**
* A way to remove an action if instance is not available
@@ -569,7 +549,7 @@ class General_Compat {
return;
- } // end if;
+ }
$handler_id = '';
@@ -579,19 +559,19 @@ class General_Compat {
$handler_id = $handler_key;
- } // end if;
+ }
- } // end foreach;
+ }
if (!empty($handler_id)) {
remove_filter( $tag, $handler_id, $priority );
- } // end if;
+ }
return;
- } // end hard_remove_action;
+ }
/**
* Remove action from perfamatters that disabled password strength meter script.
@@ -605,8 +585,8 @@ class General_Compat {
remove_action('wp_print_scripts', 'perfmatters_disable_password_strength_meter', 100);
- } // end if;
+ }
- } // end remove_perfmatters_checkout_dep;
+ }
-} // end class General_Compat;
+}
diff --git a/inc/compat/class-gutenberg-support.php b/inc/compat/class-gutenberg-support.php
index e0961c0..8906292 100644
--- a/inc/compat/class-gutenberg-support.php
+++ b/inc/compat/class-gutenberg-support.php
@@ -35,14 +35,11 @@ class Gutenberg_Support {
public function should_load() {
if (function_exists('has_blocks')) {
-
return true;
-
- } // end if;
+ }
return apply_filters('wu_gutenberg_support_should_load', true);
-
- } // end should_load;
+ }
/**
* Initializes the Class, if we need it.
@@ -53,12 +50,9 @@ class Gutenberg_Support {
public function init() {
if ($this->should_load()) {
-
add_action('admin_enqueue_scripts', array($this, 'add_scripts'));
-
- } // end if;
-
- } // end init;
+ }
+ }
/**
* Adds the Gutenberg Filters scripts.
@@ -70,16 +64,18 @@ class Gutenberg_Support {
wp_register_script('wu-gutenberg-support', wu_get_asset('gutenberg-support.js', 'js'), array('jquery'), wu_get_version(), true);
- // translators: the placeholder is replaced with the network name.
+ // translators: the placeholder is replaced with the network name.
$preview_message = apply_filters('wu_gutenberg_support_preview_message', sprintf(__('%s is generating the preview...', 'wp-ultimo'), get_network_option(null, 'site_name')));
- wp_localize_script('wu-gutenberg-support', 'wu_gutenberg', array(
- 'logo' => esc_url(wu_get_network_logo()),
- 'replacement_message' => $preview_message,
- ));
+ wp_localize_script(
+ 'wu-gutenberg-support',
+ 'wu_gutenberg',
+ array(
+ 'logo' => esc_url(wu_get_network_logo()),
+ 'replacement_message' => $preview_message,
+ )
+ );
wp_enqueue_script('wu-gutenberg-support');
-
- } // end add_scripts;
-
-} // end class Gutenberg_Support;
+ }
+}
diff --git a/inc/compat/class-legacy-shortcodes.php b/inc/compat/class-legacy-shortcodes.php
index d0d56d5..bfcdd0f 100644
--- a/inc/compat/class-legacy-shortcodes.php
+++ b/inc/compat/class-legacy-shortcodes.php
@@ -57,8 +57,7 @@ class Legacy_Shortcodes {
add_shortcode('wu_pricing_table', array($this, 'pricing_table'));
add_shortcode('wu_templates_list', array($this, 'templates_list'));
-
- } // end init;
+ }
/**
* Return the value of a user meta on the database.
@@ -81,39 +80,34 @@ class Legacy_Shortcodes {
$customer = $site->get_customer();
if ($customer) {
-
$customer_id = $customer->get_id();
$user_id = $customer->get_user_id();
+ }
- } // end if;
-
- $atts = shortcode_atts(array(
- 'user_id' => $user_id,
- 'meta_name' => 'first_name',
- 'default' => false,
- 'unique' => true,
- ), $atts, 'wu_user_meta');
+ $atts = shortcode_atts(
+ array(
+ 'user_id' => $user_id,
+ 'meta_name' => 'first_name',
+ 'default' => false,
+ 'unique' => true,
+ ),
+ $atts,
+ 'wu_user_meta'
+ );
if ($customer_id) {
-
$value = $customer->get_meta($atts['meta_name']);
-
} else {
-
$value = get_user_meta($atts['user_id'], $atts['meta_name'], $atts['unique']);
-
- } // end if;
+ }
if (is_array($value)) {
-
$value = implode(', ', $value);
-
- } // end if;
+ }
return $value ? $value : '--';
-
- } // end user_meta;
+ }
/**
* Returns the number of paying users on the platform.
@@ -129,13 +123,14 @@ class Legacy_Shortcodes {
$atts = shortcode_atts(array(), $atts, 'wu_paying_users');
- $paying_customers = wu_get_customers(array(
- 'count' => true,
- ));
+ $paying_customers = wu_get_customers(
+ array(
+ 'count' => true,
+ )
+ );
return $paying_customers;
-
- } // end paying_users;
+ }
/**
* Plan Link shortcode.
@@ -147,22 +142,24 @@ class Legacy_Shortcodes {
*/
public function plan_link($atts) {
- $atts = shortcode_atts(array(
- 'plan_id' => 0,
- 'plan_freq' => 1,
- 'skip_plan' => 1,
- ), $atts, 'wu_plan_link');
+ $atts = shortcode_atts(
+ array(
+ 'plan_id' => 0,
+ 'plan_freq' => 1,
+ 'skip_plan' => 1,
+ ),
+ $atts,
+ 'wu_plan_link'
+ );
/**
* Treat the results to make sure we are getting numbers out of it
- *
+ *
* @since 1.5.1
*/
foreach (array('plan_id', 'plan_freq') as $att) {
-
- $atts[$att] = wu_extract_number($atts[$att]);
-
- } // end foreach;
+ $atts[ $att ] = wu_extract_number($atts[ $att ]);
+ }
$path = '';
@@ -173,30 +170,23 @@ class Legacy_Shortcodes {
$plan = wu_get_product_by('migrated_from_id', $atts['plan_id']);
if ($plan) {
-
$path = $plan->get_slug();
-
- } // end if;
+ }
/**
* Second pass: try via the real ID, if new customers
* decide to use the old shortcode.
*/
if (empty($path)) {
-
$plan = wu_get_product($atts['plan_id']);
if ($plan) {
-
$path = $plan->get_slug();
-
- } // end if;
-
- } // end if;
+ }
+ }
return wu_get_registration_url($path);
-
- } // end plan_link;
+ }
/**
* Renders the restrict content shortcode.
@@ -209,40 +199,38 @@ class Legacy_Shortcodes {
*/
public function restricted_content($atts, $content) {
- $atts = shortcode_atts(array(
- 'plan_id' => false,
- 'product_id' => false,
- 'only_active' => true,
- 'only_logged' => false,
- 'exclude_trials' => false,
- 'from_request' => false,
- ), $atts, 'wu_restricted_content');
+ $atts = shortcode_atts(
+ array(
+ 'plan_id' => false,
+ 'product_id' => false,
+ 'only_active' => true,
+ 'only_logged' => false,
+ 'exclude_trials' => false,
+ 'from_request' => false,
+ ),
+ $atts,
+ 'wu_restricted_content'
+ );
- $atts['plan_id'] = !empty($atts['product_id']) ? $atts['product_id'] : $atts['plan_id'];
-
- if (empty($atts) || !$atts['plan_id']) {
+ $atts['plan_id'] = ! empty($atts['product_id']) ? $atts['product_id'] : $atts['plan_id'];
+ if (empty($atts) || ! $atts['plan_id']) {
return __('You need to pass a valid plan ID.', 'wp-ultimo');
-
- } // end if;
+ }
$query_products = get_query_var('products', array());
$request_products = array();
foreach ($query_products as $product) {
-
$product = wu_get_product($product);
- if (!$product) {
-
+ if ( ! $product) {
continue;
-
- } // end if;
+ }
$request_products[] = $product->get_id();
-
- } // end foreach;
+ }
$plan_ids = explode(',', $atts['plan_id']);
$plan_ids = array_map('trim', $plan_ids);
@@ -251,16 +239,12 @@ class Legacy_Shortcodes {
$else = '[wu_default_content]';
if (strpos($content, $else) !== false) {
-
list($if, $else) = explode($else, $content, 2);
-
} else {
-
$if = $content;
$else = '';
-
- } // end if;
+ }
$condition = false;
@@ -268,12 +252,11 @@ class Legacy_Shortcodes {
$user_logged_in = is_user_logged_in();
- $should_check = !(bool) $atts['only_logged'] || $user_logged_in;
+ $should_check = ! (bool) $atts['only_logged'] || $user_logged_in;
$from_request = $atts['from_request'] && count(array_intersect($plan_ids, $request_products)) > 0;
- if ($membership && $should_check && !$from_request) {
-
+ if ($membership && $should_check && ! $from_request) {
$membership_products = array_merge(
array($membership->get_plan_id()),
$membership->get_addon_ids()
@@ -281,29 +264,21 @@ class Legacy_Shortcodes {
$condition = in_array('all', $plan_ids, true) || count(array_intersect($membership_products, $plan_ids)) > 0;
- if ((bool) $atts['only_active']) {
-
+ if ( (bool) $atts['only_active']) {
$condition = $condition && ($membership->is_active() || $membership->get_status() === 'trialing');
+ }
- } // end if;
-
- if ((bool) $atts['exclude_trials']) {
-
- $condition = $condition && !$membership->is_trialing();
-
- } // end if;
-
+ if ( (bool) $atts['exclude_trials']) {
+ $condition = $condition && ! $membership->is_trialing();
+ }
} else {
-
$condition = $from_request && $should_check;
-
- } // end if;
+ }
$final_content = wpautop($condition ? $if : $else);
return do_shortcode($final_content);
-
- } // end restricted_content;
+ }
/**
* Adds the pricing table shortcode.
@@ -321,27 +296,29 @@ class Legacy_Shortcodes {
global $post;
- $atts = shortcode_atts(array(
- 'primary_color' => wu_get_setting('primary_color', '#00a1ff'),
- 'accent_color' => wu_get_setting('accent_color', '#78b336'),
- 'default_pricing_option' => wu_get_setting('default_pricing_option', 1),
- 'plan_id' => false,
- 'show_selector' => true,
- // New Options
- 'layout' => 'legacy',
- 'period_selector_layout' => 'legacy',
- ), $atts, 'wu_pricing_table');
+ $atts = shortcode_atts(
+ array(
+ 'primary_color' => wu_get_setting('primary_color', '#00a1ff'),
+ 'accent_color' => wu_get_setting('accent_color', '#78b336'),
+ 'default_pricing_option' => wu_get_setting('default_pricing_option', 1),
+ 'plan_id' => false,
+ 'show_selector' => true,
+ // New Options
+ 'layout' => 'legacy',
+ 'period_selector_layout' => 'legacy',
+ ),
+ $atts,
+ 'wu_pricing_table'
+ );
/**
* In the case of the legacy layout, we need to load extra styles.
*/
if ($atts['layout'] === 'legacy') {
-
wp_enqueue_style('legacy-signup', wu_get_asset('legacy-signup.css', 'css'));
wp_add_inline_style('legacy-signup', \WP_Ultimo\Checkout\Legacy_Checkout::get_instance()->get_legacy_dynamic_styles());
-
- } // end if;
+ }
do_action('wu_checkout_scripts', $post);
@@ -349,7 +326,7 @@ class Legacy_Shortcodes {
$atts['plan_id'] = is_string($atts['plan_id']) && $atts['plan_id'] !== 'all' ? explode(',', $atts['plan_id']) : false;
- $checkout_form = new \WP_Ultimo\Models\Checkout_Form;
+ $checkout_form = new \WP_Ultimo\Models\Checkout_Form();
$fields = array();
@@ -358,13 +335,10 @@ class Legacy_Shortcodes {
);
if ($atts['plan_id']) {
-
$search_arguments['id__in'] = $atts['plan_id'];
-
- } // end if;
+ }
if ($atts['show_selector']) {
-
$fields[] = array(
'step' => 'checkout',
'name' => '',
@@ -389,8 +363,7 @@ class Legacy_Shortcodes {
),
),
);
-
- } // end if;
+ }
$layout = $atts['layout'];
@@ -410,18 +383,16 @@ class Legacy_Shortcodes {
* we'll need a submit field.
*/
if ($layout !== 'legacy') {
-
- $fields[] = array (
+ $fields[] = array(
'step' => 'checkout',
'name' => __('Get Started →', 'wp-ultimo'),
'type' => 'submit_button',
'id' => 'checkout',
);
+ }
- } // end if;
-
- $steps = array (
- array (
+ $steps = array(
+ array(
'id' => 'checkout',
'name' => __('Checkout', 'wp-ultimo'),
'desc' => '',
@@ -441,14 +412,21 @@ class Legacy_Shortcodes {
do_action('wu_setup_checkout');
- wp_add_inline_script('wu-checkout', sprintf('
+ wp_add_inline_script(
+ 'wu-checkout',
+ sprintf(
+ '
/**
* Set the auto-submittable field, if one exists.
*/
window.wu_auto_submittable_field = %s;
- ', json_encode($auto_submittable_field)), 'after');
+ ',
+ json_encode($auto_submittable_field)
+ ),
+ 'after'
+ );
$final_fields = wu_create_checkout_fields($checkout_form->get_step('checkout', true)['fields']);
@@ -469,16 +447,18 @@ class Legacy_Shortcodes {
'value' => 1,
);
- return wu_get_template_contents('checkout/form', array(
- 'step' => $checkout_form->get_step('checkout', true),
- 'step_name' => 'checkout',
- 'checkout_form_name' => 'wu_pricing_table',
- 'checkout_form_action' => add_query_arg('pre-flight', 1, wu_get_registration_url()),
- 'display_title' => '',
- 'final_fields' => $final_fields,
- ));
-
- } // end pricing_table;
+ return wu_get_template_contents(
+ 'checkout/form',
+ array(
+ 'step' => $checkout_form->get_step('checkout', true),
+ 'step_name' => 'checkout',
+ 'checkout_form_name' => 'wu_pricing_table',
+ 'checkout_form_action' => add_query_arg('pre-flight', 1, wu_get_registration_url()),
+ 'display_title' => '',
+ 'final_fields' => $final_fields,
+ )
+ );
+ }
/**
* Adds the template sites shortcode.
@@ -496,18 +476,22 @@ class Legacy_Shortcodes {
global $post;
- $atts = shortcode_atts(array(
- 'show_filters' => true,
- 'show_title' => true,
- 'templates' => false,
- 'cols' => 3,
- 'layout' => 'legacy',
- 'checkout_page' => wu_guess_registration_page(),
- ), $atts, 'wu_templates_list');
+ $atts = shortcode_atts(
+ array(
+ 'show_filters' => true,
+ 'show_title' => true,
+ 'templates' => false,
+ 'cols' => 3,
+ 'layout' => 'legacy',
+ 'checkout_page' => wu_guess_registration_page(),
+ ),
+ $atts,
+ 'wu_templates_list'
+ );
/**
- * Hide header, if necessary
- */
+ * Hide header, if necessary
+ */
add_filter('wu_step_template_display_header', $atts['show_title'] ? '__return_true' : '__return_false');
/**
@@ -521,14 +505,12 @@ class Legacy_Shortcodes {
* In the case of the legacy layout, we need to load extra styles.
*/
if ($atts['layout'] === 'legacy') {
-
wp_enqueue_style('legacy-signup', wu_get_asset('legacy-signup.css', 'css'));
wp_add_inline_style('legacy-signup', \WP_Ultimo\Checkout\Legacy_Checkout::get_instance()->get_legacy_dynamic_styles());
+ }
- } // end if;
-
- $checkout_form = new \WP_Ultimo\Models\Checkout_Form;
+ $checkout_form = new \WP_Ultimo\Models\Checkout_Form();
$fields = array();
@@ -549,8 +531,8 @@ class Legacy_Shortcodes {
'element_classes' => $layout === 'legacy' ? 'wu-content-templates' : '',
);
- $steps = array (
- array (
+ $steps = array(
+ array(
'id' => 'checkout',
'name' => __('Checkout', 'wp-ultimo'),
'desc' => '',
@@ -572,14 +554,21 @@ class Legacy_Shortcodes {
do_action('wu_setup_checkout');
- wp_add_inline_script('wu-checkout', sprintf('
+ wp_add_inline_script(
+ 'wu-checkout',
+ sprintf(
+ '
/**
* Set the auto-submittable field, if one exists.
*/
window.wu_auto_submittable_field = %s;
- ', json_encode($auto_submittable_field)), 'after');
+ ',
+ json_encode($auto_submittable_field)
+ ),
+ 'after'
+ );
$final_fields['pre-flight'] = array(
'type' => 'hidden',
@@ -588,16 +577,18 @@ class Legacy_Shortcodes {
$page_url = wu_switch_blog_and_run(fn() => get_permalink($atts['checkout_page']));
- return wu_get_template_contents('checkout/form', array(
- 'step' => $checkout_form->get_step('checkout', true),
- 'step_name' => 'checkout',
- 'checkout_form_name' => 'wu_templates_list',
- 'checkout_form_action' => add_query_arg('pre-flight', 1, $page_url),
- 'display_title' => '',
- 'final_fields' => $final_fields,
- ));
-
- } // end templates_list;
+ return wu_get_template_contents(
+ 'checkout/form',
+ array(
+ 'step' => $checkout_form->get_step('checkout', true),
+ 'step_name' => 'checkout',
+ 'checkout_form_name' => 'wu_templates_list',
+ 'checkout_form_action' => add_query_arg('pre-flight', 1, $page_url),
+ 'display_title' => '',
+ 'final_fields' => $final_fields,
+ )
+ );
+ }
/**
* Makes sure we don't return any invalid values.
*
@@ -609,7 +600,5 @@ class Legacy_Shortcodes {
$list = array_map('trim', explode(',', $templates));
return array_filter($list);
-
- } // end treat_template_list;
-
-} // end class Legacy_Shortcodes;
+ }
+}
diff --git a/inc/compat/class-multiple-accounts-compat.php b/inc/compat/class-multiple-accounts-compat.php
index c0ed6d1..350bb26 100644
--- a/inc/compat/class-multiple-accounts-compat.php
+++ b/inc/compat/class-multiple-accounts-compat.php
@@ -82,10 +82,8 @@ class Multiple_Accounts_Compat {
// Adds the number of additional accounts.
add_filter('manage_users_custom_column', array($this, 'add_column_content'), 10, 3);
-
- } // end if;
-
- } // end init;
+ }
+ }
/**
* Fixes the object cache to allow multiple accounts.
@@ -98,16 +96,13 @@ class Multiple_Accounts_Compat {
public function fix_object_cache_on_multiple_accounts(): void {
$to_remove = array(
- 'useremail'
+ 'useremail',
);
if (function_exists('wp_cache_add_non_persistent_groups')) {
-
wp_cache_add_non_persistent_groups($to_remove);
-
- } // end if;
-
- } // end fix_object_cache_on_multiple_accounts;
+ }
+ }
/**
* Filters the database query so that we can get the right user.
@@ -124,7 +119,6 @@ class Multiple_Accounts_Compat {
$search = "\$db->get_row(\"SELECT * FROM $wpdb->users WHERE user_email";
if ( strpos($wpdb->func_call, $search) === 0) {
-
$prefix = "SELECT * FROM $wpdb->users WHERE user_email";
$last = substr($query, strlen($prefix));
@@ -135,17 +129,19 @@ class Multiple_Accounts_Compat {
* We can't use the $wpdb->prepare() method here because it will
* escape the %s placeholder, which will break the query.
*/
- return sprintf("SELECT u.*
+ return sprintf(
+ "SELECT u.*
FROM $wpdb->users u
JOIN $wpdb->usermeta m on u.id = m.user_id
WHERE m.meta_key = \"wp_%d_capabilities\"
- AND u.user_email%s", $site_id, $last);
-
- } // end if;
+ AND u.user_email%s",
+ $site_id,
+ $last
+ );
+ }
return $query;
-
- } // end fix_user_query;
+ }
/**
* Hooks into email_exists verification to allow duplicate emails in different sites.
@@ -159,16 +155,13 @@ class Multiple_Accounts_Compat {
public function allow_duplicate_emails($user_id, string $email) {
if ($user_id) {
-
$site_user = $this->get_right_user($email);
return $site_user ? $site_user->ID : false;
-
- } // end if;
+ }
return $user_id;
-
- } // end allow_duplicate_emails;
+ }
/**
* Prevent WooCommerce from adding users to site without us knowing.
@@ -186,8 +179,7 @@ class Multiple_Accounts_Compat {
add_filter('can_add_user_to_blog', '__return_false');
return $results;
-
- } // end prevent_woo_from_adding_to_blog;
+ }
/**
* Checks if the user belongs to a site they are currently viewing and unset them if they don't.
@@ -200,10 +192,8 @@ class Multiple_Accounts_Compat {
global $current_user;
if (is_admin() || is_main_site() || current_user_can('manage_network')) {
-
return;
-
- } // end if;
+ }
/**
* Allow developers to bypass the unset current user code.
@@ -222,10 +212,8 @@ class Multiple_Accounts_Compat {
* @return mixed
*/
if (apply_filters('wu_bypass_unset_current_user', null, $current_user) !== null) {
-
return;
-
- } // end if;
+ }
$user = wp_get_current_user();
@@ -237,16 +225,13 @@ class Multiple_Accounts_Compat {
* currently logged in.
*/
if ($has_user === false) {
-
wu_x_header('X-Ultimo-Multiple-Accounts: user-unset');
$current_user = null;
wp_set_current_user(0);
-
- } // end if;
-
- } // end maybe_unset_current_user;
+ }
+ }
/**
* Allow plugin developers to disable this functionality to prevent compatibility issues.
@@ -258,8 +243,7 @@ class Multiple_Accounts_Compat {
public function should_load() {
return apply_filters('wu_should_load_multiple_accounts_support', wu_get_setting('enable_multiple_accounts', true));
-
- } // end should_load;
+ }
// Methods
@@ -272,20 +256,27 @@ class Multiple_Accounts_Compat {
*/
public function add_settings() {
- wu_register_settings_field('login-and-registration', 'multiple_accounts_header', array(
- 'title' => __('Multiple Accounts', 'wp-ultimo'),
- 'desc' => __('Options related to the Multiple Accounts feature.', 'wp-ultimo'),
- 'type' => 'header',
- ));
+ wu_register_settings_field(
+ 'login-and-registration',
+ 'multiple_accounts_header',
+ array(
+ 'title' => __('Multiple Accounts', 'wp-ultimo'),
+ 'desc' => __('Options related to the Multiple Accounts feature.', 'wp-ultimo'),
+ 'type' => 'header',
+ )
+ );
- wu_register_settings_field('login-and-registration', 'enable_multiple_accounts', array(
- 'title' => __('Enable Multiple Accounts', 'wp-ultimo'),
- 'desc' => __('Allow users to have accounts in different sites with the same email address. This is useful when running stores with WooCommerce and other plugins, for example.', 'wp-ultimo') . ' ' . sprintf('%s', wu_get_documentation_url('multiple-accounts'), __('Read More', 'wp-ultimo')),
- 'type' => 'toggle',
- 'default' => 0,
- ));
-
- } // end add_settings;
+ wu_register_settings_field(
+ 'login-and-registration',
+ 'enable_multiple_accounts',
+ array(
+ 'title' => __('Enable Multiple Accounts', 'wp-ultimo'),
+ 'desc' => __('Allow users to have accounts in different sites with the same email address. This is useful when running stores with WooCommerce and other plugins, for example.', 'wp-ultimo') . ' ' . sprintf('%s', wu_get_documentation_url('multiple-accounts'), __('Read More', 'wp-ultimo')),
+ 'type' => 'toggle',
+ 'default' => 0,
+ )
+ );
+ }
/**
* Adds the Multiple accounts column to the users table.
@@ -300,8 +291,7 @@ class Multiple_Accounts_Compat {
$columns['multiple_accounts'] = __('Multiple Accounts', 'wp-ultimo');
return $columns;
-
- } // end add_multiple_account_column;
+ }
/**
* Renders the content of our custom column.
@@ -321,11 +311,13 @@ class Multiple_Accounts_Compat {
$user = get_user_by('ID', $user_id);
// Get all the accounts with the same email
- $users = new \WP_User_Query(array(
- 'blog_id' => 0,
- 'search' => $user->user_email,
- 'fields' => array('ID', 'user_login'),
- ));
+ $users = new \WP_User_Query(
+ array(
+ 'blog_id' => 0,
+ 'search' => $user->user_email,
+ 'fields' => array('ID', 'user_login'),
+ )
+ );
// translators: the %d is the account count for that email address.
$html = sprintf(__('%d accounts using this email.', 'wp-ultimo'), $users->total_users);
@@ -333,10 +325,8 @@ class Multiple_Accounts_Compat {
$html .= sprintf(" " . __('See all', 'wp-ultimo') . ' »', network_admin_url('users.php?s=' . $user->user_email));
echo $html;
-
- } // end if;
-
- } // end add_column_content;
+ }
+ }
/**
* Handles password resetting.
@@ -351,18 +341,14 @@ class Multiple_Accounts_Compat {
// Only do thing if is login by email
if (is_email($_REQUEST['user_login'])) {
-
$user = $this->get_right_user($_REQUEST['user_login']);
$_REQUEST['user_login'] = $user->user_login;
$_POST['user_login'] = $user->user_login;
-
- } // end if;
-
- } // end if;
-
- } // end handle_reset_password;
+ }
+ }
+ }
/**
* Checks if a given user is a member in the site.
@@ -391,12 +377,10 @@ class Multiple_Accounts_Compat {
* @since 2.0.11
*/
if ($user_id) {
-
$query['include'] = array(
absint($user_id),
);
-
- } // end if;
+ }
// Now we search for the correct user based on the password and the blog information
$users = new \WP_User_Query($query);
@@ -406,43 +390,36 @@ class Multiple_Accounts_Compat {
// Check for the pertinence of that user in this site
if ($this->user_can_for_blog($user_with_email, get_current_blog_id(), 'read')) {
-
$has_user = true;
break;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
// If nothing was found return false;
return $has_user;
+ }
+ /**
+ * Gets the right user when logging-in.
+ *
+ * @since 2.0.0
+ *
+ * @param null|\WP_User|\WP_Error $user The current user object. Usually false.
+ * @param string $username The username to search for.
+ * @param string $password The user password.
+ * @return null|\WP_User|\WP_Error
+ */
+ public function fix_login($user, $username, $password) {
- } // end check_for_user_in_site;
- /**
- * Gets the right user when logging-in.
- *
- * @since 2.0.0
- *
- * @param null|\WP_User|\WP_Error $user The current user object. Usually false.
- * @param string $username The username to search for.
- * @param string $password The user password.
- * @return null|\WP_User|\WP_Error
- */
- public function fix_login($user, $username, $password) {
-
- if (!is_email($username)) {
-
+ if ( ! is_email($username)) {
return $user;
-
- } // end if;
+ }
// Sets the right user to be returned;
$user = $this->get_right_user($username, $password);
return $user ? $user : null;
-
- } // end fix_login;
+ }
/**
* Check if user can do something in a specific blog.
@@ -461,42 +438,35 @@ class Multiple_Accounts_Compat {
$current_user = $user;
if (empty($current_user)) {
-
if ($switched) {
-
restore_current_blog();
-
- } // end if;
+ }
return false;
-
- } // end if;
+ }
$args = array_slice(func_get_args(), 2);
$args = array_merge(array($capability), $args);
- $can = call_user_func_array(\Closure::fromCallable([$current_user, 'has_cap']), $args);
+ $can = call_user_func_array(\Closure::fromCallable(array($current_user, 'has_cap')), $args);
if ($switched) {
-
restore_current_blog();
-
- } // end if;
+ }
return $can;
-
- } // end user_can_for_blog;
- /**
- * Gets the right user for a given domain.
- *
- * @since 2.0.0
- *
- * @param string $email User email address.
- * @param boolean $password User password.
- * @return \WP_User|false
- */
- protected function get_right_user($email, $password = false) {
+ }
+ /**
+ * Gets the right user for a given domain.
+ *
+ * @since 2.0.0
+ *
+ * @param string $email User email address.
+ * @param boolean $password User password.
+ * @return \WP_User|false
+ */
+ protected function get_right_user($email, $password = false) {
// Sets the right user to be returned;
$right_user = false;
@@ -507,7 +477,6 @@ class Multiple_Accounts_Compat {
// Loop the results and check which one is in this group
foreach ($users->results as $user_with_email) {
-
$conditions = $password == false ? true : wp_check_password($password, $user_with_email->user_pass, $user_with_email->ID);
// Check for the pertinence of that user in this site
@@ -517,14 +486,10 @@ class Multiple_Accounts_Compat {
$right_user = $user_with_email;
continue;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
// Return right user
return $right_user;
-
- } // end get_right_user;
-
-} // end class Multiple_Accounts_Compat;
+ }
+}
diff --git a/inc/compat/class-product-compat.php b/inc/compat/class-product-compat.php
index 0102173..e2f3e63 100644
--- a/inc/compat/class-product-compat.php
+++ b/inc/compat/class-product-compat.php
@@ -34,8 +34,7 @@ class Product_Compat {
add_filter('wu_product_options_sections', array($this, 'add_legacy_section'), 100, 2);
add_filter('update_post_metadata', array($this, 'check_update_plan'), 10, 5);
-
- } // end init;
+ }
/**
* Saves meta data from old plugins on the new plugin.
@@ -53,22 +52,18 @@ class Product_Compat {
/*
* Check if we are in the main site of the network.
*/
- if (!is_main_site()) {
-
+ if ( ! is_main_site()) {
return;
-
- } // end if;
+ }
/*
* Check if we have a new entity with this ID.
*/
$migrated_product = wu_get_product($object_id);
- if (!$migrated_product) {
-
+ if ( ! $migrated_product) {
return;
-
- } // end if;
+ }
/*
* Prevent double prefixing.
@@ -85,8 +80,7 @@ class Product_Compat {
* returning anything else will prevent meta data from being saved.
*/
return null;
-
- } // end check_update_plan;
+ }
/**
* Injects the compatibility panels to products Advanced Options.
@@ -142,7 +136,5 @@ class Product_Compat {
);
return $sections;
-
- } // end add_legacy_section;
-
-} // end class Product_Compat;
+ }
+}
diff --git a/inc/contracts/Session.php b/inc/contracts/Session.php
index b3b2867..344ec3a 100644
--- a/inc/contracts/Session.php
+++ b/inc/contracts/Session.php
@@ -12,7 +12,7 @@ interface Session {
/**
* Gets the value of a session key.
- *
+ *
* @param string $key The key to retrieve.
* @return mixed
*/
@@ -55,5 +55,4 @@ interface Session {
* @return bool
*/
public function destroy();
-
-} // end interface;
+}
diff --git a/inc/country/class-country-br.php b/inc/country/class-country-br.php
index 1caac15..2c0c8bb 100644
--- a/inc/country/class-country-br.php
+++ b/inc/country/class-country-br.php
@@ -91,8 +91,7 @@ class Country_BR extends Country {
public function get_name() {
return __('Brazil', 'wp-ultimo-locations');
-
- } // end get_name;
+ }
/**
* Returns the list of states for BR.
@@ -131,7 +130,5 @@ class Country_BR extends Country {
'SP' => __('São Paulo', 'wp-ultimo-locations'),
'TO' => __('Tocantins', 'wp-ultimo-locations'),
);
-
- } // end states;
-
-} // end class Country_BR;
+ }
+}
diff --git a/inc/country/class-country-ca.php b/inc/country/class-country-ca.php
index 501a789..3e4cafc 100644
--- a/inc/country/class-country-ca.php
+++ b/inc/country/class-country-ca.php
@@ -77,8 +77,7 @@ class Country_CA extends Country {
public function get_name() {
return __('Canada', 'wp-ultimo-locations');
-
- } // end get_name;
+ }
/**
* Returns the list of states for CA.
@@ -103,7 +102,5 @@ class Country_CA extends Country {
'SK' => __('Saskatchewan', 'wp-ultimo-locations'),
'YT' => __('Yukon', 'wp-ultimo-locations'),
);
-
- } // end states;
-
-} // end class Country_CA;
+ }
+}
diff --git a/inc/country/class-country-cn.php b/inc/country/class-country-cn.php
index 2161c1e..6ef40e6 100644
--- a/inc/country/class-country-cn.php
+++ b/inc/country/class-country-cn.php
@@ -96,8 +96,7 @@ class Country_CN extends Country {
public function get_name() {
return __('China', 'wp-ultimo-locations');
-
- } // end get_name;
+ }
/**
* Returns the list of states for CN.
@@ -143,7 +142,5 @@ class Country_CN extends Country {
'YN' => __('Yunnan', 'wp-ultimo'),
'ZJ' => __('Zhejiang', 'wp-ultimo'),
);
-
- } // end states;
-
-} // end class Country_CN;
+ }
+}
diff --git a/inc/country/class-country-de.php b/inc/country/class-country-de.php
index f0fe8fc..68be42e 100644
--- a/inc/country/class-country-de.php
+++ b/inc/country/class-country-de.php
@@ -80,8 +80,7 @@ class Country_DE extends Country {
public function get_name() {
return __('Germany', 'wp-ultimo-locations');
-
- } // end get_name;
+ }
/**
* Returns the list of states for DE.
@@ -109,7 +108,5 @@ class Country_DE extends Country {
'SH' => __('Schleswig-Holstein', 'wp-ultimo-locations'),
'TH' => __('Thuringia', 'wp-ultimo-locations'),
);
-
- } // end states;
-
-} // end class Country_DE;
+ }
+}
diff --git a/inc/country/class-country-default.php b/inc/country/class-country-default.php
index 3bf7597..4452171 100644
--- a/inc/country/class-country-default.php
+++ b/inc/country/class-country-default.php
@@ -40,8 +40,7 @@ class Country_Default extends Country {
public function get_name() {
return $this->name;
-
- } // end get_name;
+ }
/**
* Creates a country instance with a code and name.
@@ -55,18 +54,19 @@ class Country_Default extends Country {
*/
public static function build($code, $name = null, $attributes = array()) {
- $instance = new self;
+ $instance = new self();
$instance->name = $name ? $name : wu_get_country_name($code);
- $instance->attributes = wp_parse_args($attributes, array(
- 'country_code' => strtoupper($code),
- 'currency' => strtoupper($code),
- 'phone_code' => 00,
- ));
+ $instance->attributes = wp_parse_args(
+ $attributes,
+ array(
+ 'country_code' => strtoupper($code),
+ 'currency' => strtoupper($code),
+ 'phone_code' => 00,
+ )
+ );
return $instance;
-
- } // end build;
-
-} // end class Country_Default;
+ }
+}
diff --git a/inc/country/class-country-es.php b/inc/country/class-country-es.php
index e432d0a..04c21fb 100644
--- a/inc/country/class-country-es.php
+++ b/inc/country/class-country-es.php
@@ -82,8 +82,7 @@ class Country_ES extends Country {
public function get_name() {
return __('Spain', 'wp-ultimo-locations');
-
- } // end get_name;
+ }
/**
* Returns the list of states for ES.
@@ -123,7 +122,5 @@ class Country_ES extends Country {
'ZA' => __('Zamora Province', 'wp-ultimo-locations'),
'AV' => __('Ávila', 'wp-ultimo-locations'),
);
-
- } // end states;
-
-} // end class Country_ES;
+ }
+}
diff --git a/inc/country/class-country-fr.php b/inc/country/class-country-fr.php
index 87462ff..36be3d1 100644
--- a/inc/country/class-country-fr.php
+++ b/inc/country/class-country-fr.php
@@ -77,8 +77,7 @@ class Country_FR extends Country {
public function get_name() {
return __('France', 'wp-ultimo-locations');
-
- } // end get_name;
+ }
/**
* Returns the list of states for FR.
@@ -213,7 +212,5 @@ class Country_FR extends Country {
'WF' => __('Wallis and Futuna', 'wp-ultimo-locations'),
'IDF' => __('Île-de-France', 'wp-ultimo-locations'),
);
-
- } // end states;
-
-} // end class Country_FR;
+ }
+}
diff --git a/inc/country/class-country-gb.php b/inc/country/class-country-gb.php
index bd6c156..b7655f0 100644
--- a/inc/country/class-country-gb.php
+++ b/inc/country/class-country-gb.php
@@ -68,8 +68,7 @@ class Country_GB extends Country {
public function get_name() {
return __('United Kingdom', 'wp-ultimo-locations');
-
- } // end get_name;
+ }
/**
* Returns the list of states for GB.
@@ -328,7 +327,5 @@ class Country_GB extends Country {
'WOR' => __('Worcestershire', 'wp-ultimo-locations'),
'WRX' => __('Wrexham County Borough', 'wp-ultimo-locations'),
);
-
- } // end states;
-
-} // end class Country_GB;
+ }
+}
diff --git a/inc/country/class-country-in.php b/inc/country/class-country-in.php
index 279c6fe..678356f 100644
--- a/inc/country/class-country-in.php
+++ b/inc/country/class-country-in.php
@@ -100,8 +100,7 @@ class Country_IN extends Country {
public function get_name() {
return __('India', 'wp-ultimo-locations');
-
- } // end get_name;
+ }
/**
* Returns the list of states for IN.
@@ -149,7 +148,5 @@ class Country_IN extends Country {
'UT' => __('Uttarakhand', 'wp-ultimo-locations'),
'WB' => __('West Bengal', 'wp-ultimo-locations'),
);
-
- } // end states;
-
-} // end class Country_IN;
+ }
+}
diff --git a/inc/country/class-country-jp.php b/inc/country/class-country-jp.php
index 92ddd8a..9ff1521 100644
--- a/inc/country/class-country-jp.php
+++ b/inc/country/class-country-jp.php
@@ -111,8 +111,7 @@ class Country_JP extends Country {
public function get_name() {
return __('Japan', 'wp-ultimo-locations');
-
- } // end get_name;
+ }
/**
* Returns the list of states for JP.
@@ -171,7 +170,5 @@ class Country_JP extends Country {
'09' => __('Tochigi Prefecture', 'wp-ultimo-locations'),
'06' => __('Yamagata Prefecture', 'wp-ultimo-locations'),
);
-
- } // end states;
-
-} // end class Country_JP;
+ }
+}
diff --git a/inc/country/class-country-mx.php b/inc/country/class-country-mx.php
index c7dbcea..1feb0a5 100644
--- a/inc/country/class-country-mx.php
+++ b/inc/country/class-country-mx.php
@@ -96,8 +96,7 @@ class Country_MX extends Country {
public function get_name() {
return __('Mexico', 'wp-ultimo-locations');
-
- } // end get_name;
+ }
/**
* Returns the list of states for MX.
@@ -141,7 +140,5 @@ class Country_MX extends Country {
'YUC' => __('Yucatán', 'wp-ultimo-locations'),
'ZAC' => __('Zacatecas', 'wp-ultimo-locations'),
);
-
- } // end states;
-
-} // end class Country_MX;
+ }
+}
diff --git a/inc/country/class-country-my.php b/inc/country/class-country-my.php
index d3ff656..3f4a38f 100644
--- a/inc/country/class-country-my.php
+++ b/inc/country/class-country-my.php
@@ -80,8 +80,7 @@ class Country_MY extends Country {
public function get_name() {
return __('Malaysia', 'wp-ultimo-locations');
-
- } // end get_name;
+ }
/**
* Returns the list of states for MY.
@@ -109,7 +108,5 @@ class Country_MY extends Country {
'08' => __('Perak', 'wp-ultimo-locations'),
'09' => __('Perlis', 'wp-ultimo-locations'),
);
-
- } // end states;
-
-} // end class Country_MY;
+ }
+}
diff --git a/inc/country/class-country-ne.php b/inc/country/class-country-ne.php
index 5734969..15a5925 100644
--- a/inc/country/class-country-ne.php
+++ b/inc/country/class-country-ne.php
@@ -71,8 +71,7 @@ class Country_NE extends Country {
public function get_name() {
return __('Niger', 'wp-ultimo-locations');
-
- } // end get_name;
+ }
/**
* Returns the list of states for NE.
@@ -91,7 +90,5 @@ class Country_NE extends Country {
'6' => __('Tillabéri Region', 'wp-ultimo-locations'),
'7' => __('Zinder Region', 'wp-ultimo-locations'),
);
-
- } // end states;
-
-} // end class Country_NE;
+ }
+}
diff --git a/inc/country/class-country-nl.php b/inc/country/class-country-nl.php
index 5d0f55b..886d5c7 100644
--- a/inc/country/class-country-nl.php
+++ b/inc/country/class-country-nl.php
@@ -76,8 +76,7 @@ class Country_NL extends Country {
public function get_name() {
return __('Netherlands', 'wp-ultimo-locations');
-
- } // end get_name;
+ }
/**
* Returns the list of states for NL.
@@ -104,7 +103,5 @@ class Country_NL extends Country {
'UT' => __('Utrecht', 'wp-ultimo-locations'),
'ZE' => __('Zeeland', 'wp-ultimo-locations'),
);
-
- } // end states;
-
-} // end class Country_NL;
+ }
+}
diff --git a/inc/country/class-country-ru.php b/inc/country/class-country-ru.php
index 268f377..d24dbc1 100644
--- a/inc/country/class-country-ru.php
+++ b/inc/country/class-country-ru.php
@@ -147,8 +147,7 @@ class Country_RU extends Country {
public function get_name() {
return __('Russia', 'wp-ultimo-locations');
-
- } // end get_name;
+ }
/**
* Returns the list of states for RU.
@@ -244,7 +243,5 @@ class Country_RU extends Country {
'YAR' => __('Yaroslavl Oblast', 'wp-ultimo-locations'),
'ZAB' => __('Zabaykalsky Krai', 'wp-ultimo-locations'),
);
-
- } // end states;
-
-} // end class Country_RU;
+ }
+}
diff --git a/inc/country/class-country-sg.php b/inc/country/class-country-sg.php
index f35ff23..aee2a52 100644
--- a/inc/country/class-country-sg.php
+++ b/inc/country/class-country-sg.php
@@ -66,8 +66,7 @@ class Country_SG extends Country {
public function get_name() {
return __('Singapore', 'wp-ultimo-locations');
-
- } // end get_name;
+ }
/**
* Returns the list of states for SG.
@@ -84,7 +83,5 @@ class Country_SG extends Country {
'04' => __('South East Community Development Council', 'wp-ultimo-locations'),
'05' => __('South West Community Development Council', 'wp-ultimo-locations'),
);
-
- } // end states;
-
-} // end class Country_SG;
+ }
+}
diff --git a/inc/country/class-country-tr.php b/inc/country/class-country-tr.php
index 9065024..466bb77 100644
--- a/inc/country/class-country-tr.php
+++ b/inc/country/class-country-tr.php
@@ -145,8 +145,7 @@ class Country_TR extends Country {
public function get_name() {
return __('Turkey', 'wp-ultimo-locations');
-
- } // end get_name;
+ }
/**
* Returns the list of states for TR.
@@ -239,7 +238,5 @@ class Country_TR extends Country {
'09' => __('Aydın', 'wp-ultimo-locations'),
'04' => __('Ağrı', 'wp-ultimo-locations'),
);
-
- } // end states;
-
-} // end class Country_TR;
+ }
+}
diff --git a/inc/country/class-country-us.php b/inc/country/class-country-us.php
index f78bbc8..b781daa 100644
--- a/inc/country/class-country-us.php
+++ b/inc/country/class-country-us.php
@@ -116,8 +116,7 @@ class Country_US extends Country {
public function get_name() {
return __('United States', 'wp-ultimo-locations');
-
- } // end get_name;
+ }
/**
* Returns the list of states for US.
@@ -195,7 +194,5 @@ class Country_US extends Country {
'WI' => __('Wisconsin', 'wp-ultimo-locations'),
'WY' => __('Wyoming', 'wp-ultimo-locations'),
);
-
- } // end states;
-
-} // end class Country_US;
+ }
+}
diff --git a/inc/country/class-country-za.php b/inc/country/class-country-za.php
index 82b4fd0..e66d1b0 100644
--- a/inc/country/class-country-za.php
+++ b/inc/country/class-country-za.php
@@ -73,8 +73,7 @@ class Country_ZA extends Country {
public function get_name() {
return __('South Africa', 'wp-ultimo-locations');
-
- } // end get_name;
+ }
/**
* Returns the list of states for ZA.
@@ -95,7 +94,5 @@ class Country_ZA extends Country {
'NC' => __('Northern Cape', 'wp-ultimo-locations'),
'WC' => __('Western Cape', 'wp-ultimo-locations'),
);
-
- } // end states;
-
-} // end class Country_ZA;
+ }
+}
diff --git a/inc/country/class-country.php b/inc/country/class-country.php
index 64dbdfc..d776ba4 100644
--- a/inc/country/class-country.php
+++ b/inc/country/class-country.php
@@ -59,8 +59,7 @@ abstract class Country {
public function __get($attribute) {
return wu_get_isset($this->attributes, $attribute, null);
-
- } // end __get;
+ }
/**
* Returns the list of states/provinces of this country.
@@ -85,8 +84,7 @@ abstract class Country {
* @return array The filtered list of states.
*/
return apply_filters('wu_country_get_states', $states, $this->country_code, $this);
-
- } // end get_states;
+ }
/**
* Returns states as options.
@@ -103,17 +101,14 @@ abstract class Country {
$placeholder_option = array();
if ($placeholder !== false && $options) {
-
$division_name = $this->get_administrative_division_name();
// translators: %s is the name of the administrative division (state, province, etc).
$placeholder_option[''] = $placeholder !== '' ? $placeholder : sprintf(__('Select your %s', 'wp-ultimo'), $division_name);
-
- } // end if;
+ }
return array_merge($placeholder_option, $options);
-
- } // end get_states_as_options;
+ }
/**
* Returns the list of cities for a country and state.
@@ -126,20 +121,16 @@ abstract class Country {
public function get_cities($state_code = '') {
if (empty($state_code)) {
-
return array();
-
- } // end if;
+ }
$repository_file = wu_path("inc/country/{$this->country_code}/{$state_code}.php");
if (file_exists($repository_file) === false) {
-
return array();
+ }
- } // end if;
-
- $cities = include($repository_file);
+ $cities = include $repository_file;
/**
* Returns the list of cities for a state in a country.
@@ -153,8 +144,7 @@ abstract class Country {
* @return array The filtered list of states.
*/
return apply_filters('wu_country_get_cities', $cities, $this->country_code, $state_code, $this);
-
- } // end get_cities;
+ }
/**
* Get state cities as options.
@@ -172,16 +162,13 @@ abstract class Country {
$placeholder_option = array();
if ($placeholder !== false && $options) {
-
$placeholder_option[''] = $placeholder !== '' ? $placeholder : __('Select your city', 'wp-ultimo');
-
- } // end if;
+ }
$options = array_combine($options, $options);
return array_merge($placeholder_option, $options);
-
- } // end get_cities_as_options;
+ }
/**
* Returns the list of states for a country.
@@ -192,8 +179,7 @@ abstract class Country {
protected function states() {
return array();
-
- } // end states;
+ }
/**
* Get the name of municipalities for a country/state.
@@ -214,8 +200,7 @@ abstract class Country {
$name = $ucwords ? ucwords($name) : $name;
return apply_filters('wu_country_get_municipality_name', $name, $this->country_code, $state_code, $ucwords, $this);
-
- } // end get_municipality_name;
+ }
/**
* Get the name given to states for a country.
@@ -263,7 +248,5 @@ abstract class Country {
* @return string The modified division name.
*/
return apply_filters('wu_country_get_administrative_division_name', $name, $this->country_code, $state_code, $ucwords, $this);
-
- } // end get_administrative_division_name;
-
-} // end class Country;
+ }
+}
diff --git a/inc/database/broadcasts/class-broadcast-query.php b/inc/database/broadcasts/class-broadcast-query.php
index 17d56cc..ea48f15 100644
--- a/inc/database/broadcasts/class-broadcast-query.php
+++ b/inc/database/broadcasts/class-broadcast-query.php
@@ -78,7 +78,5 @@ class Broadcast_Query extends Post_Query {
$query['type__in'] = array('broadcast_email', 'broadcast_notice');
return parent::query($query);
-
- } // end query;
-
-} // end class Broadcast_Query;
+ }
+}
diff --git a/inc/database/checkout-forms/class-checkout-form-query.php b/inc/database/checkout-forms/class-checkout-form-query.php
index 023d2c9..6355810 100644
--- a/inc/database/checkout-forms/class-checkout-form-query.php
+++ b/inc/database/checkout-forms/class-checkout-form-query.php
@@ -107,7 +107,5 @@ class Checkout_Form_Query extends Query {
public function __construct($query = array()) {
parent::__construct($query);
-
- } // end __construct;
-
-} // end class Checkout_Form_Query;
+ }
+}
diff --git a/inc/database/checkout-forms/class-checkout-forms-meta-table.php b/inc/database/checkout-forms/class-checkout-forms-meta-table.php
index dcc0443..21e40ef 100644
--- a/inc/database/checkout-forms/class-checkout-forms-meta-table.php
+++ b/inc/database/checkout-forms/class-checkout-forms-meta-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Checkout_Forms_Meta_Table extends Table {
/**
- * Table name
- *
- * @since 2.0.0
- * @var string
- */
+ * Table name
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $name = 'formmeta';
/**
@@ -55,8 +55,7 @@ final class Checkout_Forms_Meta_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema
@@ -76,7 +75,5 @@ final class Checkout_Forms_Meta_Table extends Table {
PRIMARY KEY (meta_id),
KEY wu_form_id (wu_form_id),
KEY meta_key (meta_key({$max_index_length}))";
-
- } // end set_schema;
-
-} // end class Checkout_Forms_Meta_Table;
+ }
+}
diff --git a/inc/database/checkout-forms/class-checkout-forms-schema.php b/inc/database/checkout-forms/class-checkout-forms-schema.php
index 856a6d4..a789c1f 100644
--- a/inc/database/checkout-forms/class-checkout-forms-schema.php
+++ b/inc/database/checkout-forms/class-checkout-forms-schema.php
@@ -110,5 +110,4 @@ class Checkout_Forms_Schema extends Schema {
),
);
-
-} // end class Checkout_Forms_Schema;
+}
diff --git a/inc/database/checkout-forms/class-checkout-forms-table.php b/inc/database/checkout-forms/class-checkout-forms-table.php
index d25469d..0112763 100644
--- a/inc/database/checkout-forms/class-checkout-forms-table.php
+++ b/inc/database/checkout-forms/class-checkout-forms-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Checkout_Forms_Table extends Table {
/**
- * Table name
- *
- * @since 2.0.0
- * @var string
- */
+ * Table name
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $name = 'forms';
/**
@@ -64,8 +64,7 @@ final class Checkout_Forms_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema
@@ -86,8 +85,7 @@ final class Checkout_Forms_Table extends Table {
date_created datetime DEFAULT NULL,
date_modified datetime DEFAULT NULL,
PRIMARY KEY (id)";
-
- } // end set_schema;
+ }
/**
* Fixes the datetime columns to accept null.
*
@@ -101,21 +99,15 @@ final class Checkout_Forms_Table extends Table {
);
foreach ($null_columns as $column) {
-
$query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;";
$result = $this->get_db()->query($query);
- if (!$this->is_success($result)) {
-
+ if ( ! $this->is_success($result)) {
return false;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
return true;
-
- } // end __20230601;
-
-} // end class Checkout_Forms_Table;
+ }
+}
diff --git a/inc/database/customers/class-customer-query.php b/inc/database/customers/class-customer-query.php
index 5f11d4e..fd68874 100644
--- a/inc/database/customers/class-customer-query.php
+++ b/inc/database/customers/class-customer-query.php
@@ -109,7 +109,5 @@ class Customer_Query extends Query {
// $query['type'] = 'customer';
parent::__construct($query);
-
- } // end __construct;
-
-} // end class Customer_Query;
+ }
+}
diff --git a/inc/database/customers/class-customers-meta-table.php b/inc/database/customers/class-customers-meta-table.php
index a52751a..08d1769 100644
--- a/inc/database/customers/class-customers-meta-table.php
+++ b/inc/database/customers/class-customers-meta-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Customers_Meta_Table extends Table {
/**
- * Table name
- *
- * @since 2.0.0
- * @var string
- */
+ * Table name
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $name = 'customermeta';
/**
@@ -55,8 +55,7 @@ final class Customers_Meta_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema
@@ -76,7 +75,5 @@ final class Customers_Meta_Table extends Table {
PRIMARY KEY (meta_id),
KEY wu_customer_id (wu_customer_id),
KEY meta_key (meta_key({$max_index_length}))";
-
- } // end set_schema;
-
-} // end class Customers_Meta_Table;
+ }
+}
diff --git a/inc/database/customers/class-customers-schema.php b/inc/database/customers/class-customers-schema.php
index f20dda8..34b2295 100644
--- a/inc/database/customers/class-customers-schema.php
+++ b/inc/database/customers/class-customers-schema.php
@@ -129,5 +129,4 @@ class Customers_Schema extends Schema {
),
);
-
-} // end class Customers_Schema;
+}
diff --git a/inc/database/customers/class-customers-table.php b/inc/database/customers/class-customers-table.php
index 70131ff..fc7a535 100644
--- a/inc/database/customers/class-customers-table.php
+++ b/inc/database/customers/class-customers-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Customers_Table extends Table {
/**
- * Table name
- *
- * @since 2.0.0
- * @var string
- */
+ * Table name
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $name = 'customers';
/**
@@ -66,8 +66,7 @@ final class Customers_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema
@@ -91,8 +90,7 @@ final class Customers_Table extends Table {
signup_form varchar(40) DEFAULT 'by-admin',
PRIMARY KEY (id),
KEY user_id (user_id)";
-
- } // end set_schema;
+ }
/**
* Adds the signup_form column.
@@ -109,17 +107,14 @@ final class Customers_Table extends Table {
// Maybe add column
if (empty($result)) {
-
$query = "ALTER TABLE {$this->table_name} ADD COLUMN `signup_form` varchar(40) default 'by-admin' AFTER `ips`;";
$result = $this->get_db()->query($query);
-
- } // end if;
+ }
// Return success/fail
return $this->is_success($result);
-
- } // end __20210508;
+ }
/**
* Adds the signup_form column.
@@ -133,27 +128,22 @@ final class Customers_Table extends Table {
// Maybe add column
if (empty($result)) {
-
$query_set = "SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';";
$result_set = $this->get_db()->query($query_set);
if ($this->is_success($result_set) === false) {
-
return false;
-
- } // end if;
+ }
$query = "ALTER TABLE {$this->table_name} ADD COLUMN `signup_form` varchar(40) default 'by-admin' AFTER `ips`;";
$result = $this->get_db()->query($query);
-
- } // end if;
+ }
// Return success/fail
return $this->is_success($result);
-
- } // end __20210607;
+ }
/**
* Fixes the datetime columns to accept null.
@@ -169,21 +159,15 @@ final class Customers_Table extends Table {
);
foreach ($null_columns as $column) {
-
$query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;";
$result = $this->get_db()->query($query);
- if (!$this->is_success($result)) {
-
+ if ( ! $this->is_success($result)) {
return false;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
return true;
-
- } // end __20230601;
-
-} // end class Customers_Table;
+ }
+}
diff --git a/inc/database/discount-codes/class-discount-code-query.php b/inc/database/discount-codes/class-discount-code-query.php
index b4716a0..4a5f938 100644
--- a/inc/database/discount-codes/class-discount-code-query.php
+++ b/inc/database/discount-codes/class-discount-code-query.php
@@ -107,7 +107,5 @@ class Discount_Code_Query extends Query {
public function __construct($query = array()) {
parent::__construct($query);
-
- } // end __construct;
-
-} // end class Discount_Code_Query;
+ }
+}
diff --git a/inc/database/discount-codes/class-discount-codes-meta-table.php b/inc/database/discount-codes/class-discount-codes-meta-table.php
index 4590ad4..88a1635 100644
--- a/inc/database/discount-codes/class-discount-codes-meta-table.php
+++ b/inc/database/discount-codes/class-discount-codes-meta-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Discount_Codes_Meta_Table extends Table {
/**
- * Table name
- *
- * @since 2.0.0
- * @var string
- */
+ * Table name
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $name = 'discount_codemeta';
/**
@@ -55,8 +55,7 @@ final class Discount_Codes_Meta_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema
@@ -76,7 +75,5 @@ final class Discount_Codes_Meta_Table extends Table {
PRIMARY KEY (meta_id),
KEY wu_discount_code_id (wu_discount_code_id),
KEY meta_key (meta_key({$max_index_length}))";
-
- } // end set_schema;
-
-} // end class Discount_Codes_Meta_Table;
+ }
+}
diff --git a/inc/database/discount-codes/class-discount-codes-schema.php b/inc/database/discount-codes/class-discount-codes-schema.php
index fc34093..6915726 100644
--- a/inc/database/discount-codes/class-discount-codes-schema.php
+++ b/inc/database/discount-codes/class-discount-codes-schema.php
@@ -172,5 +172,4 @@ class Discount_Codes_Schema extends Schema {
),
);
-
-} // end class Discount_Codes_Schema;
+}
diff --git a/inc/database/discount-codes/class-discount-codes-table.php b/inc/database/discount-codes/class-discount-codes-table.php
index 1a6bcb9..1f532b9 100644
--- a/inc/database/discount-codes/class-discount-codes-table.php
+++ b/inc/database/discount-codes/class-discount-codes-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Discount_Codes_Table extends Table {
/**
- * Table name
- *
- * @since 2.0.0
- * @var string
- */
+ * Table name
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $name = 'discount_codes';
/**
@@ -64,8 +64,7 @@ final class Discount_Codes_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema
@@ -93,8 +92,7 @@ final class Discount_Codes_Table extends Table {
date_created datetime NULL,
date_modified datetime NULL,
PRIMARY KEY (id)";
-
- } // end set_schema;
+ }
/**
* Fixes the datetime columns to accept null.
*
@@ -108,21 +106,15 @@ final class Discount_Codes_Table extends Table {
);
foreach ($null_columns as $column) {
-
$query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;";
$result = $this->get_db()->query($query);
- if (!$this->is_success($result)) {
-
+ if ( ! $this->is_success($result)) {
return false;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
return true;
-
- } // end __20230601;
-
-} // end class Discount_Codes_Table;
+ }
+}
diff --git a/inc/database/domains/class-domain-query.php b/inc/database/domains/class-domain-query.php
index 93e7d15..f74f1e6 100644
--- a/inc/database/domains/class-domain-query.php
+++ b/inc/database/domains/class-domain-query.php
@@ -107,7 +107,5 @@ class Domain_Query extends Query {
public function __construct($query = array()) {
parent::__construct($query);
-
- } // end __construct;
-
-} // end class Domain_Query;
+ }
+}
diff --git a/inc/database/domains/class-domain-stage.php b/inc/database/domains/class-domain-stage.php
index fd2b50e..2b84b96 100644
--- a/inc/database/domains/class-domain-stage.php
+++ b/inc/database/domains/class-domain-stage.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Database\Domains;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Database\Engine\Enum;
+use WP_Ultimo\Database\Engine\Enum;
/**
* Domain Stage.
@@ -47,8 +47,7 @@ class Domain_Stage extends Enum {
static::DONE => 'wu-bg-green-200 wu-text-green-700',
static::DONE_WITHOUT_SSL => 'wu-bg-gray-800 wu-text-white',
);
-
- } // end classes;
+ }
/**
* Returns an array with values => labels.
@@ -65,7 +64,5 @@ class Domain_Stage extends Enum {
static::DONE => __('Ready', 'wp-ultimo'),
static::DONE_WITHOUT_SSL => __('Ready (without SSL)', 'wp-ultimo'),
);
-
- } // end labels;
-
-} // end class Domain_Stage;
+ }
+}
diff --git a/inc/database/domains/class-domains-schema.php b/inc/database/domains/class-domains-schema.php
index 5db966a..05be786 100644
--- a/inc/database/domains/class-domains-schema.php
+++ b/inc/database/domains/class-domains-schema.php
@@ -37,7 +37,7 @@ class Domains_Schema extends Schema {
'unsigned' => true,
'extra' => 'auto_increment',
'primary' => true,
- 'sortable' => true
+ 'sortable' => true,
),
array(
@@ -117,5 +117,4 @@ class Domains_Schema extends Schema {
),
);
-
-} // end class Domains_Schema;
+}
diff --git a/inc/database/domains/class-domains-table.php b/inc/database/domains/class-domains-table.php
index 5dbc6e3..fe441b3 100644
--- a/inc/database/domains/class-domains-table.php
+++ b/inc/database/domains/class-domains-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Domains_Table extends Table {
/**
- * Table name
- *
- * @since 2.0.0
- * @var string
- */
+ * Table name
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $name = 'domain_mappings';
/**
@@ -64,8 +64,7 @@ final class Domains_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema
@@ -88,8 +87,7 @@ final class Domains_Table extends Table {
PRIMARY KEY (id),
KEY blog_id (blog_id,domain,active),
KEY domain (domain)";
-
- } // end set_schema;
+ }
/**
* Fixes the datetime columns to accept null.
*
@@ -103,21 +101,15 @@ final class Domains_Table extends Table {
);
foreach ($null_columns as $column) {
-
$query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;";
$result = $this->get_db()->query($query);
- if (!$this->is_success($result)) {
-
+ if ( ! $this->is_success($result)) {
return false;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
return true;
-
- } // end __20230601;
-
-} // end class Domains_Table;
+ }
+}
diff --git a/inc/database/emails/class-email-query.php b/inc/database/emails/class-email-query.php
index bdd9571..afa316e 100644
--- a/inc/database/emails/class-email-query.php
+++ b/inc/database/emails/class-email-query.php
@@ -78,7 +78,5 @@ class Email_Query extends Post_Query {
$query['type__in'] = array('system_email');
return parent::query($query);
-
- } // end query;
-
-} // end class Email_Query;
+ }
+}
diff --git a/inc/database/engine/class-base.php b/inc/database/engine/class-base.php
index 095672b..00c6b98 100644
--- a/inc/database/engine/class-base.php
+++ b/inc/database/engine/class-base.php
@@ -20,5 +20,4 @@ defined('ABSPATH') || exit;
class Base extends \BerlinDB\Database\Base {
protected $prefix = 'wu';
-
-} // end class Base;
+}
diff --git a/inc/database/engine/class-column.php b/inc/database/engine/class-column.php
index eed9744..051c619 100644
--- a/inc/database/engine/class-column.php
+++ b/inc/database/engine/class-column.php
@@ -20,5 +20,4 @@ defined('ABSPATH') || exit;
class Column extends \BerlinDB\Database\Column {
protected $prefix = 'wu';
-
-} // end class Column;
+}
diff --git a/inc/database/engine/class-compare.php b/inc/database/engine/class-compare.php
index 5cc8bc5..77b24ff 100644
--- a/inc/database/engine/class-compare.php
+++ b/inc/database/engine/class-compare.php
@@ -17,4 +17,4 @@ defined('ABSPATH') || exit;
*
* @since 1.0.0
*/
-class Compare extends \BerlinDB\Database\Compare {} // end class Compare;
+class Compare extends \BerlinDB\Database\Compare {}
diff --git a/inc/database/engine/class-date.php b/inc/database/engine/class-date.php
index 8d6d2e2..ed19021 100644
--- a/inc/database/engine/class-date.php
+++ b/inc/database/engine/class-date.php
@@ -17,4 +17,4 @@ defined('ABSPATH') || exit;
*
* @since 1.0.0
*/
-class Date extends \BerlinDB\Database\Date {} // end class Date;
+class Date extends \BerlinDB\Database\Date {}
diff --git a/inc/database/engine/class-enum.php b/inc/database/engine/class-enum.php
index 21e1c34..663ad54 100644
--- a/inc/database/engine/class-enum.php
+++ b/inc/database/engine/class-enum.php
@@ -17,265 +17,242 @@ defined('ABSPATH') || exit;
*
* @since 2.0.0
*/
-abstract class Enum
-{
- /**
- * The default value.
- */
- const __default = false;
+abstract class Enum {
+
+ /**
+ * The default value.
+ */
+ const __default = false;
// phpcs:ignore
/**
- * The options available.
- *
- * @since 2.0.0
- * @var array
- */
- static $options = array();
- /**
- * @var string
- */
- private $value = '';
- /**
- * Constructor method. Takes the value you want to set.
- *
- * @since 2.0.0
- *
- * @param string $value The value to be set.
- */
- public function __construct($value = '')
- {
- $this->value = $value;
- }
- // end __construct;
- // Needs to be Implemented
- /**
- * Returns an array with values => CSS Classes.
- *
- * @since 2.0.0
- * @return array
- */
- abstract protected function classes();
- /**
- * Returns an array with values => labels.
- *
- * @since 2.0.0
- * @return void
- */
- abstract protected function labels();
- /**
- * Returns an array with values => labels.
- *
- * @since 2.0.0
- * @return void
- */
- protected function icon_classes() {
+ * The options available.
+ *
+ * @since 2.0.0
+ * @var array
+ */
+ static $options = array();
+ /**
+ * @var string
+ */
+ private $value = '';
+ /**
+ * Constructor method. Takes the value you want to set.
+ *
+ * @since 2.0.0
+ *
+ * @param string $value The value to be set.
+ */
+ public function __construct($value = '') {
+ $this->value = $value;
+ }
- return array();
+ // Needs to be Implemented
+ /**
+ * Returns an array with values => CSS Classes.
+ *
+ * @since 2.0.0
+ * @return array
+ */
+ abstract protected function classes();
+ /**
+ * Returns an array with values => labels.
+ *
+ * @since 2.0.0
+ * @return void
+ */
+ abstract protected function labels();
+ /**
+ * Returns an array with values => labels.
+ *
+ * @since 2.0.0
+ * @return void
+ */
+ protected function icon_classes() {
- }
- // end icon_classes;
- /**
- * Returns the options available as constants.
- *
- * @since 2.0.0
- * @return array
- */
- public static function get_options() {
+ return array();
+ }
- $hook = static::get_hook_name();
+ /**
+ * Returns the options available as constants.
+ *
+ * @since 2.0.0
+ * @return array
+ */
+ public static function get_options() {
- if (!isset(static::$options[$hook])) {
+ $hook = static::get_hook_name();
- $reflector = new \ReflectionClass(static::class);
+ if ( ! isset(static::$options[ $hook ])) {
+ $reflector = new \ReflectionClass(static::class);
- static::$options[$hook] = apply_filters("wu_available_{$hook}_options", $reflector->getConstants());
+ static::$options[ $hook ] = apply_filters("wu_available_{$hook}_options", $reflector->getConstants());
+ }
- } // end if;
+ return static::$options[ $hook ];
+ }
- return static::$options[$hook];
+ public static function get_allowed_list($string = false) {
- }
- // end get_options;
- public static function get_allowed_list($string = false) {
+ $options = array_unique(self::get_options());
- $options = array_unique(self::get_options());
+ return $string ? implode(',', $options) : $options;
+ }
- return $string ? implode(',', $options) : $options;
+ /**
+ * Returns the value loaded here.
+ *
+ * This runs through is_valid and returns the
+ * default value if a invalid value is passed on.
+ *
+ * @since 2.0.0
+ * @return string
+ */
+ public function get_value() {
- }
- // end get_allowed_list;
- /**
- * Returns the value loaded here.
- *
- * This runs through is_valid and returns the
- * default value if a invalid value is passed on.
- *
- * @since 2.0.0
- * @return string
- */
- public function get_value() {
+ if ($this->is_valid($this->value)) {
+ return $this->value;
+ }
- if ($this->is_valid($this->value)) {
+ return static::__default;
+ }
- return $this->value;
+ /**
+ * Check for the the validity of the value passed.
+ *
+ * @since 2.0.0
+ *
+ * @param string $value The string.
+ * @return boolean
+ */
+ public function is_valid($value) {
- } // end if;
+ $options = static::get_options();
- return static::__default;
+ return in_array($value, $options, true);
+ }
- }
- // end get_value;
- /**
- * Check for the the validity of the value passed.
- *
- * @since 2.0.0
- *
- * @param string $value The string.
- * @return boolean
- */
- public function is_valid($value) {
+ /**
+ * Returns the label of a given value.
+ *
+ * @since 2.0.0
+ * @return string
+ */
+ public function get_label() {
- $options = static::get_options();
+ $hook = static::get_hook_name();
- return in_array($value, $options, true);
+ $labels = apply_filters("wu_available_{$hook}_labels", $this->labels());
- }
- // end is_valid;
- /**
- * Returns the label of a given value.
- *
- * @since 2.0.0
- * @return string
- */
- public function get_label() {
+ return $this->exists_or_default($labels, $this->get_value());
+ }
- $hook = static::get_hook_name();
+ /**
+ * Returns the classes of a given value.
+ *
+ * @since 2.0.0
+ * @return string
+ */
+ public function get_classes() {
- $labels = apply_filters("wu_available_{$hook}_labels", $this->labels());
+ $hook = static::get_hook_name();
- return $this->exists_or_default($labels, $this->get_value());
+ $classes = apply_filters("wu_available_{$hook}_classes", $this->classes());
- }
- // end get_label;
- /**
- * Returns the classes of a given value.
- *
- * @since 2.0.0
- * @return string
- */
- public function get_classes() {
+ return $this->exists_or_default($classes, $this->get_value());
+ }
- $hook = static::get_hook_name();
+ /**
+ * Returns the classes of a given value.
+ *
+ * @since 2.0.0
+ * @return string
+ */
+ public function get_icon_classes() {
- $classes = apply_filters("wu_available_{$hook}_classes", $this->classes());
+ $hook = static::get_hook_name();
- return $this->exists_or_default($classes, $this->get_value());
+ $classes = apply_filters("wu_available_{$hook}_icon_classes", $this->icon_classes());
- }
- // end get_classes;
- /**
- * Returns the classes of a given value.
- *
- * @since 2.0.0
- * @return string
- */
- public function get_icon_classes() {
+ return $this->exists_or_default($classes, $this->get_value());
+ }
- $hook = static::get_hook_name();
+ /**
+ * Returns an array of options.
+ *
+ * @since 2.0.0
+ * @return void
+ */
+ public static function to_array() {
- $classes = apply_filters("wu_available_{$hook}_icon_classes", $this->icon_classes());
+ static $instance;
- return $this->exists_or_default($classes, $this->get_value());
+ if ($instance === null) {
+ $instance = new static();
+ }
- }
- // end get_icon_classes;
- /**
- * Returns an array of options.
- *
- * @since 2.0.0
- * @return void
- */
- public static function to_array() {
+ $hook = $instance::get_hook_name();
- static $instance;
+ $labels = apply_filters("wu_{$hook}_to_array", $instance->labels());
- if ($instance === null) {
+ return $labels;
+ }
- $instance = new static;
+ /**
+ * Get the hook name for this class, so we can add filters.
+ *
+ * @since 2.0.0
+ * @return string
+ */
+ public static function get_hook_name() {
- } // end if;
+ $class_name = (new \ReflectionClass(static::class))->getShortName();
- $hook = $instance::get_hook_name();
+ return strtolower($class_name);
+ }
- $labels = apply_filters("wu_{$hook}_to_array", $instance->labels());
+ /**
+ * Checks if a key exists on an array, otherwise returns a default value.
+ *
+ * @since 2.0.0
+ *
+ * @param array $array The array to check.
+ * @param string $key The key to check.
+ * @param string $default The default value.
+ * @return string
+ */
+ public function exists_or_default($array, $key, $default = '') {
- return $labels;
+ if (empty($default)) {
+ $default = isset($array[ static::__default ]) ? $array[ static::__default ] : '';
+ }
- }
- // end to_array;
- /**
- * Get the hook name for this class, so we can add filters.
- *
- * @since 2.0.0
- * @return string
- */
- public static function get_hook_name() {
+ return isset($array[ $key ]) ? $array[ $key ] : $default;
+ }
- $class_name = (new \ReflectionClass(static::class))->getShortName();
+ /**
+ * Converts this to string.
+ *
+ * @since 2.0.0
+ * @return string
+ */
+ public function __toString(): string {
- return strtolower($class_name);
+ return $this->get_value();
+ }
- }
- // end get_hook_name;
- /**
- * Checks if a key exists on an array, otherwise returns a default value.
- *
- * @since 2.0.0
- *
- * @param array $array The array to check.
- * @param string $key The key to check.
- * @param string $default The default value.
- * @return string
- */
- public function exists_or_default($array, $key, $default = '') {
+ /**
+ * Magic method to allow for constants to be called.
+ *
+ * @since 2.0.0
+ *
+ * @param string $name The name of the constants.
+ * @param array $arguments The list of arguments. Not really needed here.
+ * @return string
+ */
+ public static function __callStatic($name, $arguments) {
- if (empty($default)) {
+ $class_name = static::class;
- $default = isset($array[static::__default]) ? $array[static::__default] : '';
-
- } // end if;
-
- return isset($array[$key]) ? $array[$key] : $default;
-
- }
- // end exists_or_default;
- /**
- * Converts this to string.
- *
- * @since 2.0.0
- * @return string
- */
- public function __toString(): string {
-
- return $this->get_value();
-
- }
- // end __toString;
- /**
- * Magic method to allow for constants to be called.
- *
- * @since 2.0.0
- *
- * @param string $name The name of the constants.
- * @param array $arguments The list of arguments. Not really needed here.
- * @return string
- */
- public static function __callStatic($name, $arguments) {
-
- $class_name = static::class;
-
- return constant("$class_name::$name");
-
- }
- // end __callStatic;
-} // end class Enum;
+ return constant("$class_name::$name");
+ }
+}
diff --git a/inc/database/engine/class-meta.php b/inc/database/engine/class-meta.php
index d071080..b2bc601 100644
--- a/inc/database/engine/class-meta.php
+++ b/inc/database/engine/class-meta.php
@@ -17,4 +17,4 @@ defined('ABSPATH') || exit;
*
* @since 1.0.0
*/
-class Meta extends \BerlinDB\Database\Meta {} // end class Meta;
+class Meta extends \BerlinDB\Database\Meta {}
diff --git a/inc/database/engine/class-query.php b/inc/database/engine/class-query.php
index 0b116e3..9f2cb4a 100644
--- a/inc/database/engine/class-query.php
+++ b/inc/database/engine/class-query.php
@@ -19,7 +19,7 @@ defined('ABSPATH') || exit;
*/
class Query extends \BerlinDB\Database\Query {
- /**
+ /**
* The prefix for the custom table.
*
* @since 2.0.0
@@ -73,17 +73,14 @@ class Query extends \BerlinDB\Database\Query {
$cache_group = $this->apply_prefix($this->cache_group, '-');
- if ($this->global_cache && !in_array($cache_group, self::$added_globals, true)) {
-
+ if ($this->global_cache && ! in_array($cache_group, self::$added_globals, true)) {
wp_cache_add_global_groups(array($cache_group));
self::$added_globals[] = $cache_group;
-
- } // end if;
+ }
parent::__construct($query);
-
- } // end __construct;
+ }
/**
* Get the plural name.
@@ -94,7 +91,5 @@ class Query extends \BerlinDB\Database\Query {
public function get_plural_name() {
return $this->item_name_plural;
-
- } // end get_plural_name;
-
-} // end class Query;
+ }
+}
diff --git a/inc/database/engine/class-row.php b/inc/database/engine/class-row.php
index a164e82..8dd7eb7 100644
--- a/inc/database/engine/class-row.php
+++ b/inc/database/engine/class-row.php
@@ -20,5 +20,4 @@ defined('ABSPATH') || exit;
class Row extends \BerlinDB\Database\Row {
protected $prefix = 'wu';
-
-} // end class Row;
+}
diff --git a/inc/database/engine/class-schema.php b/inc/database/engine/class-schema.php
index ad3d624..fda65dd 100644
--- a/inc/database/engine/class-schema.php
+++ b/inc/database/engine/class-schema.php
@@ -20,5 +20,4 @@ defined('ABSPATH') || exit;
class Schema extends \BerlinDB\Database\Schema {
protected $prefix = 'wu';
-
-} // end class Schema;
+}
diff --git a/inc/database/engine/class-table.php b/inc/database/engine/class-table.php
index a786381..5f0aa5f 100644
--- a/inc/database/engine/class-table.php
+++ b/inc/database/engine/class-table.php
@@ -47,21 +47,16 @@ abstract class Table extends \BerlinDB\Database\Table {
*/
public function is_upgradeable() {
- if (!is_main_network()) {
-
+ if ( ! is_main_network()) {
return false;
+ }
- } // end if;
-
- if (!is_main_site()) {
-
+ if ( ! is_main_site()) {
return false;
-
- } // end if;
+ }
return true;
-
- } // end is_upgradeable;
+ }
/**
* Adds a caching layer to the parent exists method.
@@ -72,13 +67,9 @@ abstract class Table extends \BerlinDB\Database\Table {
public function exists() {
if ($this->_exists === null) {
-
$this->_exists = parent::exists();
-
- } // end if;
+ }
return $this->_exists;
-
- } // end exists;
-
-} // end class Table;
+ }
+}
diff --git a/inc/database/events/class-event-query.php b/inc/database/events/class-event-query.php
index e930d66..2b67f55 100644
--- a/inc/database/events/class-event-query.php
+++ b/inc/database/events/class-event-query.php
@@ -107,7 +107,5 @@ class Event_Query extends Query {
public function __construct($query = array()) {
parent::__construct($query);
-
- } // end __construct;
-
-} // end class Event_Query;
+ }
+}
diff --git a/inc/database/events/class-events-schema.php b/inc/database/events/class-events-schema.php
index 4a3462b..b9680e3 100644
--- a/inc/database/events/class-events-schema.php
+++ b/inc/database/events/class-events-schema.php
@@ -104,5 +104,4 @@ class Events_Schema extends Schema {
),
);
-
-} // end class Events_Schema;
+}
diff --git a/inc/database/events/class-events-table.php b/inc/database/events/class-events-table.php
index a6087d0..6d1d9ed 100644
--- a/inc/database/events/class-events-table.php
+++ b/inc/database/events/class-events-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Events_Table extends Table {
/**
- * Table name
- *
- * @since 2.0.0
- * @var string
- */
+ * Table name
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $name = 'events';
/**
@@ -64,8 +64,7 @@ final class Events_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema
@@ -89,8 +88,7 @@ final class Events_Table extends Table {
KEY severity (severity),
KEY author_id (author_id),
KEY initiator (initiator)";
-
- } // end set_schema;
+ }
/**
* Fixes the datetime columns to accept null.
*
@@ -103,21 +101,15 @@ final class Events_Table extends Table {
);
foreach ($null_columns as $column) {
-
$query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;";
$result = $this->get_db()->query($query);
- if (!$this->is_success($result)) {
-
+ if ( ! $this->is_success($result)) {
return false;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
return true;
-
- } // end __20230601;
-
-} // end class Events_Table;
+ }
+}
diff --git a/inc/database/memberships/class-membership-query.php b/inc/database/memberships/class-membership-query.php
index fdf554a..4035294 100644
--- a/inc/database/memberships/class-membership-query.php
+++ b/inc/database/memberships/class-membership-query.php
@@ -107,7 +107,5 @@ class Membership_Query extends Query {
public function __construct($query = array()) {
parent::__construct($query);
-
- } // end __construct;
-
-} // end class Membership_Query;
+ }
+}
diff --git a/inc/database/memberships/class-membership-status.php b/inc/database/memberships/class-membership-status.php
index e794601..92f3492 100644
--- a/inc/database/memberships/class-membership-status.php
+++ b/inc/database/memberships/class-membership-status.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Database\Memberships;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Database\Engine\Enum;
+use WP_Ultimo\Database\Engine\Enum;
/**
* Membership Status.
@@ -49,8 +49,7 @@ class Membership_Status extends Enum {
static::EXPIRED => 'wu-bg-yellow-200 wu-text-yellow-700',
static::CANCELLED => 'wu-bg-red-200 wu-text-red-700',
);
-
- } // end classes;
+ }
/**
* Returns an array with values => labels.
@@ -68,7 +67,5 @@ class Membership_Status extends Enum {
static::EXPIRED => __('Expired', 'wp-ultimo'),
static::CANCELLED => __('Cancelled', 'wp-ultimo'),
);
-
- } // end labels;
-
-} // end class Membership_Status;
+ }
+}
diff --git a/inc/database/memberships/class-memberships-meta-table.php b/inc/database/memberships/class-memberships-meta-table.php
index 6953a90..0a0cabc 100644
--- a/inc/database/memberships/class-memberships-meta-table.php
+++ b/inc/database/memberships/class-memberships-meta-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Memberships_Meta_Table extends Table {
/**
- * Table name
- *
- * @since 2.0.0
- * @var string
- */
+ * Table name
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $name = 'membershipmeta';
/**
@@ -55,8 +55,7 @@ final class Memberships_Meta_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema
@@ -76,7 +75,5 @@ final class Memberships_Meta_Table extends Table {
PRIMARY KEY (meta_id),
KEY wu_membership_id (wu_membership_id),
KEY meta_key (meta_key({$max_index_length}))";
-
- } // end set_schema;
-
-} // end class Memberships_Meta_Table;
+ }
+}
diff --git a/inc/database/memberships/class-memberships-schema.php b/inc/database/memberships/class-memberships-schema.php
index ccca5b3..c9c985d 100644
--- a/inc/database/memberships/class-memberships-schema.php
+++ b/inc/database/memberships/class-memberships-schema.php
@@ -57,7 +57,7 @@ class Memberships_Schema extends Schema {
'length' => '20',
'unsigned' => true,
'default' => null,
- 'allow_null' => true
+ 'allow_null' => true,
),
array(
@@ -76,7 +76,7 @@ class Memberships_Schema extends Schema {
'length' => '20',
'unsigned' => true,
'sortable' => true,
- 'transition' => true
+ 'transition' => true,
),
// addons
@@ -91,7 +91,7 @@ class Memberships_Schema extends Schema {
'type' => 'varchar',
'length' => '20',
'default' => 'USD',
- 'sortable' => true
+ 'sortable' => true,
),
array(
@@ -128,7 +128,7 @@ class Memberships_Schema extends Schema {
'unsigned' => true,
'default' => '0',
'sortable' => true,
- 'transition' => true
+ 'transition' => true,
),
array(
@@ -224,7 +224,7 @@ class Memberships_Schema extends Schema {
'type' => 'smallint',
'unsigned' => true,
'default' => '0',
- 'transition' => true
+ 'transition' => true,
),
// times_billed
@@ -234,7 +234,7 @@ class Memberships_Schema extends Schema {
'unsigned' => true,
'default' => '0',
'sortable' => true,
- 'transition' => true
+ 'transition' => true,
),
// billing_cycles
@@ -243,7 +243,7 @@ class Memberships_Schema extends Schema {
'type' => 'smallint',
'unsigned' => true,
'default' => '0',
- 'sortable' => true
+ 'sortable' => true,
),
// status
@@ -263,7 +263,7 @@ class Memberships_Schema extends Schema {
'default' => '',
'searchable' => true,
'sortable' => true,
- 'transition' => true
+ 'transition' => true,
),
// gateway_subscription_id
@@ -273,7 +273,7 @@ class Memberships_Schema extends Schema {
'default' => '',
'searchable' => true,
'sortable' => true,
- 'transition' => true
+ 'transition' => true,
),
// gateway
@@ -298,7 +298,7 @@ class Memberships_Schema extends Schema {
'length' => '32',
'default' => '',
'searchable' => true,
- 'sortable' => true
+ 'sortable' => true,
),
// upgraded_from
@@ -307,7 +307,7 @@ class Memberships_Schema extends Schema {
'type' => 'bigint',
'length' => '20',
'unsigned' => true,
- 'default' => ''
+ 'default' => '',
),
// date_modified
@@ -317,7 +317,7 @@ class Memberships_Schema extends Schema {
'default' => null,
'modified' => true,
'date_query' => true,
- 'sortable' => true
+ 'sortable' => true,
),
// disabled
@@ -326,9 +326,8 @@ class Memberships_Schema extends Schema {
'type' => 'smallint',
'unsigned' => true,
'default' => '',
- 'pattern' => '%d'
+ 'pattern' => '%d',
),
);
-
-} // end class Memberships_Schema;
+}
diff --git a/inc/database/memberships/class-memberships-table.php b/inc/database/memberships/class-memberships-table.php
index d24010f..77447b6 100644
--- a/inc/database/memberships/class-memberships-table.php
+++ b/inc/database/memberships/class-memberships-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Memberships_Table extends Table {
/**
- * Table name
- *
- * @since 2.0.0
- * @var string
- */
+ * Table name
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $name = 'memberships';
/**
@@ -64,8 +64,7 @@ final class Memberships_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema.
@@ -112,8 +111,7 @@ final class Memberships_Table extends Table {
KEY plan_id (plan_id),
KEY status (status),
KEY disabled (disabled)";
-
- } // end set_schema;
+ }
/**
* Fixes the datetime columns to accept null.
*
@@ -133,21 +131,15 @@ final class Memberships_Table extends Table {
);
foreach ($null_columns as $column) {
-
$query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;";
$result = $this->get_db()->query($query);
- if (!$this->is_success($result)) {
-
+ if ( ! $this->is_success($result)) {
return false;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
return true;
-
- } // end __20230601;
-
-} // end class Memberships_Table;
+ }
+}
diff --git a/inc/database/payments/class-payment-query.php b/inc/database/payments/class-payment-query.php
index af982cc..b058387 100644
--- a/inc/database/payments/class-payment-query.php
+++ b/inc/database/payments/class-payment-query.php
@@ -107,7 +107,5 @@ class Payment_Query extends Query {
public function __construct($query = array()) {
parent::__construct($query);
-
- } // end __construct;
-
-} // end class Payment_Query;
+ }
+}
diff --git a/inc/database/payments/class-payment-status.php b/inc/database/payments/class-payment-status.php
index fe9db2c..7acbc14 100644
--- a/inc/database/payments/class-payment-status.php
+++ b/inc/database/payments/class-payment-status.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Database\Payments;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Database\Engine\Enum;
+use WP_Ultimo\Database\Engine\Enum;
/**
* Payment Status.
@@ -51,8 +51,7 @@ class Payment_Status extends Enum {
static::FAILED => 'wu-bg-red-200 wu-text-red-700',
static::CANCELLED => 'wu-bg-orange-200 wu-text-orange-700',
);
-
- } // end classes;
+ }
/**
* Returns an array with values => CSS Classes.
@@ -71,8 +70,7 @@ class Payment_Status extends Enum {
static::FAILED => 'wu-align-middle dashicons-wu-circle-with-cross wu-text-red-700',
static::CANCELLED => 'wu-align-middle dashicons-wu-circle-with-cross wu-text-orange-700',
);
-
- } // end icon_classes;
+ }
/**
* Returns an array with values => labels.
@@ -91,7 +89,5 @@ class Payment_Status extends Enum {
static::FAILED => __('Failed', 'wp-ultimo'),
static::CANCELLED => __('Cancelled', 'wp-ultimo'),
);
-
- } // end labels;
-
-} // end class Payment_Status;
+ }
+}
diff --git a/inc/database/payments/class-payments-meta-table.php b/inc/database/payments/class-payments-meta-table.php
index f0b0c07..2f1c6eb 100644
--- a/inc/database/payments/class-payments-meta-table.php
+++ b/inc/database/payments/class-payments-meta-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Payments_Meta_Table extends Table {
/**
- * Table name
- *
- * @since 2.0.0
- * @var string
- */
+ * Table name
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $name = 'paymentmeta';
/**
@@ -55,8 +55,7 @@ final class Payments_Meta_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema
@@ -76,7 +75,5 @@ final class Payments_Meta_Table extends Table {
PRIMARY KEY (meta_id),
KEY wu_payment_id (wu_payment_id),
KEY meta_key (meta_key({$max_index_length}))";
-
- } // end set_schema;
-
-} // end class Payments_Meta_Table;
+ }
+}
diff --git a/inc/database/payments/class-payments-schema.php b/inc/database/payments/class-payments-schema.php
index 91387af..eb47fe9 100644
--- a/inc/database/payments/class-payments-schema.php
+++ b/inc/database/payments/class-payments-schema.php
@@ -101,7 +101,7 @@ class Payments_Schema extends Schema {
'type' => 'varchar',
'length' => '20',
'default' => 'USD',
- 'sortable' => true
+ 'sortable' => true,
),
array(
@@ -188,5 +188,4 @@ class Payments_Schema extends Schema {
),
);
-
-} // end class Payments_Schema;
+}
diff --git a/inc/database/payments/class-payments-table.php b/inc/database/payments/class-payments-table.php
index 764a19b..50e8c76 100644
--- a/inc/database/payments/class-payments-table.php
+++ b/inc/database/payments/class-payments-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Payments_Table extends Table {
/**
- * Table name
- *
- * @since 2.0.0
- * @var string
- */
+ * Table name
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $name = 'payments';
/**
@@ -66,8 +66,7 @@ final class Payments_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema.
@@ -102,8 +101,7 @@ final class Payments_Table extends Table {
KEY parent_id (parent_id),
KEY product_id (product_id),
KEY status (status)";
-
- } // end set_schema;
+ }
/**
* Adds the refund_total column.
@@ -120,17 +118,14 @@ final class Payments_Table extends Table {
// Maybe add column
if (empty($result)) {
-
$query = "ALTER TABLE {$this->table_name} ADD COLUMN `refund_total` decimal(13,4) default 0 AFTER `subtotal`;";
$result = $this->get_db()->query($query);
-
- } // end if;
+ }
// Return success/fail
return $this->is_success($result);
-
- } // end __20210417;
+ }
/**
* Adds the refund_total column.
@@ -144,27 +139,22 @@ final class Payments_Table extends Table {
// Maybe add column
if (empty($result)) {
-
$query_set = "SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';";
$result_set = $this->get_db()->query($query_set);
if ($this->is_success($result_set) === false) {
-
return false;
-
- } // end if;
+ }
$query = "ALTER TABLE {$this->table_name} ADD COLUMN `refund_total` decimal(13,4) default 0 AFTER `subtotal`;";
$result = $this->get_db()->query($query);
-
- } // end if;
+ }
// Return success/fail
return $this->is_success($result);
-
- } // end __20210607;
+ }
/**
* Fixes the datetime columns to accept null.
*
@@ -178,21 +168,15 @@ final class Payments_Table extends Table {
);
foreach ($null_columns as $column) {
-
$query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;";
$result = $this->get_db()->query($query);
- if (!$this->is_success($result)) {
-
+ if ( ! $this->is_success($result)) {
return false;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
return true;
-
- } // end __20230601;
-
-} // end class Payments_Table;
+ }
+}
diff --git a/inc/database/posts/class-post-query.php b/inc/database/posts/class-post-query.php
index 2dfef36..e2a057e 100644
--- a/inc/database/posts/class-post-query.php
+++ b/inc/database/posts/class-post-query.php
@@ -98,14 +98,10 @@ class Post_Query extends Query {
*/
public function query($query = array()) {
- if (!isset($query['type__in'])) {
-
+ if ( ! isset($query['type__in'])) {
$query['type'] = $this->item_name;
-
- } // end if;
+ }
return parent::query($query);
-
- } // end query;
-
-} // end class Post_Query;
+ }
+}
diff --git a/inc/database/posts/class-posts-meta-table.php b/inc/database/posts/class-posts-meta-table.php
index 2a1adfa..8e65e6d 100644
--- a/inc/database/posts/class-posts-meta-table.php
+++ b/inc/database/posts/class-posts-meta-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Posts_Meta_Table extends Table {
/**
- * Table name
- *
- * @since 2.0.0
- * @var string
- */
+ * Table name
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $name = 'postmeta';
/**
@@ -55,8 +55,7 @@ final class Posts_Meta_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema
@@ -76,7 +75,5 @@ final class Posts_Meta_Table extends Table {
PRIMARY KEY (meta_id),
KEY wu_post_id (wu_post_id),
KEY meta_key (meta_key({$max_index_length}))";
-
- } // end set_schema;
-
-} // end class Posts_Meta_Table;
+ }
+}
diff --git a/inc/database/posts/class-posts-schema.php b/inc/database/posts/class-posts-schema.php
index 6cb1002..e9ae0ca 100644
--- a/inc/database/posts/class-posts-schema.php
+++ b/inc/database/posts/class-posts-schema.php
@@ -37,7 +37,7 @@ class Posts_Schema extends Schema {
'unsigned' => true,
'extra' => 'auto_increment',
'primary' => true,
- 'sortable' => true
+ 'sortable' => true,
),
array(
@@ -51,35 +51,35 @@ class Posts_Schema extends Schema {
'name' => 'type',
'type' => 'varchar',
'searchable' => true,
- 'sortable' => true
+ 'sortable' => true,
),
array(
'name' => 'slug',
'type' => 'varchar',
'searchable' => true,
- 'sortable' => true
+ 'sortable' => true,
),
array(
'name' => 'title',
'type' => 'varchar',
'searchable' => true,
- 'sortable' => true
+ 'sortable' => true,
),
array(
'name' => 'content',
'type' => 'longtext',
'default' => '',
- 'searchable' => true
+ 'searchable' => true,
),
array(
'name' => 'excerpt',
'type' => 'longtext',
'default' => '',
- 'searchable' => true
+ 'searchable' => true,
),
array(
@@ -121,5 +121,4 @@ class Posts_Schema extends Schema {
),
);
-
-} // end class Posts_Schema;
+}
diff --git a/inc/database/posts/class-posts-table.php b/inc/database/posts/class-posts-table.php
index d97d518..1aeff3c 100644
--- a/inc/database/posts/class-posts-table.php
+++ b/inc/database/posts/class-posts-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Posts_Table extends Table {
/**
- * Table name
- *
- * @since 2.0.0
- * @var string
- */
+ * Table name
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $name = 'posts';
/**
@@ -64,8 +64,7 @@ final class Posts_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema
@@ -88,8 +87,7 @@ final class Posts_Table extends Table {
list_order tinyint default 10,
status varchar(100) NOT NULL default 'draft',
PRIMARY KEY (id)";
-
- } // end set_schema;
+ }
/**
* Fixes the datetime columns to accept null.
*
@@ -103,21 +101,15 @@ final class Posts_Table extends Table {
);
foreach ($null_columns as $column) {
-
$query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;";
$result = $this->get_db()->query($query);
- if (!$this->is_success($result)) {
-
+ if ( ! $this->is_success($result)) {
return false;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
return true;
-
- } // end __20230601;
-
-} // end class Posts_Table;
+ }
+}
diff --git a/inc/database/products/class-product-query.php b/inc/database/products/class-product-query.php
index 43c6bd4..af3da9b 100644
--- a/inc/database/products/class-product-query.php
+++ b/inc/database/products/class-product-query.php
@@ -107,7 +107,5 @@ class Product_Query extends Query {
public function __construct($query = array()) {
parent::__construct($query);
-
- } // end __construct;
-
-} // end class Product_Query;
+ }
+}
diff --git a/inc/database/products/class-product-type.php b/inc/database/products/class-product-type.php
index 068bee9..079aacc 100644
--- a/inc/database/products/class-product-type.php
+++ b/inc/database/products/class-product-type.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Database\Products;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Database\Engine\Enum;
+use WP_Ultimo\Database\Engine\Enum;
/**
* Product Types.
@@ -43,8 +43,7 @@ class Product_Type extends Enum {
static::PACKAGE => 'wu-bg-gray-200 wu-text-blue-700',
static::SERVICE => 'wu-bg-yellow-200 wu-text-yellow-700',
);
-
- } // end classes;
+ }
/**
* Returns an array with values => labels.
@@ -59,7 +58,5 @@ class Product_Type extends Enum {
static::PACKAGE => __('Package', 'wp-ultimo'),
static::SERVICE => __('Service', 'wp-ultimo'),
);
-
- } // end labels;
-
-} // end class Product_Type;
+ }
+}
diff --git a/inc/database/products/class-products-meta-table.php b/inc/database/products/class-products-meta-table.php
index 89a473a..0a529ab 100644
--- a/inc/database/products/class-products-meta-table.php
+++ b/inc/database/products/class-products-meta-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Products_Meta_Table extends Table {
/**
- * Table name
- *
- * @since 2.0.0
- * @var string
- */
+ * Table name
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $name = 'productmeta';
/**
@@ -55,8 +55,7 @@ final class Products_Meta_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema
@@ -76,7 +75,5 @@ final class Products_Meta_Table extends Table {
PRIMARY KEY (meta_id),
KEY wu_product_id (wu_product_id),
KEY meta_key (meta_key({$max_index_length}))";
-
- } // end set_schema;
-
-} // end class Products_Meta_Table;
+ }
+}
diff --git a/inc/database/products/class-products-schema.php b/inc/database/products/class-products-schema.php
index 3b887f7..9e062b0 100644
--- a/inc/database/products/class-products-schema.php
+++ b/inc/database/products/class-products-schema.php
@@ -37,7 +37,7 @@ class Products_Schema extends Schema {
'unsigned' => true,
'extra' => 'auto_increment',
'primary' => true,
- 'sortable' => true
+ 'sortable' => true,
),
array(
@@ -70,14 +70,14 @@ class Products_Schema extends Schema {
'name' => 'name',
'type' => 'varchar',
'searchable' => true,
- 'sortable' => true
+ 'sortable' => true,
),
array(
'name' => 'description',
'type' => 'longtext',
'default' => '',
- 'searchable' => true
+ 'searchable' => true,
),
array(
@@ -93,7 +93,7 @@ class Products_Schema extends Schema {
'type' => 'varchar',
'length' => '10',
'default' => 'USD',
- 'sortable' => true
+ 'sortable' => true,
),
array(
@@ -101,7 +101,7 @@ class Products_Schema extends Schema {
'type' => 'varchar',
'length' => '10',
'default' => 'paid',
- 'sortable' => true
+ 'sortable' => true,
),
array(
@@ -136,7 +136,7 @@ class Products_Schema extends Schema {
'unsigned' => true,
'default' => '0',
'sortable' => true,
- 'transition' => true
+ 'transition' => true,
),
array(
@@ -151,7 +151,7 @@ class Products_Schema extends Schema {
'unsigned' => true,
'default' => '0',
'sortable' => true,
- 'transition' => true
+ 'transition' => true,
),
array(
@@ -166,7 +166,7 @@ class Products_Schema extends Schema {
'unsigned' => true,
'default' => '0',
'sortable' => true,
- 'transition' => true
+ 'transition' => true,
),
array(
@@ -213,9 +213,8 @@ class Products_Schema extends Schema {
'name' => 'type',
'type' => 'varchar',
'searchable' => true,
- 'sortable' => true
+ 'sortable' => true,
),
);
-
-} // end class Products_Schema;
+}
diff --git a/inc/database/products/class-products-table.php b/inc/database/products/class-products-table.php
index a5cd7d7..b310fc2 100644
--- a/inc/database/products/class-products-table.php
+++ b/inc/database/products/class-products-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Products_Table extends Table {
/**
- * Table name
- *
- * @since 2.0.0
- * @var string
- */
+ * Table name
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $name = 'products';
/**
@@ -66,8 +66,7 @@ final class Products_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema
@@ -101,8 +100,7 @@ final class Products_Table extends Table {
date_created datetime NULL,
date_modified datetime NULL,
PRIMARY KEY (id)";
-
- } // end set_schema;
+ }
/**
* Adds the product_group column.
@@ -119,17 +117,14 @@ final class Products_Table extends Table {
// Maybe add column
if (empty($result)) {
-
$query = "ALTER TABLE {$this->table_name} ADD COLUMN `product_group` varchar(20) default '' AFTER `description`;";
$result = $this->get_db()->query($query);
-
- } // end if;
+ }
// Return success/fail
return $this->is_success($result);
-
- } // end __20210419;
+ }
/**
* Adds the product_group column.
@@ -143,27 +138,22 @@ final class Products_Table extends Table {
// Maybe add column
if (empty($result)) {
-
$query_set = "SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';";
$result_set = $this->get_db()->query($query_set);
if ($this->is_success($result_set) === false) {
-
return false;
-
- } // end if;
+ }
$query = "ALTER TABLE {$this->table_name} ADD COLUMN `product_group` varchar(20) default '' AFTER `description`;";
$result = $this->get_db()->query($query);
-
- } // end if;
+ }
// Return success/fail
return $this->is_success($result);
-
- } // end __20210607;
+ }
/**
* Fixes the datetime columns to accept null.
*
@@ -177,21 +167,15 @@ final class Products_Table extends Table {
);
foreach ($null_columns as $column) {
-
$query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;";
$result = $this->get_db()->query($query);
- if (!$this->is_success($result)) {
-
+ if ( ! $this->is_success($result)) {
return false;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
return true;
-
- } // end __20230601;
-
-} // end class Products_Table;
+ }
+}
diff --git a/inc/database/sites/class-site-query.php b/inc/database/sites/class-site-query.php
index c082ed1..746aff0 100644
--- a/inc/database/sites/class-site-query.php
+++ b/inc/database/sites/class-site-query.php
@@ -115,7 +115,5 @@ class Site_Query extends Query {
public function __construct($query = array()) {
parent::__construct($query);
-
- } // end __construct;
-
-} // end class Site_Query;
+ }
+}
diff --git a/inc/database/sites/class-site-type.php b/inc/database/sites/class-site-type.php
index 3a7cbf2..c93bff7 100644
--- a/inc/database/sites/class-site-type.php
+++ b/inc/database/sites/class-site-type.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\Database\Sites;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Database\Engine\Enum;
+use WP_Ultimo\Database\Engine\Enum;
/**
* Site Types.
@@ -49,8 +49,7 @@ class Site_Type extends Enum {
static::EXTERNAL => 'wu-bg-blue-200 wu-text-blue-700',
static::MAIN => 'wu-bg-pink-200 wu-text-pink-700',
);
-
- } // end classes;
+ }
/**
* Returns an array with values => labels.
@@ -67,7 +66,5 @@ class Site_Type extends Enum {
static::PENDING => __('Pending', 'wp-ultimo'),
static::MAIN => __('Main Site', 'wp-ultimo'),
);
-
- } // end labels;
-
-} // end class Site_Type;
+ }
+}
diff --git a/inc/database/sites/class-sites-meta-table.php b/inc/database/sites/class-sites-meta-table.php
index 06abf2e..49960ec 100644
--- a/inc/database/sites/class-sites-meta-table.php
+++ b/inc/database/sites/class-sites-meta-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Sites_Meta_Table extends Table {
/**
- * Table prefix, including the site prefix.
- *
- * @since 1.0.0
- * @var string
- */
+ * Table prefix, including the site prefix.
+ *
+ * @since 1.0.0
+ * @var string
+ */
protected $prefix = '';
/**
@@ -63,8 +63,7 @@ final class Sites_Meta_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema
@@ -76,7 +75,5 @@ final class Sites_Meta_Table extends Table {
protected function set_schema() {
$this->schema = false;
-
- } // end set_schema;
-
-} // end class Sites_Meta_Table;
+ }
+}
diff --git a/inc/database/sites/class-sites-schema.php b/inc/database/sites/class-sites-schema.php
index 3c0bbb1..a89a4ed 100644
--- a/inc/database/sites/class-sites-schema.php
+++ b/inc/database/sites/class-sites-schema.php
@@ -62,14 +62,14 @@ class Sites_Schema extends Schema {
'name' => 'domain',
'type' => 'varchar',
'searchable' => true,
- 'sortable' => true
+ 'sortable' => true,
),
array(
'name' => 'path',
'type' => 'varchar',
'searchable' => true,
- 'sortable' => true
+ 'sortable' => true,
),
array(
@@ -147,5 +147,4 @@ class Sites_Schema extends Schema {
),
);
-
-} // end class Sites_Schema;
+}
diff --git a/inc/database/sites/class-sites-table.php b/inc/database/sites/class-sites-table.php
index ba5c781..fe39e11 100644
--- a/inc/database/sites/class-sites-table.php
+++ b/inc/database/sites/class-sites-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Sites_Table extends Table {
/**
- * Table prefix, including the site prefix.
- *
- * @since 1.0.0
- * @var string
- */
+ * Table prefix, including the site prefix.
+ *
+ * @since 1.0.0
+ * @var string
+ */
protected $prefix = '';
/**
@@ -63,8 +63,7 @@ final class Sites_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema
@@ -76,14 +75,12 @@ final class Sites_Table extends Table {
protected function set_schema() {
$this->schema = false;
-
- } // end set_schema;
+ }
/**
* Do nothing as this table already exists.
*
* @since 2.0.0
*/
- public function install() {} // end install;
-
-} // end class Sites_Table;
+ public function install() {}
+}
diff --git a/inc/database/webhooks/class-webhook-query.php b/inc/database/webhooks/class-webhook-query.php
index 78601b6..8983048 100644
--- a/inc/database/webhooks/class-webhook-query.php
+++ b/inc/database/webhooks/class-webhook-query.php
@@ -107,7 +107,5 @@ class Webhook_Query extends Query {
public function __construct($query = array()) {
parent::__construct($query);
-
- } // end __construct;
-
-} // end class Webhook_Query;
+ }
+}
diff --git a/inc/database/webhooks/class-webhooks-schema.php b/inc/database/webhooks/class-webhooks-schema.php
index e7f345f..69bfe64 100644
--- a/inc/database/webhooks/class-webhooks-schema.php
+++ b/inc/database/webhooks/class-webhooks-schema.php
@@ -132,5 +132,4 @@ class Webhooks_Schema extends Schema {
),
);
-
-} // end class Webhooks_Schema;
+}
diff --git a/inc/database/webhooks/class-webhooks-table.php b/inc/database/webhooks/class-webhooks-table.php
index 8b9464b..8a68090 100644
--- a/inc/database/webhooks/class-webhooks-table.php
+++ b/inc/database/webhooks/class-webhooks-table.php
@@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
final class Webhooks_Table extends Table {
/**
- * Table name
- *
- * @since 2.0.0
- * @var string
- */
+ * Table name
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $name = 'webhooks';
/**
@@ -64,8 +64,7 @@ final class Webhooks_Table extends Table {
public function __construct() {
parent::__construct();
-
- } // end __construct;
+ }
/**
* Setup the database schema
@@ -94,8 +93,7 @@ final class Webhooks_Table extends Table {
KEY event (event)";
// phpcs:enable
-
- } // end set_schema;
+ }
/**
* Fixes the datetime columns to accept null.
*
@@ -109,21 +107,15 @@ final class Webhooks_Table extends Table {
);
foreach ($null_columns as $column) {
-
$query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;";
$result = $this->get_db()->query($query);
- if (!$this->is_success($result)) {
-
+ if ( ! $this->is_success($result)) {
return false;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
return true;
-
- } // end __20230601;
-
-} // end class Webhooks_Table;
+ }
+}
diff --git a/inc/debug/class-debug.php b/inc/debug/class-debug.php
index 9d5c120..ba89738 100644
--- a/inc/debug/class-debug.php
+++ b/inc/debug/class-debug.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\Debug;
-use \WP_Ultimo\Faker;
+use WP_Ultimo\Faker;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -24,11 +24,11 @@ class Debug {
use \WP_Ultimo\Traits\Singleton;
/**
- * The registry of WP Multisite WaaS admin pages.
- *
- * @since 2.0.0
- * @var array
- */
+ * The registry of WP Multisite WaaS admin pages.
+ *
+ * @since 2.0.0
+ * @var array
+ */
private array $pages = array();
/**
@@ -46,8 +46,7 @@ class Debug {
add_action('wp_ultimo_debug', array($this, 'add_additional_hooks'));
add_action('wp_ultimo_debug', array($this, 'register_forms'));
-
- } // end init;
+ }
/**
* Adds the additional debug links.
@@ -58,8 +57,7 @@ class Debug {
public function add_additional_hooks() {
add_action('wu_header_left', array($this, 'add_debug_links'));
-
- } // end add_additional_hooks;
+ }
// phpcs:disable
@@ -109,7 +107,7 @@ class Debug {
array($this, 'render_debug_generator_form'),
- 'handler' => array($this, 'handle_debug_generator_form'),
- ));
+ wu_register_form(
+ 'add_debug_generator_form',
+ array(
+ 'render' => array($this, 'render_debug_generator_form'),
+ 'handler' => array($this, 'handle_debug_generator_form'),
+ )
+ );
/*
* Adds Reset Form
*/
- wu_register_form('add_debug_reset_database_form', array(
- 'render' => array($this, 'render_debug_reset_database_form'),
- 'handler' => array($this, 'handle_debug_reset_database_form'),
- ));
+ wu_register_form(
+ 'add_debug_reset_database_form',
+ array(
+ 'render' => array($this, 'render_debug_reset_database_form'),
+ 'handler' => array($this, 'handle_debug_reset_database_form'),
+ )
+ );
/*
* Adds Drop Form
*/
- wu_register_form('add_debug_drop_database_form', array(
- 'render' => array($this, 'render_debug_drop_database_form'),
- 'handler' => array($this, 'handle_debug_drop_database_form'),
- ));
-
- } // end register_forms;
+ wu_register_form(
+ 'add_debug_drop_database_form',
+ array(
+ 'render' => array($this, 'render_debug_drop_database_form'),
+ 'handler' => array($this, 'handle_debug_drop_database_form'),
+ )
+ );
+ }
/**
* Adds the form to generate data.
@@ -283,28 +289,33 @@ class Debug {
),
);
- $form = new \WP_Ultimo\UI\Form('add_debug_generator_form', $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(
- 'data-wu-app' => 'debug_generator',
- 'data-state' => json_encode(array(
- 'customers' => false,
- 'products' => false,
- 'memberships' => false,
- 'sites' => false,
- 'domains' => false,
- 'discount_codes' => false,
- 'webhooks' => false,
- 'payments' => false,
- )),
- ),
- ));
+ $form = new \WP_Ultimo\UI\Form(
+ 'add_debug_generator_form',
+ $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(
+ 'data-wu-app' => 'debug_generator',
+ 'data-state' => json_encode(
+ array(
+ 'customers' => false,
+ 'products' => false,
+ 'memberships' => false,
+ 'sites' => false,
+ 'domains' => false,
+ 'discount_codes' => false,
+ 'webhooks' => false,
+ 'payments' => false,
+ )
+ ),
+ ),
+ )
+ );
$form->render();
-
- } // end render_debug_generator_form;
+ }
/**
* Handles the checkout
@@ -325,72 +336,50 @@ class Debug {
$wpdb->query('START TRANSACTION');
try {
-
if (wu_request('customers')) {
-
$faker->generate_fake_customers(wu_request('customers_number', 0));
-
- } // end if;
+ }
if (wu_request('products')) {
-
$faker->generate_fake_products(wu_request('products_number', 0));
-
- } // end if;
+ }
if (wu_request('memberships')) {
-
$faker->generate_fake_memberships(wu_request('memberships_number', 0));
-
- } // end if;
+ }
if (wu_request('sites')) {
-
$faker->generate_fake_site(wu_request('sites_number', 0));
-
- } // end if;
+ }
if (wu_request('domains')) {
-
$faker->generate_fake_domain(wu_request('domains_number', 0));
-
- } // end if;
+ }
if (wu_request('discount_codes')) {
-
$faker->generate_fake_discount_code(wu_request('discount_codes_number', 0));
-
- } // end if;
+ }
if (wu_request('payments')) {
-
$faker->generate_fake_payment(wu_request('payments_number', 0));
-
- } // end if;
-
+ }
} catch (\Throwable $e) {
-
$wpdb->query('ROLLBACK');
$error = new \WP_Error($e->getCode(), $e->getMessage());
wp_send_json_error($error);
-
- } // end try;
+ }
$fake_data_generated = $faker->get_fake_data_generated();
$fake_ids_generated = array();
foreach ($fake_data_generated as $key => $model) {
-
foreach ($model as $object) {
-
- $fake_ids_generated[$key][] = $object->get_id();
-
- } // end foreach;
-
- } // end foreach;
+ $fake_ids_generated[ $key ][] = $object->get_id();
+ }
+ }
$fake_ids_generated = array_merge_recursive($faker->get_option_debug_faker(), $fake_ids_generated);
@@ -398,11 +387,12 @@ class Debug {
$wpdb->query('COMMIT');
- wp_send_json_success(array(
- 'redirect_url' => wu_network_admin_url('wp-ultimo'),
- ));
-
- } // end handle_debug_generator_form;
+ wp_send_json_success(
+ array(
+ 'redirect_url' => wu_network_admin_url('wp-ultimo'),
+ )
+ );
+ }
/**
* Reset the database form.
@@ -431,21 +421,26 @@ class Debug {
),
);
- $form = new \WP_Ultimo\UI\Form('debug_reset_database_form', $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(
- 'data-wu-app' => 'debug_reset_database_form',
- 'data-state' => json_encode(array(
- 'reset_only' => true,
- )),
- ),
- ));
+ $form = new \WP_Ultimo\UI\Form(
+ 'debug_reset_database_form',
+ $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(
+ 'data-wu-app' => 'debug_reset_database_form',
+ 'data-state' => json_encode(
+ array(
+ 'reset_only' => true,
+ )
+ ),
+ ),
+ )
+ );
$form->render();
-
- } // end render_debug_reset_database_form;
+ }
/**
* Handles the database reset.
@@ -460,36 +455,29 @@ class Debug {
$wpdb->query('START TRANSACTION');
try {
-
if (wu_request('reset_only')) {
-
$this->reset_fake_data();
-
} else {
-
$this->reset_all_data();
-
- } // end if;
-
+ }
} catch (Exception $e) {
-
$wpdb->query('ROLLBACK');
$error = new \WP_Error($e->getCode(), $e->getMessage());
wp_send_json_error($error);
-
- } // end try;
+ }
$wpdb->query('COMMIT');
wu_delete_option('debug_faker');
- wp_send_json_success(array(
- 'redirect_url' => wu_network_admin_url('wp-ultimo-setup'),
- ));
-
- } // end handle_debug_reset_database_form;
+ wp_send_json_success(
+ array(
+ 'redirect_url' => wu_network_admin_url('wp-ultimo-setup'),
+ )
+ );
+ }
/**
* Reset the database form.
@@ -513,21 +501,26 @@ class Debug {
),
);
- $form = new \WP_Ultimo\UI\Form('debug_drop_database_form', $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(
- 'data-wu-app' => 'debug_drop_database_form',
- 'data-state' => json_encode(array(
- 'reset_only' => true,
- )),
- ),
- ));
+ $form = new \WP_Ultimo\UI\Form(
+ 'debug_drop_database_form',
+ $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(
+ 'data-wu-app' => 'debug_drop_database_form',
+ 'data-state' => json_encode(
+ array(
+ 'reset_only' => true,
+ )
+ ),
+ ),
+ )
+ );
$form->render();
-
- } // end render_debug_drop_database_form;
+ }
/**
* Handles the database reset.
@@ -540,28 +533,23 @@ class Debug {
global $wpdb;
try {
-
wu_drop_tables();
-
} catch (\Throwable $e) {
-
$error = new \WP_Error($e->getCode(), $e->getMessage());
wp_send_json_error($error);
-
} catch (\Exception $e) {
-
$error = new \WP_Error($e->getCode(), $e->getMessage());
wp_send_json_error($error);
+ }
- } // end try;
-
- wp_send_json_success(array(
- 'redirect_url' => wu_network_admin_url('wp-ultimo-setup&step=installation'),
- ));
-
- } // end handle_debug_drop_database_form;
+ wp_send_json_success(
+ array(
+ 'redirect_url' => wu_network_admin_url('wp-ultimo-setup&step=installation'),
+ )
+ );
+ }
/**
* Checks if we need to add the menu or not.
@@ -575,8 +563,7 @@ class Debug {
public function should_load() {
return defined('WP_ULTIMO_DEBUG') && WP_ULTIMO_DEBUG;
-
- } // end should_load;
+ }
/**
* Loads the debug pages and functions if we should.
@@ -587,20 +574,19 @@ class Debug {
public function load() {
if ($this->should_load()) {
-
add_action('wu_page_added', array($this, 'add_page'));
add_filter('wu_tour_finished', '__return_false');
- add_action('plugins_loaded', function() {
+ add_action(
+ 'plugins_loaded',
+ function () {
- do_action('wp_ultimo_debug');
-
- });
-
- } // end if;
-
- } // end load;
+ do_action('wp_ultimo_debug');
+ }
+ );
+ }
+ }
/**
* Add a WP Multisite WaaS page to the registry.
@@ -612,9 +598,8 @@ class Debug {
*/
public function add_page($page_id) {
- $this->pages[$page_id] = wu_network_admin_url($page_id);
-
- } // end add_page;
+ $this->pages[ $page_id ] = wu_network_admin_url($page_id);
+ }
/**
* Returns the pages registred.
@@ -625,8 +610,7 @@ class Debug {
public function get_pages() {
return $this->pages;
-
- } // end get_pages;
+ }
/**
* Adds the debug menu pages.
@@ -636,9 +620,8 @@ class Debug {
*/
public function add_main_debug_menu() {
- new \WP_Ultimo\Admin_Pages\Debug\Debug_Admin_Page;
-
- } // end add_main_debug_menu;
+ new \WP_Ultimo\Admin_Pages\Debug\Debug_Admin_Page();
+ }
/**
* Reset fake data.
@@ -677,8 +660,7 @@ class Debug {
$payments_id = wu_get_isset($fake_data_generated, 'payments');
$this->reset_payments($payments_id);
-
- } // end reset_fake_data;
+ }
/**
* Reset all data.
@@ -709,8 +691,7 @@ class Debug {
$this->reset_events();
$this->reset_settings();
-
- } // end reset_all_data;
+ }
/**
* Reset table.
@@ -726,10 +707,8 @@ class Debug {
global $wpdb;
- if (!empty($table)) {
-
- if (!empty($ids)) {
-
+ if ( ! empty($table)) {
+ if ( ! empty($ids)) {
$ids = array_filter($ids);
$id_placeholders = implode(', ', array_fill(0, count($ids), '%d'));
@@ -737,24 +716,17 @@ class Debug {
$result = $wpdb->query(
$wpdb->prepare("DELETE FROM $table WHERE $field IN ($id_placeholders)", $ids) // phpcs:ignore
);
-
} else {
-
$result = $wpdb->query(
"DELETE FROM $table" // phpcs:ignore
);
-
- } // end if;
+ }
if ($result === false) {
-
throw new \Exception("Error $table");
-
- } // end if;
-
- } // end if;
-
- } // end reset_table;
+ }
+ }
+ }
/**
* Reset customers and customermeta table.
@@ -771,33 +743,24 @@ class Debug {
$customer_meta_table = "{$wpdb->base_prefix}wu_customermeta";
- if (!empty($ids)) {
-
+ if ( ! empty($ids)) {
foreach ($ids as $id) {
-
$customer = wu_get_customer($id);
if ($customer) {
-
$deleted = wpmu_delete_user($customer->get_user_id());
- if (!$deleted) {
-
+ if ( ! $deleted) {
throw new \Exception('Error customer delete');
-
- } // end if;
-
- } // end if;
-
- } // end foreach;
-
- } // end if;
+ }
+ }
+ }
+ }
$this->reset_table($customers_table, $ids);
$this->reset_table($customer_meta_table, $ids, 'wu_customer_id');
-
- } // end reset_customers;
+ }
/**
* Reset customers and customermeta table.
@@ -809,23 +772,16 @@ class Debug {
*/
private function reset_sites($ids = array()) {
- if (!empty($ids)) {
-
+ if ( ! empty($ids)) {
foreach ($ids as $id) {
-
$site = wu_get_site($id);
if ($site) {
-
wpmu_delete_blog($site->get_id(), true);
-
- } // end if;
-
- } // end foreach;
-
- } // end if;
-
- } // end reset_sites;
+ }
+ }
+ }
+ }
/**
* Reset products and productmeta table.
@@ -845,8 +801,7 @@ class Debug {
$this->reset_table($products_table, $ids);
$this->reset_table($product_meta_table, $ids, 'wu_product_id');
-
- } // end reset_products;
+ }
/**
* Reset memberships and membershipmeta table.
@@ -866,8 +821,7 @@ class Debug {
$this->reset_table($memberships_table, $ids);
$this->reset_table($membership_meta_table, $ids, 'wu_membership_id');
-
- } // end reset_memberships;
+ }
/**
* Reset domains table.
@@ -883,8 +837,7 @@ class Debug {
$domain_table = "{$wpdb->base_prefix}wu_domain_mappings";
$this->reset_table($domain_table, $ids);
-
- } // end reset_domains;
+ }
/**
* Reset discount codes table.
@@ -900,8 +853,7 @@ class Debug {
$discount_codes_table = "{$wpdb->base_prefix}wu_discount_codes";
$this->reset_table($discount_codes_table, $ids);
-
- } // end reset_discount_codes;
+ }
/**
* Reset webhooks table.
@@ -917,8 +869,7 @@ class Debug {
$webhooks_table = "{$wpdb->base_prefix}wu_webhooks";
$this->reset_table($webhooks_table, $ids);
-
- } // end reset_webhooks;
+ }
/**
* Reset payments table.
@@ -934,8 +885,7 @@ class Debug {
$payments_table = "{$wpdb->base_prefix}wu_payments";
$this->reset_table($payments_table, $ids);
-
- } // end reset_payments;
+ }
/**
* Reset checkout forms
@@ -955,8 +905,7 @@ class Debug {
$this->reset_table($forms_table, $ids);
$this->reset_table($form_meta_table, $ids, 'wu_form_id');
-
- } // end reset_checkout_forms;
+ }
/**
* Reset custom posts.
@@ -976,8 +925,7 @@ class Debug {
$this->reset_table($posts_table, $ids);
$this->reset_table($post_meta_table, $ids, 'wu_post_id');
-
- } // end reset_post_like_models;
+ }
/**
* Reset events.
@@ -993,8 +941,7 @@ class Debug {
$events_table = "{$wpdb->base_prefix}wu_events";
$this->reset_table($events_table, $ids);
-
- } // end reset_events;
+ }
/**
* Reset the settings.
@@ -1026,13 +973,9 @@ class Debug {
);
foreach ($options as $option_name => $should_use_prefix) {
-
$prefix = $should_use_prefix ? $the_prefix : '';
delete_network_option(null, $prefix . $option_name);
-
- } // end foreach;
-
- } // end reset_settings;
-
-} // end class Debug;
+ }
+ }
+}
diff --git a/inc/deprecated/deprecated.php b/inc/deprecated/deprecated.php
index 12997bb..bea5499 100644
--- a/inc/deprecated/deprecated.php
+++ b/inc/deprecated/deprecated.php
@@ -34,8 +34,7 @@ class WU_Settings {
_deprecated_function(__METHOD__, '2.0.0', 'WP_Ultimo()->settings->get_sections()');
return WP_Ultimo()->settings->get_sections();
-
- } // end get_sections;
+ }
/**
* Deprecated: Get all the settings from the plugin.
@@ -49,8 +48,7 @@ class WU_Settings {
_deprecated_function(__METHOD__, '2.0.0', 'wu_get_all_settings()');
return wu_get_all_settings();
-
- } // end get_settings;
+ }
/**
* Deprecated: Handles the saving of the settings after the save button is pressed.
@@ -66,8 +64,7 @@ class WU_Settings {
_deprecated_function(__METHOD__, '2.0.0', 'WP_Ultimo()->settings->save_settings()');
return WP_Ultimo()->settings->save_settings(array(), $reset);
-
- } // end save_settings;
+ }
/**
* Deprecated: Get a specific settings from the plugin.
@@ -85,8 +82,7 @@ class WU_Settings {
_deprecated_function(__METHOD__, '2.0.0', 'wu_get_setting()');
return wu_get_setting($setting, $default);
-
- } // end get_setting;
+ }
/**
* Deprecated: Saves a specific setting into the database.
@@ -100,8 +96,7 @@ class WU_Settings {
_deprecated_function(__METHOD__, '2.0.0', 'wu_save_setting()');
return wu_save_setting($setting, $value);
-
- } // end save_setting;
+ }
/**
* Deprecated: Returns the image being used as a logo.
@@ -121,8 +116,7 @@ class WU_Settings {
_deprecated_function(__METHOD__, '2.0.0', 'wu_get_network_logo()');
return wu_get_network_logo($size);
-
- } // end get_logo;
+ }
/**
* Deprecated: Return the countries list.
@@ -135,10 +129,8 @@ class WU_Settings {
_deprecated_function(__METHOD__, '2.0.0', 'wu_get_countries()');
return wu_get_countries();
-
- } // end get_countries;
-
-} // end class WU_Settings;
+ }
+}
/**
* Deprecated: WU_Page
@@ -168,18 +160,21 @@ class WU_Page extends \WP_Ultimo\Admin_Pages\Base_Admin_Page {
_deprecated_function(__METHOD__, '2.0.0', 'wu_send_mail()');
- $this->attributes = wp_parse_args($atts, array(
- 'badge_count' => 0,
- 'position' => 10,
- 'submenu_title' => false,
- 'id' => 'wp-ultimo-page',
- 'type' => 'menu',
- 'parent' => 'wp-ultimo',
- 'capability' => 'manage_network',
- 'menu_icon' => 'dashicons-menu',
- 'title' => __('Admin Page', 'wp-ultimo'),
- 'menu_title' => __('Admin Page', 'wp-ultimo'),
- ));
+ $this->attributes = wp_parse_args(
+ $atts,
+ array(
+ 'badge_count' => 0,
+ 'position' => 10,
+ 'submenu_title' => false,
+ 'id' => 'wp-ultimo-page',
+ 'type' => 'menu',
+ 'parent' => 'wp-ultimo',
+ 'capability' => 'manage_network',
+ 'menu_icon' => 'dashicons-menu',
+ 'title' => __('Admin Page', 'wp-ultimo'),
+ 'menu_title' => __('Admin Page', 'wp-ultimo'),
+ )
+ );
/*
* Sets the defaults.
@@ -192,8 +187,7 @@ class WU_Page extends \WP_Ultimo\Admin_Pages\Base_Admin_Page {
$this->id = $this->attributes['id'] . '-one';
parent::__construct();
-
- } // end __construct;
+ }
/**
* Returns the title of the page. Must be declared on the child classes.
@@ -204,8 +198,7 @@ class WU_Page extends \WP_Ultimo\Admin_Pages\Base_Admin_Page {
public function get_title() {
return $this->attributes['title'];
-
- } // end get_title;
+ }
/**
* Returns the title of menu for this page. Must be declared on the child classes.
@@ -216,8 +209,7 @@ class WU_Page extends \WP_Ultimo\Admin_Pages\Base_Admin_Page {
public function get_menu_title() {
return $this->attributes['menu_title'];
-
- } // end get_menu_title;
+ }
/**
* Every child class should implement the output method to display the contents of the page.
@@ -225,9 +217,8 @@ class WU_Page extends \WP_Ultimo\Admin_Pages\Base_Admin_Page {
* @since 1.8.2
* @return void
*/
- public function output() {} // end output;
-
-} // end class WU_Page;
+ public function output() {}
+}
/**
* Deprecated: WU_Site_Templates
@@ -249,10 +240,8 @@ class WU_Site_Templates {
_deprecated_function(__METHOD__, '2.0.0', 'WP_Ultimo\UI\Template_Previewer::get_instance()->get_preview_url()');
return \WP_Ultimo\UI\Template_Previewer::get_instance()->get_preview_url($site_id);
-
- } // end get_template_preview_url;
-
-} // end class WU_Site_Templates;
+ }
+}
/**
* Deprecated: WU_Mail
@@ -297,12 +286,11 @@ class WU_Mail {
'site_url' => get_site_url(wu_get_main_site_id()),
'attachments' => $attachments,
'type' => $html ? 'html' : 'plain',
- 'bcc' => $bcc
+ 'bcc' => $bcc,
);
return wu_send_mail($from, $to, $args);
-
- } // end send_mail;
+ }
/**
* Deprecated: Send an email template registered in our framework.
@@ -318,8 +306,7 @@ class WU_Mail {
public function send_template($slug, $to, $shortcodes, $attachments = array()) {
_deprecated_function(__METHOD__, '2.0.0');
-
- } // end send_template;
+ }
/**
* Deprecated: Register template of a certain email.
@@ -333,10 +320,8 @@ class WU_Mail {
public function register_template($slug, $args) {
_deprecated_function(__METHOD__, '2.0.0');
-
- } // end register_template;
-
-} // end class WU_Mail;
+ }
+}
/**
* Deprecated: Returns the WU_Mail instance.
@@ -350,8 +335,7 @@ function WU_Mail() { // phpcs:ignore
_deprecated_function(__METHOD__, '2.0.0');
return WU_Mail::get_instance();
-
-} // end WU_Mail;
+}
/**
* Deprecated: WU_Plans class.
@@ -368,9 +352,8 @@ class WU_Plans {
*/
public static function get_instance() {
- return new self;
-
- } // end get_instance;
+ return new self();
+ }
/**
* Deprecated: WP_Plans::get_plans().
@@ -385,8 +368,7 @@ class WU_Plans {
$plans = wu_get_plans();
return $plans;
-
- } // end get_plans;
+ }
/**
* Deprecated: WU_Plans::get_most_popular_plan()
@@ -404,10 +386,8 @@ class WU_Plans {
$plans = wu_get_plans();
return $plans ? $plans[0] : false;
-
- } // end get_most_popular_plan;
-
-} // end class WU_Plans;
+ }
+}
/**
* Deprecated: WU_Multi_Network
@@ -436,10 +416,8 @@ class WU_Multi_Network {
_deprecated_function(__CLASS__ . "::$method_name()", '2.0.0');
return false;
-
- } // end __callStatic;
-
-} // end class WU_Multi_Network;
+ }
+}
/**
* Deprecated: WU_Help_Pointers
@@ -462,10 +440,8 @@ class WU_Help_Pointers {
public function __construct($pntrs = array()) {
_deprecated_function(__CLASS__, '2.0.0');
-
- } // end __construct;
-
-} // end class WU_Help_Pointers;
+ }
+}
/**
* Deprecated: WU_Util
@@ -478,17 +454,16 @@ class WU_Help_Pointers {
class WU_Util {
/**
- * Deprecated: is_login_page()
- *
- * @deprecated 2.0.0
- */
+ * Deprecated: is_login_page()
+ *
+ * @deprecated 2.0.0
+ */
public static function is_login_page(): bool {
_deprecated_function(__METHOD__, '2.0.0');
return false;
-
- } // end is_login_page;
+ }
/**
* Deprecated: format_megabytes
@@ -504,8 +479,7 @@ class WU_Util {
_deprecated_function(__METHOD__, '2.0.0', 'size_format()');
return size_format($size * MB_IN_BYTES);
-
- } // end format_megabytes;
+ }
/**
* Deprecated: to_float
@@ -520,8 +494,7 @@ class WU_Util {
_deprecated_function(__METHOD__, '2.0.0', 'wu_to_float()');
return wu_to_float($num);
-
- } // end to_float;
+ }
/**
* Deprecated: tooltip
@@ -537,8 +510,7 @@ class WU_Util {
_deprecated_function(__METHOD__, '2.0.0', 'wu_tooltip()');
return wu_tooltip($text, $icon);
-
- } // end tooltip;
+ }
/**
* Deprecated: wp_die
@@ -557,8 +529,7 @@ class WU_Util {
_deprecated_function(__METHOD__, '2.0.0', 'wp_die()');
wp_die($message, $title, $args);
-
- } // end wp_die;
+ }
/**
* Deprecated: display_alert
@@ -574,8 +545,7 @@ class WU_Util {
public static function display_alert($title, $message, $type = 'success', $arguments = false) {
_deprecated_function(__METHOD__, '2.0.0');
-
- } // end display_alert;
+ }
/**
* Deprecated: registers_today
@@ -587,18 +557,19 @@ class WU_Util {
_deprecated_function(__METHOD__, '2.0.0', 'wu_get_customers() w/ count = true');
- $signups = wu_get_customers(array(
- 'count' => true,
- 'date_query' => array(
- 'column' => 'date_registered',
- 'after' => 'today',
- 'inclusive' => true,
- ),
- ));
+ $signups = wu_get_customers(
+ array(
+ 'count' => true,
+ 'date_query' => array(
+ 'column' => 'date_registered',
+ 'after' => 'today',
+ 'inclusive' => true,
+ ),
+ )
+ );
return $signups;
-
- } // end registers_today;
+ }
/**
* Deprecated: users_on_trial
*
@@ -609,8 +580,7 @@ class WU_Util {
_deprecated_function(__METHOD__, '1.5.3');
return 0;
-
- } // end users_on_trial;
+ }
/**
* Deprecated: array_filter_key
@@ -629,8 +599,7 @@ class WU_Util {
_deprecated_function(__METHOD__, '2.0.0');
return $array;
-
- } // end array_filter_key;
+ }
/**
* Deprecated: generate_csv
@@ -646,8 +615,7 @@ class WU_Util {
_deprecated_function(__METHOD__, '2.0.0', 'wu_generate_csv()');
wu_generate_csv($file_name, $data);
-
- } // end generate_csv;
+ }
/**
* Deprecated: color
@@ -662,10 +630,8 @@ class WU_Util {
_deprecated_function(__METHOD__, '2.0.0', 'wu_color()');
return wu_color($hex);
-
- } // end color;
-
-} // end class WU_Util;
+ }
+}
/**
* Deprecated: WU_Logger
@@ -691,22 +657,16 @@ class WU_Logger {
$alternative = "\\WP_Ultimo\\Logger::$method_name";
if ($method_name === 'add') {
-
$alternative = 'wu_log_add';
-
} elseif ($method_name === 'clear') {
-
$alternative = 'wu_log_clear';
-
- } // end if;
+ }
_deprecated_function(__CLASS__ . "::$method_name()", '2.0.0', "$alternative()");
return call_user_func_array($alternative, $args);
-
- } // end __callStatic;
-
-} // end class WU_Logger;
+ }
+}
/**
* Deprecated: WU_Links
@@ -730,10 +690,8 @@ class WU_Links {
_deprecated_function(__METHOD__, '2.0.0', 'wu_get_documentation_url()');
return wu_get_documentation_url($slug);
-
- } // end get_link;
-
-} // end class WU_Links;
+ }
+}
/*
* Models
@@ -758,22 +716,16 @@ class WU_Site extends \WP_Ultimo\Models\Site {
_deprecated_function(__CLASS__, '2.0.0', '\WP_Ultimo\Models\Site');
if (is_numeric($object)) {
-
$object = wu_get_site($object);
-
- } // end if;
+ }
if ($object) {
-
$object = get_object_vars($object);
-
- } // end if;
+ }
parent::__construct($object);
-
- } // end __construct;
-
-} // end class WU_Site;
+ }
+}
/**
* Deprecated: WU_Site_Template
@@ -794,22 +746,16 @@ class WU_Site_Template extends \WP_Ultimo\Models\Site {
_deprecated_function(__CLASS__, '2.0.0', '\WP_Ultimo\Models\Site');
if (is_numeric($object)) {
-
$object = wu_get_site($object);
-
- } // end if;
+ }
if ($object) {
-
$object = get_object_vars($object);
-
- } // end if;
+ }
parent::__construct($object);
-
- } // end __construct;
-
-} // end class WU_Site_Template;
+ }
+}
/**
* Deprecated: WU_Site_Template
@@ -826,10 +772,8 @@ class WU_Site_Owner {
public function __construct() {
_deprecated_function(__CLASS__, '2.0.0');
-
- } // end __construct;
-
-} // end class WU_Site_Owner;
+ }
+}
/**
* Deprecated Trait.
@@ -849,16 +793,13 @@ trait WU_Deprecated_Model {
public function __set($key, $value) {
if (method_exists($this, "set_$key")) {
-
call_user_func(array($this, "set_$key"), $value);
-
- } // end if;
+ }
$this->{$key} = $value;
$this->after_set($key, $value);
-
- } // end __set;
+ }
/**
* Generic get method to bypass the protected status of the new models.
@@ -870,14 +811,11 @@ trait WU_Deprecated_Model {
public function __get($key) {
if (method_exists($this, "get_$key")) {
-
return call_user_func(array($this, "get_$key"));
-
- } // end if;
+ }
return false;
-
- } // end __get;
+ }
/**
* Generic method to bypass the protected status of the new models.
@@ -887,9 +825,8 @@ trait WU_Deprecated_Model {
* @param string $key The key to set.
* @param mixed $value The value to set.
*/
- public function after_set($key, $value) {} // end after_set;
-
-} // end trait WU_Deprecated_Model;
+ public function after_set($key, $value) {}
+}
/**
* Deprecated: WU_Coupon
@@ -912,28 +849,19 @@ class WU_Coupon extends \WP_Ultimo\Models\Discount_Code {
_deprecated_function(__CLASS__, '2.0.0', '\WP_Ultimo\Models\Discount_Code');
if (is_numeric($object)) {
-
$object = wu_get_discount_code($object);
-
- } // end if;
-
- if ($object) {
-
- $object = get_object_vars($object);
-
- } // end if;
-
- if (is_array($object)) {
-
- foreach ($object as $att => $value) {
-
- $this->{$att} = $value;
-
- } // end foreach;
-
}
- } // end __construct;
+ if ($object) {
+ $object = get_object_vars($object);
+ }
+
+ if (is_array($object)) {
+ foreach ($object as $att => $value) {
+ $this->{$att} = $value;
+ }
+ }
+ }
/**
* Generic method to bypass the protected status of the new models.
@@ -946,18 +874,14 @@ class WU_Coupon extends \WP_Ultimo\Models\Discount_Code {
public function after_set($key, $value) {
if ($key === 'title') {
-
$this->set_code($value);
$this->set_name($value);
$this->set_description($value);
-
- } // end if;
-
- } // end after_set;
-
-} // end class WU_Coupon;
+ }
+ }
+}
/**
* Deprecated: WU_Plan
@@ -980,32 +904,23 @@ class WU_Plan extends \WP_Ultimo\Models\Product {
_deprecated_function(__CLASS__, '2.0.0', '\WP_Ultimo\Models\Product');
if (is_numeric($object)) {
-
$object = wu_get_product($object);
-
- } // end if;
+ }
if ($object) {
-
$object = get_object_vars($object);
-
- } // end if;
+ }
if (is_array($object)) {
-
foreach ($object as $att => $value) {
-
$this->{$att} = $value;
-
- } // end foreach;
-
- } // end if;
+ }
+ }
$this->set_slug(uniqid());
parent::__construct($object);
-
- } // end __construct;
+ }
/**
* Generic get method to bypass the protected status of the new models.
@@ -1017,20 +932,15 @@ class WU_Plan extends \WP_Ultimo\Models\Product {
public function __get($key) {
if ($key === 'price_1') {
-
return $this->get_amount();
-
- } // end if;
+ }
if (method_exists($this, "get_$key")) {
-
return call_user_func(array($this, "get_$key"));
-
- } // end if;
+ }
return $this->get_meta('wpu_' . $key, false);
-
- } // end __get;
+ }
/**
* Generic method to bypass the protected status of the new models.
@@ -1043,14 +953,10 @@ class WU_Plan extends \WP_Ultimo\Models\Product {
public function after_set($key, $value) {
if ($key === 'price_1') {
-
$this->set_amount($value);
-
- } // end if;
-
- } // end after_set;
-
-} // end class WU_Plan;
+ }
+ }
+}
/**
* Deprecated: WU_Subscription
@@ -1073,20 +979,15 @@ class WU_Subscription extends \WP_Ultimo\Models\Membership {
_deprecated_function(__CLASS__, '2.0.0', '\WP_Ultimo\Models\Membership');
if (is_numeric($object)) {
-
$object = wu_get_membership($object);
-
- } // end if;
+ }
if ($object) {
-
$object = get_object_vars($object);
-
- } // end if;
+ }
parent::__construct($object);
-
- } // end __construct;
+ }
/**
* Generic method to bypass the protected status of the new models.
@@ -1096,7 +997,7 @@ class WU_Subscription extends \WP_Ultimo\Models\Membership {
* @param string $key The key to set.
* @param mixed $value The value to set.
*/
- public function after_set($key, $value) {} // end after_set;
+ public function after_set($key, $value) {}
/**
* Deprecated: Add a valid coupon code to the subscription.
@@ -1107,8 +1008,7 @@ class WU_Subscription extends \WP_Ultimo\Models\Membership {
public function apply_coupon_code($coupon_code = null) {
_deprecated_function(__METHOD__, '2.0.0');
-
- } // end apply_coupon_code;
+ }
/**
* Deprecated: Add a valid coupon code to the subscription.
@@ -1118,10 +1018,8 @@ class WU_Subscription extends \WP_Ultimo\Models\Membership {
public function get_price_after_coupon_code() {
_deprecated_function(__METHOD__, '2.0.0');
-
- } // end get_price_after_coupon_code;
-
-} // end class WU_Subscription;
+ }
+}
/**
* Deprecated: WU_Signup
@@ -1136,10 +1034,8 @@ class WU_Signup extends \WP_Ultimo\Checkout\Legacy_Checkout {
public function __construct() {
_deprecated_function(__CLASS__, '2.0.0', '\WP_Ultimo\Checkout\Legacy_Checkout');
-
- } // end __construct;
-
-} // end class WU_Signup;
+ }
+}
/**
* Deprecated: WU_Gateway
@@ -1148,7 +1044,7 @@ class WU_Signup extends \WP_Ultimo\Checkout\Legacy_Checkout {
*/
abstract class WU_Gateway {
-} // end class WU_Gateway;
+}
/**
* Deprecated: WU_Site_Hooks
@@ -1174,8 +1070,7 @@ class WU_Site_Hooks {
_deprecated_function(__CLASS__, '2.0.0');
return array();
-
- } // end get_available_templates;
+ }
/**
* Deprecated: Duplicates our template site in the creation of the new user site.
@@ -1207,8 +1102,7 @@ class WU_Site_Hooks {
);
return \WP_Ultimo\Helpers\Site_Duplicator::duplicate_site($site_to_duplicate, $title, $arguments);
-
- } // end duplicate_site;
+ }
/**
* Deprecated: Returns the preview URL to a given site id.
@@ -1224,17 +1118,13 @@ class WU_Site_Hooks {
$site = wu_get_site($site_id);
- if (!$site) {
-
+ if ( ! $site) {
return '';
-
- } // end if;
+ }
return $site->get_featured_image();
-
- } // end get_template_preview_url;
-
-} // end class WU_Site_Hooks;
+ }
+}
/**
* Deprecated: WU_Transactions
@@ -1258,10 +1148,8 @@ class WU_Transactions {
$date = new \DateTime();
return $type === 'mysql' ? $date->format('Y-m-d H:i:s') : $date->format('U');
-
- } // end get_current_time;
-
-} // end class WU_Transactions;
+ }
+}
/*
* Functions
*/
@@ -1281,21 +1169,16 @@ function wu_get_coupon($coupon_code, $return_invalid = false) {
$discount_code = wu_get_discount_code_by_code($coupon_code);
- if (!$discount_code) {
-
+ if ( ! $discount_code) {
return false;
+ }
- } // end if;
-
- if (!$return_invalid && !$discount_code->is_valid()) {
-
+ if ( ! $return_invalid && ! $discount_code->is_valid()) {
return false;
-
- } // end if;
+ }
return new WU_Coupon($discount_code);
-
-} // end wu_get_coupon;
+}
/**
* Deprecated: Returns a plan based on the id passed
@@ -1311,15 +1194,12 @@ function wu_get_plan($plan_id) {
$plan = wu_get_product($plan_id);
- if (!$plan) {
-
+ if ( ! $plan) {
return false;
-
- } // end if;
+ }
return new WU_Plan($plan);
-
-} // end wu_get_plan;
+}
/**
* Deprecated: Gets a plan by its slug.
@@ -1335,8 +1215,7 @@ function wu_get_plan_by_slug($plan_slug) {
_deprecated_function(__FUNCTION__, '2.0.0', 'wu_get_product_by_slug()');
return wu_get_product_by_slug($plan_slug);
-
-} // end wu_get_plan_by_slug;
+}
/**
* Deprecated: Returns a subscription object based on the user.
*
@@ -1354,8 +1233,7 @@ function wu_get_subscription($user_id) {
_deprecated_function(__FUNCTION__, '2.0.0', 'wu_get_membership_by()');
return wu_get_membership_by('user_id', $user_id);
-
-} // end wu_get_subscription;
+}
/**
* Deprecated: Returns a subscription object based on the integration key.
*
@@ -1369,8 +1247,7 @@ function wu_get_subscription_by_integration_key($integration_key) {
_deprecated_function(__FUNCTION__, '2.0.0', 'wu_get_membership_by()');
return wu_get_membership_by('gateway_subscription_id', $integration_key);
-
-} // end wu_get_subscription_by_integration_key;
+}
/**
* Deprecated: Return a subscription object based on the current user.
*
@@ -1385,8 +1262,7 @@ function wu_get_current_subscription() {
_deprecated_function(__FUNCTION__, '2.0.0', 'wu_get_membership_by()');
return wu_get_membership_by('user_id', $user_id);
-
-} // end wu_get_current_subscription;
+}
/**
* Deprecated: Checks if the current user is an active subscriber.
@@ -1405,18 +1281,13 @@ function wu_is_active_subscriber($user_id = false) {
_deprecated_function(__FUNCTION__, '2.0.0');
if ($user_id === false) {
-
$membership = wu_get_current_site()->get_membership();
-
} else {
-
$membership = wu_get_membership_by('user_id', get_current_user_id());
-
- } // end if;
+ }
return $membership && $membership->is_active();
-
-} // end wu_is_active_subscriber;
+}
/**
* Deprecated: Checks if a given user is a customer of a given plan.
@@ -1440,16 +1311,13 @@ function wu_has_plan($user_id, $plan_id) {
* to prevent a fatal error.
*/
if (function_exists('wu_get_membership_by') === false) {
-
return false;
-
- } // end if;
+ }
$membership = wu_get_membership_by('user_id', $user_id);
return $membership && absint($membership->get_plan_id()) === absint($plan_id);
-
-} // end wu_has_plan;
+}
/**
* Deprecated: Returns the gateway being used by the current user at the moment.
@@ -1466,8 +1334,7 @@ function wu_get_active_gateway() {
$active_gateways = wu_get_active_gateways();
return reset($active_gateways);
-
-} // end wu_get_active_gateway;
+}
/**
* Deprecated: Generates the price description.
*
@@ -1483,8 +1350,7 @@ function wu_get_interval_string($price = null, $interval = null, $extended = nul
_deprecated_function(__FUNCTION__, '2.0.0', '\WP_Ultimo\Models\Product::get_price_description()');
return '';
-
-} // end wu_get_interval_string;
+}
/**
* Deprecated: get_wu_currencies.
@@ -1499,8 +1365,7 @@ function get_wu_currencies() { // phpcs:ignore
_deprecated_function(__FUNCTION__, '2.0.0', 'wu_get_currencies()');
return wu_get_currencies();
-
-} // end get_wu_currencies;
+}
/**
* Deprecated: get_wu_currency_symbol.
@@ -1516,5 +1381,4 @@ function get_wu_currency_symbol($currency = '') { // phpcs:ignore
_deprecated_function(__FUNCTION__, '2.0.0', 'wu_get_currency_symbol()');
return wu_get_currency_symbol($currency);
-
-} // end get_wu_currency_symbol;
+}
diff --git a/inc/deprecated/early-deprecated.php b/inc/deprecated/early-deprecated.php
index 619ca14..c9f82ad 100644
--- a/inc/deprecated/early-deprecated.php
+++ b/inc/deprecated/early-deprecated.php
@@ -34,8 +34,7 @@ class WU_Domain_Mapping {
$ip = \WP_Ultimo\Domain_Mapping\Helper::get_network_public_ip();
return apply_filters('wu_domain_mapping_get_ip_address', $ip, $_SERVER['SERVER_ADDR']);
-
- } // end get_ip_address;
+ }
/**
* Deprecated: get_hosting_support_text
@@ -48,7 +47,5 @@ class WU_Domain_Mapping {
_deprecated_function(__METHOD__, '2.0.0');
return '';
-
- } // end get_hosting_support_text;
-
-} // end class WU_Domain_Mapping;
+ }
+}
diff --git a/inc/deprecated/mercator.php b/inc/deprecated/mercator.php
index 87b05a0..e959487 100644
--- a/inc/deprecated/mercator.php
+++ b/inc/deprecated/mercator.php
@@ -32,30 +32,22 @@ class Mapping {
_deprecated_function(__METHOD__, '2.0.0', 'wu_get_domain_by_domain($domain)');
- if (!function_exists('wu_get_domain_by_domain')) {
-
+ if ( ! function_exists('wu_get_domain_by_domain')) {
return false;
-
- } // end if;
+ }
$domain = false;
foreach ((array) $domains as $url_to_search) {
-
$found_domain = wu_get_domain_by_domain($url_to_search);
if ($found_domain) {
-
$domain = $found_domain;
break;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
return $domain;
-
- } // end get_by_domain;
-
-} // end class Mapping;
+ }
+}
diff --git a/inc/development/bootstrap.php b/inc/development/bootstrap.php
index 7c396c2..8ec038f 100644
--- a/inc/development/bootstrap.php
+++ b/inc/development/bootstrap.php
@@ -10,7 +10,7 @@
* @since 2.1.0
*/
-use \Rarst\wps\Plugin as Whoops;
+use Rarst\wps\Plugin as Whoops;
return;
@@ -19,10 +19,8 @@ return;
* or by setting the constant we used to have on previous versions.
*/
if (isset($_GET['whoops-disable']) || (defined('WP_ULTIMO_DISABLE_WHOOPS') && WP_ULTIMO_DISABLE_WHOOPS)) {
-
return;
-
-} // end if;
+}
$wu_whoops = new Whoops();
diff --git a/inc/development/class-toolkit.php b/inc/development/class-toolkit.php
index 56d8f58..5548ea0 100644
--- a/inc/development/class-toolkit.php
+++ b/inc/development/class-toolkit.php
@@ -81,8 +81,7 @@ class Toolkit {
add_filter('qm/collectors', array($this, 'register_collector_overview'), 1, 2);
add_filter('qm/outputter/html', array($this, 'add_overview_panel'), 50, 2);
-
- } // end init;
+ }
/**
* Registers the default listeners.
@@ -107,8 +106,7 @@ class Toolkit {
$this->listen('save-rest-arguments', array($this, 'save_route_arguments'), 'wu_rest_register_routes_general');
$this->listen('save-rest-arguments', array($this, 'save_route_arguments'), 'wu_rest_register_routes_with_id');
-
- } // end register_default_listeners;
+ }
/**
* Save route arguments to files to deal with opcache.
@@ -128,8 +126,7 @@ class Toolkit {
$args = $manager->get_arguments_schema($context === 'update');
file_put_contents(wu_path("/mpb/data/endpoint/.endpoint-$class_name-$context"), json_encode($args)); // phpcs:ignore
-
- } // end save_route_arguments;
+ }
/**
* Adds a listener for development purposes.
@@ -144,35 +141,38 @@ class Toolkit {
*/
public function listen($hook, $callback, $wp_hook = 'wp_ultimo_load', $order = 1) {
- $this->listeners[$hook] = ($this->listeners[$hook] ?? 0) + 1;
+ $this->listeners[ $hook ] = ($this->listeners[ $hook ] ?? 0) + 1;
- $this->wp_hooks[$wp_hook] = 1;
+ $this->wp_hooks[ $wp_hook ] = 1;
$action = $this->get_action($hook, $wp_hook);
$order = $this->get_order($hook, $order);
- add_action($action, function(...$arguments) use ($callback, $action, $order) {
+ add_action(
+ $action,
+ function (...$arguments) use ($callback, $action, $order) {
- $timing_id = sprintf('%s_%s_%s', $action, $this->run + 1, $order);
+ $timing_id = sprintf('%s_%s_%s', $action, $this->run + 1, $order);
// phpcs:ignore
do_action('qm/start', $timing_id);
- $result = call_user_func_array($callback, $arguments);
+ $result = call_user_func_array($callback, $arguments);
// phpcs:ignore
do_action('qm/stop', $timing_id);
- $this->run++;
+ $this->run++;
- return $result;
-
- }, $order, 100);
+ return $result;
+ },
+ $order,
+ 100
+ );
return $this;
-
- } // end listen;
+ }
/**
* Sets flags for the development environment.
@@ -197,17 +197,12 @@ class Toolkit {
);
foreach ($configs as $constant_name => $constant_value) {
-
if (in_array($constant_name, $allowed_configs, true)) {
-
// phpcs:ignore
defined($constant_name) === false && define($constant_name, $constant_value);
-
- } // end if;
-
- } // end foreach;
-
- } // end config;
+ }
+ }
+ }
/**
* Marks the development environment to finish execution after all listeners are run.
@@ -220,14 +215,11 @@ class Toolkit {
public function die($should_die = true) {
if ($should_die === true) {
-
$should_die = is_admin() ? 'admin_enqueue_scripts' : 'wp_enqueue_scripts';
-
- } // end if;
+ }
$this->should_die = $should_die;
-
- } // end die;
+ }
/**
* Run a registered listener.
@@ -243,20 +235,15 @@ class Toolkit {
$listener = wu_request(self::LISTENER_PARAM, 'no-dev-param');
if ($listener === 'no-dev-param') {
-
return current($arguments);
-
} elseif ($listener === '') {
-
$listener = 'index';
-
- } // end if;
+ }
$action = $this->get_action($listener, $wp_hook);
return do_action_ref_array($action, $arguments); // phpcs:ignore
-
- } // end run_listener;
+ }
/**
* Loads the sandbox environment.
@@ -280,26 +267,20 @@ class Toolkit {
$toolkit = $this;
include $dev_file;
-
- } // end if;
+ }
$wp_hooks = array_keys($this->wp_hooks);
foreach ($wp_hooks as $wp_hook) {
-
add_action($wp_hook, fn(...$arguments) => $this->run_listener($wp_hook, $arguments), 0, 100);
-
- } // end foreach;
+ }
add_action('shutdown', array($this, 'setup_query_monitor'));
if ($this->should_die) {
-
$this->dump_and_die(end($wp_hooks));
-
- } // end if;
-
- } // end load_sandbox;
+ }
+ }
/**
* Setups the query monitor integration.
@@ -310,7 +291,6 @@ class Toolkit {
public function setup_query_monitor() {
if (class_exists('\QM_Dispatchers')) {
-
// phpcs:ignore
do_action('qm/debug', sprintf('Actions with listeners: %s', $this->get_wp_hooks_list()));
@@ -320,23 +300,17 @@ class Toolkit {
// phpcs:ignore
$dispatcher = \QM_Dispatchers::get('html');
- if (!$dispatcher) {
-
+ if (! $dispatcher) {
return;
-
- } // end if;
+ }
$dispatcher->did_footer = true;
if ($this->should_die && $this->run) {
-
$this->enqueue_scripts($dispatcher);
-
- } // end if;
-
- } // end if;
-
- } // end setup_query_monitor;
+ }
+ }
+ }
/**
* Registers the collector overview.
@@ -352,8 +326,7 @@ class Toolkit {
$collectors['wp-ultimo'] = new Query_Monitor\Collectors\Collector_Overview();
return $collectors;
-
- } // end register_collector_overview;
+ }
/**
* Adds the overview panel.
@@ -370,8 +343,7 @@ class Toolkit {
$output['wp-ultimo'] = new Query_Monitor\Panel\Overview($collector);
return $output;
-
- } // end add_overview_panel;
+ }
/**
* Manually enqueues query monitor and WP Multisite WaaS styles.
@@ -383,15 +355,16 @@ class Toolkit {
*/
protected function enqueue_scripts($dispatcher) {
- echo sprintf('', wu_url('inc/development/assets/development.css'));
+ printf('', wu_url('inc/development/assets/development.css'));
- wp_print_styles(array(
- 'wu-admin',
- ));
+ wp_print_styles(
+ array(
+ 'wu-admin',
+ )
+ );
$dispatcher->manually_print_assets(); // phpcs:ignore
-
- } // end enqueue_scripts;
+ }
/**
* Returns a comma-separated list of listeners.
@@ -403,8 +376,7 @@ class Toolkit {
$listener_names = array_keys($this->listeners);
return implode(', ', $listener_names);
-
- } // end get_listeners_list;
+ }
/**
* Returns a comma-separated list of WordPress hooks.
@@ -416,8 +388,7 @@ class Toolkit {
$wp_hook_names = array_keys($this->wp_hooks);
return implode(', ', $wp_hook_names);
-
- } // end get_wp_hooks_list;
+ }
/**
* Dumps the development content and kill the execution.
@@ -429,29 +400,27 @@ class Toolkit {
*/
protected function dump_and_die($hook) {
- add_action($hook, function() use ($hook) {
+ add_action(
+ $hook,
+ function () use ($hook) {
- if (did_action($this->should_die) && $this->run) {
+ if (did_action($this->should_die) && $this->run) {
+ $this->render_listeners_menu();
- $this->render_listeners_menu();
+ do_action('shutdown'); // phpcs:ignore
- do_action('shutdown'); // phpcs:ignore
+ $message = sprintf('Execution killed on %s.', $hook);
- $message = sprintf('Execution killed on %s.', $hook);
+ do_action('qm/info', $message); // phpcs:ignore
- do_action('qm/info', $message); // phpcs:ignore
-
- die();
-
- } else {
-
- return $this->dump_and_die($this->should_die);
-
- } // end if;
-
- }, 110);
-
- } // end dump_and_die;
+ die();
+ } else {
+ return $this->dump_and_die($this->should_die);
+ }
+ },
+ 110
+ );
+ }
/**
* Get the order of a newly added listener.
@@ -464,9 +433,8 @@ class Toolkit {
*/
protected function get_order($hook, $order = 1) {
- return 10 + (absint($this->listeners[$hook]) * $order * 10) + 5;
-
- } // end get_order;
+ return 10 + (absint($this->listeners[ $hook ]) * $order * 10) + 5;
+ }
/**
* Get the action name based on the listener hook and WP action.
@@ -481,8 +449,7 @@ class Toolkit {
$hook = str_replace('-', '_', $hook);
return sprintf('wu_sandbox_run_%s_%s', $hook, $wp_hook);
-
- } // end get_action;
+ }
/**
* Render the list of listeners with links.
@@ -496,10 +463,8 @@ class Toolkit {
* Make sure we display it only once.
*/
if ($this->displayed_footer) {
-
return;
-
- } // end if;
+ }
// phpcs:disable
echo '
@@ -509,13 +474,13 @@ class Toolkit {
foreach (array_keys($this->listeners) as $listener) {
- echo sprintf(
- '
';
return $html;
-
- } // end column_customer_status;
+ }
/**
* Returns the number of memberships owned by this customer.
*
@@ -220,8 +223,7 @@ class Customer_List_Table extends Base_List_Table {
);
return $subscription_count . $this->row_actions($actions);
-
- } // end column_memberships;
+ }
/**
* Returns the list of columns for this particular List Table.
@@ -242,8 +244,7 @@ class Customer_List_Table extends Base_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Handles the item display for grid mode.
@@ -255,12 +256,14 @@ class Customer_List_Table extends Base_List_Table {
*/
public function single_row_grid($item) {
- wu_get_template('base/customers/grid-item', array(
- 'item' => $item,
- 'table' => $this,
- ));
-
- } // end single_row_grid;
+ wu_get_template(
+ 'base/customers/grid-item',
+ array(
+ 'item' => $item,
+ 'table' => $this,
+ )
+ );
+ }
/**
* Returns the filters for this page.
@@ -269,46 +272,46 @@ class Customer_List_Table extends Base_List_Table {
*/
public function get_filters(): array {
- $filters = $this->get_schema_columns(array(
- 'searchable' => true,
- 'date_query' => true,
- ), 'or');
+ $filters = $this->get_schema_columns(
+ array(
+ 'searchable' => true,
+ 'date_query' => true,
+ ),
+ 'or'
+ );
$labels = $this->get_columns();
- $filters = array_map(function($item) use ($labels) {
+ $filters = array_map(
+ function ($item) use ($labels) {
- $label = wu_get_isset($labels, $item->name);
- $label = $label ? sprintf('%s (%s)', $item->label, $item->name) : $item->name;
+ $label = wu_get_isset($labels, $item->name);
+ $label = $label ? sprintf('%s (%s)', $item->label, $item->name) : $item->name;
- $filter_type = 'text';
- $rule = 'is';
+ $filter_type = 'text';
+ $rule = 'is';
- if ($item->date_query === true) {
+ if ($item->date_query === true) {
+ $filter_type = 'date';
+ $rule = 'is_after';
+ } elseif (in_array(strtolower((string) $item->name), array('smallint'), true)) {
+ $filter_type = 'bool';
+ $rule = 'is_true';
+ }
- $filter_type = 'date';
- $rule = 'is_after';
-
- } elseif (in_array(strtolower((string) $item->name), array('smallint'), true)) {
-
- $filter_type = 'bool';
- $rule = 'is_true';
-
- } // end if;
-
- return array(
- 'field' => $item->name,
- 'label' => $label,
- 'type' => $filter_type,
- 'rule' => $rule,
- 'value' => wu_request($item->name, ''),
- );
-
- }, $filters);
+ return array(
+ 'field' => $item->name,
+ 'label' => $label,
+ 'type' => $filter_type,
+ 'rule' => $rule,
+ 'value' => wu_request($item->name, ''),
+ );
+ },
+ $filters
+ );
return array_values($filters);
-
- } // end get_filters;
+ }
/**
* Returns the pre-selected filters on the filter bar.
@@ -321,9 +324,11 @@ class Customer_List_Table extends Base_List_Table {
return array(
'all' => array(
'field' => 'filter',
- 'url' => add_query_arg(array(
- 'filter' => 'all'
- )),
+ 'url' => add_query_arg(
+ array(
+ 'filter' => 'all',
+ )
+ ),
'label' => __('All Customers', 'wp-ultimo'),
'count' => 0,
),
@@ -340,8 +345,7 @@ class Customer_List_Table extends Base_List_Table {
'count' => 0,
),
);
-
- } // end get_views;
+ }
/**
* Displays the last login.
@@ -354,13 +358,9 @@ class Customer_List_Table extends Base_List_Table {
public function column_last_login($item) {
if ($item->is_online()) {
-
return '' . __('Online', 'wp-ultimo');
-
- } // end if;
+ }
return $this->_column_datetime($item->get_last_login());
-
- } // end column_last_login;
-
-} // end class Customer_List_Table;
+ }
+}
diff --git a/inc/list-tables/class-customers-membership-list-table.php b/inc/list-tables/class-customers-membership-list-table.php
index ba64dee..48fab15 100644
--- a/inc/list-tables/class-customers-membership-list-table.php
+++ b/inc/list-tables/class-customers-membership-list-table.php
@@ -32,8 +32,7 @@ class Customers_Membership_List_Table extends Membership_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Renders the inside column responsive.
@@ -53,43 +52,47 @@ class Customers_Membership_List_Table extends Membership_List_Table {
$products_list = $p ? sprintf(_n('Contains %s', 'Contains %1$s and %2$s other product(s)', $product_count, 'wp-ultimo'), $p->get_name(), count($item->get_addon_ids())) : ''; // phpcs:ignore
- echo wu_responsive_table_row(array(
- 'id' => $item->get_id(),
- 'title' => $item->get_hash(),
- 'url' => wu_network_admin_url('wp-ultimo-edit-membership', array(
- 'id' => $item->get_id(),
- )),
- 'status' => $this->column_status($item),
- ), array(
- 'total' => array(
- 'icon' => 'dashicons-wu-shopping-bag1 wu-align-middle wu-mr-1',
- 'label' => __('Payment Total', 'wp-ultimo'),
- 'value' => $item->get_price_description(),
+ echo wu_responsive_table_row(
+ array(
+ 'id' => $item->get_id(),
+ 'title' => $item->get_hash(),
+ 'url' => wu_network_admin_url(
+ 'wp-ultimo-edit-membership',
+ array(
+ 'id' => $item->get_id(),
+ )
+ ),
+ 'status' => $this->column_status($item),
),
- 'products' => array(
- 'icon' => 'dashicons-wu-package wu-align-middle wu-mr-1',
- 'label' => __('Products', 'wp-ultimo'),
- 'value' => $products_list,
+ array(
+ 'total' => array(
+ 'icon' => 'dashicons-wu-shopping-bag1 wu-align-middle wu-mr-1',
+ 'label' => __('Payment Total', 'wp-ultimo'),
+ 'value' => $item->get_price_description(),
+ ),
+ 'products' => array(
+ 'icon' => 'dashicons-wu-package wu-align-middle wu-mr-1',
+ 'label' => __('Products', 'wp-ultimo'),
+ 'value' => $products_list,
+ ),
+ 'gateway' => array(
+ 'icon' => 'dashicons-wu-credit-card2 wu-align-middle wu-mr-1',
+ 'label' => __('Gateway', 'wp-ultimo'),
+ 'value' => wu_slug_to_name($item->get_gateway()),
+ ),
),
- 'gateway' => array(
- 'icon' => 'dashicons-wu-credit-card2 wu-align-middle wu-mr-1',
- 'label' => __('Gateway', 'wp-ultimo'),
- 'value' => wu_slug_to_name($item->get_gateway()),
- ),
- ),
- array(
- 'date_expiration' => array(
- 'icon' => 'dashicons-wu-calendar1 wu-align-middle wu-mr-1',
- 'label' => __('Expires', 'wp-ultimo'),
- 'value' => sprintf($expired ? __('Expired %s', 'wp-ultimo') : __('Expiring %s', 'wp-ultimo'), wu_human_time_diff(strtotime((string) $item->get_date_expiration()))),
- ),
- 'date_created' => array(
- 'icon' => 'dashicons-wu-calendar1 wu-align-middle wu-mr-1',
- 'label' => __('Created at', 'wp-ultimo'),
- 'value' => sprintf(__('Created %s', 'wp-ultimo'), wu_human_time_diff(strtotime((string) $item->get_date_created()))),
- ),
- ));
-
- } // end column_responsive;
-
-} // end class Customers_Membership_List_Table;
+ array(
+ 'date_expiration' => array(
+ 'icon' => 'dashicons-wu-calendar1 wu-align-middle wu-mr-1',
+ 'label' => __('Expires', 'wp-ultimo'),
+ 'value' => sprintf($expired ? __('Expired %s', 'wp-ultimo') : __('Expiring %s', 'wp-ultimo'), wu_human_time_diff(strtotime((string) $item->get_date_expiration()))),
+ ),
+ 'date_created' => array(
+ 'icon' => 'dashicons-wu-calendar1 wu-align-middle wu-mr-1',
+ 'label' => __('Created at', 'wp-ultimo'),
+ 'value' => sprintf(__('Created %s', 'wp-ultimo'), wu_human_time_diff(strtotime((string) $item->get_date_created()))),
+ ),
+ )
+ );
+ }
+}
diff --git a/inc/list-tables/class-customers-payment-list-table.php b/inc/list-tables/class-customers-payment-list-table.php
index 771f968..7f39a32 100644
--- a/inc/list-tables/class-customers-payment-list-table.php
+++ b/inc/list-tables/class-customers-payment-list-table.php
@@ -32,8 +32,7 @@ class Customers_Payment_List_Table extends Payment_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Renders the inside column responsive.
@@ -45,33 +44,37 @@ class Customers_Payment_List_Table extends Payment_List_Table {
*/
public function column_responsive($item) {
- echo wu_responsive_table_row(array(
- 'id' => $item->get_id(),
- 'title' => $item->get_hash(),
- 'url' => wu_network_admin_url('wp-ultimo-edit-payment', array(
- 'id' => $item->get_id(),
- )),
- 'status' => $this->column_status($item),
- ), array(
- 'total' => array(
- 'icon' => 'dashicons-wu-shopping-bag1 wu-align-middle wu-mr-1',
- 'label' => __('Payment Total', 'wp-ultimo'),
- 'value' => wu_format_currency($item->get_total()),
+ echo wu_responsive_table_row(
+ array(
+ 'id' => $item->get_id(),
+ 'title' => $item->get_hash(),
+ 'url' => wu_network_admin_url(
+ 'wp-ultimo-edit-payment',
+ array(
+ 'id' => $item->get_id(),
+ )
+ ),
+ 'status' => $this->column_status($item),
),
- 'gateway' => array(
- 'icon' => 'dashicons-wu-credit-card2 wu-align-middle wu-mr-1',
- 'label' => __('Gateway', 'wp-ultimo'),
- 'value' => wu_slug_to_name($item->get_gateway()),
+ array(
+ 'total' => array(
+ 'icon' => 'dashicons-wu-shopping-bag1 wu-align-middle wu-mr-1',
+ 'label' => __('Payment Total', 'wp-ultimo'),
+ 'value' => wu_format_currency($item->get_total()),
+ ),
+ 'gateway' => array(
+ 'icon' => 'dashicons-wu-credit-card2 wu-align-middle wu-mr-1',
+ 'label' => __('Gateway', 'wp-ultimo'),
+ 'value' => wu_slug_to_name($item->get_gateway()),
+ ),
),
- ),
- array(
- 'date_created' => array(
- 'icon' => 'dashicons-wu-calendar1 wu-align-middle wu-mr-1',
- 'label' => '',
- 'value' => sprintf(__('Created %s', 'wp-ultimo'), wu_human_time_diff(strtotime((string) $item->get_date_created()))),
- ),
- ));
-
- } // end column_responsive;
-
-} // end class Customers_Payment_List_Table;
+ array(
+ 'date_created' => array(
+ 'icon' => 'dashicons-wu-calendar1 wu-align-middle wu-mr-1',
+ 'label' => '',
+ 'value' => sprintf(__('Created %s', 'wp-ultimo'), wu_human_time_diff(strtotime((string) $item->get_date_created()))),
+ ),
+ )
+ );
+ }
+}
diff --git a/inc/list-tables/class-customers-site-list-table.php b/inc/list-tables/class-customers-site-list-table.php
index 5e3e242..026acb4 100644
--- a/inc/list-tables/class-customers-site-list-table.php
+++ b/inc/list-tables/class-customers-site-list-table.php
@@ -29,8 +29,7 @@ class Customers_Site_List_Table extends Site_List_Table {
parent::__construct();
$this->current_mode = 'list';
-
- } // end __construct;
+ }
/**
* Returns the list of columns for this particular List Table.
@@ -45,8 +44,7 @@ class Customers_Site_List_Table extends Site_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Renders the inside column responsive.
@@ -62,46 +60,54 @@ class Customers_Site_List_Table extends Site_List_Table {
$redirect = current_user_can('wu_edit_sites') ? 'wp-ultimo-edit-site' : 'wp-ultimo-sites';
- echo wu_responsive_table_row(array(
- 'id' => $item->get_id(),
- 'title' => $item->get_title(),
- 'url' => wu_network_admin_url($redirect, array(
- 'id' => $item->get_id(),
- )),
- 'image' => $this->column_featured_image_id($item),
- 'status' => $this->column_type($item),
- ), array(
- 'link' => array(
- 'icon' => 'dashicons-wu-link1 wu-align-middle wu-mr-1',
- 'label' => __('Visit Site', 'wp-ultimo'),
- 'url' => $item->get_active_site_url(),
- 'value' => $item->get_active_site_url(),
+ echo wu_responsive_table_row(
+ array(
+ 'id' => $item->get_id(),
+ 'title' => $item->get_title(),
+ 'url' => wu_network_admin_url(
+ $redirect,
+ array(
+ 'id' => $item->get_id(),
+ )
+ ),
+ 'image' => $this->column_featured_image_id($item),
+ 'status' => $this->column_type($item),
),
- 'dashboard' => array(
- 'icon' => 'dashicons-wu-browser wu-align-middle wu-mr-1',
- 'label' => __('Go to the Dashboard', 'wp-ultimo'),
- 'value' => __('Dashboard', 'wp-ultimo'),
- 'url' => get_admin_url($item->get_id()),
+ array(
+ 'link' => array(
+ 'icon' => 'dashicons-wu-link1 wu-align-middle wu-mr-1',
+ 'label' => __('Visit Site', 'wp-ultimo'),
+ 'url' => $item->get_active_site_url(),
+ 'value' => $item->get_active_site_url(),
+ ),
+ 'dashboard' => array(
+ 'icon' => 'dashicons-wu-browser wu-align-middle wu-mr-1',
+ 'label' => __('Go to the Dashboard', 'wp-ultimo'),
+ 'value' => __('Dashboard', 'wp-ultimo'),
+ 'url' => get_admin_url($item->get_id()),
+ ),
+ 'membership' => array(
+ 'icon' => 'dashicons-wu-rotate-ccw wu-align-middle wu-mr-1',
+ 'label' => __('Go to the Membership', 'wp-ultimo'),
+ 'value' => $m ? $m->get_hash() : '',
+ 'url' => $m ? wu_network_admin_url(
+ 'wp-ultimo-edit-membership',
+ array(
+ 'id' => $m->get_id(),
+ )
+ ) : '',
+ ),
),
- 'membership' => array(
- 'icon' => 'dashicons-wu-rotate-ccw wu-align-middle wu-mr-1',
- 'label' => __('Go to the Membership', 'wp-ultimo'),
- 'value' => $m ? $m->get_hash() : '',
- 'url' => $m ? wu_network_admin_url('wp-ultimo-edit-membership', array(
- 'id' => $m->get_id(),
- )) : '',
- ),
- ),
- array(
- 'date_created' => array(
- 'icon' => 'dashicons-wu-calendar1 wu-align-middle wu-mr-1',
- 'label' => '',
- /* translators: the placeholder is a date */
- 'value' => $item->get_type() === 'pending' ? __('Not Available', 'wp-ultimo') : sprintf(__('Created %s', 'wp-ultimo'), wu_human_time_diff(strtotime((string) $item->get_date_registered()))),
- ),
- ));
-
- } // end column_responsive;
+ array(
+ 'date_created' => array(
+ 'icon' => 'dashicons-wu-calendar1 wu-align-middle wu-mr-1',
+ 'label' => '',
+ /* translators: the placeholder is a date */
+ 'value' => $item->get_type() === 'pending' ? __('Not Available', 'wp-ultimo') : sprintf(__('Created %s', 'wp-ultimo'), wu_human_time_diff(strtotime((string) $item->get_date_registered()))),
+ ),
+ )
+ );
+ }
/**
* Overrides the parent method to add pending sites.
@@ -118,10 +124,8 @@ class Customers_Site_List_Table extends Site_List_Table {
$sites = parent::get_items($per_page, $page_number, $count);
if ($count) {
-
return $sites;
-
- } // end if;
+ }
$pending_sites = array();
@@ -129,14 +133,11 @@ class Customers_Site_List_Table extends Site_List_Table {
$id = wu_request('id');
- if (!$id) {
-
+ if ( ! $id) {
return $sites;
-
- } // end if;
+ }
switch ($page) {
-
case 'wp-ultimo-edit-membership':
$membership = wu_get_membership($id);
$pending_sites = $membership && $membership->get_pending_site() ? array($membership->get_pending_site()) : array();
@@ -145,18 +146,13 @@ class Customers_Site_List_Table extends Site_List_Table {
$customer = wu_get_customer($id);
$pending_sites = $customer ? $customer->get_pending_sites() : array();
break;
-
- } // end switch;
+ }
foreach ($pending_sites as &$site) {
-
$site->set_type('pending');
$site->set_blog_id('--');
-
- } // end foreach;
+ }
return array_merge($pending_sites, $sites);
-
- } // end get_items;
-
-} // end class Customers_Site_List_Table;
+ }
+}
diff --git a/inc/list-tables/class-discount-code-list-table.php b/inc/list-tables/class-discount-code-list-table.php
index 17e929e..c9cb7dd 100644
--- a/inc/list-tables/class-discount-code-list-table.php
+++ b/inc/list-tables/class-discount-code-list-table.php
@@ -34,17 +34,18 @@ class Discount_Code_List_Table extends Base_List_Table {
*/
public function __construct() {
- parent::__construct(array(
- 'singular' => __('Discount Code', 'wp-ultimo'), // singular name of the listed records
- 'plural' => __('Discount Codes', 'wp-ultimo'), // plural name of the listed records
- 'ajax' => true, // does this table support ajax?
- 'add_new' => array(
- 'url' => wu_network_admin_url('wp-ultimo-edit-discount-code'),
- 'classes' => '',
- ),
- ));
-
- } // end __construct;
+ parent::__construct(
+ array(
+ 'singular' => __('Discount Code', 'wp-ultimo'), // singular name of the listed records
+ 'plural' => __('Discount Codes', 'wp-ultimo'), // plural name of the listed records
+ 'ajax' => true, // does this table support ajax?
+ 'add_new' => array(
+ 'url' => wu_network_admin_url('wp-ultimo-edit-discount-code'),
+ 'classes' => '',
+ ),
+ )
+ );
+ }
/**
* Displays the content of the name column.
*
@@ -75,8 +76,7 @@ class Discount_Code_List_Table extends Base_List_Table {
);
return $title . $this->row_actions($actions);
-
- } // end column_name;
+ }
/**
* Displays the content of the value column.
@@ -89,24 +89,19 @@ class Discount_Code_List_Table extends Base_List_Table {
*/
public function column_value($item) {
- if (!$item->get_value()) {
-
+ if ( ! $item->get_value()) {
return __('No Discount', 'wp-ultimo');
-
- } // end if;
+ }
$value = wu_format_currency($item->get_value());
if ($item->get_type() === 'percentage') {
-
$value = number_format($item->get_value(), 0) . '%';
-
- } // end if;
+ }
// translators: placeholder is the amount of discount. e.g. 10% or $5.
return sprintf(__('%s OFF', 'wp-ultimo'), $value);
-
- } // end column_value;
+ }
/**
* Displays the content of the setup fee value column.
@@ -119,24 +114,19 @@ class Discount_Code_List_Table extends Base_List_Table {
*/
public function column_setup_fee_value($item) {
- if (!$item->get_setup_fee_value()) {
-
+ if ( ! $item->get_setup_fee_value()) {
return __('No Discount', 'wp-ultimo');
-
- } // end if;
+ }
$value = wu_format_currency($item->get_setup_fee_value());
if ($item->get_setup_fee_type() === 'percentage') {
-
$value = number_format($item->get_setup_fee_value()) . '%';
-
- } // end if;
+ }
// translators: placeholder is the amount of discount. e.g. 10% or $5.
return sprintf(__('%s OFF', 'wp-ultimo'), $value);
-
- } // end column_setup_fee_value;
+ }
/**
* Displays the use limitations.
@@ -155,16 +145,12 @@ class Discount_Code_List_Table extends Base_List_Table {
// translators: the placeholder is the number of times this coupon can be used before becoming inactive.
$html .= '' . sprintf(__('Allowed uses: %d', 'wp-ultimo'), $item->get_max_uses()) . '';
-
} else {
-
$html .= '' . __('No Limits', 'wp-ultimo') . '';
-
- } // end if;
+ }
return $html;
-
- } // end column_uses;
+ }
/**
* Shows the code as a tag.
@@ -183,14 +169,11 @@ class Discount_Code_List_Table extends Base_List_Table {
$valid = $item->is_valid();
if (is_wp_error($valid)) {
-
$html .= sprintf('%s', wu_tooltip_text($valid->get_error_message()), __('Inactive', 'wp-ultimo'));
-
- } // end if;
+ }
return $html;
-
- } // end column_coupon_code;
+ }
/**
* Returns the list of columns for this particular List Table.
@@ -211,8 +194,7 @@ class Discount_Code_List_Table extends Base_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Returns the filters for this page.
*
@@ -224,7 +206,5 @@ class Discount_Code_List_Table extends Base_List_Table {
'filters' => array(),
'date_filters' => array(),
);
-
- } // end get_filters;
-
-} // end class Discount_Code_List_Table;
+ }
+}
diff --git a/inc/list-tables/class-domain-list-table.php b/inc/list-tables/class-domain-list-table.php
index fa0f72d..72d1f81 100644
--- a/inc/list-tables/class-domain-list-table.php
+++ b/inc/list-tables/class-domain-list-table.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\List_Tables;
-use \WP_Ultimo\Models\Domain;
+use WP_Ultimo\Models\Domain;
use WP_Ultimo\Database\Domains\Domain_Stage;
// Exit if accessed directly
@@ -37,17 +37,18 @@ class Domain_List_Table extends Base_List_Table {
*/
public function __construct() {
- parent::__construct(array(
- 'singular' => __('Domain', 'wp-ultimo'), // singular name of the listed records
- 'plural' => __('Domains', 'wp-ultimo'), // plural name of the listed records
- 'ajax' => true, // does this table support ajax?
- 'add_new' => array(
- 'url' => wu_get_form_url('add_new_domain'),
- 'classes' => 'wubox',
- ),
- ));
-
- } // end __construct;
+ parent::__construct(
+ array(
+ 'singular' => __('Domain', 'wp-ultimo'), // singular name of the listed records
+ 'plural' => __('Domains', 'wp-ultimo'), // plural name of the listed records
+ 'ajax' => true, // does this table support ajax?
+ 'add_new' => array(
+ 'url' => wu_get_form_url('add_new_domain'),
+ 'classes' => 'wubox',
+ ),
+ )
+ );
+ }
/**
* Adds the extra search field when the search element is present.
@@ -60,14 +61,11 @@ class Domain_List_Table extends Base_List_Table {
$_filter_fields = parent::get_extra_query_fields();
if (wu_request('blog_id')) {
-
$_filter_fields['blog_id'] = wu_request('blog_id');
-
- } // end if;
+ }
return $_filter_fields;
-
- } // end get_extra_query_fields;
+ }
/**
* Displays the content of the domain column.
*
@@ -92,8 +90,7 @@ class Domain_List_Table extends Base_List_Table {
);
return $html . $this->row_actions($actions);
-
- } // end column_domain;
+ }
/**
* Displays the content of the active column.
@@ -106,8 +103,7 @@ class Domain_List_Table extends Base_List_Table {
public function column_active($item) {
return $item->is_active() ? __('Yes', 'wp-ultimo') : __('No', 'wp-ultimo');
-
- } // end column_active;
+ }
/**
* Displays the content of the primary domain column.
@@ -120,8 +116,7 @@ class Domain_List_Table extends Base_List_Table {
public function column_primary_domain($item) {
return $item->is_primary_domain() ? __('Yes', 'wp-ultimo') : __('No', 'wp-ultimo');
-
- } // end column_primary_domain;
+ }
/**
* Displays the content of the secure column.
@@ -134,8 +129,7 @@ class Domain_List_Table extends Base_List_Table {
public function column_secure($item) {
return $item->is_secure() ? __('Yes', 'wp-ultimo') : __('No', 'wp-ultimo');
-
- } // end column_secure;
+ }
/**
* Returns the markup for the stage column.
@@ -152,8 +146,7 @@ class Domain_List_Table extends Base_List_Table {
$class = $item->get_stage_class();
return "{$label}";
-
- } // end column_stage;
+ }
/**
* Returns the list of columns for this particular List Table.
@@ -175,8 +168,7 @@ class Domain_List_Table extends Base_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Returns the filters for this page.
*
@@ -229,11 +221,7 @@ class Domain_List_Table extends Base_List_Table {
),
),
- 'date_filters' => array(
-
- ),
+ 'date_filters' => array(),
);
-
- } // end get_filters;
-
-} // end class Domain_List_Table;
+ }
+}
diff --git a/inc/list-tables/class-email-list-table.php b/inc/list-tables/class-email-list-table.php
index 3f0b291..0ce2318 100644
--- a/inc/list-tables/class-email-list-table.php
+++ b/inc/list-tables/class-email-list-table.php
@@ -20,11 +20,11 @@ defined('ABSPATH') || exit;
class Email_List_Table extends Base_List_Table {
/**
- * Holds the query class for the object being listed.
- *
- * @since 2.0.0
- * @var string
- */
+ * Holds the query class for the object being listed.
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $query_class = '\\WP_Ultimo\\Database\\Emails\\Email_Query';
/**
@@ -34,17 +34,18 @@ class Email_List_Table extends Base_List_Table {
*/
public function __construct() {
- parent::__construct(array(
- 'singular' => __('Email', 'wp-ultimo'), // singular name of the listed records
- 'plural' => __('Emails', 'wp-ultimo'), // plural name of the listed records
- 'ajax' => true, // does this table support ajax?
- 'add_new' => array(
- 'url' => wu_network_admin_url('wp-ultimo-edit-email'),
- 'classes' => '',
- ),
- ));
-
- } // end __construct;
+ parent::__construct(
+ array(
+ 'singular' => __('Email', 'wp-ultimo'), // singular name of the listed records
+ 'plural' => __('Emails', 'wp-ultimo'), // plural name of the listed records
+ 'ajax' => true, // does this table support ajax?
+ 'add_new' => array(
+ 'url' => wu_network_admin_url('wp-ultimo-edit-email'),
+ 'classes' => '',
+ ),
+ )
+ );
+ }
/**
* Overrides the parent method to add pending sites.
@@ -67,29 +68,24 @@ class Email_List_Table extends Base_List_Table {
$search = wu_request('s');
if ($search) {
-
$query['search'] = $search;
-
- } // end if;
+ }
$target = wu_request('target');
if ($target && $target !== 'all') {
-
$query['meta_query'] = array(
'type' => array(
'key' => 'wu_target',
'value' => $target,
),
);
-
- } // end if;
+ }
$query = apply_filters("wu_{$this->id}_get_items", $query, $this);
return wu_get_emails($query);
-
- } // end get_items;
+ }
/**
* Displays the title of the email.
*
@@ -101,7 +97,7 @@ class Email_List_Table extends Base_List_Table {
$url_atts = array(
'id' => $item->get_id(),
- 'model' => 'email'
+ 'model' => 'email',
);
$title = sprintf('%s', wu_network_admin_url('wp-ultimo-edit-email', $url_atts), $item->get_title());
@@ -115,24 +111,21 @@ class Email_List_Table extends Base_List_Table {
$actions = array(
'edit' => sprintf('%s', wu_network_admin_url('wp-ultimo-edit-email', $url_atts), __('Edit', 'wp-ultimo')),
'duplicate' => sprintf('%s', wu_network_admin_url('wp-ultimo-edit-email', $url_atts), __('Duplicate', 'wp-ultimo')),
- 'send-test' => sprintf('%s', __('Send Test Email', 'wp-ultimo'), wu_get_form_url('send_new_test', $url_atts), __('Send Test Email', 'wp-ultimo'))
+ 'send-test' => sprintf('%s', __('Send Test Email', 'wp-ultimo'), wu_get_form_url('send_new_test', $url_atts), __('Send Test Email', 'wp-ultimo')),
);
$slug = $item->get_slug();
$default_system_emails = wu_get_default_system_emails();
- if (isset($default_system_emails[$slug])) {
-
+ if (isset($default_system_emails[ $slug ])) {
$actions['reset'] = sprintf('%s', __('Reset', 'wp-ultimo'), wu_get_form_url('reset_confirmation', $url_atts), __('Reset', 'wp-ultimo'));
-
- } // end if;
+ }
$actions['delete'] = sprintf('%s', __('Delete', 'wp-ultimo'), wu_get_form_url('delete_modal', $url_atts), __('Delete', 'wp-ultimo'));
return $title . $content . $this->row_actions($actions);
-
- } // end column_title;
+ }
/**
* Displays the event of the email.
@@ -147,8 +140,7 @@ class Email_List_Table extends Base_List_Table {
$event = $item->get_event();
return "{$event}";
-
- } // end column_event;
+ }
/**
* Displays the slug of the email.
@@ -163,8 +155,7 @@ class Email_List_Table extends Base_List_Table {
$slug = $item->get_slug();
return "{$slug}";
-
- } // end column_slug;
+ }
/**
* Displays if the email is schedule for later send or not.
@@ -177,28 +168,19 @@ class Email_List_Table extends Base_List_Table {
public function column_schedule($item) {
if ($item->has_schedule()) {
-
if ($item->get_schedule_type() === 'hours') {
-
$time = explode(':', (string) $item->get_send_hours());
$text = sprintf(__('%1$s hour(s) and %2$s minute(s) after the event.', 'wp-ultimo'), $time[0], $time[1]);
-
} elseif ($item->get_schedule_type() === 'days') {
-
$text = sprintf(__('%s day(s) after the event.', 'wp-ultimo'), $item->get_send_days());
-
- } // end if;
-
+ }
} else {
-
$text = __('Sent immediately after the event.', 'wp-ultimo');
-
- } // end if;
+ }
return $text;
-
- } // end column_schedule;
+ }
/**
* Returns the list of columns for this particular List Table.
@@ -218,10 +200,9 @@ class Email_List_Table extends Base_List_Table {
);
return $columns;
+ }
- } // end get_columns;
-
- /**
+ /**
* Handles the bulk processing adding duplication.
*
* @since 2.0.0
@@ -232,18 +213,15 @@ class Email_List_Table extends Base_List_Table {
$bulk_action = $this->current_action();
if ($bulk_action === 'duplicate') {
-
$email_id = wu_request('id');
$email = wu_get_email($email_id);
- if (!$email) {
-
+ if ( ! $email) {
WP_Ultimo()->notices->add(__('Email not found.', 'wp-ultimo'), 'error', 'network-admin');
return;
-
- } // end if;
+ }
$new_email = $email->duplicate();
@@ -260,30 +238,22 @@ class Email_List_Table extends Base_List_Table {
$new_email->set_event($email->get_event());
if ($email->has_schedule()) {
-
$new_email->set_schedule($email->has_schedule());
if ($email->get_schedule_type() === 'hours') {
-
$new_email->set_send_hours($email->get_send_hours());
-
} elseif ($email->get_schedule_type() === 'days') {
-
$new_email->set_send_days($email->get_send_days());
-
- } // end if;
-
- } // end if;
+ }
+ }
if ($email->get_custom_sender()) {
-
$new_email->set_custom_sender($email->get_custom_sender());
$new_email->set_custom_sender_name($email->get_custom_sender_name());
$new_email->set_custom_sender_email($email->get_custom_sender_email());
-
- } // end if;
+ }
$new_email->set_send_copy_to_admin($email->get_send_copy_to_admin());
@@ -292,25 +262,24 @@ class Email_List_Table extends Base_List_Table {
$result = $new_email->save();
if (is_wp_error($result)) {
-
WP_Ultimo()->notices->add($result->get_error_message(), 'error', 'network-admin');
return;
+ }
- } // end if;
-
- $redirect_url = wu_network_admin_url('wp-ultimo-edit-email', array(
- 'id' => $new_email->get_id(),
- 'updated' => 1,
- ));
+ $redirect_url = wu_network_admin_url(
+ 'wp-ultimo-edit-email',
+ array(
+ 'id' => $new_email->get_id(),
+ 'updated' => 1,
+ )
+ );
wp_redirect($redirect_url);
exit;
-
- } // end if;
-
- } // end process_single_action;
+ }
+ }
/**
* Returns the filters for this page.
*
@@ -335,8 +304,7 @@ class Email_List_Table extends Base_List_Table {
),
),
);
-
- } // end get_filters;
+ }
/**
* Returns the pre-selected filters on the filter bar.
@@ -366,7 +334,5 @@ class Email_List_Table extends Base_List_Table {
'count' => 0,
),
);
-
- } // end get_views;
-
-} // end class Email_List_Table;
+ }
+}
diff --git a/inc/list-tables/class-event-list-table.php b/inc/list-tables/class-event-list-table.php
index 3aa5667..3bf48d1 100644
--- a/inc/list-tables/class-event-list-table.php
+++ b/inc/list-tables/class-event-list-table.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\List_Tables;
-use \WP_Ultimo\Models\Event;
+use WP_Ultimo\Models\Event;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -36,13 +36,14 @@ class Event_List_Table extends Base_List_Table {
*/
public function __construct() {
- parent::__construct(array(
- 'singular' => __('Event', 'wp-ultimo'), // singular name of the listed records
- 'plural' => __('Events', 'wp-ultimo'), // plural name of the listed records
- 'ajax' => true // does this table support ajax?
- ));
-
- } // end __construct;
+ parent::__construct(
+ array(
+ 'singular' => __('Event', 'wp-ultimo'), // singular name of the listed records
+ 'plural' => __('Events', 'wp-ultimo'), // plural name of the listed records
+ 'ajax' => true, // does this table support ajax?
+ )
+ );
+ }
/**
* Returns the markup for the object_type column.
@@ -57,8 +58,7 @@ class Event_List_Table extends Base_List_Table {
$object_type = $item->get_object_type();
return "{$object_type}";
-
- } // end column_object_type;
+ }
/**
* Returns the markup for the initiator column.
@@ -79,7 +79,6 @@ class Event_List_Table extends Base_List_Table {
$object_label_tooltip = substr($object_severity_label, 0, 1);
if ($object_initiator === 'system') {
-
$avatar = '';
$system_text = ucfirst($object_initiator);
@@ -98,13 +97,17 @@ class Event_List_Table extends Base_List_Table {
";
// phpcs:enable
-
} elseif ($object_initiator === 'manual') {
-
- $avatar = get_avatar($item->get_author_id(), 32, 'identicon', '', array(
- 'force_display' => true,
- 'class' => 'wu-rounded-full',
- ));
+ $avatar = get_avatar(
+ $item->get_author_id(),
+ 32,
+ 'identicon',
+ '',
+ array(
+ 'force_display' => true,
+ 'class' => 'wu-rounded-full',
+ )
+ );
$display_name = $item->get_author_display_name();
@@ -133,9 +136,7 @@ class Event_List_Table extends Base_List_Table {
{$email}
";
-
} else {
-
$not_found = __('No initiator found', 'wp-ultimo');
$html = "
@@ -144,12 +145,10 @@ class Event_List_Table extends Base_List_Table {
{$not_found}
";
-
- } // end if;
+ }
return $html;
-
- } // end column_initiator;
+ }
/**
* Returns the markup for the initiator column.
@@ -164,8 +163,7 @@ class Event_List_Table extends Base_List_Table {
$object_slug = $item->get_slug();
return "{$object_slug}";
-
- } // end column_slug;
+ }
/**
* Returns the markup for the message column.
*
@@ -179,7 +177,7 @@ class Event_List_Table extends Base_List_Table {
$url_atts = array(
'id' => $item->get_id(),
- 'model' => 'event'
+ 'model' => 'event',
);
$actions = array(
@@ -196,8 +194,7 @@ class Event_List_Table extends Base_List_Table {
);
return $message . $this->row_actions($actions);
-
- } // end column_message;
+ }
/**
* Returns the list of columns for this particular List Table.
@@ -218,8 +215,7 @@ class Event_List_Table extends Base_List_Table {
);
return apply_filters('wu_events_list_table_get_columns', $columns, $this);
-
- } // end get_columns;
+ }
/**
* Returns the filters for this page.
*
@@ -247,7 +243,5 @@ class Event_List_Table extends Base_List_Table {
),
),
);
-
- } // end get_filters;
-
-} // end class Event_List_Table;
+ }
+}
diff --git a/inc/list-tables/class-inside-events-list-table.php b/inc/list-tables/class-inside-events-list-table.php
index c19fc37..21ae48e 100644
--- a/inc/list-tables/class-inside-events-list-table.php
+++ b/inc/list-tables/class-inside-events-list-table.php
@@ -32,8 +32,7 @@ class Inside_Events_List_Table extends Event_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Renders the inside column responsive.
@@ -61,39 +60,44 @@ class Inside_Events_List_Table extends Event_List_Table {
$object_initiator = $item->get_initiator();
if ($object_initiator === 'system') {
-
$value = sprintf('%s', __('Automatically processed by WP Multisite WaaS', 'wp-ultimo'));
-
} elseif ($object_initiator === 'manual') {
-
- $avatar = get_avatar($item->get_author_id(), 16, 'identicon', '', array(
- 'force_display' => true,
- 'class' => 'wu-rounded-full wu-mr-1 wu-align-text-bottom',
- ));
+ $avatar = get_avatar(
+ $item->get_author_id(),
+ 16,
+ 'identicon',
+ '',
+ array(
+ 'force_display' => true,
+ 'class' => 'wu-rounded-full wu-mr-1 wu-align-text-bottom',
+ )
+ );
$display_name = $item->get_author_display_name();
$value = sprintf('%s%s', $avatar, $display_name);
+ }
- } // end if;
-
- echo wu_responsive_table_row(array(
- 'id' => '',
- 'title' => sprintf('%s', wp_trim_words($item->get_message(), 15)),
- 'url' => wu_network_admin_url('wp-ultimo-view-event', array(
- 'id' => $item->get_id(),
- )),
- 'status' => $value,
- ),
- $first_row,
- array(
- 'date_created' => array(
- 'icon' => 'dashicons-wu-calendar1 wu-align-middle wu-mr-1',
- 'label' => '',
- 'value' => sprintf(__('Processed %s', 'wp-ultimo'), wu_human_time_diff($item->get_date_created(), '-1 day')),
+ echo wu_responsive_table_row(
+ array(
+ 'id' => '',
+ 'title' => sprintf('%s', wp_trim_words($item->get_message(), 15)),
+ 'url' => wu_network_admin_url(
+ 'wp-ultimo-view-event',
+ array(
+ 'id' => $item->get_id(),
+ )
+ ),
+ 'status' => $value,
),
- ));
-
- } // end column_responsive;
-
-} // end class Inside_Events_List_Table;
+ $first_row,
+ array(
+ 'date_created' => array(
+ 'icon' => 'dashicons-wu-calendar1 wu-align-middle wu-mr-1',
+ 'label' => '',
+ 'value' => sprintf(__('Processed %s', 'wp-ultimo'), wu_human_time_diff($item->get_date_created(), '-1 day')),
+ ),
+ )
+ );
+ }
+}
diff --git a/inc/list-tables/class-line-item-list-table.php b/inc/list-tables/class-line-item-list-table.php
index 2a0cc0b..ac68d6d 100644
--- a/inc/list-tables/class-line-item-list-table.php
+++ b/inc/list-tables/class-line-item-list-table.php
@@ -34,13 +34,14 @@ class Line_Item_List_Table extends Payment_List_Table {
*/
public function __construct() {
- parent::__construct(array(
- 'singular' => __('Line Item', 'wp-ultimo'), // singular name of the listed records
- 'plural' => __('Line Items', 'wp-ultimo'), // plural name of the listed records
- 'ajax' => true // does this table support ajax?
- ));
-
- } // end __construct;
+ parent::__construct(
+ array(
+ 'singular' => __('Line Item', 'wp-ultimo'), // singular name of the listed records
+ 'plural' => __('Line Items', 'wp-ultimo'), // plural name of the listed records
+ 'ajax' => true, // does this table support ajax?
+ )
+ );
+ }
/**
* Get the payment object.
@@ -53,8 +54,7 @@ class Line_Item_List_Table extends Payment_List_Table {
$payment_id = wu_request('id');
return wu_get_payment($payment_id);
-
- } // end get_payment;
+ }
/**
* Overrides the parent get_items to add a total line.
@@ -73,14 +73,11 @@ class Line_Item_List_Table extends Payment_List_Table {
$items = $payment->get_line_items();
if ($count) {
-
return count($items);
-
- } // end if;
+ }
return $items;
-
- } // end get_items;
+ }
/**
* Displays the name of the product and description being hired.
@@ -92,11 +89,9 @@ class Line_Item_List_Table extends Payment_List_Table {
*/
public function column_service($item) {
- if (!$item) {
-
+ if ( ! $item) {
return '--';
-
- } // end if;
+ }
$url_atts = array(
'id' => $this->get_payment()->get_id(),
@@ -113,8 +108,7 @@ class Line_Item_List_Table extends Payment_List_Table {
$html .= sprintf('%s', $item->get_description());
return $html . $this->row_actions($actions);
-
- } // end column_service;
+ }
/**
* Displays the tax rate for the item.
@@ -131,8 +125,7 @@ class Line_Item_List_Table extends Payment_List_Table {
$quantity = sprintf(__('Quantity: %s', 'wp-ultimo'), $item->get_quantity()); // phpcs:ignore
return $html . sprintf('%s', $quantity);
-
- } // end column_unit_price;
+ }
/**
* Displays the tax rate for the item.
@@ -149,16 +142,13 @@ class Line_Item_List_Table extends Payment_List_Table {
$tax_rate = '';
if ($item->get_tax_type() === 'percentage' && $item->get_tax_rate()) {
-
$tax_rate = $item->get_tax_rate() . '%';
-
- } // end if;
+ }
$tax_label = $item->get_tax_rate() ? ($item->get_tax_label() ? $item->get_tax_label() : __('Tax Applied', 'wp-ultimo')) : __('No Taxes Applied', 'wp-ultimo');
return $html . sprintf('%s (%s)', $tax_rate, $tax_label);
-
- } // end column_tax_total;
+ }
/**
* Displays the tax rate for the item.
@@ -175,16 +165,13 @@ class Line_Item_List_Table extends Payment_List_Table {
$tax_rate = '';
if ($item->get_discount_type() === 'percentage' && $item->get_discount_rate()) {
-
$tax_rate = $item->get_discount_rate() . '%';
-
- } // end if;
+ }
$tax_label = $item->get_discount_rate() ? ($item->get_discount_label() ? $item->get_discount_label() : __('Discount', 'wp-ultimo')) : __('No discount', 'wp-ultimo');
return $html . sprintf('%s (%s)', $tax_rate, $tax_label);
-
- } // end column_discounts_total;
+ }
/**
* Displays the total column.
@@ -197,8 +184,7 @@ class Line_Item_List_Table extends Payment_List_Table {
public function column_total($item) {
return wu_format_currency($item->get_total());
-
- } // end column_total;
+ }
/**
* Displays the subtotal column.
@@ -211,8 +197,7 @@ class Line_Item_List_Table extends Payment_List_Table {
public function column_subtotal($item) {
return wu_format_currency($item->get_subtotal());
-
- } // end column_subtotal;
+ }
/**
* Returns the list of columns for this particular List Table.
@@ -232,8 +217,7 @@ class Line_Item_List_Table extends Payment_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Leaves no sortable items on the columns.
@@ -244,7 +228,5 @@ class Line_Item_List_Table extends Payment_List_Table {
public function get_sortable_columns() {
return array();
-
- } // end get_sortable_columns;
-
-} // end class Line_Item_List_Table;
+ }
+}
diff --git a/inc/list-tables/class-membership-line-item-list-table.php b/inc/list-tables/class-membership-line-item-list-table.php
index 30cab18..cd94848 100644
--- a/inc/list-tables/class-membership-line-item-list-table.php
+++ b/inc/list-tables/class-membership-line-item-list-table.php
@@ -32,8 +32,7 @@ class Membership_Line_Item_List_Table extends Product_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Overrides the parent get_items to add a total line.
@@ -52,14 +51,11 @@ class Membership_Line_Item_List_Table extends Product_List_Table {
$products = $membership->get_all_products();
if ($count) {
-
return count($products);
-
- } // end if;
+ }
return $products;
-
- } // end get_items;
+ }
/**
* Renders the inside column responsive.
@@ -77,25 +73,26 @@ class Membership_Line_Item_List_Table extends Product_List_Table {
$item = $item['product'];
- if (!$item) {
-
- echo wu_responsive_table_row(array(
- 'url' => false,
- 'id' => 'not-found',
- 'title' => __('Product not found', 'wp-ultimo'),
- 'status' => '',
- 'image' => $this->column_featured_image_id(new \WP_Ultimo\Models\Product()),
- ), array(
- 'quantity' => array(
- 'icon' => 'dashicons-wu-package wu-align-middle wu-mr-1',
- 'label' => __('Quantity', 'wp-ultimo'),
- 'value' => sprintf(__('x%d', 'wp-ultimo'), $quantity),
+ if ( ! $item) {
+ echo wu_responsive_table_row(
+ array(
+ 'url' => false,
+ 'id' => 'not-found',
+ 'title' => __('Product not found', 'wp-ultimo'),
+ 'status' => '',
+ 'image' => $this->column_featured_image_id(new \WP_Ultimo\Models\Product()),
),
- ));
+ array(
+ 'quantity' => array(
+ 'icon' => 'dashicons-wu-package wu-align-middle wu-mr-1',
+ 'label' => __('Quantity', 'wp-ultimo'),
+ 'value' => sprintf(__('x%d', 'wp-ultimo'), $quantity),
+ ),
+ )
+ );
return;
-
- } // end if;
+ }
$first_row = array(
'quantity' => array(
@@ -119,46 +116,50 @@ class Membership_Line_Item_List_Table extends Product_List_Table {
);
if ($item->get_type() === 'plan') {
-
$first_row['change'] = array(
'wrapper_classes' => 'wubox',
'icon' => 'dashicons-wu-edit1 wu-align-middle wu-mr-1',
'label' => '',
'value' => __('Upgrade or Downgrade', 'wp-ultimo'),
- 'url' => wu_get_form_url('change_membership_plan', array(
- 'id' => $membership_id,
- 'product_id' => $item->get_id(),
- )),
+ 'url' => wu_get_form_url(
+ 'change_membership_plan',
+ array(
+ 'id' => $membership_id,
+ 'product_id' => $item->get_id(),
+ )
+ ),
);
-
} else {
-
$first_row['remove'] = array(
'wrapper_classes' => 'wu-text-red-500 wubox',
'icon' => 'dashicons-wu-trash-2 wu-align-middle wu-mr-1',
'label' => '',
'value' => __('Remove', 'wp-ultimo'),
- 'url' => wu_get_form_url('remove_membership_product', array(
- 'id' => $membership_id,
- 'product_id' => $item->get_id(),
- )),
+ 'url' => wu_get_form_url(
+ 'remove_membership_product',
+ array(
+ 'id' => $membership_id,
+ 'product_id' => $item->get_id(),
+ )
+ ),
);
+ }
- } // end if;
-
- echo wu_responsive_table_row(array(
- 'id' => $item->get_id(),
- 'title' => $item->get_name(),
- 'url' => wu_network_admin_url('wp-ultimo-edit-product', array(
- 'id' => $item->get_id(),
- )),
- 'image' => $this->column_featured_image_id($item),
- 'status' => $this->column_type($item),
- ),
- $first_row,
- $second_row
+ echo wu_responsive_table_row(
+ array(
+ 'id' => $item->get_id(),
+ 'title' => $item->get_name(),
+ 'url' => wu_network_admin_url(
+ 'wp-ultimo-edit-product',
+ array(
+ 'id' => $item->get_id(),
+ )
+ ),
+ 'image' => $this->column_featured_image_id($item),
+ 'status' => $this->column_type($item),
+ ),
+ $first_row,
+ $second_row
);
-
- } // end column_responsive;
-
-} // end class Membership_Line_Item_List_Table;
+ }
+}
diff --git a/inc/list-tables/class-membership-list-table-widget.php b/inc/list-tables/class-membership-list-table-widget.php
index a4d9710..2c56a00 100644
--- a/inc/list-tables/class-membership-list-table-widget.php
+++ b/inc/list-tables/class-membership-list-table-widget.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\List_Tables;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Helpers\Hash;
+use WP_Ultimo\Helpers\Hash;
/**
* Membership List Table class.
@@ -22,11 +22,11 @@ use \WP_Ultimo\Helpers\Hash;
class Membership_List_Table_Widget extends Base_List_Table {
/**
- * Holds the query class for the object being listed.
- *
- * @since 2.0.0
- * @var string
- */
+ * Holds the query class for the object being listed.
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $query_class = '\\WP_Ultimo\\Database\\Memberships\\Membership_Query';
/**
@@ -36,13 +36,14 @@ class Membership_List_Table_Widget extends Base_List_Table {
*/
public function __construct() {
- parent::__construct(array(
- 'singular' => __('Membership', 'wp-ultimo'), // singular name of the listed records
- 'plural' => __('Memberships', 'wp-ultimo'), // plural name of the listed records
- 'ajax' => true // does this table support ajax?
- ));
-
- } // end __construct;
+ parent::__construct(
+ array(
+ 'singular' => __('Membership', 'wp-ultimo'), // singular name of the listed records
+ 'plural' => __('Memberships', 'wp-ultimo'), // plural name of the listed records
+ 'ajax' => true, // does this table support ajax?
+ )
+ );
+ }
/**
* Uses the query class to return the items to be displayed.
@@ -71,18 +72,14 @@ class Membership_List_Table_Widget extends Base_List_Table {
* Accounts for hashes
*/
if (isset($query_args['search']) && strlen((string) $query_args['search']) === Hash::LENGTH) {
-
$item_id = Hash::decode($query_args['search']);
if ($item_id) {
-
unset($query_args['search']);
$query_args['id'] = $item_id;
-
- } // end if;
-
- } // end if;
+ }
+ }
$query_args = array_merge($query_args, $this->get_extra_query_fields());
@@ -91,18 +88,13 @@ class Membership_List_Table_Widget extends Base_List_Table {
$function_name = 'wu_get_' . $query_class->get_plural_name();
if (function_exists($function_name)) {
-
$query = $function_name($query_args);
-
} else {
-
$query = $query_class->query($query_args);
-
- } // end if;
+ }
return $query;
-
- } // end get_items;
+ }
/**
* Adds the extra search field when the search element is present.
@@ -119,8 +111,7 @@ class Membership_List_Table_Widget extends Base_List_Table {
$_filter_fields['customer_id'] = wu_request('customer_id');
return $_filter_fields;
-
- } // end get_extra_query_fields;
+ }
/**
* Displays the membership reference code.
*
@@ -144,8 +135,7 @@ class Membership_List_Table_Widget extends Base_List_Table {
$html = "{$code}";
return $html . $this->row_actions($actions);
-
- } // end column_hash;
+ }
/**
* Displays the status of the membership.
@@ -162,8 +152,7 @@ class Membership_List_Table_Widget extends Base_List_Table {
$class = $item->get_status_class();
return "{$label}";
-
- } // end column_status;
+ }
/**
* Displays the price of the membership.
@@ -176,15 +165,12 @@ class Membership_List_Table_Widget extends Base_List_Table {
public function column_amount($item) {
if (empty($item->get_amount())) {
-
return __('Free', 'wp-ultimo');
-
- } // end if;
+ }
$amount = wu_format_currency($item->get_amount(), $item->get_currency());
if ($item->is_recurring()) {
-
$duration = $item->get_duration();
$message = sprintf(
@@ -194,8 +180,7 @@ class Membership_List_Table_Widget extends Base_List_Table {
$item->get_duration_unit()
);
- if (!$item->is_forever_recurring()) {
-
+ if ( ! $item->is_forever_recurring()) {
$billing_cycles_message = sprintf(
// translators: %s is the number of billing cycles.
_n('for %s cycle', 'for %s cycles', $item->get_billing_cycles(), 'wp-ultimo'),
@@ -203,18 +188,13 @@ class Membership_List_Table_Widget extends Base_List_Table {
);
$message .= ' ' . $billing_cycles_message;
-
- } // end if;
-
+ }
} else {
-
$message = __('one time payment', 'wp-ultimo');
-
- } // end if;
+ }
return sprintf('%s %s', $amount, $message);
-
- } // end column_amount;
+ }
/**
* Displays the customer of the membership.
@@ -228,8 +208,7 @@ class Membership_List_Table_Widget extends Base_List_Table {
$customer = $item->get_customer();
- if (!$customer) {
-
+ if ( ! $customer) {
$not_found = __('No customer found', 'wp-ultimo');
return "
@@ -238,17 +217,22 @@ class Membership_List_Table_Widget extends Base_List_Table {
{$not_found}
";
-
- } // end if;
+ }
$url_atts = array(
'id' => $customer->get_id(),
);
- $avatar = get_avatar($customer->get_user_id(), 32, 'identicon', '', array(
- 'force_display' => true,
- 'class' => 'wu-rounded-full wu-mr-2',
- ));
+ $avatar = get_avatar(
+ $customer->get_user_id(),
+ 32,
+ 'identicon',
+ '',
+ array(
+ 'force_display' => true,
+ 'class' => 'wu-rounded-full wu-mr-2',
+ )
+ );
$display_name = $customer->get_display_name();
@@ -266,8 +250,7 @@ class Membership_List_Table_Widget extends Base_List_Table {
";
return $html;
-
- } // end column_customer;
+ }
/**
* Returns the list of columns for this particular List Table.
@@ -285,14 +268,12 @@ class Membership_List_Table_Widget extends Base_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Overrides the parent method to include the custom ajax functionality for WP Multisite WaaS.
*
* @since 2.0.0
* @return void
*/
- public function _js_vars() {} // end _js_vars;
-
-} // end class Membership_List_Table_Widget;
+ public function _js_vars() {}
+}
diff --git a/inc/list-tables/class-membership-list-table.php b/inc/list-tables/class-membership-list-table.php
index 932b1f3..d4f2bde 100644
--- a/inc/list-tables/class-membership-list-table.php
+++ b/inc/list-tables/class-membership-list-table.php
@@ -34,17 +34,18 @@ class Membership_List_Table extends Base_List_Table {
*/
public function __construct() {
- parent::__construct(array(
- 'singular' => __('Membership', 'wp-ultimo'), // singular name of the listed records
- 'plural' => __('Memberships', 'wp-ultimo'), // plural name of the listed records
- 'ajax' => true, // does this table support ajax?
- 'add_new' => array(
- 'url' => wu_get_form_url('add_new_membership'),
- 'classes' => 'wubox',
- ),
- ));
-
- } // end __construct;
+ parent::__construct(
+ array(
+ 'singular' => __('Membership', 'wp-ultimo'), // singular name of the listed records
+ 'plural' => __('Memberships', 'wp-ultimo'), // plural name of the listed records
+ 'ajax' => true, // does this table support ajax?
+ 'add_new' => array(
+ 'url' => wu_get_form_url('add_new_membership'),
+ 'classes' => 'wubox',
+ ),
+ )
+ );
+ }
/**
* Adds the extra search field when the search element is present.
@@ -61,8 +62,7 @@ class Membership_List_Table extends Base_List_Table {
$_filter_fields['customer_id'] = wu_request('customer_id');
return $_filter_fields;
-
- } // end get_extra_query_fields;
+ }
/**
* Displays the membership reference code.
@@ -97,8 +97,7 @@ class Membership_List_Table extends Base_List_Table {
$html = "{$code}";
return $html . $this->row_actions($actions);
-
- } // end column_hash;
+ }
/**
* Displays the status of the membership.
@@ -117,8 +116,7 @@ class Membership_List_Table extends Base_List_Table {
$html = "{$label}";
return $html;
-
- } // end column_status;
+ }
/**
* Displays the price of the membership.
@@ -131,13 +129,10 @@ class Membership_List_Table extends Base_List_Table {
public function column_amount($item) {
if (empty($item->get_amount()) && empty($item->get_initial_amount())) {
-
return __('Free', 'wp-ultimo');
-
- } // end if;
+ }
if ($item->is_recurring()) {
-
$amount = wu_format_currency($item->get_amount(), $item->get_currency());
$duration = $item->get_duration();
@@ -149,8 +144,7 @@ class Membership_List_Table extends Base_List_Table {
$item->get_duration_unit()
);
- if (!$item->is_forever_recurring()) {
-
+ if ( ! $item->is_forever_recurring()) {
$billing_cycles_message = sprintf(
// translators: %s is the number of billing cycles.
_n('for %s cycle', 'for %s cycles', $item->get_billing_cycles(), 'wp-ultimo'),
@@ -158,20 +152,15 @@ class Membership_List_Table extends Base_List_Table {
);
$message .= ' ' . $billing_cycles_message;
-
- } // end if;
-
+ }
} else {
-
$amount = wu_format_currency($item->get_initial_amount(), $item->get_currency());
$message = __('one time payment', 'wp-ultimo');
-
- } // end if;
+ }
return sprintf('%s %s', $amount, $message);
-
- } // end column_amount;
+ }
/**
* Returns the list of columns for this particular List Table.
@@ -195,8 +184,7 @@ class Membership_List_Table extends Base_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Handles the default displaying of datetime columns.
@@ -211,16 +199,12 @@ class Membership_List_Table extends Base_List_Table {
$date = $item->get_date_expiration();
if (empty($date) || $date === '0000-00-00 00:00:00') {
-
return sprintf('%s %s', __('Lifetime', 'wp-ultimo'), __('It never expires', 'wp-ultimo'));
+ }
- } // end if;
-
- if (!wu_validate_date($date)) {
-
+ if ( ! wu_validate_date($date)) {
return __('--', 'wp-ultimo');
-
- } // end if;
+ }
$time = strtotime(get_date_from_gmt($date));
@@ -231,8 +215,7 @@ class Membership_List_Table extends Base_List_Table {
$text = $formatted_value . sprintf(' %s', sprintf($placeholder, human_time_diff($time)));
return sprintf('%s', wu_tooltip_text(date_i18n('Y-m-d H:i:s', $time)), $text);
-
- } // end column_date_expiration;
+ }
/**
* Returns the filters for this page.
@@ -250,7 +233,7 @@ class Membership_List_Table extends Base_List_Table {
* Status
*/
'status' => array(
- 'label' => __( 'Status', 'wp-ultimo' ),
+ 'label' => __('Status', 'wp-ultimo'),
'options' => $membership_status::to_array(),
),
@@ -282,8 +265,7 @@ class Membership_List_Table extends Base_List_Table {
),
),
);
-
- } // end get_filters;
+ }
/**
* Returns the pre-selected filters on the filter bar.
@@ -337,7 +319,5 @@ class Membership_List_Table extends Base_List_Table {
'count' => 0,
),
);
-
- } // end get_views;
-
-} // end class Membership_List_Table;
+ }
+}
diff --git a/inc/list-tables/class-memberships-site-list-table.php b/inc/list-tables/class-memberships-site-list-table.php
index 3f92594..64d7140 100644
--- a/inc/list-tables/class-memberships-site-list-table.php
+++ b/inc/list-tables/class-memberships-site-list-table.php
@@ -32,8 +32,7 @@ class Memberships_Site_List_Table extends Customers_Site_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Renders the inside column responsive.
@@ -47,36 +46,40 @@ class Memberships_Site_List_Table extends Customers_Site_List_Table {
$redirect = current_user_can('wu_edit_sites') ? 'wp-ultimo-edit-site' : 'wp-ultimo-sites';
- echo wu_responsive_table_row(array(
- 'id' => $item->get_id(),
- 'title' => $item->get_title(),
- 'url' => wu_network_admin_url($redirect, array(
- 'id' => $item->get_id(),
- )),
- 'image' => $this->column_featured_image_id($item),
- 'status' => $this->column_type($item),
- ), array(
- 'link' => array(
- 'icon' => 'dashicons-wu-link1 wu-align-middle wu-mr-1',
- 'label' => __('Visit Site', 'wp-ultimo'),
- 'value' => __('Homepage', 'wp-ultimo'),
- 'url' => $item->get_active_site_url(),
+ echo wu_responsive_table_row(
+ array(
+ 'id' => $item->get_id(),
+ 'title' => $item->get_title(),
+ 'url' => wu_network_admin_url(
+ $redirect,
+ array(
+ 'id' => $item->get_id(),
+ )
+ ),
+ 'image' => $this->column_featured_image_id($item),
+ 'status' => $this->column_type($item),
),
- 'dashboard' => array(
- 'icon' => 'dashicons-wu-browser wu-align-middle wu-mr-1',
- 'label' => __('Go to the Dashboard', 'wp-ultimo'),
- 'value' => __('Dashboard', 'wp-ultimo'),
- 'url' => get_admin_url($item->get_id()),
+ array(
+ 'link' => array(
+ 'icon' => 'dashicons-wu-link1 wu-align-middle wu-mr-1',
+ 'label' => __('Visit Site', 'wp-ultimo'),
+ 'value' => __('Homepage', 'wp-ultimo'),
+ 'url' => $item->get_active_site_url(),
+ ),
+ 'dashboard' => array(
+ 'icon' => 'dashicons-wu-browser wu-align-middle wu-mr-1',
+ 'label' => __('Go to the Dashboard', 'wp-ultimo'),
+ 'value' => __('Dashboard', 'wp-ultimo'),
+ 'url' => get_admin_url($item->get_id()),
+ ),
),
- ),
- array(
- 'date_created' => array(
- 'icon' => 'dashicons-wu-calendar1 wu-align-middle wu-mr-1',
- 'label' => '',
- 'value' => $item->get_type() === 'pending' ? __('Not Available', 'wp-ultimo') : sprintf(__('Created %s', 'wp-ultimo'), wu_human_time_diff(strtotime((string) $item->get_date_registered()))),
- ),
- ));
-
- } // end column_responsive;
-
-} // end class Memberships_Site_List_Table;
+ array(
+ 'date_created' => array(
+ 'icon' => 'dashicons-wu-calendar1 wu-align-middle wu-mr-1',
+ 'label' => '',
+ 'value' => $item->get_type() === 'pending' ? __('Not Available', 'wp-ultimo') : sprintf(__('Created %s', 'wp-ultimo'), wu_human_time_diff(strtotime((string) $item->get_date_registered()))),
+ ),
+ )
+ );
+ }
+}
diff --git a/inc/list-tables/class-payment-line-item-list-table.php b/inc/list-tables/class-payment-line-item-list-table.php
index e1a1b38..f7eeeaa 100644
--- a/inc/list-tables/class-payment-line-item-list-table.php
+++ b/inc/list-tables/class-payment-line-item-list-table.php
@@ -32,8 +32,7 @@ class Payment_Line_Item_List_Table extends Line_Item_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Renders the inside column responsive.
@@ -83,16 +82,13 @@ class Payment_Line_Item_List_Table extends Line_Item_List_Table {
'url' => wu_get_form_url('delete_line_item', $url_atts),
);
- /*
- * Adds discounts
- */
+ /*
+ * Adds discounts
+ */
if ($item->get_discount_total()) {
-
if ($item->get_discount_type() === 'percentage' && $item->get_discount_rate()) {
-
$tax_rate = $item->get_discount_rate() . '%';
-
- } // end if;
+ }
$tax_label = $item->get_discount_rate() ? ($item->get_discount_label() ? $item->get_discount_label() : __('Discount', 'wp-ultimo')) : __('No discount', 'wp-ultimo');
@@ -103,8 +99,7 @@ class Payment_Line_Item_List_Table extends Line_Item_List_Table {
'label' => $tooltip,
'value' => sprintf(__('Discounts: %s', 'wp-ultimo'), wu_format_currency($item->get_discount_total())),
);
-
- } // end if;
+ }
$first_row['subtotal'] = array(
'icon' => 'dashicons-wu-info1 wu-align-middle wu-mr-1',
@@ -112,16 +107,13 @@ class Payment_Line_Item_List_Table extends Line_Item_List_Table {
'value' => sprintf(__('Subtotal: %s', 'wp-ultimo'), wu_format_currency($item->get_subtotal())),
);
- /*
- * Adds Taxes
- */
+ /*
+ * Adds Taxes
+ */
if ($item->get_tax_total()) {
-
if ($item->get_tax_type() === 'percentage' && $item->get_tax_rate()) {
-
$tax_rate = $item->get_tax_rate() . '%';
-
- } // end if;
+ }
$tax_label = $item->get_tax_rate() ? ($item->get_tax_label() ? $item->get_tax_label() : __('Tax Applied', 'wp-ultimo')) : __('No Taxes Applied', 'wp-ultimo');
@@ -132,8 +124,7 @@ class Payment_Line_Item_List_Table extends Line_Item_List_Table {
'label' => $tooltip,
'value' => sprintf(__('Taxes: %s', 'wp-ultimo'), wu_format_currency($item->get_tax_total())),
);
-
- } // end if;
+ }
$first_row['description'] = array(
'icon' => 'dashicons-wu-file-text wu-align-middle wu-mr-1',
@@ -141,17 +132,16 @@ class Payment_Line_Item_List_Table extends Line_Item_List_Table {
'value' => $item->get_description(),
);
- echo wu_responsive_table_row(array(
- 'id' => '',
- 'title' => $item->get_title(),
- 'url' => '',
- 'image' => '',
- 'status' => sprintf('%s', wu_format_currency($item->get_total())),
- ),
- $first_row,
- $second_row
+ echo wu_responsive_table_row(
+ array(
+ 'id' => '',
+ 'title' => $item->get_title(),
+ 'url' => '',
+ 'image' => '',
+ 'status' => sprintf('%s', wu_format_currency($item->get_total())),
+ ),
+ $first_row,
+ $second_row
);
-
- } // end column_responsive;
-
-} // end class Payment_Line_Item_List_Table;
+ }
+}
diff --git a/inc/list-tables/class-payment-list-table-widget.php b/inc/list-tables/class-payment-list-table-widget.php
index 8b8a629..76542a3 100644
--- a/inc/list-tables/class-payment-list-table-widget.php
+++ b/inc/list-tables/class-payment-list-table-widget.php
@@ -12,7 +12,7 @@ namespace WP_Ultimo\List_Tables;
// Exit if accessed directly
defined('ABSPATH') || exit;
-use \WP_Ultimo\Helpers\Hash;
+use WP_Ultimo\Helpers\Hash;
/**
* Payment List Table class.
@@ -22,11 +22,11 @@ use \WP_Ultimo\Helpers\Hash;
class Payment_List_Table_Widget extends Base_List_Table {
/**
- * Holds the query class for the object being listed.
- *
- * @since 2.0.0
- * @var string
- */
+ * Holds the query class for the object being listed.
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $query_class = '\\WP_Ultimo\\Database\\Payments\\Payment_Query';
/**
@@ -36,13 +36,14 @@ class Payment_List_Table_Widget extends Base_List_Table {
*/
public function __construct() {
- parent::__construct(array(
- 'singular' => __('Payment', 'wp-ultimo'), // singular name of the listed records
- 'plural' => __('Payments', 'wp-ultimo'), // plural name of the listed records
- 'ajax' => true // does this table support ajax?
- ));
-
- } // end __construct;
+ parent::__construct(
+ array(
+ 'singular' => __('Payment', 'wp-ultimo'), // singular name of the listed records
+ 'plural' => __('Payments', 'wp-ultimo'), // plural name of the listed records
+ 'ajax' => true, // does this table support ajax?
+ )
+ );
+ }
/**
* Uses the query class to return the items to be displayed.
@@ -71,18 +72,14 @@ class Payment_List_Table_Widget extends Base_List_Table {
* Accounts for hashes
*/
if (isset($query_args['search']) && strlen((string) $query_args['search']) === Hash::LENGTH) {
-
$item_id = Hash::decode($query_args['search']);
if ($item_id) {
-
unset($query_args['search']);
$query_args['id'] = $item_id;
-
- } // end if;
-
- } // end if;
+ }
+ }
$query_args = array_merge($query_args, $this->get_extra_query_fields());
@@ -91,18 +88,13 @@ class Payment_List_Table_Widget extends Base_List_Table {
$function_name = 'wu_get_' . $query_class->get_plural_name();
if (function_exists($function_name)) {
-
$query = $function_name($query_args);
-
} else {
-
$query = $query_class->query($query_args);
-
- } // end if;
+ }
return $query;
-
- } // end get_items;
+ }
/**
* Displays the payment reference code.
*
@@ -126,8 +118,7 @@ class Payment_List_Table_Widget extends Base_List_Table {
$html = "{$code}";
return $html . $this->row_actions($actions);
-
- } // end column_hash;
+ }
/**
* Displays the membership photo and special status.
@@ -144,8 +135,7 @@ class Payment_List_Table_Widget extends Base_List_Table {
$class = $item->get_status_class();
return "{$label}";
-
- } // end column_status;
+ }
/**
@@ -160,8 +150,7 @@ class Payment_List_Table_Widget extends Base_List_Table {
$customer = $item->get_customer();
- if (!$customer) {
-
+ if ( ! $customer) {
$not_found = __('No customer found', 'wp-ultimo');
return "
@@ -170,17 +159,22 @@ class Payment_List_Table_Widget extends Base_List_Table {
{$not_found}
";
-
- } // end if;
+ }
$url_atts = array(
'id' => $customer->get_id(),
);
- $avatar = get_avatar($customer->get_user_id(), 32, 'identicon', '', array(
- 'force_display' => true,
- 'class' => 'wu-rounded-full wu-mr-2',
- ));
+ $avatar = get_avatar(
+ $customer->get_user_id(),
+ 32,
+ 'identicon',
+ '',
+ array(
+ 'force_display' => true,
+ 'class' => 'wu-rounded-full wu-mr-2',
+ )
+ );
$display_name = $customer->get_display_name();
@@ -198,8 +192,7 @@ class Payment_List_Table_Widget extends Base_List_Table {
";
return $html;
-
- } // end column_customer;
+ }
/**
* Displays the column for the total amount of the payment.
*
@@ -212,8 +205,7 @@ class Payment_List_Table_Widget extends Base_List_Table {
$gateway = wu_slug_to_name($item->get_gateway());
return wu_format_currency($item->get_total()) . "{$gateway}";
-
- } // end column_total;
+ }
/**
* Returns the list of columns for this particular List Table.
@@ -231,8 +223,7 @@ class Payment_List_Table_Widget extends Base_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Returns the filters for this page.
@@ -240,7 +231,7 @@ class Payment_List_Table_Widget extends Base_List_Table {
* @since 2.0.0
* @return void.
*/
- public function get_filters() {} // end get_filters;
+ public function get_filters() {}
/**
* Overrides the parent method to include the custom ajax functionality for WP Multisite WaaS.
@@ -248,6 +239,5 @@ class Payment_List_Table_Widget extends Base_List_Table {
* @since 2.0.0
* @return void
*/
- public function _js_vars() {} // end _js_vars;
-
-} // end class Payment_List_Table_Widget;
+ public function _js_vars() {}
+}
diff --git a/inc/list-tables/class-payment-list-table.php b/inc/list-tables/class-payment-list-table.php
index c8693ca..2a8a4ab 100644
--- a/inc/list-tables/class-payment-list-table.php
+++ b/inc/list-tables/class-payment-list-table.php
@@ -9,7 +9,7 @@
namespace WP_Ultimo\List_Tables;
-use \WP_Ultimo\Database\Payments\Payment_Status;
+use WP_Ultimo\Database\Payments\Payment_Status;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -36,17 +36,18 @@ class Payment_List_Table extends Base_List_Table {
*/
public function __construct() {
- parent::__construct(array(
- 'singular' => __('Payment', 'wp-ultimo'),
- 'plural' => __('Payments', 'wp-ultimo'),
- 'ajax' => true,
- 'add_new' => array(
- 'url' => wu_get_form_url('add_new_payment'),
- 'classes' => 'wubox',
- ),
- ));
-
- } // end __construct;
+ parent::__construct(
+ array(
+ 'singular' => __('Payment', 'wp-ultimo'),
+ 'plural' => __('Payments', 'wp-ultimo'),
+ 'ajax' => true,
+ 'add_new' => array(
+ 'url' => wu_get_form_url('add_new_payment'),
+ 'classes' => 'wubox',
+ ),
+ )
+ );
+ }
/**
* Adds the extra search field when the search element is present.
@@ -67,8 +68,7 @@ class Payment_List_Table extends Base_List_Table {
$_filter_fields['parent_id__in'] = array('0', 0, '', null);
return $_filter_fields;
-
- } // end get_extra_query_fields;
+ }
/**
* Displays the payment reference code.
@@ -95,7 +95,7 @@ class Payment_List_Table extends Base_List_Table {
'delete_modal',
array(
'model' => 'payment',
- 'id' => $item->get_id()
+ 'id' => $item->get_id(),
)
),
__('Delete', 'wp-ultimo')
@@ -105,8 +105,7 @@ class Payment_List_Table extends Base_List_Table {
$html = "{$code}";
return $html . $this->row_actions($actions);
-
- } // end column_hash;
+ }
/**
* Displays the membership photo and special status.
@@ -123,8 +122,7 @@ class Payment_List_Table extends Base_List_Table {
$class = $item->get_status_class();
return "{$label}";
-
- } // end column_status;
+ }
/**
* Returns the number of subscriptions owned by this membership.
@@ -138,11 +136,9 @@ class Payment_List_Table extends Base_List_Table {
$product = $item->get_product();
- if (!$product) {
-
+ if ( ! $product) {
return __('No product found', 'wp-ultimo');
-
- } // end if;
+ }
$url_atts = array(
'product_id' => $product->get_id(),
@@ -155,8 +151,7 @@ class Payment_List_Table extends Base_List_Table {
$html = $product->get_name();
return $html . $this->row_actions($actions);
-
- } // end column_product;
+ }
/**
* Displays the column for the total amount of the payment.
@@ -171,8 +166,7 @@ class Payment_List_Table extends Base_List_Table {
$gateway = wu_slug_to_name($item->get_gateway());
return wu_format_currency($item->get_total()) . "{$gateway}";
-
- } // end column_total;
+ }
/**
* Returns the list of columns for this particular List Table.
@@ -194,8 +188,7 @@ class Payment_List_Table extends Base_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Returns the filters for this page.
@@ -211,13 +204,13 @@ class Payment_List_Table extends Base_List_Table {
* Status
*/
'status' => array(
- 'label' => __( 'Status', 'wp-ultimo' ),
+ 'label' => __('Status', 'wp-ultimo'),
'options' => array(
- 'pending' => __( 'Pending', 'wp-ultimo' ),
- 'completed' => __( 'Completed', 'wp-ultimo' ),
- 'refund' => __( 'Refund', 'wp-ultimo' ),
- 'partial' => __( 'Partial', 'wp-ultimo' ),
- 'failed' => __( 'Failed', 'wp-ultimo' ),
+ 'pending' => __('Pending', 'wp-ultimo'),
+ 'completed' => __('Completed', 'wp-ultimo'),
+ 'refund' => __('Refund', 'wp-ultimo'),
+ 'partial' => __('Partial', 'wp-ultimo'),
+ 'failed' => __('Failed', 'wp-ultimo'),
),
),
@@ -225,12 +218,12 @@ class Payment_List_Table extends Base_List_Table {
* Gateway
*/
'gateway' => array(
- 'label' => __( 'Gateway', 'wp-ultimo' ),
+ 'label' => __('Gateway', 'wp-ultimo'),
'options' => array(
- 'free' => __( 'Free', 'wp-ultimo' ),
- 'manual' => __( 'Manual', 'wp-ultimo' ),
- 'paypal' => __( 'Paypal', 'wp-ultimo' ),
- 'stripe' => __( 'Stripe', 'wp-ultimo' ),
+ 'free' => __('Free', 'wp-ultimo'),
+ 'manual' => __('Manual', 'wp-ultimo'),
+ 'paypal' => __('Paypal', 'wp-ultimo'),
+ 'stripe' => __('Stripe', 'wp-ultimo'),
),
),
),
@@ -240,13 +233,12 @@ class Payment_List_Table extends Base_List_Table {
* Created At
*/
'date_created' => array(
- 'label' => __( 'Created At', 'wp-ultimo' ),
+ 'label' => __('Created At', 'wp-ultimo'),
'options' => $this->get_default_date_filter_options(),
),
),
);
-
- } // end get_filters;
+ }
/**
* Returns the pre-selected filters on the filter bar.
@@ -294,7 +286,5 @@ class Payment_List_Table extends Base_List_Table {
'count' => 0,
),
);
-
- } // end get_views;
-
-} // end class Payment_List_Table;
+ }
+}
diff --git a/inc/list-tables/class-product-list-table.php b/inc/list-tables/class-product-list-table.php
index e0ad8ab..fbc9278 100644
--- a/inc/list-tables/class-product-list-table.php
+++ b/inc/list-tables/class-product-list-table.php
@@ -34,17 +34,18 @@ class Product_List_Table extends Base_List_Table {
*/
public function __construct() {
- parent::__construct(array(
- 'singular' => __('Product', 'wp-ultimo'), // singular name of the listed records
- 'plural' => __('Products', 'wp-ultimo'), // plural name of the listed records
- 'ajax' => true, // does this table support ajax?
- 'add_new' => array(
- 'url' => wu_network_admin_url('wp-ultimo-edit-product'),
- 'classes' => '',
- ),
- ));
-
- } // end __construct;
+ parent::__construct(
+ array(
+ 'singular' => __('Product', 'wp-ultimo'), // singular name of the listed records
+ 'plural' => __('Products', 'wp-ultimo'), // plural name of the listed records
+ 'ajax' => true, // does this table support ajax?
+ 'add_new' => array(
+ 'url' => wu_network_admin_url('wp-ultimo-edit-product'),
+ 'classes' => '',
+ ),
+ )
+ );
+ }
/**
* Displays the content of the product column.
@@ -58,7 +59,7 @@ class Product_List_Table extends Base_List_Table {
$url_atts = array(
'id' => $item->get_id(),
- 'model' => 'product'
+ 'model' => 'product',
);
$title = sprintf('%s', wu_network_admin_url('wp-ultimo-edit-product', $url_atts), $item->get_name());
@@ -68,13 +69,22 @@ class Product_List_Table extends Base_List_Table {
$actions = array(
'edit' => sprintf('%s', wu_network_admin_url('wp-ultimo-edit-product', $url_atts), __('Edit', 'wp-ultimo')),
- 'duplicate' => sprintf('%s', wu_network_admin_url('wp-ultimo-products', array('action' => 'duplicate', 'id' => $item->get_id())), __('Duplicate', 'wp-ultimo')),
+ 'duplicate' => sprintf(
+ '%s',
+ wu_network_admin_url(
+ 'wp-ultimo-products',
+ array(
+ 'action' => 'duplicate',
+ 'id' => $item->get_id(),
+ )
+ ),
+ __('Duplicate', 'wp-ultimo')
+ ),
'delete' => sprintf('%s', __('Delete', 'wp-ultimo'), wu_get_form_url('delete_modal', $url_atts), __('Delete', 'wp-ultimo')),
);
return $title . $this->row_actions($actions);
-
- } // end column_name;
+ }
/**
* Displays the type of the product.
@@ -91,8 +101,7 @@ class Product_List_Table extends Base_List_Table {
$class = $item->get_type_class();
return "{$label}";
-
- } // end column_type;
+ }
/**
* Displays the slug of the product.
@@ -107,8 +116,7 @@ class Product_List_Table extends Base_List_Table {
$slug = $item->get_slug();
return "{$slug}";
-
- } // end column_slug;
+ }
/**
* Displays the price of the product.
@@ -121,21 +129,16 @@ class Product_List_Table extends Base_List_Table {
public function column_amount($item) {
if ($item->get_pricing_type() === 'contact_us') {
-
return __('None', 'wp-ultimo') . sprintf(' %s', __('Requires contact', 'wp-ultimo'));
-
- } // end if;
+ }
if (empty($item->get_amount())) {
-
return __('Free', 'wp-ultimo');
-
- } // end if;
+ }
$amount = wu_format_currency($item->get_amount(), $item->get_currency());
if ($item->is_recurring()) {
-
$duration = $item->get_duration();
$message = sprintf(
@@ -145,8 +148,7 @@ class Product_List_Table extends Base_List_Table {
$item->get_duration_unit()
);
- if (!$item->is_forever_recurring()) {
-
+ if ( ! $item->is_forever_recurring()) {
$billing_cycles_message = sprintf(
// translators: %s is the number of billing cycles.
_n('for %s cycle', 'for %s cycles', $item->get_billing_cycles(), 'wp-ultimo'),
@@ -154,18 +156,13 @@ class Product_List_Table extends Base_List_Table {
);
$message .= ' ' . $billing_cycles_message;
-
- } // end if;
-
+ }
} else {
-
$message = __('one time payment', 'wp-ultimo');
-
- } // end if;
+ }
return sprintf('%s %s', $amount, $message);
-
- } // end column_amount;
+ }
/**
* Displays the setup fee of the product.
@@ -178,20 +175,15 @@ class Product_List_Table extends Base_List_Table {
public function column_setup_fee($item) {
if ($item->get_pricing_type() === 'contact_us') {
-
return __('None', 'wp-ultimo') . sprintf(' %s', __('Requires contact', 'wp-ultimo'));
+ }
- } // end if;
-
- if (!$item->has_setup_fee()) {
-
+ if ( ! $item->has_setup_fee()) {
return __('No Setup Fee', 'wp-ultimo');
-
- } // end if;
+ }
return wu_format_currency($item->get_setup_fee(), $item->get_currency());
-
- } // end column_setup_fee;
+ }
/**
* Handles the bulk processing adding duplication.
@@ -204,18 +196,15 @@ class Product_List_Table extends Base_List_Table {
$bulk_action = $this->current_action();
if ($bulk_action === 'duplicate') {
-
$product = wu_request('id');
$product = wu_get_product($product);
- if (!$product) {
-
+ if ( ! $product) {
WP_Ultimo()->notices->add(__('Product not found.', 'wp-ultimo'), 'error', 'network-admin');
return;
-
- } // end if;
+ }
$new_product = $product->duplicate();
@@ -230,25 +219,24 @@ class Product_List_Table extends Base_List_Table {
$result = $new_product->save();
if (is_wp_error($result)) {
-
WP_Ultimo()->notices->add($result->get_error_message(), 'error', 'network-admin');
return;
+ }
- } // end if;
-
- $redirect_url = wu_network_admin_url('wp-ultimo-edit-product', array(
- 'id' => $new_product->get_id(),
- 'updated' => 1,
- ));
+ $redirect_url = wu_network_admin_url(
+ 'wp-ultimo-edit-product',
+ array(
+ 'id' => $new_product->get_id(),
+ 'updated' => 1,
+ )
+ );
wp_redirect($redirect_url);
exit;
-
- } // end if;
-
- } // end process_single_action;
+ }
+ }
/**
* Returns the list of columns for this particular List Table.
@@ -270,8 +258,7 @@ class Product_List_Table extends Base_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Handles the item display for grid mode.
@@ -283,12 +270,14 @@ class Product_List_Table extends Base_List_Table {
*/
public function single_row_grid($item) {
- wu_get_template('base/products/grid-item', array(
- 'item' => $item,
- 'table' => $this,
- ));
-
- } // end single_row_grid;
+ wu_get_template(
+ 'base/products/grid-item',
+ array(
+ 'item' => $item,
+ 'table' => $this,
+ )
+ );
+ }
/**
* Returns the filters for this page.
@@ -300,8 +289,7 @@ class Product_List_Table extends Base_List_Table {
return array(
'filters' => array(),
);
-
- } // end get_filters;
+ }
/**
* Returns the pre-selected filters on the filter bar.
@@ -337,7 +325,5 @@ class Product_List_Table extends Base_List_Table {
'count' => 0,
),
);
-
- } // end get_views;
-
-} // end class Product_List_Table;
+ }
+}
diff --git a/inc/list-tables/class-site-customer-list-table.php b/inc/list-tables/class-site-customer-list-table.php
index 8919b9c..b222045 100644
--- a/inc/list-tables/class-site-customer-list-table.php
+++ b/inc/list-tables/class-site-customer-list-table.php
@@ -20,17 +20,16 @@ defined('ABSPATH') || exit;
class Site_Customer_List_Table extends Customer_List_Table {
/**
- * Initializes the table.
- *
- * @since 2.0.0
- */
+ * Initializes the table.
+ *
+ * @since 2.0.0
+ */
public function __construct() {
parent::__construct();
$this->current_mode = 'list';
-
- } // end __construct;
+ }
/**
* Returns the list of columns for this particular List Table.
@@ -45,8 +44,7 @@ class Site_Customer_List_Table extends Customer_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Renders the inside column responsive.
@@ -61,42 +59,50 @@ class Site_Customer_List_Table extends Customer_List_Table {
$last_login = sprintf(__('Last login %s', 'wp-ultimo'), wu_human_time_diff(strtotime((string) $item->get_last_login())));
if ($item->is_online()) {
-
$last_login = '' . __('Online', 'wp-ultimo');
+ }
- } // end if;
-
- echo wu_responsive_table_row(array(
- 'id' => $item->get_id(),
- 'title' => $item->get_display_name(),
- 'url' => wu_network_admin_url('wp-ultimo-edit-customer', array(
- 'id' => $item->get_id(),
- )),
- 'image' => get_avatar($item->get_user_id(), 36, 'identicon', '', array(
- 'force_display' => true,
- 'class' => 'wu-rounded-full',
- )),
- 'status' => $this->column_status($item),
- ), array(
- 'total' => array(
- 'icon' => 'dashicons-wu-at-sign wu-align-middle wu-mr-1',
- 'label' => __('Email Address', 'wp-ultimo'),
- 'value' => $item->get_email_address(),
+ echo wu_responsive_table_row(
+ array(
+ 'id' => $item->get_id(),
+ 'title' => $item->get_display_name(),
+ 'url' => wu_network_admin_url(
+ 'wp-ultimo-edit-customer',
+ array(
+ 'id' => $item->get_id(),
+ )
+ ),
+ 'image' => get_avatar(
+ $item->get_user_id(),
+ 36,
+ 'identicon',
+ '',
+ array(
+ 'force_display' => true,
+ 'class' => 'wu-rounded-full',
+ )
+ ),
+ 'status' => $this->column_status($item),
),
- ),
- array(
- 'date_expiration' => array(
- 'icon' => $item->is_online() === false ? 'dashicons-wu-calendar1 wu-align-middle wu-mr-1' : '',
- 'label' => __('Last Login', 'wp-ultimo'),
- 'value' => $last_login,
+ array(
+ 'total' => array(
+ 'icon' => 'dashicons-wu-at-sign wu-align-middle wu-mr-1',
+ 'label' => __('Email Address', 'wp-ultimo'),
+ 'value' => $item->get_email_address(),
+ ),
),
- 'date_created' => array(
- 'icon' => 'dashicons-wu-calendar1 wu-align-middle wu-mr-1',
- 'label' => '',
- 'value' => sprintf(__('Registered %s', 'wp-ultimo'), wu_human_time_diff(strtotime((string) $item->get_date_registered()))),
- ),
- ));
-
- } // end column_responsive;
-
-} // end class Site_Customer_List_Table;
+ array(
+ 'date_expiration' => array(
+ 'icon' => $item->is_online() === false ? 'dashicons-wu-calendar1 wu-align-middle wu-mr-1' : '',
+ 'label' => __('Last Login', 'wp-ultimo'),
+ 'value' => $last_login,
+ ),
+ 'date_created' => array(
+ 'icon' => 'dashicons-wu-calendar1 wu-align-middle wu-mr-1',
+ 'label' => '',
+ 'value' => sprintf(__('Registered %s', 'wp-ultimo'), wu_human_time_diff(strtotime((string) $item->get_date_registered()))),
+ ),
+ )
+ );
+ }
+}
diff --git a/inc/list-tables/class-site-list-table.php b/inc/list-tables/class-site-list-table.php
index a0e6627..38afd7a 100644
--- a/inc/list-tables/class-site-list-table.php
+++ b/inc/list-tables/class-site-list-table.php
@@ -20,11 +20,11 @@ defined('ABSPATH') || exit;
class Site_List_Table extends Base_List_Table {
/**
- * Holds the query class for the object being listed.
- *
- * @since 2.0.0
- * @var string
- */
+ * Holds the query class for the object being listed.
+ *
+ * @since 2.0.0
+ * @var string
+ */
protected $query_class = '\\WP_Ultimo\\Database\\Sites\\Site_Query';
/**
@@ -39,17 +39,18 @@ class Site_List_Table extends Base_List_Table {
'list' => __('List View'),
);
- parent::__construct(array(
- 'singular' => __('Site', 'wp-ultimo'), // singular name of the listed records
- 'plural' => __('Sites', 'wp-ultimo'), // plural name of the listed records
- 'ajax' => true, // does this table support ajax?
- 'add_new' => array(
- 'url' => wu_get_form_url('add_new_site'),
- 'classes' => 'wubox',
- ),
- ));
-
- } // end __construct;
+ parent::__construct(
+ array(
+ 'singular' => __('Site', 'wp-ultimo'), // singular name of the listed records
+ 'plural' => __('Sites', 'wp-ultimo'), // plural name of the listed records
+ 'ajax' => true, // does this table support ajax?
+ 'add_new' => array(
+ 'url' => wu_get_form_url('add_new_site'),
+ 'classes' => 'wubox',
+ ),
+ )
+ );
+ }
/**
* Overrides the parent method to add pending sites.
@@ -66,12 +67,10 @@ class Site_List_Table extends Base_List_Table {
$type = wu_request('type');
if ($type === 'pending') {
-
$pending_sites = \WP_Ultimo\Models\Site::get_all_by_type('pending');
return $count ? count($pending_sites) : $pending_sites;
-
- } // end if;
+ }
$query = array(
'number' => $per_page,
@@ -81,21 +80,18 @@ class Site_List_Table extends Base_List_Table {
);
if ($type && $type !== 'all') {
-
$query['meta_query'] = array(
'type' => array(
'key' => 'wu_type',
'value' => $type,
),
);
-
- } // end if;
+ }
$query = apply_filters("wu_{$this->id}_get_items", $query, $this);
return wu_get_sites($query);
-
- } // end get_items;
+ }
/**
* Render the bulk edit checkbox.
*
@@ -104,14 +100,11 @@ class Site_List_Table extends Base_List_Table {
public function column_cb($item): string {
if ($item->get_type() === 'pending') {
-
return sprintf('', $item->get_membership_id());
-
- } // end if;
+ }
return sprintf('', $item->get_id());
-
- } // end column_cb;
+ }
/**
* Displays the content of the name column.
*
@@ -123,7 +116,7 @@ class Site_List_Table extends Base_List_Table {
$url_atts = array(
'id' => $item->get_id(),
- 'model' => 'site'
+ 'model' => 'site',
);
$title = $item->get_title();
@@ -156,13 +149,13 @@ class Site_List_Table extends Base_List_Table {
);
if ($item->get_type() === 'pending') {
-
$actions = array(
'duplicate' => sprintf(
'%s',
__('Publish Site', 'wp-ultimo'),
wu_get_form_url(
- 'publish_pending_site', array('membership_id' => $item->get_membership_id())
+ 'publish_pending_site',
+ array('membership_id' => $item->get_membership_id())
),
__('Publish', 'wp-ultimo')
),
@@ -174,21 +167,24 @@ class Site_List_Table extends Base_List_Table {
array(
'id' => $item->get_membership_id(),
'model' => 'membership_meta_pending_site',
- 'redirect_to' => urlencode((string) wu_network_admin_url('wp-ultimo-sites', array(
- 'type' => 'pending',
- 'page' => wu_request('page', 1),
- ))),
+ 'redirect_to' => urlencode(
+ (string) wu_network_admin_url(
+ 'wp-ultimo-sites',
+ array(
+ 'type' => 'pending',
+ 'page' => wu_request('page', 1),
+ )
+ )
+ ),
)
),
__('Delete', 'wp-ultimo')
),
);
-
- } // end if;
+ }
return $title . sprintf('%s', make_clickable($item->get_active_site_url())) . $this->row_actions($actions);
-
- } // end column_path;
+ }
/**
* Returns the date of the customer registration.
*
@@ -201,8 +197,7 @@ class Site_List_Table extends Base_List_Table {
$time = strtotime((string) $item->get_last_login(false));
return $item->get_date_registered() . sprintf(' %s', human_time_diff($time));
-
- } // end column_date_registered;
+ }
/**
* Returns the blog_id.
@@ -215,8 +210,7 @@ class Site_List_Table extends Base_List_Table {
public function column_blog_id($item) {
return $item->get_type() === \WP_Ultimo\Database\Sites\Site_Type::PENDING ? '--' : $item->get_blog_id();
-
- } // end column_blog_id;
+ }
/**
* Displays the type of the site.
@@ -233,8 +227,7 @@ class Site_List_Table extends Base_List_Table {
$class = $item->get_type_class();
return "{$label}";
-
- } // end column_type;
+ }
/**
* Column for the domains associated with this site.
*
@@ -244,10 +237,12 @@ class Site_List_Table extends Base_List_Table {
*/
public function column_domains($item): string {
- $domain = wu_get_domains(array(
- 'blog_id' => $item->get_id(),
- 'count' => true,
- ));
+ $domain = wu_get_domains(
+ array(
+ 'blog_id' => $item->get_id(),
+ 'count' => true,
+ )
+ );
$url_atts = array(
'blog_id' => $item->get_id(),
@@ -258,8 +253,7 @@ class Site_List_Table extends Base_List_Table {
);
return $domain . $this->row_actions($actions);
-
- } // end column_domains;
+ }
/**
* Returns the list of columns for this particular List Table.
@@ -281,8 +275,7 @@ class Site_List_Table extends Base_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Renders the customer card for grid mode.
@@ -294,12 +287,14 @@ class Site_List_Table extends Base_List_Table {
*/
public function single_row_grid($item) {
- wu_get_template('base/sites/grid-item', array(
- 'item' => $item,
- 'list_table' => $this,
- ));
-
- } // end single_row_grid;
+ wu_get_template(
+ 'base/sites/grid-item',
+ array(
+ 'item' => $item,
+ 'list_table' => $this,
+ )
+ );
+ }
/**
* Returns the filters for this page.
*
@@ -328,8 +323,7 @@ class Site_List_Table extends Base_List_Table {
),
),
);
-
- } // end get_filters;
+ }
/**
* Returns the pre-selected filters on the filter bar.
@@ -365,8 +359,7 @@ class Site_List_Table extends Base_List_Table {
'count' => 0,
),
);
-
- } // end get_views;
+ }
/**
* Returns an associative array containing the bulk action
@@ -379,11 +372,10 @@ class Site_List_Table extends Base_List_Table {
'screenshot' => __('Take Screenshot', 'wp-ultimo'),
);
- $actions[wu_request('type', 'all') === 'pending' ? 'delete-pending' : 'delete'] = __('Delete', 'wp-ultimo');
+ $actions[ wu_request('type', 'all') === 'pending' ? 'delete-pending' : 'delete' ] = __('Delete', 'wp-ultimo');
return $actions;
-
- } // end get_bulk_actions;
+ }
/**
* Handles the bulk processing.
@@ -396,18 +388,15 @@ class Site_List_Table extends Base_List_Table {
$action = $this->current_action();
if ($action === 'duplicate') {
-
$site_id = wu_request('id');
$site = wu_get_site($site_id);
- if (!$site) {
-
+ if ( ! $site) {
WP_Ultimo()->notices->add(__('Site not found.', 'wp-ultimo'), 'error', 'network-admin');
return;
-
- } // end if;
+ }
$new_site = $site->duplicate();
@@ -428,24 +417,22 @@ class Site_List_Table extends Base_List_Table {
$result = $new_site->save();
if (is_wp_error($result)) {
-
WP_Ultimo()->notices->add($result->get_error_message(), 'error', 'network-admin');
return;
+ }
- } // end if;
-
- $redirect_url = wu_network_admin_url('wp-ultimo-edit-site', array(
- 'id' => $new_site->get_id(),
- 'updated' => 1,
- ));
+ $redirect_url = wu_network_admin_url(
+ 'wp-ultimo-edit-site',
+ array(
+ 'id' => $new_site->get_id(),
+ 'updated' => 1,
+ )
+ );
wp_redirect($redirect_url);
exit;
-
- } // end if;
-
- } // end process_single_action;
-
-} // end class Site_List_Table;
+ }
+ }
+}
diff --git a/inc/list-tables/class-sites-domain-list-table.php b/inc/list-tables/class-sites-domain-list-table.php
index 3eb1b18..63197b8 100644
--- a/inc/list-tables/class-sites-domain-list-table.php
+++ b/inc/list-tables/class-sites-domain-list-table.php
@@ -32,8 +32,7 @@ class Sites_Domain_List_Table extends Domain_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Renders the inside column responsive.
@@ -45,34 +44,38 @@ class Sites_Domain_List_Table extends Domain_List_Table {
*/
public function column_responsive($item) {
- echo wu_responsive_table_row(array(
- 'id' => $item->get_id(),
- 'title' => strtolower((string) $item->get_domain()),
- 'url' => wu_network_admin_url('wp-ultimo-edit-domain', array(
- 'id' => $item->get_id(),
- )),
- 'status' => $this->column_stage($item),
- ), array(
- 'primary' => array(
- 'icon' => $item->is_primary_domain() ? 'dashicons-wu-filter_1 wu-align-text-bottom wu-mr-1' : 'dashicons-wu-plus-square wu-align-text-bottom wu-mr-1',
- 'label' => '',
- 'value' => $item->is_primary_domain() ? __('Primary', 'wp-ultimo') : __('Alias', 'wp-ultimo'),
+ echo wu_responsive_table_row(
+ array(
+ 'id' => $item->get_id(),
+ 'title' => strtolower((string) $item->get_domain()),
+ 'url' => wu_network_admin_url(
+ 'wp-ultimo-edit-domain',
+ array(
+ 'id' => $item->get_id(),
+ )
+ ),
+ 'status' => $this->column_stage($item),
),
- 'secure' => array(
- 'wrapper_classes' => $item->is_secure() ? 'wu-text-green-500' : '',
- 'icon' => $item->is_secure() ? 'dashicons-wu-lock1 wu-align-text-bottom wu-mr-1' : 'dashicons-wu-lock1 wu-align-text-bottom wu-mr-1',
- 'label' => '',
- 'value' => $item->is_secure() ? __('Secure (HTTPS)', 'wp-ultimo') : __('Not Secure (HTTP)', 'wp-ultimo'),
+ array(
+ 'primary' => array(
+ 'icon' => $item->is_primary_domain() ? 'dashicons-wu-filter_1 wu-align-text-bottom wu-mr-1' : 'dashicons-wu-plus-square wu-align-text-bottom wu-mr-1',
+ 'label' => '',
+ 'value' => $item->is_primary_domain() ? __('Primary', 'wp-ultimo') : __('Alias', 'wp-ultimo'),
+ ),
+ 'secure' => array(
+ 'wrapper_classes' => $item->is_secure() ? 'wu-text-green-500' : '',
+ 'icon' => $item->is_secure() ? 'dashicons-wu-lock1 wu-align-text-bottom wu-mr-1' : 'dashicons-wu-lock1 wu-align-text-bottom wu-mr-1',
+ 'label' => '',
+ 'value' => $item->is_secure() ? __('Secure (HTTPS)', 'wp-ultimo') : __('Not Secure (HTTP)', 'wp-ultimo'),
+ ),
),
- ),
- array(
- 'date_created' => array(
- 'icon' => 'dashicons-wu-calendar1 wu-align-middle wu-mr-1',
- 'label' => '',
- 'value' => sprintf(__('Created %s', 'wp-ultimo'), wu_human_time_diff(strtotime((string) $item->get_date_created()))),
- ),
- ));
-
- } // end column_responsive;
-
-} // end class Sites_Domain_List_Table;
+ array(
+ 'date_created' => array(
+ 'icon' => 'dashicons-wu-calendar1 wu-align-middle wu-mr-1',
+ 'label' => '',
+ 'value' => sprintf(__('Created %s', 'wp-ultimo'), wu_human_time_diff(strtotime((string) $item->get_date_created()))),
+ ),
+ )
+ );
+ }
+}
diff --git a/inc/list-tables/class-webhook-list-table.php b/inc/list-tables/class-webhook-list-table.php
index 8c71042..886c5ae 100644
--- a/inc/list-tables/class-webhook-list-table.php
+++ b/inc/list-tables/class-webhook-list-table.php
@@ -34,16 +34,18 @@ class Webhook_List_Table extends Base_List_Table {
*/
public function __construct() {
- parent::__construct(array(
- 'singular' => __('Webhook', 'wp-ultimo'), // singular name of the listed records
- 'plural' => __('Webhooks', 'wp-ultimo'), // plural name of the listed records
- 'ajax' => true, // does this table support ajax?
- 'add_new' => array(
- 'url' => wu_get_form_url('add_new_webhook_modal'),
- 'classes' => 'wubox',
- ),
- ));
- } // end __construct;
+ parent::__construct(
+ array(
+ 'singular' => __('Webhook', 'wp-ultimo'), // singular name of the listed records
+ 'plural' => __('Webhooks', 'wp-ultimo'), // plural name of the listed records
+ 'ajax' => true, // does this table support ajax?
+ 'add_new' => array(
+ 'url' => wu_get_form_url('add_new_webhook_modal'),
+ 'classes' => 'wubox',
+ ),
+ )
+ );
+ }
/**
* Displays the content of the name column.
*
@@ -58,8 +60,14 @@ class Webhook_List_Table extends Base_List_Table {
'model' => 'webhook',
);
- $title = sprintf('%s
- %s', wu_network_admin_url('wp-ultimo-edit-webhook', $url_atts), $item->get_name(), $item->get_id(), __('Sending Test..', 'wp-ultimo'));
+ $title = sprintf(
+ '%s
+ %s',
+ wu_network_admin_url('wp-ultimo-edit-webhook', $url_atts),
+ $item->get_name(),
+ $item->get_id(),
+ __('Sending Test..', 'wp-ultimo')
+ );
$actions = array(
'edit' => sprintf('%s', wu_network_admin_url('wp-ultimo-edit-webhook', $url_atts), __('Edit', 'wp-ultimo')),
@@ -76,8 +84,7 @@ class Webhook_List_Table extends Base_List_Table {
);
return $title . $this->row_actions($actions);
-
- } // end column_name;
+ }
/**
* Displays the content of the webhook url column.
@@ -92,8 +99,7 @@ class Webhook_List_Table extends Base_List_Table {
$trimmed_url = mb_strimwidth((string) $item->get_webhook_url(), 0, 50, '...');
return "{$trimmed_url}";
-
- } // end column_webhook_url;
+ }
/**
* Displays the content of the event column.
@@ -108,8 +114,7 @@ class Webhook_List_Table extends Base_List_Table {
$event = $item->get_event();
return "{$event}";
-
- } // end column_event;
+ }
/**
* Displays the content of the count column.
*
@@ -126,8 +131,7 @@ class Webhook_List_Table extends Base_List_Table {
);
return $count . $this->row_actions($actions);
-
- } // end column_count;
+ }
/**
* Displays the content of the integration column.
*
@@ -138,8 +142,7 @@ class Webhook_List_Table extends Base_List_Table {
public function column_integration($item): string {
return ucwords(str_replace(array('_', '-'), ' ', (string) $item->get_integration()));
-
- } // end column_integration;
+ }
/**
* Displays the content of the active column.
@@ -152,8 +155,7 @@ class Webhook_List_Table extends Base_List_Table {
public function column_active($item) {
return $item->is_active() ? __('Yes', 'wp-ultimo') : __('No', 'wp-ultimo');
-
- } // end column_active;
+ }
/**
* Returns the list of columns for this particular List Table.
@@ -175,8 +177,7 @@ class Webhook_List_Table extends Base_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Returns the filters for this page.
*
@@ -188,7 +189,5 @@ class Webhook_List_Table extends Base_List_Table {
'filters' => array(),
'date_filters' => array(),
);
-
- } // end get_filters;
-
-} // end class Webhook_List_Table;
+ }
+}
diff --git a/inc/list-tables/customer-panel/class-invoice-list-table.php b/inc/list-tables/customer-panel/class-invoice-list-table.php
index cf41bfc..17bcda2 100644
--- a/inc/list-tables/customer-panel/class-invoice-list-table.php
+++ b/inc/list-tables/customer-panel/class-invoice-list-table.php
@@ -37,8 +37,7 @@ class Invoice_List_Table extends Parent_Payment_List_Table {
);
return $columns;
-
- } // end get_columns;
+ }
/**
* Clears the bulk actions.
@@ -51,8 +50,5 @@ class Invoice_List_Table extends Parent_Payment_List_Table {
public function bulk_actions($which = '') {
return array();
-
- } // end bulk_actions;
-
-} // end class Invoice_List_Table;
-
+ }
+}
diff --git a/inc/list-tables/customer-panel/class-product-list-table.php b/inc/list-tables/customer-panel/class-product-list-table.php
index a2a2f46..ffd26d9 100644
--- a/inc/list-tables/customer-panel/class-product-list-table.php
+++ b/inc/list-tables/customer-panel/class-product-list-table.php
@@ -35,8 +35,7 @@ class Product_List_Table extends Parent_Product_List_Table {
);
$this->current_mode = 'grid';
-
- } // end __construct;
+ }
/**
* Returns the list of columns for this particular List Table.
@@ -47,8 +46,7 @@ class Product_List_Table extends Parent_Product_List_Table {
public function get_columns() {
return array();
-
- } // end get_columns;
+ }
/**
* Resets the filters.
@@ -61,8 +59,7 @@ class Product_List_Table extends Parent_Product_List_Table {
'filters' => array(),
'date_filters' => array(),
);
-
- } // end get_filters;
+ }
/**
* Resets bulk actions.
@@ -75,8 +72,7 @@ class Product_List_Table extends Parent_Product_List_Table {
public function bulk_actions($which = '') {
return array();
-
- } // end bulk_actions;
+ }
/**
* Renders the customer card for grid mode.
@@ -88,11 +84,12 @@ class Product_List_Table extends Parent_Product_List_Table {
*/
public function single_row_grid($item) {
- wu_get_template('base/products/grid-item', array(
- 'item' => $item,
- 'list_table' => $this,
- ));
-
- } // end single_row_grid;
-
-} // end class Product_List_Table;
+ wu_get_template(
+ 'base/products/grid-item',
+ array(
+ 'item' => $item,
+ 'list_table' => $this,
+ )
+ );
+ }
+}
diff --git a/inc/list-tables/customer-panel/class-site-list-table.php b/inc/list-tables/customer-panel/class-site-list-table.php
index 8062402..c127155 100644
--- a/inc/list-tables/customer-panel/class-site-list-table.php
+++ b/inc/list-tables/customer-panel/class-site-list-table.php
@@ -35,8 +35,7 @@ class Site_List_Table extends Parent_Site_List_Table {
);
$this->current_mode = 'grid';
-
- } // end __construct;
+ }
/**
* Returns the list of columns for this particular List Table.
@@ -47,8 +46,7 @@ class Site_List_Table extends Parent_Site_List_Table {
public function get_columns() {
return array();
-
- } // end get_columns;
+ }
/**
* Clears filters.
@@ -61,8 +59,7 @@ class Site_List_Table extends Parent_Site_List_Table {
'filters' => array(),
'date_filters' => array(),
);
-
- } // end get_filters;
+ }
/**
* Clears views.
@@ -80,8 +77,7 @@ class Site_List_Table extends Parent_Site_List_Table {
'count' => 0,
),
);
-
- } // end get_views;
+ }
/**
* Get the extra fields based on the request.
@@ -93,13 +89,11 @@ class Site_List_Table extends Parent_Site_List_Table {
$customer = wu_get_current_customer();
- if (!$customer) {
-
+ if ( ! $customer) {
return array(
'blog_id__in' => array('null_id'), // pass absurd value to make sure the query returns nothing.
);
-
- } // end if;
+ }
$fields = parent::get_extra_fields();
@@ -113,7 +107,5 @@ class Site_List_Table extends Parent_Site_List_Table {
);
return $fields;
-
- } // end get_extra_fields;
-
-} // end class Site_List_Table;
+ }
+}
diff --git a/inc/loaders/class-table-loader.php b/inc/loaders/class-table-loader.php
index 2fbaa20..5b316c7 100644
--- a/inc/loaders/class-table-loader.php
+++ b/inc/loaders/class-table-loader.php
@@ -244,8 +244,7 @@ class Table_Loader {
*/
$this->checkout_form_table = new \WP_Ultimo\Database\Checkout_Forms\Checkout_Forms_Table();
$this->checkout_formmeta_table = new \WP_Ultimo\Database\Checkout_Forms\Checkout_Forms_Meta_Table();
-
- } // end init;
+ }
/**
* Returns all the table objects.
@@ -256,8 +255,7 @@ class Table_Loader {
public function get_tables() {
return get_object_vars($this);
-
- } // end get_tables;
+ }
/**
* Checks if we have all the tables installed.
@@ -272,17 +270,11 @@ class Table_Loader {
$tables = $this->get_tables();
foreach ($tables as $table) {
-
- if (!$table->exists()) {
-
+ if ( ! $table->exists()) {
$all_installed = false;
-
- } // end if;
-
- } // end foreach;
+ }
+ }
return $all_installed;
-
- } // end is_installed;
-
-} // end class Table_Loader;
+ }
+}
diff --git a/inc/managers/class-base-manager.php b/inc/managers/class-base-manager.php
index 8649ecb..d83046a 100644
--- a/inc/managers/class-base-manager.php
+++ b/inc/managers/class-base-manager.php
@@ -27,6 +27,5 @@ class Base_Manager {
* @since 2.0.11
* @return void
*/
- public function init() {} // end init;
-
-} // end class Base_Manager;
+ public function init() {}
+}
diff --git a/inc/managers/class-block-manager.php b/inc/managers/class-block-manager.php
index bfad902..7f2b235 100644
--- a/inc/managers/class-block-manager.php
+++ b/inc/managers/class-block-manager.php
@@ -38,8 +38,7 @@ class Block_Manager extends Base_Manager {
$hook = version_compare($wp_version, '5.8', '<') ? 'block_categories' : 'block_categories_all';
add_filter($hook, array($this, 'add_wp_ultimo_block_category'), 1, 2);
-
- } // end init;
+ }
/**
* Adds wp-ultimo as a Block category on Gutenberg.
@@ -52,13 +51,14 @@ class Block_Manager extends Base_Manager {
*/
public function add_wp_ultimo_block_category($categories, $post) {
- return array_merge($categories, array(
+ return array_merge(
+ $categories,
array(
- 'slug' => 'wp-ultimo',
- 'title' => __('Multisite WaaS', 'wp-ultimo'),
- ),
- ));
-
- } // end add_wp_ultimo_block_category;
-
-} // end class Block_Manager;
+ array(
+ 'slug' => 'wp-ultimo',
+ 'title' => __('Multisite WaaS', 'wp-ultimo'),
+ ),
+ )
+ );
+ }
+}
diff --git a/inc/managers/class-broadcast-manager.php b/inc/managers/class-broadcast-manager.php
index a9381b9..e7e08f4 100644
--- a/inc/managers/class-broadcast-manager.php
+++ b/inc/managers/class-broadcast-manager.php
@@ -25,7 +25,9 @@ defined('ABSPATH') || exit;
*/
class Broadcast_Manager extends Base_Manager {
- use \WP_Ultimo\Apis\Rest_Api, \WP_Ultimo\Apis\WP_CLI, \WP_Ultimo\Traits\Singleton;
+ use \WP_Ultimo\Apis\Rest_Api;
+ use \WP_Ultimo\Apis\WP_CLI;
+ use \WP_Ultimo\Traits\Singleton;
/**
* The manager slug.
@@ -58,13 +60,10 @@ class Broadcast_Manager extends Base_Manager {
/**
* Add unseen broadcast notices to the panel.
*/
- if (!is_network_admin() && !is_main_site()) {
-
+ if ( ! is_network_admin() && ! is_main_site()) {
add_action('init', array($this, 'add_unseen_broadcast_notices'));
-
- } // end if;
-
- } // end init;
+ }
+ }
/**
* Add unseen broadcast messages.
@@ -76,52 +75,41 @@ class Broadcast_Manager extends Base_Manager {
$current_customer = wu_get_current_customer();
- if (!$current_customer) {
-
+ if ( ! $current_customer) {
return;
+ }
- } // end if;
-
- $all_broadcasts = Broadcast::query(array(
- 'number' => 10,
- 'order' => 'DESC',
- 'order_by' => 'id',
- 'type__in' => array('broadcast_notice'),
- ));
+ $all_broadcasts = Broadcast::query(
+ array(
+ 'number' => 10,
+ 'order' => 'DESC',
+ 'order_by' => 'id',
+ 'type__in' => array('broadcast_notice'),
+ )
+ );
if (isset($all_broadcasts)) {
-
foreach ($all_broadcasts as $key => $broadcast) {
-
if (isset($broadcast) && 'broadcast_notice' === $broadcast->get_type()) {
-
$targets = $this->get_all_notice_customer_targets($broadcast->get_id());
- if (!is_array($targets)) {
-
+ if ( ! is_array($targets)) {
$targets = array($targets);
-
- } // end if;
+ }
$dismissed = get_user_meta(get_current_user_id(), 'wu_dismissed_admin_notices');
- if (in_array($current_customer->get_id(), $targets, true) && !in_array($broadcast->get_id(), $dismissed, true)) {
-
+ if (in_array($current_customer->get_id(), $targets, true) && ! in_array($broadcast->get_id(), $dismissed, true)) {
$notice = '' . $broadcast->get_title() . ' ' . $broadcast->get_content() . '';
WP_Ultimo()->notices->add($notice, $broadcast->get_notice_type(), 'admin', strval($broadcast->get_id()));
WP_Ultimo()->notices->add($notice, $broadcast->get_notice_type(), 'user', strval($broadcast->get_id()));
-
- } // end if;
-
- } // end if;
-
- } // end foreach;
-
- } // end if;
-
- } // end add_unseen_broadcast_notices;
+ }
+ }
+ }
+ }
+ }
/**
* Handles the broadcast message send via modal.
@@ -138,21 +126,18 @@ class Broadcast_Manager extends Base_Manager {
$target_products = wu_request('target_products', '');
- if (!$target_customers && !$target_products) {
-
+ if ( ! $target_customers && ! $target_products) {
wp_send_json_error(new \WP_Error('error', __('No product or customer target was selected.', 'wp-ultimo')));
-
- } // end if;
+ }
$broadcast_type = wu_request('type', 'broadcast_notice');
$args['type'] = $broadcast_type;
if ($broadcast_type === 'broadcast_notice') {
-
$targets = array(
'customers' => $target_customers,
- 'products' => $target_products
+ 'products' => $target_products,
);
$args['targets'] = $targets;
@@ -161,21 +146,19 @@ class Broadcast_Manager extends Base_Manager {
$saved = $this->save_broadcast($args);
if (is_wp_error($saved)) {
-
wp_send_json_error($saved);
-
- } // end if;
+ }
$redirect = current_user_can('wu_edit_broadcasts') ? 'wp-ultimo-edit-broadcast' : 'wp-ultimo-broadcasts';
- wp_send_json_success(array(
- 'redirect_url' => add_query_arg('id', $saved->get_id(), wu_network_admin_url($redirect))
- ));
-
- } // end if;
+ wp_send_json_success(
+ array(
+ 'redirect_url' => add_query_arg('id', $saved->get_id(), wu_network_admin_url($redirect)),
+ )
+ );
+ }
if ($args['type'] === 'broadcast_email') {
-
$to = array();
$bcc = array();
@@ -183,28 +166,22 @@ class Broadcast_Manager extends Base_Manager {
$targets = array();
if ($args['target_customers']) {
-
$customers = explode(',', (string) $args['target_customers']);
$targets = array_merge($targets, $customers);
-
- } // end if;
+ }
if ($args['target_products']) {
-
$product_targets = explode(',', (string) $args['target_products']);
$customers = array();
foreach ($product_targets as $product_id) {
-
$customers = array_merge($customers, wu_get_membership_customers($product_id));
-
- } // end foreach;
+ }
$targets = array_merge($targets, $customers);
-
- } // end if;
+ }
$targets = array_unique($targets);
@@ -212,35 +189,27 @@ class Broadcast_Manager extends Base_Manager {
* Get name and email based on user id
*/
foreach ($targets as $target) {
-
$customer = wu_get_customer($target);
if ($customer) {
-
$to[] = array(
'name' => $customer->get_display_name(),
'email' => $customer->get_email_address(),
);
+ }
+ }
- } // end if;
-
- } // end foreach;
-
- if (!isset($args['custom_sender'])) {
-
+ if ( ! isset($args['custom_sender'])) {
$from = array(
'name' => wu_get_setting('from_name', get_network_option(null, 'site_name')),
'email' => wu_get_setting('from_email', get_network_option(null, 'admin_email')),
);
-
} else {
-
$from = array(
'name' => $args['custom_sender']['from_name'],
'email' => $args['custom_sender']['from_email'],
);
-
- } // end if;
+ }
$template_type = wu_get_setting('email_template_type', 'html');
@@ -255,19 +224,14 @@ class Broadcast_Manager extends Base_Manager {
);
try {
-
$status = Sender::send_mail($from, $to, $send_args);
-
} catch (\Throwable $e) {
-
$error = new \WP_Error($e->getCode(), $e->getMessage());
wp_send_json_error($error);
-
- } // end try;
+ }
if ($status) {
-
$args['targets'] = array(
'customers' => $args['target_customers'],
'products' => $args['target_products'],
@@ -276,19 +240,18 @@ class Broadcast_Manager extends Base_Manager {
// then we save with the message status (success, fail)
$this->save_broadcast($args);
- wp_send_json_success(array(
- 'redirect_url' => wu_network_admin_url('wp-ultimo-broadcasts')
- ));
-
- } // end if;
-
- } // end if;
+ wp_send_json_success(
+ array(
+ 'redirect_url' => wu_network_admin_url('wp-ultimo-broadcasts'),
+ )
+ );
+ }
+ }
$error = new \WP_Error('mail-error', __('Something wrong happened.', 'wp-ultimo'));
wp_send_json_error($error);
-
- } // end handle_broadcast;
+ }
/**
* Saves the broadcast message in the database
@@ -310,18 +273,15 @@ class Broadcast_Manager extends Base_Manager {
$broadcast = new Broadcast($broadcast_data);
if ($args['type'] === 'broadcast_notice') {
-
$broadcast->set_notice_type($args['notice_type']);
-
- } // end if;
+ }
$broadcast->set_message_targets($args['targets']);
$saved = $broadcast->save();
return is_wp_error($saved) ? $saved : $broadcast;
-
- } // end save_broadcast;
+ }
/**
* Returns targets for a specific broadcast.
@@ -338,21 +298,16 @@ class Broadcast_Manager extends Base_Manager {
$targets = $broadcast->get_message_targets();
- if (isset($targets[$type])) {
+ if (isset($targets[ $type ])) {
+ if (is_string($targets[ $type ])) {
+ return explode(',', $targets[ $type ]);
+ }
- if (is_string($targets[$type])) {
-
- return explode(',', $targets[$type]);
-
- } // end if;
-
- return (array) $targets[$type];
-
- } // end if;
+ return (array) $targets[ $type ];
+ }
return array();
-
- } // end get_broadcast_targets;
+ }
/**
* Returns all customer from targets.
@@ -371,41 +326,25 @@ class Broadcast_Manager extends Base_Manager {
$product_customers = array();
if (is_array($products) && $products[0]) {
-
foreach ($products as $product_key => $product) {
-
$membership_customers = wu_get_membership_customers($product);
if ($membership_customers) {
-
if (is_array($membership_customers)) {
-
$product_customers = array_merge($membership_customers, $product_customers);
-
} else {
-
array_push($product_customers, $membership_customers);
-
- } // end if;
-
- } // end if;
-
- } // end foreach;
-
- } // end if;
+ }
+ }
+ }
+ }
if (isset($product_customers) ) {
-
$targets = array_merge($product_customers, $customers_targets);
-
} else {
-
$targets = $customers_targets;
-
- } // end if;
+ }
return array_map('absint', array_filter(array_unique($targets)));
-
- } // end get_all_notice_customer_targets;
-
-} // end class Broadcast_Manager;
+ }
+}
diff --git a/inc/managers/class-cache-manager.php b/inc/managers/class-cache-manager.php
index fec3b96..75ebca5 100644
--- a/inc/managers/class-cache-manager.php
+++ b/inc/managers/class-cache-manager.php
@@ -38,21 +38,16 @@ class Cache_Manager {
* To support more caching plugins, just add a method to this class suffixed with '_cache_flush'
*/
foreach (get_class_methods($this) as $method) {
-
if (substr_compare($method, '_cache_flush', -strlen('_cache_flush')) === 0) {
-
$this->$method();
-
- } // end if;
-
- } // end foreach;
+ }
+ }
/**
* Hook to additional cleaning
*/
do_action('wu_flush_known_caches');
-
- } // end flush_known_caches;
+ }
/**
* Flush WPEngine Cache
@@ -63,14 +58,12 @@ class Cache_Manager {
protected function wp_engine_cache_flush() {
if (class_exists('\WpeCommon') && method_exists('\WpeCommon', 'purge_varnish_cache')) {
-
\WpeCommon::purge_memcached(); // WPEngine Cache Flushing
\WpeCommon::clear_maxcdn_cache(); // WPEngine Cache Flushing
\WpeCommon::purge_varnish_cache(); // WPEngine Cache Flushing
- } // end if;
-
- } // end wp_engine_cache_flush;
+ }
+ }
/**
* Flush WP Rocket Cache
@@ -81,12 +74,9 @@ class Cache_Manager {
protected function wp_rocket_cache_flush() {
if (function_exists('rocket_clean_domain')) {
-
\rocket_clean_domain();
-
- } // end if;
-
- } // end wp_rocket_cache_flush;
+ }
+ }
/**
* Flush WP Super Cache
@@ -97,12 +87,10 @@ class Cache_Manager {
protected function wp_super_cache_flush() {
if (function_exists('wp_cache_clear_cache')) {
-
\wp_cache_clear_cache(); // WP Super Cache Flush
- } // end if;
-
- } // end wp_super_cache_flush;
+ }
+ }
/**
* Flush WP Fastest Cache
@@ -113,12 +101,10 @@ class Cache_Manager {
protected function wp_fastest_cache_flush() {
if (function_exists('wpfc_clear_all_cache')) {
-
\wpfc_clear_all_cache(); // WP Fastest Cache Flushing
- } // end if;
-
- } // end wp_fastest_cache_flush;
+ }
+ }
/**
* Flush W3 Total Cache
@@ -129,12 +115,10 @@ class Cache_Manager {
protected function w3_total_cache_flush() {
if (function_exists('w3tc_pgcache_flush')) {
-
\w3tc_pgcache_flush(); // W3TC Cache Flushing
- } // end if;
-
- } // end w3_total_cache_flush;
+ }
+ }
/**
* Flush Hummingbird Cache
@@ -145,12 +129,10 @@ class Cache_Manager {
protected function hummingbird_cache_flush() {
if (class_exists('\Hummingbird\WP_Hummingbird') && method_exists('\Hummingbird\WP_Hummingbird', 'flush_cache')) {
-
\Hummingbird\WP_Hummingbird::flush_cache(); // Hummingbird Cache Flushing
- } // end if;
-
- } // end hummingbird_cache_flush;
+ }
+ }
/**
* Flush WP Optimize Cache
@@ -161,18 +143,14 @@ class Cache_Manager {
protected function wp_optimize_cache_flush() {
if (class_exists('\WP_Optimize') && method_exists('\WP_Optimize', 'get_page_cache')) {
-
$wp_optimize = \WP_Optimize()->get_page_cache();
if (method_exists($wp_optimize, 'purge')) {
-
$wp_optimize->purge(); // WP Optimize Cache Flushing
- } // end if;
-
- } // end if;
-
- } // end wp_optimize_cache_flush;
+ }
+ }
+ }
/**
* Flush Comet Cache
@@ -183,12 +161,10 @@ class Cache_Manager {
protected function comet_cache_flush() {
if (class_exists('\Comet_Cache') && method_exists('\Comet_Cache', 'clear')) {
-
\Comet_Cache::clear(); // Comet Cache Flushing
- } // end if;
-
- } // end comet_cache_flush;
+ }
+ }
/**
* Flush LiteSpeed Cache
@@ -199,11 +175,8 @@ class Cache_Manager {
protected function litespeed_cache_flush() {
if (class_exists('\LiteSpeed_Cache_API') && method_exists('\LiteSpeed_Cache_API', 'purge_all')) {
-
\LiteSpeed_Cache_API::purge_all(); // LiteSpeed Cache Flushing
- } // end if;
-
- } // end litespeed_cache_flush;
-
-} // end class Cache_Manager;
+ }
+ }
+}
diff --git a/inc/managers/class-checkout-form-manager.php b/inc/managers/class-checkout-form-manager.php
index fb14ec8..76fb6e0 100644
--- a/inc/managers/class-checkout-form-manager.php
+++ b/inc/managers/class-checkout-form-manager.php
@@ -23,7 +23,9 @@ defined('ABSPATH') || exit;
*/
class Checkout_Form_Manager extends Base_Manager {
- use \WP_Ultimo\Apis\Rest_Api, \WP_Ultimo\Apis\WP_CLI, \WP_Ultimo\Traits\Singleton;
+ use \WP_Ultimo\Apis\Rest_Api;
+ use \WP_Ultimo\Apis\WP_CLI;
+ use \WP_Ultimo\Traits\Singleton;
/**
* The manager slug.
@@ -52,7 +54,5 @@ class Checkout_Form_Manager extends Base_Manager {
$this->enable_rest_api();
$this->enable_wp_cli();
-
- } // end init;
-
-} // end class Checkout_Form_Manager;
+ }
+}
diff --git a/inc/managers/class-customer-manager.php b/inc/managers/class-customer-manager.php
index 11fab65..ef1c854 100644
--- a/inc/managers/class-customer-manager.php
+++ b/inc/managers/class-customer-manager.php
@@ -11,9 +11,9 @@
namespace WP_Ultimo\Managers;
-use \WP_Ultimo\Managers\Base_Manager;
-use \WP_Ultimo\Models\Customer;
-use \WP_Ultimo\Database\Memberships\Membership_Status;
+use WP_Ultimo\Managers\Base_Manager;
+use WP_Ultimo\Models\Customer;
+use WP_Ultimo\Database\Memberships\Membership_Status;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -25,7 +25,9 @@ defined('ABSPATH') || exit;
*/
class Customer_Manager extends Base_Manager {
- use \WP_Ultimo\Apis\Rest_Api, \WP_Ultimo\Apis\WP_CLI, \WP_Ultimo\Traits\Singleton;
+ use \WP_Ultimo\Apis\Rest_Api;
+ use \WP_Ultimo\Apis\WP_CLI;
+ use \WP_Ultimo\Traits\Singleton;
/**
* The manager slug.
@@ -55,11 +57,16 @@ class Customer_Manager extends Base_Manager {
$this->enable_wp_cli();
- add_action('init', function () {
- Event_Manager::register_model_events( 'customer',
- __( 'Customer', 'wp-ultimo' ),
- array( 'created', 'updated' ) );
- });
+ add_action(
+ 'init',
+ function () {
+ Event_Manager::register_model_events(
+ 'customer',
+ __('Customer', 'wp-ultimo'),
+ array('created', 'updated')
+ );
+ }
+ );
add_action('wp_login', array($this, 'log_ip_and_last_login'), 10, 2);
add_filter('heartbeat_send', array($this, 'on_heartbeat_send'));
@@ -71,8 +78,7 @@ class Customer_Manager extends Base_Manager {
add_action('wu_maybe_create_customer', array($this, 'maybe_add_to_main_site'), 10, 2);
add_action('wp_ajax_wu_resend_verification_email', array($this, 'handle_resend_verification_email'));
-
- } // end init;
+ }
/**
* Handle the resend verification email ajax action.
@@ -82,31 +88,26 @@ class Customer_Manager extends Base_Manager {
*/
public function handle_resend_verification_email() {
- if (!check_ajax_referer('wu_resend_verification_email_nonce', false, false)) {
-
+ if ( ! check_ajax_referer('wu_resend_verification_email_nonce', false, false)) {
wp_send_json_error(new \WP_Error('not-allowed', __('Error: you are not allowed to perform this action.', 'wp-ultimo')));
exit;
-
- } // end if;
+ }
$customer = wu_get_current_customer();
- if (!$customer) {
-
+ if ( ! $customer) {
wp_send_json_error(new \WP_Error('customer-not-found', __('Error: customer not found.', 'wp-ultimo')));
exit;
-
- } // end if;
+ }
$customer->send_verification_email();
wp_send_json_success();
exit;
-
- } // end handle_resend_verification_email;
+ }
/**
* Handle heartbeat response sent.
@@ -121,8 +122,7 @@ class Customer_Manager extends Base_Manager {
$this->log_ip_and_last_login(wp_get_current_user());
return $response;
-
- } // end on_heartbeat_send;
+ }
/**
* Saves the IP address and last_login date onto the user.
@@ -134,29 +134,22 @@ class Customer_Manager extends Base_Manager {
*/
public function log_ip_and_last_login($user) {
- if (!is_a($user, '\WP_User')) {
-
+ if ( ! is_a($user, '\WP_User')) {
$user = get_user_by('login', $user);
+ }
- } // end if;
-
- if (!$user) {
-
+ if ( ! $user) {
return;
-
- } // end if;
+ }
$customer = wu_get_customer_by_user_id($user->ID);
- if (!$customer) {
-
+ if ( ! $customer) {
return;
-
- } // end if;
+ }
$customer->update_last_login();
-
- } // end log_ip_and_last_login;
+ }
/**
* Watches the change in customer verification status to take action when needed.
@@ -171,20 +164,15 @@ class Customer_Manager extends Base_Manager {
public function transition_customer_email_verification($old_status, $new_status, $customer_id) {
if ($new_status !== 'pending') {
-
return;
-
- } // end if;
+ }
$customer = wu_get_customer($customer_id);
if ($customer) {
-
$customer->send_verification_email();
-
- } // end if;
-
- } // end transition_customer_email_verification;
+ }
+ }
/**
* Verifies a customer by checking the email key.
@@ -200,72 +188,58 @@ class Customer_Manager extends Base_Manager {
$email_verify_key = wu_request('email-verification-key');
- if (!$email_verify_key) {
-
+ if ( ! $email_verify_key) {
return;
-
- } // end if;
+ }
$customer_hash = wu_request('customer');
$customer_to_verify = wu_get_customer_by_hash($customer_hash);
- if (!is_user_logged_in()) {
-
+ if ( ! is_user_logged_in()) {
wp_die(
sprintf(
/* translators: the placeholder is the login URL */
__('You must be authenticated in order to verify your email address. Click here to access your account.', 'wp-ultimo'),
- wp_login_url(add_query_arg(
- array(
- 'email-verification-key' => $email_verify_key,
- 'customer' => $customer_hash,
+ wp_login_url(
+ add_query_arg(
+ array(
+ 'email-verification-key' => $email_verify_key,
+ 'customer' => $customer_hash,
+ )
)
- ))
+ )
)
);
+ }
- } // end if;
-
- if (!$customer_to_verify) {
-
+ if ( ! $customer_to_verify) {
wp_die(__('Invalid verification key.', 'wp-ultimo'));
-
- } // end if;
+ }
$current_customer = wu_get_current_customer();
- if (!$current_customer) {
-
+ if ( ! $current_customer) {
wp_die(__('Invalid verification key.', 'wp-ultimo'));
-
- } // end if;
+ }
if ($current_customer->get_id() !== $customer_to_verify->get_id()) {
-
wp_die(__('Invalid verification key.', 'wp-ultimo'));
-
- } // end if;
+ }
if ($customer_to_verify->get_email_verification() !== 'pending') {
-
wp_die(__('Invalid verification key.', 'wp-ultimo'));
-
- } // end if;
+ }
$key = $customer_to_verify->get_verification_key();
- if (!$key) {
-
+ if ( ! $key) {
wp_die(__('Invalid verification key.', 'wp-ultimo'));
-
- } // end if;
+ }
if ($key !== $email_verify_key) {
-
wp_die(__('Invalid verification key.', 'wp-ultimo'));
-
- } // end if;
+ }
/*
* Uff! If we got here, we can verify the customer.
@@ -285,52 +259,44 @@ class Customer_Manager extends Base_Manager {
* which one to manage.
*/
if (count($memberships) === 1) {
-
$membership = current($memberships);
/*
* Only publish pending memberships
*/
if ($membership->get_status() === Membership_Status::PENDING) {
-
$membership->publish_pending_site_async();
if ($membership->get_date_trial_end() <= gmdate('Y-m-d 23:59:59')) {
-
$membership->set_status(Membership_Status::ACTIVE);
-
- } // end if;
+ }
$membership->save();
-
} elseif ($membership->get_status() === Membership_Status::TRIALING) {
-
$membership->publish_pending_site_async();
-
- } // end if;
+ }
$payments = $membership->get_payments();
if ($payments) {
-
- $redirect_url = add_query_arg(array(
- 'payment' => $payments[0]->get_hash(),
- 'status' => 'done',
- ), wu_get_registration_url());
+ $redirect_url = add_query_arg(
+ array(
+ 'payment' => $payments[0]->get_hash(),
+ 'status' => 'done',
+ ),
+ wu_get_registration_url()
+ );
wp_redirect($redirect_url);
exit;
-
- } // end if;
-
- } // end if;
+ }
+ }
wp_redirect(get_admin_url($customer_to_verify->get_primary_site_id()));
exit;
-
- } // end maybe_verify_email_address;
+ }
/**
* Maybe adds the customer to the main site.
@@ -343,24 +309,18 @@ class Customer_Manager extends Base_Manager {
*/
public function maybe_add_to_main_site($customer, $checkout) {
- if (!wu_get_setting('add_users_to_main_site')) {
-
+ if ( ! wu_get_setting('add_users_to_main_site')) {
return;
-
- } // end if;
+ }
$user_id = $customer->get_user_id();
$is_already_user = is_user_member_of_blog($user_id, wu_get_main_site_id());
if ($is_already_user === false) {
-
$role = wu_get_setting('main_site_default_role', 'subscriber');
add_user_to_blog(wu_get_main_site_id(), $user_id, $role);
-
- } // end if;
-
- } // end maybe_add_to_main_site;
-
-} // end class Customer_Manager;
+ }
+ }
+}
diff --git a/inc/managers/class-discount-code-manager.php b/inc/managers/class-discount-code-manager.php
index a3d2577..ae5db16 100644
--- a/inc/managers/class-discount-code-manager.php
+++ b/inc/managers/class-discount-code-manager.php
@@ -24,7 +24,9 @@ defined('ABSPATH') || exit;
*/
class Discount_Code_Manager extends Base_Manager {
- use \WP_Ultimo\Apis\Rest_Api, \WP_Ultimo\Apis\WP_CLI, \WP_Ultimo\Traits\Singleton;
+ use \WP_Ultimo\Apis\Rest_Api;
+ use \WP_Ultimo\Apis\WP_CLI;
+ use \WP_Ultimo\Traits\Singleton;
/**
* The manager slug.
@@ -55,8 +57,7 @@ class Discount_Code_Manager extends Base_Manager {
$this->enable_wp_cli();
add_action('wu_gateway_payment_processed', array($this, 'maybe_add_use_on_payment_received'));
-
- } // end init;
+ }
/**
* Listens for payments received in order to increase the discount code uses.
@@ -68,11 +69,9 @@ class Discount_Code_Manager extends Base_Manager {
*/
public function maybe_add_use_on_payment_received($payment) {
- if (!$payment) {
-
+ if ( ! $payment) {
return;
-
- } // end if;
+ }
/*
* Try to fetch the original cart of the payment.
@@ -82,18 +81,14 @@ class Discount_Code_Manager extends Base_Manager {
$original_cart = $payment->get_meta('wu_original_cart');
if (is_a($original_cart, \WP_Ultimo\Checkout\Cart::class) === false) {
-
return;
-
- } // end if;
+ }
$discount_code = $original_cart->get_discount_code();
- if (!$discount_code) {
-
+ if ( ! $discount_code) {
return;
-
- } // end if;
+ }
/*
* Refetch the object, as the original version
@@ -102,13 +97,9 @@ class Discount_Code_Manager extends Base_Manager {
$discount_code = wu_get_discount_code($discount_code->get_id());
if ($discount_code) {
-
$discount_code->add_use();
$discount_code->save();
-
- } // end if;
-
- } // end maybe_add_use_on_payment_received;
-
-} // end class Discount_Code_Manager;
+ }
+ }
+}
diff --git a/inc/managers/class-domain-manager.php b/inc/managers/class-domain-manager.php
index b2a7f21..2096c0b 100644
--- a/inc/managers/class-domain-manager.php
+++ b/inc/managers/class-domain-manager.php
@@ -25,7 +25,9 @@ defined('ABSPATH') || exit;
*/
class Domain_Manager extends Base_Manager {
- use \WP_Ultimo\Apis\Rest_Api, \WP_Ultimo\Apis\WP_CLI, \WP_Ultimo\Traits\Singleton;
+ use \WP_Ultimo\Apis\Rest_Api;
+ use \WP_Ultimo\Apis\WP_CLI;
+ use \WP_Ultimo\Traits\Singleton;
/**
* The manager slug.
@@ -62,8 +64,7 @@ class Domain_Manager extends Base_Manager {
public function get_integrations() {
return apply_filters('wu_domain_manager_get_integrations', $this->integrations, $this);
-
- } // end get_integrations;
+ }
/**
* Get the instance of one of the integrations classes.
@@ -77,17 +78,14 @@ class Domain_Manager extends Base_Manager {
$integrations = $this->get_integrations();
- if (isset($integrations[$id])) {
-
- $class_name = $integrations[$id];
+ if (isset($integrations[ $id ])) {
+ $class_name = $integrations[ $id ];
return $class_name::get_instance();
-
- } // end if;
+ }
return false;
-
- } // end get_integration_instance;
+ }
/**
* Instantiate the necessary hooks.
@@ -134,8 +132,7 @@ class Domain_Manager extends Base_Manager {
add_action('wp_insert_site', array($this, 'handle_site_created'));
add_action('wp_delete_site', array($this, 'handle_site_deleted'));
-
- } // end init;
+ }
/**
* Set COOKIE_DOMAIN if not defined in sites with mapped domains.
@@ -146,13 +143,10 @@ class Domain_Manager extends Base_Manager {
*/
protected function set_cookie_domain() {
- if (defined('DOMAIN_CURRENT_SITE') && !defined('COOKIE_DOMAIN') && !preg_match('/' . DOMAIN_CURRENT_SITE . '$/', '.' . $_SERVER['HTTP_HOST'])) {
-
- define( 'COOKIE_DOMAIN', '.' . $_SERVER['HTTP_HOST'] );
-
- } // end if;
-
- } // end set_cookie_domain;
+ if (defined('DOMAIN_CURRENT_SITE') && ! defined('COOKIE_DOMAIN') && ! preg_match('/' . DOMAIN_CURRENT_SITE . '$/', '.' . $_SERVER['HTTP_HOST'])) {
+ define('COOKIE_DOMAIN', '.' . $_SERVER['HTTP_HOST']);
+ }
+ }
/**
* Triggers subdomain mapping events on site creation.
@@ -168,11 +162,9 @@ class Domain_Manager extends Base_Manager {
$has_subdomain = str_replace($current_site->domain, '', $site->domain);
- if (!$has_subdomain) {
-
+ if ( ! $has_subdomain) {
return;
-
- } // end if;
+ }
$args = array(
'subdomain' => $site->domain,
@@ -180,8 +172,7 @@ class Domain_Manager extends Base_Manager {
);
wu_enqueue_async_action('wu_add_subdomain', $args, 'domain');
-
- } // end handle_site_created;
+ }
/**
* Triggers subdomain mapping events on site deletion.
@@ -197,11 +188,9 @@ class Domain_Manager extends Base_Manager {
$has_subdomain = str_replace($current_site->domain, '', $site->domain);
- if (!$has_subdomain) {
-
+ if ( ! $has_subdomain) {
return;
-
- } // end if;
+ }
$args = array(
'subdomain' => $site->domain,
@@ -209,8 +198,7 @@ class Domain_Manager extends Base_Manager {
);
wu_enqueue_async_action('wu_remove_subdomain', $args, 'domain');
-
- } // end handle_site_deleted;
+ }
/**
* Triggers the do_event of the payment successful.
@@ -232,8 +220,7 @@ class Domain_Manager extends Base_Manager {
);
wu_do_event('domain_created', $payload);
-
- } // end handle_domain_created;
+ }
/**
* Remove send domain removal event.
@@ -247,17 +234,14 @@ class Domain_Manager extends Base_Manager {
public function handle_domain_deleted($result, $domain) {
if ($result) {
-
$args = array(
'domain' => $domain->get_domain(),
'site_id' => $domain->get_site_id(),
);
wu_enqueue_async_action('wu_remove_domain', $args, 'domain');
-
- } // end if;
-
- } // end handle_domain_deleted;
+ }
+ }
/**
* Add all domain mapping settings.
@@ -267,59 +251,78 @@ class Domain_Manager extends Base_Manager {
*/
public function add_domain_mapping_settings() {
- wu_register_settings_field('domain-mapping', 'domain_mapping_header', array(
- 'title' => __('Domain Mapping Settings', 'wp-ultimo'),
- 'desc' => __('Define the domain mapping settings for your network.', 'wp-ultimo'),
- 'type' => 'header',
- ));
+ wu_register_settings_field(
+ 'domain-mapping',
+ 'domain_mapping_header',
+ array(
+ 'title' => __('Domain Mapping Settings', 'wp-ultimo'),
+ 'desc' => __('Define the domain mapping settings for your network.', 'wp-ultimo'),
+ 'type' => 'header',
+ )
+ );
- wu_register_settings_field('domain-mapping', 'enable_domain_mapping', array(
- 'title' => __('Enable Domain Mapping?', 'wp-ultimo'),
- 'desc' => __('Do you want to enable domain mapping?', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 1,
- ));
+ wu_register_settings_field(
+ 'domain-mapping',
+ 'enable_domain_mapping',
+ array(
+ 'title' => __('Enable Domain Mapping?', 'wp-ultimo'),
+ 'desc' => __('Do you want to enable domain mapping?', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 1,
+ )
+ );
- wu_register_settings_field('domain-mapping', 'force_admin_redirect', array(
- 'title' => __('Force Admin Redirect', 'wp-ultimo'),
- 'desc' => __('Select how you want your users to access the admin panel if they have mapped domains.', 'wp-ultimo') . '
' . __('Force Redirect to Mapped Domain: your users with mapped domains will be redirected to theirdomain.com/wp-admin, even if they access using yournetworkdomain.com/wp-admin.', 'wp-ultimo') . '
' . __('Force Redirect to Network Domain: your users with mapped domains will be redirect to yournetworkdomain.com/wp-admin, even if they access using theirdomain.com/wp-admin.', 'wp-ultimo'),
- 'tooltip' => '',
- 'type' => 'select',
- 'default' => 'both',
- 'require' => array('enable_domain_mapping' => 1),
- 'options' => array(
- 'both' => __('Allow access to the admin by both mapped domain and network domain', 'wp-ultimo'),
- 'force_map' => __('Force Redirect to Mapped Domain', 'wp-ultimo'),
- 'force_network' => __('Force Redirect to Network Domain', 'wp-ultimo'),
- ),
- ));
+ wu_register_settings_field(
+ 'domain-mapping',
+ 'force_admin_redirect',
+ array(
+ 'title' => __('Force Admin Redirect', 'wp-ultimo'),
+ 'desc' => __('Select how you want your users to access the admin panel if they have mapped domains.', 'wp-ultimo') . '
' . __('Force Redirect to Mapped Domain: your users with mapped domains will be redirected to theirdomain.com/wp-admin, even if they access using yournetworkdomain.com/wp-admin.', 'wp-ultimo') . '
' . __('Force Redirect to Network Domain: your users with mapped domains will be redirect to yournetworkdomain.com/wp-admin, even if they access using theirdomain.com/wp-admin.', 'wp-ultimo'),
+ 'tooltip' => '',
+ 'type' => 'select',
+ 'default' => 'both',
+ 'require' => array('enable_domain_mapping' => 1),
+ 'options' => array(
+ 'both' => __('Allow access to the admin by both mapped domain and network domain', 'wp-ultimo'),
+ 'force_map' => __('Force Redirect to Mapped Domain', 'wp-ultimo'),
+ 'force_network' => __('Force Redirect to Network Domain', 'wp-ultimo'),
+ ),
+ )
+ );
- wu_register_settings_field('domain-mapping', 'custom_domains', array(
- 'title' => __('Enable Custom Domains?', 'wp-ultimo'),
- 'desc' => __('Toggle this option if you wish to allow end-customers to add their own domains. This can be controlled on a plan per plan basis.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 1,
- 'require' => array(
- 'enable_domain_mapping' => true,
- ),
- ));
+ wu_register_settings_field(
+ 'domain-mapping',
+ 'custom_domains',
+ array(
+ 'title' => __('Enable Custom Domains?', 'wp-ultimo'),
+ 'desc' => __('Toggle this option if you wish to allow end-customers to add their own domains. This can be controlled on a plan per plan basis.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 1,
+ 'require' => array(
+ 'enable_domain_mapping' => true,
+ ),
+ )
+ );
- wu_register_settings_field('domain-mapping', 'domain_mapping_instructions', array(
- 'title' => __('Add New Domain Instructions', 'wp-ultimo'),
- 'tooltip' => __('Display a customized message with instructions for the mapping and alerting the end-user of the risks of mapping a misconfigured domain.', 'wp-ultimo'),
- 'desc' => __('You can use the placeholder %NETWORK_DOMAIN% and %NETWORK_IP%.', 'wp-ultimo'),
- 'type' => 'textarea',
- 'default' => array($this, 'default_domain_mapping_instructions'),
- 'html_attr' => array(
- 'rows' => 8,
- ),
- 'require' => array(
- 'enable_domain_mapping' => true,
- 'custom_domains' => true,
- ),
- ));
-
- } // end add_domain_mapping_settings;
+ wu_register_settings_field(
+ 'domain-mapping',
+ 'domain_mapping_instructions',
+ array(
+ 'title' => __('Add New Domain Instructions', 'wp-ultimo'),
+ 'tooltip' => __('Display a customized message with instructions for the mapping and alerting the end-user of the risks of mapping a misconfigured domain.', 'wp-ultimo'),
+ 'desc' => __('You can use the placeholder %NETWORK_DOMAIN% and %NETWORK_IP%.', 'wp-ultimo'),
+ 'type' => 'textarea',
+ 'default' => array($this, 'default_domain_mapping_instructions'),
+ 'html_attr' => array(
+ 'rows' => 8,
+ ),
+ 'require' => array(
+ 'enable_domain_mapping' => true,
+ 'custom_domains' => true,
+ ),
+ )
+ );
+ }
/**
* Add all SSO settings.
@@ -329,40 +332,55 @@ class Domain_Manager extends Base_Manager {
*/
public function add_sso_settings() {
- wu_register_settings_field('sso', 'sso_header', array(
- 'title' => __('Single Sign-On Settings', 'wp-ultimo'),
- 'desc' => __('Settings to configure the Single Sign-On functionality of WP Multisite WaaS, responsible for keeping customers and admins logged in across all network domains.', 'wp-ultimo'),
- 'type' => 'header',
- ));
+ wu_register_settings_field(
+ 'sso',
+ 'sso_header',
+ array(
+ 'title' => __('Single Sign-On Settings', 'wp-ultimo'),
+ 'desc' => __('Settings to configure the Single Sign-On functionality of WP Multisite WaaS, responsible for keeping customers and admins logged in across all network domains.', 'wp-ultimo'),
+ 'type' => 'header',
+ )
+ );
- wu_register_settings_field('sso', 'enable_sso', array(
- 'title' => __('Enable Single Sign-On', 'wp-ultimo'),
- 'desc' => __('Enables the Single Sign-on functionality.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 1,
- ));
+ wu_register_settings_field(
+ 'sso',
+ 'enable_sso',
+ array(
+ 'title' => __('Enable Single Sign-On', 'wp-ultimo'),
+ 'desc' => __('Enables the Single Sign-on functionality.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 1,
+ )
+ );
- wu_register_settings_field('sso', 'restrict_sso_to_login_pages', array(
- 'title' => __('Restrict SSO Checks to Login Pages', 'wp-ultimo'),
- 'desc' => __('The Single Sign-on feature adds one extra ajax calls to every page load on sites with custom domains active to check if it should perform an auth loopback. You can restrict these extra calls to the login pages of sub-sites using this option. If enabled, SSO will only work on login pages.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 0,
- 'require' => array(
- 'enable_sso' => true,
- ),
- ));
+ wu_register_settings_field(
+ 'sso',
+ 'restrict_sso_to_login_pages',
+ array(
+ 'title' => __('Restrict SSO Checks to Login Pages', 'wp-ultimo'),
+ 'desc' => __('The Single Sign-on feature adds one extra ajax calls to every page load on sites with custom domains active to check if it should perform an auth loopback. You can restrict these extra calls to the login pages of sub-sites using this option. If enabled, SSO will only work on login pages.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 0,
+ 'require' => array(
+ 'enable_sso' => true,
+ ),
+ )
+ );
- wu_register_settings_field('sso', 'enable_sso_loading_overlay', array(
- 'title' => __('Enable SSO Loading Overlay', 'wp-ultimo'),
- 'desc' => __('When active, a loading overlay will be added on-top of the site currently being viewed while the SSO auth loopback is performed on the background.', 'wp-ultimo'),
- 'type' => 'toggle',
- 'default' => 1,
- 'require' => array(
- 'enable_sso' => true,
- ),
- ));
-
- } // end add_sso_settings;
+ wu_register_settings_field(
+ 'sso',
+ 'enable_sso_loading_overlay',
+ array(
+ 'title' => __('Enable SSO Loading Overlay', 'wp-ultimo'),
+ 'desc' => __('When active, a loading overlay will be added on-top of the site currently being viewed while the SSO auth loopback is performed on the background.', 'wp-ultimo'),
+ 'type' => 'toggle',
+ 'default' => 1,
+ 'require' => array(
+ 'enable_sso' => true,
+ ),
+ )
+ );
+ }
/**
* Returns the default instructions for domain mapping.
*
@@ -379,8 +397,7 @@ class Domain_Manager extends Base_Manager {
$instructions[] = __('After you finish that step, come back to this screen and click the button below.', 'wp-ultimo');
return implode(PHP_EOL . PHP_EOL, $instructions);
-
- } // end default_domain_mapping_instructions;
+ }
/**
* Gets the instructions, filtered and without the shortcodes.
@@ -394,11 +411,9 @@ class Domain_Manager extends Base_Manager {
$instructions = wu_get_setting('domain_mapping_instructions');
- if (!$instructions) {
-
+ if ( ! $instructions) {
$instructions = $this->default_domain_mapping_instructions();
-
- } // end if;
+ }
$domain = $current_site->domain;
$ip = Helper::get_network_public_ip();
@@ -410,8 +425,7 @@ class Domain_Manager extends Base_Manager {
$instructions = str_replace('%NETWORK_IP%', $ip, $instructions);
return apply_filters('wu_get_domain_mapping_instructions', $instructions, $domain, $ip);
-
- } // end get_domain_mapping_instructions;
+ }
/**
* Creates the event to save the transition.
@@ -426,7 +440,6 @@ class Domain_Manager extends Base_Manager {
public function send_domain_to_host($old_value, $new_value, $item_id) {
if ($old_value !== $new_value) {
-
$domain = wu_get_domain($item_id);
$args = array(
@@ -435,10 +448,8 @@ class Domain_Manager extends Base_Manager {
);
wu_enqueue_async_action('wu_add_domain', $args, 'domain');
-
- } // end if;
-
- } // end send_domain_to_host;
+ }
+ }
/**
* Checks the DNS and SSL status of a domain.
@@ -453,17 +464,15 @@ class Domain_Manager extends Base_Manager {
$domain = wu_get_domain($domain_id);
- if (!$domain) {
-
+ if ( ! $domain) {
return;
-
- } // end if;
+ }
$max_tries = apply_filters('wu_async_process_domain_stage_max_tries', 5, $domain);
$try_again_time = apply_filters('wu_async_process_domains_try_again_time', 5, $domain); // minutes
- $tries++;
+ ++$tries;
$stage = $domain->get_stage();
@@ -473,9 +482,7 @@ class Domain_Manager extends Base_Manager {
wu_log_add("domain-{$domain_url}", sprintf(__('Starting Check for %s', 'wp-ultimo'), $domain_url));
if ($stage === 'checking-dns') {
-
if ($domain->has_correct_dns()) {
-
$domain->set_stage('checking-ssl-cert');
$domain->save();
@@ -485,18 +492,23 @@ class Domain_Manager extends Base_Manager {
__('- DNS propagation finished, advancing domain to next step...', 'wp-ultimo')
);
- wu_enqueue_async_action('wu_async_process_domain_stage', array('domain_id' => $domain_id, 'tries' => 0), 'domain');
+ wu_enqueue_async_action(
+ 'wu_async_process_domain_stage',
+ array(
+ 'domain_id' => $domain_id,
+ 'tries' => 0,
+ ),
+ 'domain'
+ );
do_action('wu_domain_manager_dns_propagation_finished', $domain);
return;
-
} else {
/*
* Max attempts
*/
if ($tries > $max_tries) {
-
$domain->set_stage('failed');
$domain->save();
@@ -508,8 +520,7 @@ class Domain_Manager extends Base_Manager {
);
return;
-
- } // end if;
+ }
wu_log_add(
"domain-{$domain_url}",
@@ -528,13 +539,9 @@ class Domain_Manager extends Base_Manager {
);
return;
-
- } // end if;
-
+ }
} elseif ($stage === 'checking-ssl-cert') {
-
if ($domain->has_valid_ssl_certificate()) {
-
$domain->set_stage('done');
$domain->set_secure(true);
@@ -547,13 +554,11 @@ class Domain_Manager extends Base_Manager {
);
return;
-
} else {
/*
* Max attempts
*/
if ($tries > $max_tries) {
-
$domain->set_stage('done-without-ssl');
$domain->save();
@@ -565,8 +570,7 @@ class Domain_Manager extends Base_Manager {
);
return;
-
- } // end if;
+ }
wu_log_add(
"domain-{$domain_url}",
@@ -574,15 +578,20 @@ class Domain_Manager extends Base_Manager {
sprintf(__('- SSL Cert not found, retrying in %d minute(s)...', 'wp-ultimo'), $try_again_time)
);
- wu_schedule_single_action(strtotime("+{$try_again_time} minutes"), 'wu_async_process_domain_stage', array('domain_id' => $domain_id, 'tries' => $tries), 'domain');
+ wu_schedule_single_action(
+ strtotime("+{$try_again_time} minutes"),
+ 'wu_async_process_domain_stage',
+ array(
+ 'domain_id' => $domain_id,
+ 'tries' => $tries,
+ ),
+ 'domain'
+ );
return;
-
- } // end if;
-
- } // end if;
-
- } // end async_process_domain_stage;
+ }
+ }
+ }
/**
* Alternative implementation for PHP's native dns_get_record.
@@ -606,7 +615,6 @@ class Domain_Manager extends Base_Manager {
);
foreach ($record_types as $record_type) {
-
$chain = new \RemotelyLiving\PHPDNS\Resolvers\Chain(
new \RemotelyLiving\PHPDNS\Resolvers\CloudFlare(),
new \RemotelyLiving\PHPDNS\Resolvers\GoogleDNS(),
@@ -617,7 +625,6 @@ class Domain_Manager extends Base_Manager {
$records = $chain->getRecords($domain, $record_type);
foreach ($records as $record_data) {
-
$record = array();
$record['type'] = $record_type;
@@ -625,10 +632,8 @@ class Domain_Manager extends Base_Manager {
$record['data'] = (string) $record_data->getData();
if (empty($record['data'])) {
-
$record['data'] = (string) $record_data->getIPAddress();
-
- } // end if;
+ }
// Some DNS providers return a trailing dot.
$record['data'] = rtrim($record['data'], '.');
@@ -642,14 +647,11 @@ class Domain_Manager extends Base_Manager {
$record['tag'] = ''; // Used by integrations.
$results[] = $record;
-
- } // end foreach;
-
- } // end foreach;
+ }
+ }
return apply_filters('wu_domain_dns_get_record', $results, $domain);
-
- } // end dns_get_record;
+ }
/**
* Get the DNS records for a given domain.
@@ -661,42 +663,41 @@ class Domain_Manager extends Base_Manager {
$domain = wu_request('domain');
- if (!$domain) {
-
+ if ( ! $domain) {
wp_send_json_error(new \WP_Error('domain-missing', __('A valid domain was not passed.', 'wp-ultimo')));
-
- } // end if;
+ }
$auth_ns = array();
$additional = array();
try {
-
$result = self::dns_get_record($domain);
-
} catch (\Throwable $e) {
-
- wp_send_json_error(new \WP_Error('error', __('Not able to fetch DNS entries.', 'wp-ultimo'), array(
- 'exception' => $e->getMessage(),
- )));
-
- } // end try;
+ wp_send_json_error(
+ new \WP_Error(
+ 'error',
+ __('Not able to fetch DNS entries.', 'wp-ultimo'),
+ array(
+ 'exception' => $e->getMessage(),
+ )
+ )
+ );
+ }
if ($result === false) {
-
wp_send_json_error(new \WP_Error('error', __('Not able to fetch DNS entries.', 'wp-ultimo')));
+ }
- } // end if;
-
- wp_send_json_success(array(
- 'entries' => $result,
- 'auth' => $auth_ns,
- 'additional' => $additional,
- 'network_ip' => Helper::get_network_public_ip(),
- ));
-
- } // end get_dns_records;
+ wp_send_json_success(
+ array(
+ 'entries' => $result,
+ 'auth' => $auth_ns,
+ 'additional' => $additional,
+ 'network_ip' => Helper::get_network_public_ip(),
+ )
+ );
+ }
/**
* Takes the list of domains and set them to non-primary when a new primary is added.
@@ -711,20 +712,15 @@ class Domain_Manager extends Base_Manager {
public function async_remove_old_primary_domains($domains) {
foreach ($domains as $domain_id) {
-
$domain = wu_get_domain($domain_id);
if ($domain) {
-
$domain->set_primary_domain(false);
$domain->save();
-
- } // end if;
-
- } // end foreach;
-
- } // end async_remove_old_primary_domains;
+ }
+ }
+ }
/**
* Tests the integration in the Wizard context.
@@ -738,31 +734,30 @@ class Domain_Manager extends Base_Manager {
$integration = $this->get_integration_instance($integration_id);
- if (!$integration) {
-
- wp_send_json_error(array(
- 'message' => __('Invalid Integration ID', 'wp-ultimo'),
- ));
-
- } // end if;
+ if ( ! $integration) {
+ wp_send_json_error(
+ array(
+ 'message' => __('Invalid Integration ID', 'wp-ultimo'),
+ )
+ );
+ }
/*
* Checks for the constants...
*/
- if (!$integration->is_setup()) {
-
- wp_send_json_error(array(
- 'message' => sprintf(
- __('The necessary constants were not found on your wp-config.php file: %s', 'wp-ultimo'),
- implode(', ', $integration->get_missing_constants())
- ),
- ));
-
- } // end if;
+ if ( ! $integration->is_setup()) {
+ wp_send_json_error(
+ array(
+ 'message' => sprintf(
+ __('The necessary constants were not found on your wp-config.php file: %s', 'wp-ultimo'),
+ implode(', ', $integration->get_missing_constants())
+ ),
+ )
+ );
+ }
return $integration->test_connection();
-
- } // end test_integration;
+ }
/**
* Loads all the host provider integrations we have available.
@@ -818,11 +813,9 @@ class Domain_Manager extends Base_Manager {
/**
* Allow developers to add their own host provider integrations via wp plugins.
- *
+ *
* @since 2.0.0
*/
do_action('wp_ultimo_host_providers_load');
-
- } // end load_integrations;
-
-} // end class Domain_Manager;
+ }
+}
diff --git a/inc/managers/class-email-manager.php b/inc/managers/class-email-manager.php
index fc8634a..6086f77 100644
--- a/inc/managers/class-email-manager.php
+++ b/inc/managers/class-email-manager.php
@@ -12,10 +12,10 @@
namespace WP_Ultimo\Managers;
use Psr\Log\LogLevel;
-use \WP_Ultimo\Managers\Base_Manager;
-use \WP_Ultimo\Models\Email;
-use \WP_Ultimo\Helpers\Sender;
-use \WP_Ultimo\Models\Base_Model;
+use WP_Ultimo\Managers\Base_Manager;
+use WP_Ultimo\Models\Email;
+use WP_Ultimo\Helpers\Sender;
+use WP_Ultimo\Models\Base_Model;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -27,7 +27,9 @@ defined('ABSPATH') || exit;
*/
class Email_Manager extends Base_Manager {
- use \WP_Ultimo\Apis\Rest_Api, \WP_Ultimo\Apis\WP_CLI, \WP_Ultimo\Traits\Singleton;
+ use \WP_Ultimo\Apis\Rest_Api;
+ use \WP_Ultimo\Apis\WP_CLI;
+ use \WP_Ultimo\Traits\Singleton;
/**
* The manager slug.
@@ -65,9 +67,12 @@ class Email_Manager extends Base_Manager {
$this->enable_wp_cli();
- add_action('init', function () {
- $this->register_all_default_system_emails();
- });
+ add_action(
+ 'init',
+ function () {
+ $this->register_all_default_system_emails();
+ }
+ );
/*
* Adds the Email fields
@@ -87,8 +92,7 @@ class Email_Manager extends Base_Manager {
add_action('wp_mail_failed', array($this, 'log_mailer_failure'));
add_action('wp_ajax_wu_get_event_payload_placeholders', array($this, 'get_event_placeholders'));
-
- } // end init;
+ }
/**
* Send the email related to the current event.
@@ -99,9 +103,11 @@ class Email_Manager extends Base_Manager {
*/
public function send_system_email($slug, $payload) {
- $all_emails = wu_get_emails(array(
- 'event' => $slug,
- ));
+ $all_emails = wu_get_emails(
+ array(
+ 'event' => $slug,
+ )
+ );
$original_from = array(
'name' => wu_get_setting('from_name'),
@@ -112,19 +118,14 @@ class Email_Manager extends Base_Manager {
* Loop through all the emails registered.
*/
foreach ($all_emails as $email) {
-
if ($email->get_custom_sender()) {
-
$from = array(
'name' => $email->get_custom_sender_name(),
'email' => $email->get_custom_sender_email(),
);
-
} else {
-
$from = $original_from;
-
- } // end if;
+ }
/*
* Compiles the target list.
@@ -132,12 +133,10 @@ class Email_Manager extends Base_Manager {
$to = $email->get_target_list($payload);
if (empty($to)) {
-
wu_log_add('mailer', __('No targets found.', 'wp-ultimo'));
return;
-
- } // end if;
+ }
$args = array(
'style' => $email->get_style(),
@@ -150,26 +149,20 @@ class Email_Manager extends Base_Manager {
* Add the invoice attachment, if need be.
*/
if (wu_get_isset($payload, 'payment_invoice_url') && wu_get_setting('attach_invoice_pdf', true)) {
-
$file_name = 'invoice-' . $payload['payment_reference_code'] . '.pdf';
$this->attach_file_by_url($payload['payment_invoice_url'], $file_name, $args['subject']);
-
- } // end if;
+ }
$when_to_send = $email->get_when_to_send();
if ($when_to_send) {
-
$args['schedule'] = $when_to_send;
-
- } // end if;
+ }
Sender::send_mail($from, $to, $args);
-
- } // end foreach;
-
- } // end send_system_email;
+ }
+ }
/**
* Attach a file by a URL
@@ -183,34 +176,35 @@ class Email_Manager extends Base_Manager {
*/
public function attach_file_by_url($file_url, $file_name, $email_subject = '') {
- add_action('phpmailer_init', function($mail) use ($file_url, $file_name, $email_subject) {
+ add_action(
+ 'phpmailer_init',
+ function ($mail) use ($file_url, $file_name, $email_subject) {
if ($email_subject && $mail->Subject !== $email_subject) { // phpcs:ignore
- return;
+ return;
+ }
- } // end if;
+ $response = wp_remote_get(
+ $file_url,
+ array(
+ 'timeout' => 50,
+ )
+ );
- $response = wp_remote_get($file_url, array(
- 'timeout' => 50,
- ));
+ if (is_wp_error($response)) {
+ return;
+ }
- if (is_wp_error($response)) {
+ $file = wp_remote_retrieve_body($response);
- return;
-
- } // end if;
-
- $file = wp_remote_retrieve_body($response);
-
- /*
- * Use the default PHPMailer APIs to attach the file.
- */
- $mail->addStringAttachment($file, $file_name);
-
- });
-
- } // end attach_file_by_url;
+ /*
+ * Use the default PHPMailer APIs to attach the file.
+ */
+ $mail->addStringAttachment($file, $file_name);
+ }
+ );
+ }
/**
* Add all email fields.
@@ -220,71 +214,98 @@ class Email_Manager extends Base_Manager {
*/
public function add_email_fields() {
- wu_register_settings_field('emails', 'sender_header', array(
- 'title' => __('Sender Settings', 'wp-ultimo'),
- 'desc' => __('Change the settings of the email headers, like from and name.', 'wp-ultimo'),
- 'type' => 'header',
- ));
+ wu_register_settings_field(
+ 'emails',
+ 'sender_header',
+ array(
+ 'title' => __('Sender Settings', 'wp-ultimo'),
+ 'desc' => __('Change the settings of the email headers, like from and name.', 'wp-ultimo'),
+ 'type' => 'header',
+ )
+ );
- wu_register_settings_field('emails', 'from_name', array(
- 'title' => __('"From" Name', 'wp-ultimo'),
- 'desc' => __('How the sender name will appear in emails sent by WP Multisite WaaS.', 'wp-ultimo'),
- 'type' => 'text',
- 'placeholder' => get_network_option(null, 'site_name'),
- 'default' => get_network_option(null, 'site_name'),
- 'html_attr' => array(
- 'v-model' => 'from_name',
- ),
- ));
+ wu_register_settings_field(
+ 'emails',
+ 'from_name',
+ array(
+ 'title' => __('"From" Name', 'wp-ultimo'),
+ 'desc' => __('How the sender name will appear in emails sent by WP Multisite WaaS.', 'wp-ultimo'),
+ 'type' => 'text',
+ 'placeholder' => get_network_option(null, 'site_name'),
+ 'default' => get_network_option(null, 'site_name'),
+ 'html_attr' => array(
+ 'v-model' => 'from_name',
+ ),
+ )
+ );
- wu_register_settings_field('emails', 'from_email', array(
- 'title' => __('"From" E-mail', 'wp-ultimo'),
- 'desc' => __('How the sender email will appear in emails sent by WP Multisite WaaS.', 'wp-ultimo'),
- 'type' => 'email',
- 'placeholder' => get_network_option(null, 'admin_email'),
- 'default' => get_network_option(null, 'admin_email'),
- 'html_attr' => array(
- 'v-model' => 'from_email',
- ),
- ));
+ wu_register_settings_field(
+ 'emails',
+ 'from_email',
+ array(
+ 'title' => __('"From" E-mail', 'wp-ultimo'),
+ 'desc' => __('How the sender email will appear in emails sent by WP Multisite WaaS.', 'wp-ultimo'),
+ 'type' => 'email',
+ 'placeholder' => get_network_option(null, 'admin_email'),
+ 'default' => get_network_option(null, 'admin_email'),
+ 'html_attr' => array(
+ 'v-model' => 'from_email',
+ ),
+ )
+ );
- wu_register_settings_field('emails', 'template_header', array(
- 'title' => __('Template Settings', 'wp-ultimo'),
- 'desc' => __('Change the settings of the email templates.', 'wp-ultimo'),
- 'type' => 'header',
- ));
+ wu_register_settings_field(
+ 'emails',
+ 'template_header',
+ array(
+ 'title' => __('Template Settings', 'wp-ultimo'),
+ 'desc' => __('Change the settings of the email templates.', 'wp-ultimo'),
+ 'type' => 'header',
+ )
+ );
- wu_register_settings_field('emails', 'email_template_type', array(
- 'title' => __('Email Templates Style', 'wp-ultimo'),
- 'desc' => __('Choose if email body will be sent using the HTML template or in plain text.', 'wp-ultimo'),
- 'type' => 'select',
- 'default' => 'html',
- 'options' => array(
- 'html' => __('HTML Emails', 'wp-ultimo'),
- 'plain' => __('Plain Emails', 'wp-ultimo'),
- ),
- 'html_attr' => array(
- 'v-model' => 'emails_template',
- ),
- ));
+ wu_register_settings_field(
+ 'emails',
+ 'email_template_type',
+ array(
+ 'title' => __('Email Templates Style', 'wp-ultimo'),
+ 'desc' => __('Choose if email body will be sent using the HTML template or in plain text.', 'wp-ultimo'),
+ 'type' => 'select',
+ 'default' => 'html',
+ 'options' => array(
+ 'html' => __('HTML Emails', 'wp-ultimo'),
+ 'plain' => __('Plain Emails', 'wp-ultimo'),
+ ),
+ 'html_attr' => array(
+ 'v-model' => 'emails_template',
+ ),
+ )
+ );
- wu_register_settings_field('emails', 'expiring_header', array(
- 'title' => __('Expiring Notification Settings', 'wp-ultimo'),
- 'desc' => __('Change the settings for the expiring notification (trials and subscriptions) emails.', 'wp-ultimo'),
- 'type' => 'header',
- ));
+ wu_register_settings_field(
+ 'emails',
+ 'expiring_header',
+ array(
+ 'title' => __('Expiring Notification Settings', 'wp-ultimo'),
+ 'desc' => __('Change the settings for the expiring notification (trials and subscriptions) emails.', 'wp-ultimo'),
+ 'type' => 'header',
+ )
+ );
- wu_register_settings_field('emails', 'expiring_days', array(
- 'title' => __('Days to Expire', 'wp-ultimo'),
- 'desc' => __('Select when we should send the notification email. If you select 3 days, for example, a notification email will be sent to every membership (or trial period) expiring in the next 3 days. Memberships are checked hourly.', 'wp-ultimo'),
- 'type' => 'number',
- 'placeholder' => __('e.g. 3', 'wp-ultimo'),
- 'html_attr' => array(
- 'v-model' => 'expiring_days',
- ),
- ));
-
- } // end add_email_fields;
+ wu_register_settings_field(
+ 'emails',
+ 'expiring_days',
+ array(
+ 'title' => __('Days to Expire', 'wp-ultimo'),
+ 'desc' => __('Select when we should send the notification email. If you select 3 days, for example, a notification email will be sent to every membership (or trial period) expiring in the next 3 days. Memberships are checked hourly.', 'wp-ultimo'),
+ 'type' => 'number',
+ 'placeholder' => __('e.g. 3', 'wp-ultimo'),
+ 'html_attr' => array(
+ 'v-model' => 'expiring_days',
+ ),
+ )
+ );
+ }
/**
* Register in the global variable all the default system emails.
@@ -296,9 +317,8 @@ class Email_Manager extends Base_Manager {
*/
public function register_default_system_email($args) {
- $this->registered_default_system_emails[$args['slug']] = $args;
-
- } // end register_default_system_email;
+ $this->registered_default_system_emails[ $args['slug'] ] = $args;
+ }
/**
* Create a system email.
@@ -311,33 +331,33 @@ class Email_Manager extends Base_Manager {
public function create_system_email($args) {
if ($this->is_created($args['slug'])) {
-
return;
+ }
- } // end if;
-
- $email_args = wp_parse_args($args, array(
- 'event' => '',
- 'title' => '',
- 'content' => '',
- 'slug' => '',
- 'target' => 'admin',
- 'style' => 'use_default',
- 'send_copy_to_admin' => true,
- 'active' => true,
- 'legacy' => false,
- 'date_registered' => wu_get_current_time('mysql', true),
- 'date_modified' => wu_get_current_time('mysql', true),
- 'status' => 'publish'
- ));
+ $email_args = wp_parse_args(
+ $args,
+ array(
+ 'event' => '',
+ 'title' => '',
+ 'content' => '',
+ 'slug' => '',
+ 'target' => 'admin',
+ 'style' => 'use_default',
+ 'send_copy_to_admin' => true,
+ 'active' => true,
+ 'legacy' => false,
+ 'date_registered' => wu_get_current_time('mysql', true),
+ 'date_modified' => wu_get_current_time('mysql', true),
+ 'status' => 'publish',
+ )
+ );
$email = new Email($email_args);
$saved = $email->save();
return is_wp_error($saved) ? $saved : $email;
-
- } // end create_system_email;
+ }
/**
* Register all default system emails.
@@ -351,12 +371,9 @@ class Email_Manager extends Base_Manager {
$system_emails = wu_get_default_system_emails();
foreach ($system_emails as $email_key => $email_value) {
-
$this->create_system_email($email_value);
-
- } // end foreach;
-
- } // end create_all_system_emails;
+ }
+ }
/**
* Register all default system emails.
@@ -369,83 +386,96 @@ class Email_Manager extends Base_Manager {
/*
* Payment Successful - Admin
*/
- $this->register_default_system_email(array(
- 'event' => 'payment_received',
- 'slug' => 'payment_received_admin',
- 'target' => 'admin',
- 'title' => __('You got a new payment!', 'wp-ultimo'),
- 'content' => wu_get_template_contents('emails/admin/payment-received'),
- ));
+ $this->register_default_system_email(
+ array(
+ 'event' => 'payment_received',
+ 'slug' => 'payment_received_admin',
+ 'target' => 'admin',
+ 'title' => __('You got a new payment!', 'wp-ultimo'),
+ 'content' => wu_get_template_contents('emails/admin/payment-received'),
+ )
+ );
/*
* Payment Successful - Customer
*/
- $this->register_default_system_email(array(
- 'event' => 'payment_received',
- 'slug' => 'payment_received_customer',
- 'target' => 'customer',
- 'title' => __('We got your payment!', 'wp-ultimo'),
- 'content' => wu_get_template_contents('emails/customer/payment-received'),
- ));
+ $this->register_default_system_email(
+ array(
+ 'event' => 'payment_received',
+ 'slug' => 'payment_received_customer',
+ 'target' => 'customer',
+ 'title' => __('We got your payment!', 'wp-ultimo'),
+ 'content' => wu_get_template_contents('emails/customer/payment-received'),
+ )
+ );
/*
* Site Published - Admin
*/
- $this->register_default_system_email(array(
- 'event' => 'site_published',
- 'target' => 'admin',
- 'slug' => 'site_published_admin',
- 'title' => __('A new site was created on your Network!', 'wp-ultimo'),
- 'content' => wu_get_template_contents('emails/admin/site-published'),
- ));
+ $this->register_default_system_email(
+ array(
+ 'event' => 'site_published',
+ 'target' => 'admin',
+ 'slug' => 'site_published_admin',
+ 'title' => __('A new site was created on your Network!', 'wp-ultimo'),
+ 'content' => wu_get_template_contents('emails/admin/site-published'),
+ )
+ );
/*
* Site Published - Customer
*/
- $this->register_default_system_email(array(
- 'event' => 'site_published',
- 'target' => 'customer',
- 'slug' => 'site_published_customer',
- 'title' => __('Your site is ready!', 'wp-ultimo'),
- 'content' => wu_get_template_contents('emails/customer/site-published'),
- ));
+ $this->register_default_system_email(
+ array(
+ 'event' => 'site_published',
+ 'target' => 'customer',
+ 'slug' => 'site_published_customer',
+ 'title' => __('Your site is ready!', 'wp-ultimo'),
+ 'content' => wu_get_template_contents('emails/customer/site-published'),
+ )
+ );
/*
* Site Published - Customer
*/
- $this->register_default_system_email(array(
- 'event' => 'confirm_email_address',
- 'target' => 'customer',
- 'slug' => 'confirm_email_address',
- 'title' => __('Confirm your email address!', 'wp-ultimo'),
- 'content' => wu_get_template_contents('emails/customer/confirm-email-address'),
- ));
+ $this->register_default_system_email(
+ array(
+ 'event' => 'confirm_email_address',
+ 'target' => 'customer',
+ 'slug' => 'confirm_email_address',
+ 'title' => __('Confirm your email address!', 'wp-ultimo'),
+ 'content' => wu_get_template_contents('emails/customer/confirm-email-address'),
+ )
+ );
/*
* Domain Created - Admin
*/
- $this->register_default_system_email(array(
- 'event' => 'domain_created',
- 'target' => 'admin',
- 'slug' => 'domain_created_admin',
- 'title' => __('A new domain was added to your Network!', 'wp-ultimo'),
- 'content' => wu_get_template_contents('emails/admin/domain-created'),
- ));
+ $this->register_default_system_email(
+ array(
+ 'event' => 'domain_created',
+ 'target' => 'admin',
+ 'slug' => 'domain_created_admin',
+ 'title' => __('A new domain was added to your Network!', 'wp-ultimo'),
+ 'content' => wu_get_template_contents('emails/admin/domain-created'),
+ )
+ );
/*
* Pending Renewal Payment Created - Customer
*/
- $this->register_default_system_email(array(
- 'event' => 'renewal_payment_created',
- 'target' => 'customer',
- 'slug' => 'renewal_payment_created',
- 'title' => __('You have a new pending payment!', 'wp-ultimo'),
- 'content' => wu_get_template_contents('emails/customer/renewal-payment-created'),
- ));
+ $this->register_default_system_email(
+ array(
+ 'event' => 'renewal_payment_created',
+ 'target' => 'customer',
+ 'slug' => 'renewal_payment_created',
+ 'title' => __('You have a new pending payment!', 'wp-ultimo'),
+ 'content' => wu_get_template_contents('emails/customer/renewal-payment-created'),
+ )
+ );
do_action('wu_system_emails_after_register');
-
- } // end register_all_default_system_emails;
+ }
/**
* Get a single or all default registered system emails.
@@ -457,15 +487,12 @@ class Email_Manager extends Base_Manager {
*/
public function get_default_system_emails($slug = '') {
- if ($slug && isset($this->registered_default_system_emails[$slug])) {
-
- return $this->registered_default_system_emails[$slug];
-
- } // end if;
+ if ($slug && isset($this->registered_default_system_emails[ $slug ])) {
+ return $this->registered_default_system_emails[ $slug ];
+ }
return $this->registered_default_system_emails;
-
- } // end get_default_system_emails;
+ }
/**
* Check if the system email already exists.
@@ -476,8 +503,7 @@ class Email_Manager extends Base_Manager {
public function is_created($slug): bool {
return (bool) wu_get_email_by('slug', $slug);
-
- } // end is_created;
+ }
/**
* Get the default template email.
@@ -492,43 +518,30 @@ class Email_Manager extends Base_Manager {
$placeholders = array();
if (wu_request('email_event')) {
-
$slug = wu_request('email_event');
-
- } // end if;
+ }
if ($slug) {
-
$event = wu_get_event_type($slug);
if ($event) {
-
foreach (wu_maybe_lazy_load_payload($event['payload']) as $placeholder => $value) {
-
$name = ucwords(str_replace('_', ' ', $placeholder));
$placeholders[] = array(
'name' => $name,
- 'placeholder' => $placeholder
+ 'placeholder' => $placeholder,
);
-
- } // end foreach;
-
- } // end if;
-
- } // end if;
+ }
+ }
+ }
if (wu_request('email_event')) {
-
wp_send_json($placeholders);
-
} else {
-
return $placeholders;
-
- } // end if;
-
- } // end get_event_placeholders;
+ }
+ }
/**
* Sends a schedule email.
@@ -545,8 +558,7 @@ class Email_Manager extends Base_Manager {
public function send_schedule_system_email($to, $subject, $template, $headers, $attachments) {
return Sender::send_mail($to, $subject, $template, $headers, $attachments);
-
- } // end send_schedule_system_email;
+ }
/**
* Log failures on the WordPress mailer, just so we have a copy of the issues for debugging.
@@ -559,11 +571,7 @@ class Email_Manager extends Base_Manager {
public function log_mailer_failure($error) {
if (is_wp_error($error)) {
-
wu_log_add('mailer-errors', $error->get_error_message(), LogLevel::ERROR);
-
- } // end if;
-
- } // end log_mailer_failure;
-
-} // end class Email_Manager;
+ }
+ }
+}
diff --git a/inc/managers/class-event-manager.php b/inc/managers/class-event-manager.php
index 89d7dfa..de4b243 100644
--- a/inc/managers/class-event-manager.php
+++ b/inc/managers/class-event-manager.php
@@ -11,9 +11,9 @@
namespace WP_Ultimo\Managers;
-use \WP_Ultimo\Managers\Base_Manager;
+use WP_Ultimo\Managers\Base_Manager;
use WP_Ultimo\Models\Base_Model;
-use \WP_Ultimo\Models\Event;
+use WP_Ultimo\Models\Event;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -25,7 +25,9 @@ defined('ABSPATH') || exit;
*/
class Event_Manager extends Base_Manager {
- use \WP_Ultimo\Apis\Rest_Api, \WP_Ultimo\Apis\WP_CLI, \WP_Ultimo\Traits\Singleton;
+ use \WP_Ultimo\Apis\Rest_Api;
+ use \WP_Ultimo\Apis\WP_CLI;
+ use \WP_Ultimo\Traits\Singleton;
/**
* The manager slug.
@@ -80,8 +82,7 @@ class Event_Manager extends Base_Manager {
add_action('wu_model_post_save', array($this, 'log_transitions'), 10, 4);
add_action('wu_daily', array($this, 'clean_old_events'));
-
- } // end init;
+ }
/**
* Returns the payload to be displayed in the payload preview field.
@@ -98,45 +99,41 @@ class Event_Manager extends Base_Manager {
public function log_transitions($model, $data, $data_unserialized, $object) {
if ($model === 'event') {
-
return;
-
- } // end if;
+ }
/*
* Editing Model
*/
if (wu_get_isset($data_unserialized, 'id')) {
-
$original = $object->_get_original();
$diff = wu_array_recursive_diff($data_unserialized, $original);
- $keys_to_remove = apply_filters('wu_exclude_transitions_keys', array(
- 'meta',
- 'last_login',
- 'ips',
- 'query_class',
- 'settings',
- '_compiled_product_list',
- '_gateway_info',
- '_limitations',
- ));
+ $keys_to_remove = apply_filters(
+ 'wu_exclude_transitions_keys',
+ array(
+ 'meta',
+ 'last_login',
+ 'ips',
+ 'query_class',
+ 'settings',
+ '_compiled_product_list',
+ '_gateway_info',
+ '_limitations',
+ )
+ );
foreach ($keys_to_remove as $key_to_remove) {
-
- unset($diff[$key_to_remove]);
-
- } // end foreach;
+ unset($diff[ $key_to_remove ]);
+ }
/**
* If empty, go home.
*/
if (empty($diff)) {
-
return;
-
- } // end if;
+ }
$changed = array();
@@ -144,27 +141,21 @@ class Event_Manager extends Base_Manager {
* Loop changed data.
*/
foreach ($diff as $key => $new_value) {
-
$old_value = wu_get_isset($original, $key, '');
if ($key === 'id' && intval($old_value) === 0) {
-
return;
-
- } // end if;
+ }
if (empty(json_encode($old_value)) && empty(json_encode($new_value))) {
-
return;
+ }
- } // end if;
-
- $changed[$key] = array(
+ $changed[ $key ] = array(
'old_value' => $old_value,
'new_value' => $new_value,
);
-
- } // end foreach;
+ }
$event_data = array(
'severity' => Event::SEVERITY_INFO,
@@ -173,9 +164,7 @@ class Event_Manager extends Base_Manager {
'object_id' => $object->get_id(),
'payload' => $changed,
);
-
} else {
-
$event_data = array(
'severity' => Event::SEVERITY_INFO,
'slug' => 'created',
@@ -183,19 +172,15 @@ class Event_Manager extends Base_Manager {
'object_id' => $object->get_id(),
'payload' => array(),
);
+ }
- } // end if;
-
- if (!empty($_POST) && is_user_logged_in()) {
-
+ if ( ! empty($_POST) && is_user_logged_in()) {
$event_data['initiator'] = 'manual';
$event_data['author_id'] = get_current_user_id();
-
- } // end if;
+ }
return wu_create_event($event_data);
-
- } // end log_transitions;
+ }
/**
* Returns the payload to be displayed in the payload preview field.
@@ -205,37 +190,28 @@ class Event_Manager extends Base_Manager {
*/
public function event_payload_preview() {
- if (!wu_request('event')) {
-
+ if ( ! wu_request('event')) {
wp_send_json_error(new \WP_Error('error', __('No event was selected.', 'wp-ultimo')));
-
- } // end if;
+ }
$slug = wu_request('event');
- if (!$slug) {
-
+ if ( ! $slug) {
wp_send_json_error(new \WP_Error('not-found', __('Event was not found.', 'wp-ultimo')));
-
- } // end if;
+ }
$event = wu_get_event_type($slug);
- if (!$event) {
-
+ if ( ! $event) {
wp_send_json_error(new \WP_Error('not-found', __('Data not found.', 'wp-ultimo')));
-
} else {
-
$payload = isset($event['payload']) ? wu_maybe_lazy_load_payload($event['payload']) : '{}';
$payload = array_map('htmlentities2', $payload);
wp_send_json_success($payload);
-
- } // end if;
-
- } // end event_payload_preview;
+ }
+ }
/**
* Returns the list of event types to register.
@@ -263,8 +239,7 @@ class Event_Manager extends Base_Manager {
$types = array_filter($types, fn($item) => $item['hidden'] === false);
return $types;
-
- } // end get_event_type_as_options;
+ }
/**
* Add a new event.
@@ -280,23 +255,17 @@ class Event_Manager extends Base_Manager {
$registered_event = $this->get_event($slug);
- if (!$registered_event) {
-
+ if ( ! $registered_event) {
return array('error' => 'Event not found');
-
- } // end if;
+ }
$payload_diff = array_diff_key(wu_maybe_lazy_load_payload($registered_event['payload']), $payload);
if (isset($payload_diff[0])) {
-
foreach ($payload_diff[0] as $diff_key => $diff_value) {
-
return array('error' => 'Param required:' . $diff_key);
-
- } // end foreach;
-
- } // end if;
+ }
+ }
$payload['wu_version'] = wu_get_version();
@@ -308,8 +277,7 @@ class Event_Manager extends Base_Manager {
* Saves in the database
*/
$this->save_event($slug, $payload);
-
- } // end do_event;
+ }
/**
* Register a new event to be used as param.
@@ -323,11 +291,10 @@ class Event_Manager extends Base_Manager {
*/
public function register_event($slug, $args): bool {
- $this->events[$slug] = $args;
+ $this->events[ $slug ] = $args;
return true;
-
- } // end register_event;
+ }
/**
* Returns the list of available webhook events.
@@ -338,8 +305,7 @@ class Event_Manager extends Base_Manager {
public function get_events() {
return $this->events;
-
- } // end get_events;
+ }
/**
* Returns the list of available webhook events.
@@ -354,22 +320,15 @@ class Event_Manager extends Base_Manager {
$events = $this->get_events();
if ($events) {
-
foreach ($events as $key => $event) {
-
if ($key === $slug) {
-
return $event;
-
- } // end if;
-
- } // end foreach;
-
- } // end if;
+ }
+ }
+ }
return false;
-
- } // end get_event;
+ }
/**
* Saves event in the database.
@@ -380,18 +339,19 @@ class Event_Manager extends Base_Manager {
*/
public function save_event($slug, $payload) {
- $event = new Event(array(
- 'object_id' => wu_get_isset($payload, 'object_id', ''),
- 'object_type' => wu_get_isset($payload, 'object_type', ''),
- 'severity' => wu_get_isset($payload, 'type', Event::SEVERITY_INFO),
- 'date_created' => wu_get_current_time('mysql', true),
- 'slug' => strtolower($slug),
- 'payload' => $payload,
- ));
+ $event = new Event(
+ array(
+ 'object_id' => wu_get_isset($payload, 'object_id', ''),
+ 'object_type' => wu_get_isset($payload, 'object_type', ''),
+ 'severity' => wu_get_isset($payload, 'type', Event::SEVERITY_INFO),
+ 'date_created' => wu_get_current_time('mysql', true),
+ 'slug' => strtolower($slug),
+ 'payload' => $payload,
+ )
+ );
$event->save();
-
- } // end save_event;
+ }
/**
* Registers the list of default events.
@@ -404,80 +364,94 @@ class Event_Manager extends Base_Manager {
/**
* Payment Received.
*/
- wu_register_event_type('payment_received', array(
- 'name' => __('Payment Received', 'wp-ultimo'),
- 'desc' => __('This event is fired every time a new payment is received, regardless of the payment status.', 'wp-ultimo'),
- 'payload' => fn() => array_merge(
+ wu_register_event_type(
+ 'payment_received',
+ array(
+ 'name' => __('Payment Received', 'wp-ultimo'),
+ 'desc' => __('This event is fired every time a new payment is received, regardless of the payment status.', 'wp-ultimo'),
+ 'payload' => fn() => array_merge(
wu_generate_event_payload('payment'),
wu_generate_event_payload('membership'),
wu_generate_event_payload('customer')
),
- 'deprecated_args' => array(
- 'user_id' => 'customer_user_id',
- 'amount' => 'payment_total',
- 'gateway' => 'payment_gateway',
- 'status' => 'payment_status',
- 'date' => 'payment_date_created',
- ),
- ));
+ 'deprecated_args' => array(
+ 'user_id' => 'customer_user_id',
+ 'amount' => 'payment_total',
+ 'gateway' => 'payment_gateway',
+ 'status' => 'payment_status',
+ 'date' => 'payment_date_created',
+ ),
+ )
+ );
/**
* Site Published.
*/
- wu_register_event_type('site_published', array(
- 'name' => __('Site Published', 'wp-ultimo'),
- 'desc' => __('This event is fired every time a new site is created tied to a membership, or transitions from a pending state to a published state.', 'wp-ultimo'),
- 'payload' => fn() => array_merge(
+ wu_register_event_type(
+ 'site_published',
+ array(
+ 'name' => __('Site Published', 'wp-ultimo'),
+ 'desc' => __('This event is fired every time a new site is created tied to a membership, or transitions from a pending state to a published state.', 'wp-ultimo'),
+ 'payload' => fn() => array_merge(
wu_generate_event_payload('site'),
wu_generate_event_payload('customer'),
wu_generate_event_payload('membership')
),
- 'deprecated_args' => array(),
- ));
+ 'deprecated_args' => array(),
+ )
+ );
/**
* Confirm Email Address
*/
- wu_register_event_type('confirm_email_address', array(
- 'name' => __('Email Verification Needed', 'wp-ultimo'),
- 'desc' => __('This event is fired every time a new customer is added with an email verification status of pending.', 'wp-ultimo'),
- 'payload' => fn() => array_merge(
+ wu_register_event_type(
+ 'confirm_email_address',
+ array(
+ 'name' => __('Email Verification Needed', 'wp-ultimo'),
+ 'desc' => __('This event is fired every time a new customer is added with an email verification status of pending.', 'wp-ultimo'),
+ 'payload' => fn() => array_merge(
array(
'verification_link' => 'https://linktoverifyemail.com',
),
wu_generate_event_payload('customer')
),
- 'deprecated_args' => array(),
- ));
+ 'deprecated_args' => array(),
+ )
+ );
/**
* Domain Mapping Added
*/
- wu_register_event_type('domain_created', array(
- 'name' => __('New Domain Mapping Added', 'wp-ultimo'),
- 'desc' => __('This event is fired every time a new domain mapping is added by a customer.', 'wp-ultimo'),
- 'payload' => fn() => array_merge(
+ wu_register_event_type(
+ 'domain_created',
+ array(
+ 'name' => __('New Domain Mapping Added', 'wp-ultimo'),
+ 'desc' => __('This event is fired every time a new domain mapping is added by a customer.', 'wp-ultimo'),
+ 'payload' => fn() => array_merge(
wu_generate_event_payload('domain'),
wu_generate_event_payload('site'),
wu_generate_event_payload('membership'),
wu_generate_event_payload('customer')
),
- 'deprecated_args' => array(
- 'user_id' => 1,
- 'user_site_id' => 1,
- 'mapped_domain' => 'mydomain.com',
- 'user_site_url' => 'http://test.mynetwork.com/',
- 'network_ip' => '125.399.3.23',
- ),
- ));
+ 'deprecated_args' => array(
+ 'user_id' => 1,
+ 'user_site_id' => 1,
+ 'mapped_domain' => 'mydomain.com',
+ 'user_site_url' => 'http://test.mynetwork.com/',
+ 'network_ip' => '125.399.3.23',
+ ),
+ )
+ );
/**
* Renewal payment created
*/
- wu_register_event_type('renewal_payment_created', array(
- 'name' => __('New Renewal Payment Created', 'wp-ultimo'),
- 'desc' => __('This event is fired every time a new renewal payment is created by WP Multisite WaaS.', 'wp-ultimo'),
- 'payload' => fn() => array_merge(
+ wu_register_event_type(
+ 'renewal_payment_created',
+ array(
+ 'name' => __('New Renewal Payment Created', 'wp-ultimo'),
+ 'desc' => __('This event is fired every time a new renewal payment is created by WP Multisite WaaS.', 'wp-ultimo'),
+ 'payload' => fn() => array_merge(
array(
'default_payment_url' => 'https://linktopayment.com',
),
@@ -485,31 +459,30 @@ class Event_Manager extends Base_Manager {
wu_generate_event_payload('membership'),
wu_generate_event_payload('customer')
),
- 'deprecated_args' => array(),
- ));
+ 'deprecated_args' => array(),
+ )
+ );
$models = $this->models_events;
foreach ($models as $model => $params) {
-
foreach ($params['types'] as $type) {
-
- wu_register_event_type($model . '_' . $type, array(
- 'name' => sprintf(__('%1$s %2$s', 'wp-ultimo'), $params['label'], ucfirst($type)),
- 'desc' => sprintf(__('This event is fired every time a %1$s is %2$s by WP Multisite WaaS.', 'wp-ultimo'), $params['label'], $type),
- 'deprecated_args' => array(),
- 'payload' => fn() => $this->get_model_payload($model),
- ));
-
- } // end foreach;
+ wu_register_event_type(
+ $model . '_' . $type,
+ array(
+ 'name' => sprintf(__('%1$s %2$s', 'wp-ultimo'), $params['label'], ucfirst($type)),
+ 'desc' => sprintf(__('This event is fired every time a %1$s is %2$s by WP Multisite WaaS.', 'wp-ultimo'), $params['label'], $type),
+ 'deprecated_args' => array(),
+ 'payload' => fn() => $this->get_model_payload($model),
+ )
+ );
+ }
add_action("wu_{$model}_post_save", array($this, 'dispatch_base_model_event'), 10, 3);
-
- } // end foreach;
+ }
do_action('wu_register_all_events');
-
- } // end register_all_events;
+ }
/**
* Register models events
@@ -523,12 +496,11 @@ class Event_Manager extends Base_Manager {
$instance = self::get_instance();
- $instance->models_events[$slug] = array(
+ $instance->models_events[ $slug ] = array(
'label' => $label,
'types' => $event_types,
);
-
- } // end register_model_events;
+ }
/**
* Dispatch registered model events
@@ -547,17 +519,14 @@ class Event_Manager extends Base_Manager {
$registered_model = wu_get_isset($this->models_events, $model);
- if (!$registered_model || !in_array($type, $registered_model['types'], true)) {
-
+ if ( ! $registered_model || ! in_array($type, $registered_model['types'], true)) {
return;
-
- } // end if;
+ }
$payload = $this->get_model_payload($model, $obj);
wu_do_event($model . '_' . $type, $payload);
-
- } // end dispatch_base_model_event;
+ }
/**
* Returns the full payload for a given model.
@@ -574,31 +543,25 @@ class Event_Manager extends Base_Manager {
$payload = wu_generate_event_payload($model, $obj);
if (method_exists($obj, 'get_membership')) {
-
$membership = $model_object ? $obj->get_membership() : false;
$payload = array_merge(
$payload,
wu_generate_event_payload('membership', $membership)
);
-
- } // end if;
+ }
if (method_exists($obj, 'get_customer')) {
-
$customer = $model_object ? $obj->get_customer() : false;
$payload = array_merge(
$payload,
wu_generate_event_payload('customer', $customer)
);
-
- } // end if;
+ }
if (method_exists($obj, 'get_billing_address') || method_exists($obj, 'get_membership')) {
-
if ($model_object) {
-
$payload = method_exists($obj, 'get_billing_address')
? array_merge(
$payload,
@@ -607,23 +570,21 @@ class Event_Manager extends Base_Manager {
$payload,
$obj->get_membership()->get_billing_address()->to_array()
);
-
} else {
-
$payload = array_merge(
$payload,
- array_map(function () {
- return '';
- }, \WP_Ultimo\Objects\Billing_Address::fields())
+ array_map(
+ function () {
+ return '';
+ },
+ \WP_Ultimo\Objects\Billing_Address::fields()
+ )
);
-
- } // end if;
-
- } // end if;
+ }
+ }
return $payload;
-
- } // end get_model_payload;
+ }
/**
* Every day, deletes old events that we don't want to keep.
@@ -638,39 +599,34 @@ class Event_Manager extends Base_Manager {
$threshold_days = apply_filters('wu_events_threshold_days', 1);
if (empty($threshold_days)) {
-
return false;
+ }
- } // end if;
-
- $events_to_remove = wu_get_events(array(
- 'number' => 100,
- 'date_query' => array(
- 'column' => 'date_created',
- 'before' => "-{$threshold_days} days",
- 'inclusive' => true,
- ),
- ));
+ $events_to_remove = wu_get_events(
+ array(
+ 'number' => 100,
+ 'date_query' => array(
+ 'column' => 'date_created',
+ 'before' => "-{$threshold_days} days",
+ 'inclusive' => true,
+ ),
+ )
+ );
$success_count = 0;
foreach ($events_to_remove as $event) {
-
$status = $event->delete();
- if (!is_wp_error($status) && $status) {
-
- $success_count++;
-
- } // end if;
-
- } // end foreach;
+ if ( ! is_wp_error($status) && $status) {
+ ++$success_count;
+ }
+ }
wu_log_add('wu-cron', sprintf(__('Removed %1$d events successfully. Failed to remove %2$d events.', 'wp-ultimo'), $success_count, count($events_to_remove) - $success_count));
return true;
-
- } // end clean_old_events;
+ }
/**
* Create a endpoint to retrieve all available event hooks.
@@ -681,21 +637,22 @@ class Event_Manager extends Base_Manager {
*/
public function hooks_endpoint() {
- if (!wu_get_setting('enable_api', true)) {
-
+ if ( ! wu_get_setting('enable_api', true)) {
return;
-
- } // end if;
+ }
$api = \WP_Ultimo\API::get_instance();
- register_rest_route($api->get_namespace(), '/hooks', array(
- 'methods' => 'GET',
- 'callback' => array($this, 'get_hooks_rest'),
- 'permission_callback' => array($api, 'check_authorization'),
- ));
-
- } // end hooks_endpoint;
+ register_rest_route(
+ $api->get_namespace(),
+ '/hooks',
+ array(
+ 'methods' => 'GET',
+ 'callback' => array($this, 'get_hooks_rest'),
+ 'permission_callback' => array($api, 'check_authorization'),
+ )
+ );
+ }
/**
* Return all event types for the REST API request.
@@ -710,19 +667,13 @@ class Event_Manager extends Base_Manager {
$response = wu_get_event_types();
foreach ($response as $key => $value) {
-
$payload = wu_get_isset($value, 'payload');
if (is_callable($payload)) {
-
- $response[$key]['payload'] = $payload();
-
- } // end if;
-
- } // end foreach;
+ $response[ $key ]['payload'] = $payload();
+ }
+ }
return rest_ensure_response($response);
-
- } // end get_hooks_rest;
-
-} // end class Event_Manager;
+ }
+}
diff --git a/inc/managers/class-field-templates-manager.php b/inc/managers/class-field-templates-manager.php
index 0b53928..ed32687 100644
--- a/inc/managers/class-field-templates-manager.php
+++ b/inc/managers/class-field-templates-manager.php
@@ -11,7 +11,7 @@
namespace WP_Ultimo\Managers;
-use \WP_Ultimo\Managers\Base_Manager;
+use WP_Ultimo\Managers\Base_Manager;
// Exit if accessed directly
defined('ABSPATH') || exit;
@@ -44,8 +44,7 @@ class Field_Templates_Manager extends Base_Manager {
add_action('wu_ajax_nopriv_wu_render_field_template', array($this, 'serve_field_template'));
add_action('wu_ajax_wu_render_field_template', array($this, 'serve_field_template'));
-
- } // end init;
+ }
/**
* Serve the HTML markup for the templates.
@@ -61,21 +60,20 @@ class Field_Templates_Manager extends Base_Manager {
$template_class = $this->get_template_class($template_parts[0], $template_parts[1]);
- if (!$template_class) {
-
+ if ( ! $template_class) {
wp_send_json_error(new \WP_Error('template', __('Template not found.', 'wp-ultimo')));
-
- } // end if;
+ }
$key = $template_parts[0];
$attributes = apply_filters("wu_{$key}_render_attributes", wu_request('attributes'));
- wp_send_json_success(array(
- 'html' => $template_class->render($attributes),
- ));
-
- } // end serve_field_template;
+ wp_send_json_success(
+ array(
+ 'html' => $template_class->render($attributes),
+ )
+ );
+ }
/**
* Returns the list of registered signup field types.
@@ -157,8 +155,7 @@ class Field_Templates_Manager extends Base_Manager {
* @return array
*/
return apply_filters('wu_checkout_field_templates', $field_templates);
-
- } // end get_field_templates;
+ }
/**
* Get the field templates for a field type. Returns only the class names.
@@ -171,8 +168,7 @@ class Field_Templates_Manager extends Base_Manager {
public function get_templates($field_type) {
return wu_get_isset($this->get_field_templates(), $field_type, array());
-
- } // end get_templates;
+ }
/**
* Get the instance of the template class.
@@ -188,8 +184,7 @@ class Field_Templates_Manager extends Base_Manager {
$templates = $this->get_instantiated_field_types($field_type);
return wu_get_isset($templates, $field_template_id);
-
- } // end get_template_class;
+ }
/**
* Returns the field templates as a key => title array of options.
@@ -206,14 +201,11 @@ class Field_Templates_Manager extends Base_Manager {
$options = array();
foreach ($templates as $template_id => $template) {
-
- $options[$template_id] = $template->get_title();
-
- } // end foreach;
+ $options[ $template_id ] = $template->get_title();
+ }
return $options;
-
- } // end get_templates_as_options;
+ }
/**
* Returns the field templates as a key => info_array array of fields.
@@ -230,19 +222,16 @@ class Field_Templates_Manager extends Base_Manager {
$options = array();
foreach ($templates as $template_id => $template) {
-
- $options[$template_id] = array(
+ $options[ $template_id ] = array(
'id' => $template_id,
'title' => $template->get_title(),
'description' => $template->get_description(),
'preview' => $template->get_preview(),
);
-
- } // end foreach;
+ }
return $options;
-
- } // end get_templates_info;
+ }
/**
* Instantiate a field template.
@@ -255,8 +244,7 @@ class Field_Templates_Manager extends Base_Manager {
public function instantiate_field_template($class_name) {
return new $class_name();
-
- } // end instantiate_field_template;
+ }
/**
* Returns an array with all fields, instantiated.
@@ -269,15 +257,12 @@ class Field_Templates_Manager extends Base_Manager {
$holder_name = "instantiated_{$field_type}_templates";
- if (!isset($this->holders[$holder_name]) || $this->holders[$holder_name] === null) {
+ if ( ! isset($this->holders[ $holder_name ]) || $this->holders[ $holder_name ] === null) {
+ $this->holders[ $holder_name ] = array_map(array($this, 'instantiate_field_template'), $this->get_templates($field_type));
+ }
- $this->holders[$holder_name] = array_map(array($this, 'instantiate_field_template'), $this->get_templates($field_type));
-
- } // end if;
-
- return $this->holders[$holder_name];
-
- } // end get_instantiated_field_types;
+ return $this->holders[ $holder_name ];
+ }
/**
* Render preview block.
@@ -291,22 +276,24 @@ class Field_Templates_Manager extends Base_Manager {
$preview_block = '
- Log in using your account.', 'wp-ultimo'), wp_get_current_user()->display_name, $login_url);
+ // translators: 1$s is the display name of the user currently logged in.
+ printf(__('Not %1$s? Log in using your account.', 'wp-ultimo'), wp_get_current_user()->display_name, $login_url);
- ?>
+ ?>
-
-} else { ?>
+
+ /**
+ * Required: Prints the essential fields necessary to this form to work properly
+ */
+ $signup->form_fields($current_plan);
-
- /**
- * Required: Prints the essential fields necessary to this form to work properly
- */
- $signup->form_fields($current_plan);
+
- $field) {
+ foreach ($fields as $field_slug => $field) {
- /**
- * Prints each of our fields using a helper function
- */
- wu_print_signup_field($field_slug, $field, $results);
+ /**
+ * Prints each of our fields using a helper function
+ */
+ wu_print_signup_field($field_slug, $field, $results);
+ } // end foreach;
- } // end foreach;
+ ?>
- ?>
+ step"); ?>
- step"); ?>
-
-
-
- this tutorial to create the wildcard entry and deactivate this integration entirely.', 'wp-ultimo'), 'https://support.cloudflare.com/hc/en-us/articles/200169356-How-do-I-use-WordPress-Multi-Site-WPMU-With-Cloudflare'); ?>
+
+ this tutorial to create the wildcard entry and deactivate this integration entirely.', 'wp-ultimo'), 'https://support.cloudflare.com/hc/en-us/articles/200169356-How-do-I-use-WordPress-Multi-Site-WPMU-With-Cloudflare'); ?>
Follow the steps 1 and 2 of the official Cloudways tutorial to obtain an API key for your account (Read the tutorial). Copy the API Key as we will need it in the following steps.
-
Step 2: Get the Server ID
-
The next piece of information we will need is the server ID of the server hosting your WordPress install on Cloudways. To discover the server ID, visit the Server Management screen of the server. The server ID will be present on the URL of that page after the “/server/” portion of it.
-
-
-
-
The URL takes the form of https://platform.cloudways.com/server/SERVER_ID_HERE/access_detail
-
Step 3: Get the App ID
-
We’ll need to do a similar thing to obtain the App ID for your WordPress installation. Go to Application Management screen of your WordPress app and the App ID will be present on the URL, after the “/apps/” portion of it.
-
-
-
-
The same thing happens here: the URL takes the form of https://platform.cloudways.com/apps/YOUR_APP_ID_HERE/access_detail
+
Step 1: Getting a Cloudways API Key
+
Follow the steps 1 and 2 of the official Cloudways tutorial to obtain an API key for your account (Read the tutorial). Copy the API Key as we will need it in the following steps.
+
Step 2: Get the Server ID
+
The next piece of information we will need is the server ID of the server hosting your WordPress install on Cloudways. To discover the server ID, visit the Server Management screen of the server. The server ID will be present on the URL of that page after the “/server/” portion of it.
+
+
+
+
The URL takes the form of https://platform.cloudways.com/server/SERVER_ID_HERE/access_detail
+
Step 3: Get the App ID
+
We’ll need to do a similar thing to obtain the App ID for your WordPress installation. Go to Application Management screen of your WordPress app and the App ID will be present on the URL, after the “/apps/” portion of it.
+
+
+
+
The same thing happens here: the URL takes the form of https://platform.cloudways.com/apps/YOUR_APP_ID_HERE/access_detail
-
Additional Step – Extra Domains
-
The Cloudways API is a bit strange in that it doesn’t offer a way to add or remove just one domain, only a way to update the whole domain list. That means that WP Multisite WaaS will replace all domains you might have there with the list of mapped domains of the network every time a new domain is added.
-
If there are domains you want to keep on the list, use the WU_CLOUDWAYS_EXTRA_DOMAINS as demonstrated below, with a comma-separated list of the domains you wanna keep (this is useful if you need a wildcard setting, for example, that needs to be on that list at all times).
Here’s how it should look on your wp-config.php (fake values used below):
-
-
-
-
You’re all set!
-
Now, every time a new domain is mapped in the network (via the Aliases tab by the network admin or via the custom domain meta-box on the user’s Account page) will be added to the Cloudways platform automatically.
-
The same is true for domain removals. Every time a domain is deleted from the network, that change will be communicated to your Cloudways account instantly!
+
Additional Step – Extra Domains
+
The Cloudways API is a bit strange in that it doesn’t offer a way to add or remove just one domain, only a way to update the whole domain list. That means that WP Multisite WaaS will replace all domains you might have there with the list of mapped domains of the network every time a new domain is added.
+
If there are domains you want to keep on the list, use the WU_CLOUDWAYS_EXTRA_DOMAINS as demonstrated below, with a comma-separated list of the domains you wanna keep (this is useful if you need a wildcard setting, for example, that needs to be on that list at all times).
Here’s how it should look on your wp-config.php (fake values used below):
+
+
+
+
You’re all set!
+
Now, every time a new domain is mapped in the network (via the Aliases tab by the network admin or via the custom domain meta-box on the user’s Account page) will be added to the Cloudways platform automatically.
+
The same is true for domain removals. Every time a domain is deleted from the network, that change will be communicated to your Cloudways account instantly!
In Your ServerPilot admin panel, first go to the Account Settings page and navigate to the API link, there you can get the API Key and Client ID (if the API Key field is empty, click the New API Key button). Paste those values somewhere as we'll need them in a later step.
-
-
-
+
Step 1: Getting the API Key and the Client ID
+
In Your ServerPilot admin panel, first go to the Account Settings page and navigate to the API link, there you can get the API Key and Client ID (if the API Key field is empty, click the New API Key button). Paste those values somewhere as we'll need them in a later step.
+
+
+
-
Step 2: Getting the App ID
-
Next, we’ll need to get the App ID for your WordPress site. To find that ID, navigate to your app’s manage page:
-
-
-
-
Then, take a look at the URL at the top of your browser. The APP ID is the portion between the app/ and the /settings segments of the URL.
+
Step 2: Getting the App ID
+
Next, we’ll need to get the App ID for your WordPress site. To find that ID, navigate to your app’s manage page:
+
+
+
+
Then, take a look at the URL at the top of your browser. The APP ID is the portion between the app/ and the /settings segments of the URL.
-
-
-
+
+
+
-
After this you can proceed to the next integration step where you can paste these values in the related fields.
+
After this you can proceed to the next integration step where you can paste these values in the related fields.
- Read More links on each item to see what steps you need to take to bring your environment up to the WP Multisite WaaS current requirements.', 'wp-ultimo'); ?>
-
+
+ Read More links on each item to see what steps you need to take to bring your environment up to the WP Multisite WaaS current requirements.', 'wp-ultimo'); ?>
+
support@wpultimo.com and includes:', 'wp-ultimo'); ?>
+
support@wpultimo.com and includes:', 'wp-ultimo'); ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
DOES NOT Include:', 'wp-ultimo'); ?>
+
DOES NOT Include:', 'wp-ultimo'); ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/wp-multisite-waas.php b/wp-multisite-waas.php
index a2f903f..009ee5a 100644
--- a/wp-multisite-waas.php
+++ b/wp-multisite-waas.php
@@ -38,10 +38,10 @@ defined('ABSPATH') || exit;
if ( defined('WP_SANDBOX_SCRAPING') && WP_SANDBOX_SCRAPING ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
- if ( is_plugin_active( 'wp-ultimo/wp-ultimo.php' ) ) {
+ if ( is_plugin_active('wp-ultimo/wp-ultimo.php') ) {
// old plugin still installed and active with the old name and path
// and the user is trying to activate this plugin. So deactivate and return.
- deactivate_plugins( 'wp-ultimo/wp-ultimo.php', true, true);
+ deactivate_plugins('wp-ultimo/wp-ultimo.php', true, true);
if ( file_exists(WP_CONTENT_DIR . '/sunrise.php')) {
// We must override the old sunrise file or more name conflicts will occur.
@@ -51,7 +51,7 @@ if ( defined('WP_SANDBOX_SCRAPING') && WP_SANDBOX_SCRAPING ) {
}
}
-if (!defined('WP_ULTIMO_PLUGIN_FILE')) {
+if ( ! defined('WP_ULTIMO_PLUGIN_FILE')) {
define('WP_ULTIMO_PLUGIN_FILE', __FILE__);
}
@@ -82,9 +82,7 @@ if ( ! function_exists('WP_Ultimo')) {
* @since 2.0.0
*/
function WP_Ultimo() { // phpcs:ignore
-
return WP_Ultimo::get_instance();
-
} // end WP_Ultimo;
}
// Initialize and set to global for back-compat