diff --git a/inc/admin-pages/class-base-admin-page.php b/inc/admin-pages/class-base-admin-page.php index 2b7d1e2..5194ba6 100644 --- a/inc/admin-pages/class-base-admin-page.php +++ b/inc/admin-pages/class-base-admin-page.php @@ -240,7 +240,7 @@ abstract class Base_Admin_Page { global $submenu; - if ($this->get_submenu_title() && $this->type === 'menu' && isset($submenu[ $this->id ]) && $submenu[ $this->id ][0][3] === $this->get_title()) { + if ($this->get_submenu_title() && 'menu' === $this->type && isset($submenu[ $this->id ]) && $submenu[ $this->id ][0][3] === $this->get_title()) { $submenu[ $this->id ][0][0] = $this->get_submenu_title(); } } @@ -416,7 +416,7 @@ abstract class Base_Admin_Page { /** * Create the admin page or sub-page */ - $this->page_hook = $this->type === 'menu' ? $this->add_toplevel_menu_page() : $this->add_submenu_page(); + $this->page_hook = 'menu' === $this->type ? $this->add_toplevel_menu_page() : $this->add_submenu_page(); /** * Add the default hooks diff --git a/inc/admin-pages/class-base-customer-facing-admin-page.php b/inc/admin-pages/class-base-customer-facing-admin-page.php index 5e135af..5dca316 100644 --- a/inc/admin-pages/class-base-customer-facing-admin-page.php +++ b/inc/admin-pages/class-base-customer-facing-admin-page.php @@ -196,7 +196,7 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page { */ public function handle_edit_page(): void { - $settings_to_save = wu_request('submit') !== 'restore' ? $_POST : []; // don't worry, this gets cleaned later on. + $settings_to_save = 'restore' !== wu_request('submit') ? $_POST : []; // don't worry, this gets cleaned later on. $this->save_page_settings($settings_to_save); @@ -413,7 +413,7 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page { */ public function save_settings($meta_id, $user_id, $meta_key, $_meta_value): void { - if (wu_request('action') !== 'meta-box-order') { + if ('meta-box-order' !== wu_request('action')) { return; } diff --git a/inc/admin-pages/class-broadcast-edit-admin-page.php b/inc/admin-pages/class-broadcast-edit-admin-page.php index 0ae617d..1c41a75 100644 --- a/inc/admin-pages/class-broadcast-edit-admin-page.php +++ b/inc/admin-pages/class-broadcast-edit-admin-page.php @@ -195,7 +195,7 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page { "; break; - case $targets_count === 1: + case 1 === $targets_count: $customer = wu_get_customer($targets[0]); $url_atts = [ diff --git a/inc/admin-pages/class-broadcast-list-admin-page.php b/inc/admin-pages/class-broadcast-list-admin-page.php index 0aab802..bb8083d 100644 --- a/inc/admin-pages/class-broadcast-list-admin-page.php +++ b/inc/admin-pages/class-broadcast-list-admin-page.php @@ -118,7 +118,7 @@ class Broadcast_List_Admin_Page extends List_Admin_Page { $display_targets = []; if ($targets) { - if ($target_type === 'customers') { + if ('customers' === $target_type) { foreach ($targets as $key => $value) { $customer = wu_get_customer($value); @@ -149,7 +149,7 @@ class Broadcast_List_Admin_Page extends List_Admin_Page { } } - if ($target_type === 'products') { + if ('products' === $target_type) { foreach ($targets as $key => $value) { $product = wu_get_product($value); diff --git a/inc/admin-pages/class-checkout-form-edit-admin-page.php b/inc/admin-pages/class-checkout-form-edit-admin-page.php index ef7b823..181908e 100644 --- a/inc/admin-pages/class-checkout-form-edit-admin-page.php +++ b/inc/admin-pages/class-checkout-form-edit-admin-page.php @@ -187,7 +187,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { $preview_type = wu_request('type', 'user'); - if ($preview_type === 'visitor') { + if ('visitor' === $preview_type) { global $current_user; $current_user = wp_set_current_user(0); @@ -549,13 +549,13 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { ] ); - if ($default_field_slug === 'name' || $default_field_slug === 'id' || $default_field_slug === 'default_value') { + if ('name' === $default_field_slug || 'id' === $default_field_slug || 'default_value' === $default_field_slug) { unset($default_field['wrapper_html_attr']['v-if']); $default_field['wrapper_html_attr']['v-show'] = sprintf('type && require("type", %s) && require("tab", "%s")', json_encode($reqs), $tab); } - if ($default_field_slug === 'id') { + if ('id' === $default_field_slug) { $default_field['html_attr']['v-bind:required'] = sprintf('type && require("type", %s) && require("tab", "content")', json_encode($reqs)); } } @@ -701,7 +701,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { $state = array_map( function ($value) { - if ($value === 'false' || $value === 'true') { + if ('false' === $value || 'true' === $value) { $value = (int) wu_string_to_bool($value); } diff --git a/inc/admin-pages/class-discount-code-edit-admin-page.php b/inc/admin-pages/class-discount-code-edit-admin-page.php index 322b784..c571cd9 100644 --- a/inc/admin-pages/class-discount-code-edit-admin-page.php +++ b/inc/admin-pages/class-discount-code-edit-admin-page.php @@ -623,6 +623,7 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page { return $this->object; } + /** * Discount_Codes have titles. * diff --git a/inc/admin-pages/class-domain-edit-admin-page.php b/inc/admin-pages/class-domain-edit-admin-page.php index 1c5e214..61668e0 100644 --- a/inc/admin-pages/class-domain-edit-admin-page.php +++ b/inc/admin-pages/class-domain-edit-admin-page.php @@ -511,6 +511,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page { return $this->object; } + /** * Domains have titles. * diff --git a/inc/admin-pages/class-edit-admin-page.php b/inc/admin-pages/class-edit-admin-page.php index d826cab..71d5d34 100644 --- a/inc/admin-pages/class-edit-admin-page.php +++ b/inc/admin-pages/class-edit-admin-page.php @@ -367,7 +367,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { $show_modified = wu_get_isset($atts, 'modified', true); - if ($this->edit && $show_modified === true) { + if ($this->edit && true === $show_modified) { $atts['fields']['date_modified'] = [ 'title' => __('Last Modified at', 'wp-ultimo'), 'type' => 'text-display', diff --git a/inc/admin-pages/class-email-edit-admin-page.php b/inc/admin-pages/class-email-edit-admin-page.php index 142d51b..d8ef1a6 100644 --- a/inc/admin-pages/class-email-edit-admin-page.php +++ b/inc/admin-pages/class-email-edit-admin-page.php @@ -496,7 +496,7 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page { */ public function handle_page_redirect($page): void { - if ($page->get_id() === 'wp-ultimo-edit-email') { + if ('wp-ultimo-edit-email' === $page->get_id()) { if (wu_request('test_notice')) { $test_notice = wu_request('test_notice'); diff --git a/inc/admin-pages/class-event-view-admin-page.php b/inc/admin-pages/class-event-view-admin-page.php index 6eb1bef..238c84c 100644 --- a/inc/admin-pages/class-event-view-admin-page.php +++ b/inc/admin-pages/class-event-view-admin-page.php @@ -276,6 +276,7 @@ class Event_View_Admin_Page extends Edit_Admin_Page { exit; } + /** * Events have titles. * @@ -285,6 +286,7 @@ class Event_View_Admin_Page extends Edit_Admin_Page { return false; } + /** * Handles the save of this form. * diff --git a/inc/admin-pages/class-list-admin-page.php b/inc/admin-pages/class-list-admin-page.php index 02821df..07a63b6 100644 --- a/inc/admin-pages/class-list-admin-page.php +++ b/inc/admin-pages/class-list-admin-page.php @@ -26,6 +26,7 @@ abstract class List_Admin_Page extends Base_Admin_Page { * @var bool */ public $has_search; + /** * The id/name/slug of the object being edited/created. e.g: plan * @@ -209,7 +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; + return false === $value && is_numeric($other_value) ? (int) $other_value : $value; } /** diff --git a/inc/admin-pages/class-membership-edit-admin-page.php b/inc/admin-pages/class-membership-edit-admin-page.php index 481d01a..8f3b55e 100644 --- a/inc/admin-pages/class-membership-edit-admin-page.php +++ b/inc/admin-pages/class-membership-edit-admin-page.php @@ -1120,6 +1120,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { return $this->object; } + /** * Memberships have titles. * @@ -1129,6 +1130,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { return false; } + /** * Handle convert to lifetime. * diff --git a/inc/admin-pages/class-payment-edit-admin-page.php b/inc/admin-pages/class-payment-edit-admin-page.php index e5490ad..c1ce10f 100644 --- a/inc/admin-pages/class-payment-edit-admin-page.php +++ b/inc/admin-pages/class-payment-edit-admin-page.php @@ -537,7 +537,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { */ $type = wu_request('type', 'product'); - if ($type === 'product') { + if ('product' === $type) { $product = wu_get_product(wu_request('product_id')); if (empty($product)) { @@ -1270,7 +1270,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { static $payment; - if ($payment !== null) { + if (null !== $payment) { return $payment; } @@ -1292,6 +1292,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { return new Payment(); } + /** * Payments have titles. * diff --git a/inc/admin-pages/class-product-edit-admin-page.php b/inc/admin-pages/class-product-edit-admin-page.php index 514da3f..585e4be 100644 --- a/inc/admin-pages/class-product-edit-admin-page.php +++ b/inc/admin-pages/class-product-edit-admin-page.php @@ -1050,6 +1050,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { return $this->object; } + /** * Products have titles. * diff --git a/inc/admin-pages/class-settings-admin-page.php b/inc/admin-pages/class-settings-admin-page.php index 36864f1..b89bae6 100644 --- a/inc/admin-pages/class-settings-admin-page.php +++ b/inc/admin-pages/class-settings-admin-page.php @@ -520,7 +520,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page { wp_die(__('You do not have the permissions required to change settings.', 'wp-ultimo')); } - if ( ! isset($_POST['active_gateways']) && wu_request('tab') === 'payment-gateways') { + if ( ! isset($_POST['active_gateways']) && 'payment-gateways' === wu_request('tab')) { $_POST['active_gateways'] = []; } diff --git a/inc/admin-pages/class-setup-wizard-admin-page.php b/inc/admin-pages/class-setup-wizard-admin-page.php index cfc4984..727a88f 100644 --- a/inc/admin-pages/class-setup-wizard-admin-page.php +++ b/inc/admin-pages/class-setup-wizard-admin-page.php @@ -735,9 +735,9 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { $step = wu_request('step'); - if ($step === 'your-company') { + if ('your-company' === $step) { $fields_to_save = $this->get_general_settings(); - } elseif ($step === 'payment-gateways') { + } elseif ('payment-gateways' === $step) { $fields_to_save = $this->get_payment_settings(); } else { return; diff --git a/inc/admin-pages/class-site-edit-admin-page.php b/inc/admin-pages/class-site-edit-admin-page.php index 9af44f3..d15ebe0 100644 --- a/inc/admin-pages/class-site-edit-admin-page.php +++ b/inc/admin-pages/class-site-edit-admin-page.php @@ -738,6 +738,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { return $this->object; } + /** * Sites have titles. * diff --git a/inc/admin-pages/class-site-list-admin-page.php b/inc/admin-pages/class-site-list-admin-page.php index 15d4e82..4e2d07b 100644 --- a/inc/admin-pages/class-site-list-admin-page.php +++ b/inc/admin-pages/class-site-list-admin-page.php @@ -239,7 +239,7 @@ class Site_List_Admin_Page extends List_Admin_Page { $domain_type = wu_request('tab', is_subdomain_install() ? 'sub-domain' : 'sub-directory'); - if ($domain_type === 'domain') { + if ('domain' === $domain_type) { $domain = wu_request('domain', ''); $path = '/'; } else { diff --git a/inc/admin-pages/class-system-info-admin-page.php b/inc/admin-pages/class-system-info-admin-page.php index fff4973..704d77a 100644 --- a/inc/admin-pages/class-system-info-admin-page.php +++ b/inc/admin-pages/class-system-info-admin-page.php @@ -630,7 +630,7 @@ class System_Info_Admin_Page extends Base_Admin_Page { // Finally get the correct version number $known = ['Version', $browser_name_short, 'other']; - $pattern = '#(?' . join('|', $known) . ')[/ ]+(?[0-9.|a-zA-Z.]*)#'; + $pattern = '#(?' . implode('|', $known) . ')[/ ]+(?[0-9.|a-zA-Z.]*)#'; if ( ! preg_match_all($pattern, (string) $user_agent, $matches)) { // We have no matching number just continue @@ -639,7 +639,7 @@ class System_Info_Admin_Page extends Base_Admin_Page { // See how many we have $i = count($matches['browser']); - if ($i !== 1) { + if (1 !== $i) { // We will have two since we are not using 'other' argument yet // See if version is before or after the name @@ -695,6 +695,7 @@ class System_Info_Admin_Page extends Base_Admin_Page { return (array) get_option('active_plugins', []); } + /** * Get memory usage */ diff --git a/inc/admin-pages/class-view-logs-admin-page.php b/inc/admin-pages/class-view-logs-admin-page.php index bd21af3..0422e8f 100644 --- a/inc/admin-pages/class-view-logs-admin-page.php +++ b/inc/admin-pages/class-view-logs-admin-page.php @@ -322,7 +322,7 @@ class View_Logs_Admin_Page extends Edit_Admin_Page { $action = wu_request('submit_button', 'none'); - if ($action === 'none') { + if ('none' === $action) { WP_Ultimo()->notices->add(__('Something wrong happened', 'wp-ultimo'), 'error', 'network-admin'); return; @@ -336,7 +336,7 @@ class View_Logs_Admin_Page extends Edit_Admin_Page { return; } - if ($action === 'download') { + if ('download' === $action) { $file_name = str_replace(Logger::get_logs_folder(), '', (string) $file); header('Content-Type: application/octet-stream'); @@ -346,7 +346,7 @@ class View_Logs_Admin_Page extends Edit_Admin_Page { readfile($file); exit; - } elseif ($action === 'delete') { + } elseif ('delete' === $action) { $status = unlink($file); if ( ! $status) { diff --git a/inc/admin-pages/class-webhook-edit-admin-page.php b/inc/admin-pages/class-webhook-edit-admin-page.php index 281d4cf..76bd49b 100644 --- a/inc/admin-pages/class-webhook-edit-admin-page.php +++ b/inc/admin-pages/class-webhook-edit-admin-page.php @@ -367,6 +367,7 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page { return new Webhook(); } + /** * Webhooks have titles. * diff --git a/inc/admin-pages/customer-panel/class-my-sites-admin-page.php b/inc/admin-pages/customer-panel/class-my-sites-admin-page.php index 80fdeef..c698d1c 100644 --- a/inc/admin-pages/customer-panel/class-my-sites-admin-page.php +++ b/inc/admin-pages/customer-panel/class-my-sites-admin-page.php @@ -110,7 +110,7 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page { $this->register_page_settings(); - if ($this->current_site->get_type() === 'customer_owned') { + if ('customer_owned' === $this->current_site->get_type()) { parent::__construct(); add_action('admin_menu', [$this, 'unset_default_my_sites_menu']); @@ -187,7 +187,7 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page { */ public function force_screen_options(): void { - if (get_current_screen()->id !== 'toplevel_page_sites') { + if ('toplevel_page_sites' !== get_current_screen()->id) { return; } diff --git a/inc/api/class-register-endpoint.php b/inc/api/class-register-endpoint.php index c168e91..202fcaa 100644 --- a/inc/api/class-register-endpoint.php +++ b/inc/api/class-register-endpoint.php @@ -274,7 +274,7 @@ class Register_Endpoint { /* * Deal with status changes. */ - if ($membership_status !== $membership->get_status()) { + if ($membership->get_status() !== $membership_status) { $membership->set_status($membership_status); $membership->save(); @@ -293,7 +293,7 @@ class Register_Endpoint { } } - if ($payment_status !== $payment->get_status()) { + if ($payment->get_status() !== $payment_status) { $payment->set_status($payment_status); $payment->save(); @@ -533,6 +533,7 @@ class Register_Endpoint { return apply_filters('wu_rest_register_endpoint_args', $args, $this); } + /** * Maybe create a customer, if needed. * @@ -675,6 +676,7 @@ class Register_Endpoint { 'site.site_title' => 'required_with:site|min:4', ]; } + /** * Validates the rules and make sure we only save models when necessary. * diff --git a/inc/api/trait-rest-api.php b/inc/api/trait-rest-api.php index c73c7ff..a9e4ad2 100644 --- a/inc/api/trait-rest-api.php +++ b/inc/api/trait-rest-api.php @@ -152,6 +152,7 @@ trait Rest_Api { do_action('wu_rest_register_routes_with_id', $routes, $this->get_rest_base(), 'update', $this); } + /** * Returns a specific item. * @@ -170,6 +171,7 @@ trait Rest_Api { return rest_ensure_response($item); } + /** * Returns a list of items. * @@ -184,6 +186,7 @@ trait Rest_Api { return rest_ensure_response($items); } + /** * Creates an item. * @@ -220,6 +223,7 @@ trait Rest_Api { return rest_ensure_response($item); } + /** * Updates an item. * @@ -247,7 +251,7 @@ trait Rest_Api { foreach ($params as $param => $value) { $set_method = "set_{$param}"; - if ($param === 'meta') { + if ('meta' === $param) { $item->update_meta_batch($value); } elseif (method_exists($item, $set_method)) { call_user_func([$item, $set_method], $value); @@ -279,6 +283,7 @@ trait Rest_Api { return rest_ensure_response($item); } + /** * Deletes an item. * @@ -464,7 +469,7 @@ trait Rest_Api { 'id', ]; - if ($this->slug === 'site') { + if ('site' === $this->slug) { $arr = [ 'id', 'blog_id', @@ -511,7 +516,7 @@ trait Rest_Api { */ apply_filters('wu_before_' . $this->slug . '_api_arguments', $args, $this); - if ($this->slug !== 'broadcast' && isset($args['author_id'])) { + if ('broadcast' !== $this->slug && isset($args['author_id'])) { unset($args['author_id']); } @@ -547,15 +552,15 @@ trait Rest_Api { unset($args['slug']); } - if ($this->slug === 'product' && isset($args['price_variations'])) { + if ('product' === $this->slug && isset($args['price_variations'])) { unset($args['price_variations']); } - if ($this->slug === 'payment' && isset($args['line_items'])) { + if ('payment' === $this->slug && isset($args['line_items'])) { unset($args['line_items']); } - if ($this->slug === 'site') { + if ('site' === $this->slug) { if (isset($args['duplication_arguments'])) { unset($args['duplication_arguments']); } @@ -565,7 +570,7 @@ trait Rest_Api { } } - if ($this->slug === 'email') { + if ('email' === $this->slug) { if (isset($args['status'])) { unset($args['status']); } @@ -575,7 +580,7 @@ trait Rest_Api { } } - if ($this->slug === 'broadcast') { + if ('broadcast' === $this->slug) { if (isset($args['message_targets'])) { unset($args['message_targets']); } diff --git a/inc/api/trait-wp-cli.php b/inc/api/trait-wp-cli.php index d7209f7..678769f 100644 --- a/inc/api/trait-wp-cli.php +++ b/inc/api/trait-wp-cli.php @@ -200,6 +200,7 @@ trait WP_CLI { $this ); } + /** * Allows the additional of additional parameters. * @@ -283,7 +284,7 @@ trait WP_CLI { $success = $item->save(); - if ($success === true) { + if (true === $success) { $item_id = $item->get_id(); if ( ! empty($array_assoc['porcelain'])) { @@ -327,7 +328,7 @@ trait WP_CLI { foreach ($params as $param => $value) { $set_method = "set_{$param}"; - if ($param === 'meta') { + if ('meta' === $param) { $item->update_meta_batch($value); } elseif (method_exists($item, $set_method)) { call_user_func([$item, $set_method], $value); diff --git a/inc/checkout/class-cart.php b/inc/checkout/class-cart.php index 445c02b..07a0031 100644 --- a/inc/checkout/class-cart.php +++ b/inc/checkout/class-cart.php @@ -533,6 +533,7 @@ class Cart implements \JsonSerializable { $this->cart_descriptor = $descriptor; } + /** * Decides if we are trying to recover a payment. * @@ -707,6 +708,7 @@ class Cart implements \JsonSerializable { return true; } + /** * Uses the membership to decide if this is a upgrade/downgrade/addon cart. * @@ -1050,6 +1052,7 @@ class Cart implements \JsonSerializable { */ return true; } + /** * Search for variations of the plans with same duration. * @@ -1235,6 +1238,7 @@ class Cart implements \JsonSerializable { $this->add_line_item($credit_line_item); } + /** * Adds a discount code to the cart. * @@ -1485,6 +1489,7 @@ class Cart implements \JsonSerializable { krsort($this->line_items); } + /** * Adds a new product to the cart. * @@ -1762,6 +1767,7 @@ class Cart implements \JsonSerializable { return $this->recovered_payment; } + /** * Add discount to the order. * @@ -1787,6 +1793,7 @@ class Cart implements \JsonSerializable { return true; } + /** * Get registration discounts. * @@ -1836,6 +1843,7 @@ class Cart implements \JsonSerializable { return array_filter($this->line_items, fn($id) => in_array($id, $ids, true), ARRAY_FILTER_USE_KEY); } + /** * Get registration fees. * @@ -2137,6 +2145,7 @@ class Cart implements \JsonSerializable { return $smallest_trial; } + /** * Returns the timestamp of the next charge, if recurring. * diff --git a/inc/checkout/class-checkout-pages.php b/inc/checkout/class-checkout-pages.php index b0831c8..06f492d 100644 --- a/inc/checkout/class-checkout-pages.php +++ b/inc/checkout/class-checkout-pages.php @@ -516,7 +516,7 @@ class Checkout_Pages { $function_caller = wu_get_function_caller(5); - if ($function_caller === 'wp_auth_check_html') { + if ('wp_auth_check_html' === $function_caller) { return $login_url; } diff --git a/inc/checkout/class-checkout.php b/inc/checkout/class-checkout.php index 9c80c2c..544aa8b 100644 --- a/inc/checkout/class-checkout.php +++ b/inc/checkout/class-checkout.php @@ -311,10 +311,10 @@ class Checkout { * * @since 2.0.8 */ - if ($key === 'template_id') { + if ('template_id' === $key) { $template_name = get_query_var('template_name', null); - if ($template_name !== null) { + if (null !== $template_name) { $d = wu_get_site_domain_and_path($template_name); $wp_site = get_site_by_path($d->domain, $d->path); @@ -550,6 +550,7 @@ class Checkout { wp_send_json_success($results); } + /** * Process an order. * @@ -892,6 +893,7 @@ class Checkout { */ return $success_data; } + /** * Checks if a customer exists, otherwise, creates a new one. * @@ -1059,7 +1061,7 @@ class Checkout { */ protected function handle_customer_meta_fields($customer, $form_slug) { - if (empty($form_slug) || $form_slug === 'none') { + if (empty($form_slug) || 'none' === $form_slug) { return; } @@ -1131,6 +1133,7 @@ class Checkout { do_action('wu_handle_user_meta_fields', $user_meta_repository, $user, $customer, $this); } } + /** * Checks if a membership exists, otherwise, creates a new one. * @@ -1181,6 +1184,7 @@ class Checkout { return $membership; } + /** * Checks if a pending site exists, otherwise, creates a new one. * @@ -1235,8 +1239,8 @@ class Checkout { * The strategy here is simple, we basically set the site_url to the username and * check if it is already taken. */ - if (empty($site_url) || $auto_generate_url === 'username') { - if ($auto_generate_url === 'username') { + if (empty($site_url) || 'username' === $auto_generate_url) { + if ('username' === $auto_generate_url) { $site_url = $this->customer->get_username(); $site_title = $site_title ?: $site_url; @@ -1339,7 +1343,7 @@ class Checkout { */ protected function get_site_meta_fields($form_slug, $meta_type = 'site_meta') { - if (empty($form_slug) || $form_slug === 'none') { + if (empty($form_slug) || 'none' === $form_slug) { return []; } @@ -1357,6 +1361,7 @@ class Checkout { return $list; } + /** * Checks if a pending payment exists, otherwise, creates a new one. * @@ -1821,7 +1826,7 @@ class Checkout { $stack = array_merge($session, $_REQUEST); } - if ($rules === null) { + if (null === $rules) { $rules = $this->get_validation_rules(); } @@ -2102,7 +2107,7 @@ class Checkout { * * In that case, we simply return. */ - if ($status === false) { + if (false === $status) { return; } @@ -2320,7 +2325,7 @@ class Checkout { * it means that we don't have a step name set * so we need to set it to the first. */ - if ($current_step_index === false) { + if (false === $current_step_index) { $current_step_index = 0; } diff --git a/inc/checkout/class-legacy-checkout.php b/inc/checkout/class-legacy-checkout.php index affa119..105631d 100644 --- a/inc/checkout/class-legacy-checkout.php +++ b/inc/checkout/class-legacy-checkout.php @@ -959,12 +959,7 @@ class Legacy_Checkout { public function has_plan_step(): bool { $transient = static::get_transient(); - - if (isset($transient['skip_plan']) && isset($transient['plan_id']) && isset($transient['plan_freq'])) { - return false; - } - - return true; + return !(isset($transient['skip_plan']) && isset($transient['plan_id']) && isset($transient['plan_freq'])); } /** @@ -1048,9 +1043,9 @@ class Legacy_Checkout { $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 ]; + $key = false === $search_key ? '' : $keys[ $search_key ]; - if ( ! $key || $key == 'begin-signup') { + if ( ! $key || 'begin-signup' == $key) { return false; } @@ -1096,7 +1091,7 @@ class Legacy_Checkout { ?> - + @@ -1267,7 +1262,7 @@ class Legacy_Checkout { */ public function array_filter_key(array $array, $callback): array { - $matched_keys = array_filter(array_keys($array), $callback ?? fn($v, $k): bool => ! empty($v), $callback === null ? ARRAY_FILTER_USE_BOTH : 0); + $matched_keys = array_filter(array_keys($array), $callback ?? fn($v, $k): bool => ! empty($v), null === $callback ? ARRAY_FILTER_USE_BOTH : 0); return array_intersect_key($array, array_flip($matched_keys)); } @@ -1332,7 +1327,7 @@ class Legacy_Checkout { function ($steps) use ($step, $id, $order, $field) { // Checks for honey-trap id - if ($id === 'site_url') { + if ('site_url' === $id) { 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')); } diff --git a/inc/checkout/class-line-item.php b/inc/checkout/class-line-item.php index ec26c78..92405e8 100644 --- a/inc/checkout/class-line-item.php +++ b/inc/checkout/class-line-item.php @@ -372,6 +372,7 @@ class Line_Item implements \JsonSerializable { $this->type = $type; } + /** * Get product associated with this 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 d9112b2..c0ac3cd 100644 --- a/inc/checkout/signup-fields/class-base-signup-field.php +++ b/inc/checkout/signup-fields/class-base-signup-field.php @@ -224,7 +224,7 @@ abstract class Base_Signup_Field { $width = (int) wu_get_isset($this->attributes, 'width'); if ($width) { - if ($width !== 100) { + if (100 !== $width) { $styles[] = 'float: left'; $styles[] = sprintf('width: %s%%', $width); @@ -332,7 +332,7 @@ abstract class Base_Signup_Field { $field['default'] = wu_get_isset($this->defaults(), $key, ''); - if ($value === null) { + if (null === $value) { $value = $field['default']; } diff --git a/inc/checkout/signup-fields/class-signup-field-checkbox.php b/inc/checkout/signup-fields/class-signup-field-checkbox.php index b6ad748..da569fb 100644 --- a/inc/checkout/signup-fields/class-signup-field-checkbox.php +++ b/inc/checkout/signup-fields/class-signup-field-checkbox.php @@ -201,7 +201,7 @@ class Signup_Field_Checkbox extends Base_Signup_Field { $value = $this->get_value(); - if ($value !== '' && (bool) $value === true) { + if ('' !== $value && (bool) $value === true) { $checkout_fields[ $attributes['id'] ]['html_attr']['checked'] = 'checked'; } 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 846dd31..ef9a93f 100644 --- a/inc/checkout/signup-fields/class-signup-field-order-summary.php +++ b/inc/checkout/signup-fields/class-signup-field-order-summary.php @@ -33,6 +33,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field { return 'order_summary'; } + /** * Returns if this field should be present on the checkout flow or not. * @@ -81,6 +82,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field { return __('Adds a summary table with prices, key subscription dates, discounts, and taxes.', 'wp-ultimo'); } + /** * Returns the icon to be used on the selector. * 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 25a6d5e..9888e4f 100644 --- a/inc/checkout/signup-fields/class-signup-field-period-selection.php +++ b/inc/checkout/signup-fields/class-signup-field-period-selection.php @@ -33,6 +33,7 @@ class Signup_Field_Period_Selection extends Base_Signup_Field { return 'period_selection'; } + /** * Returns if this field should be present on the checkout flow or not. * @@ -81,6 +82,7 @@ class Signup_Field_Period_Selection extends Base_Signup_Field { return __('Adds a period selector, that allows customers to switch between different billing periods.', 'wp-ultimo'); } + /** * Returns the icon to be used on the selector. * @@ -285,7 +287,7 @@ class Signup_Field_Period_Selection extends Base_Signup_Field { */ public function to_fields_array($attributes) { - if (wu_get_isset($attributes, 'period_selection_template') === 'legacy') { + if ('legacy' === wu_get_isset($attributes, 'period_selection_template')) { wp_register_script('wu-legacy-signup', wu_get_asset('legacy-signup.js', 'js'), ['wu-functions'], wu_get_version()); wp_enqueue_script('wu-legacy-signup'); 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 23fe975..7cea9f6 100644 --- a/inc/checkout/signup-fields/class-signup-field-pricing-table.php +++ b/inc/checkout/signup-fields/class-signup-field-pricing-table.php @@ -33,6 +33,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field { return 'pricing_table'; } + /** * Returns if this field should be present on the checkout flow or not. * @@ -81,6 +82,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field { return __('Adds a pricing table section that customers can use to choose a plan to subscribe to.', 'wp-ultimo'); } + /** * Returns the icon to be used on the selector. * @@ -244,7 +246,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field { */ public function to_fields_array($attributes) { - if (wu_get_isset($attributes, 'pricing_table_template') === 'legacy') { + if ('legacy' === wu_get_isset($attributes, 'pricing_table_template')) { wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), ['dashicons'], wu_get_version()); wp_add_inline_style('legacy-shortcodes', \WP_Ultimo\Checkout\Legacy_Checkout::get_instance()->get_legacy_dynamic_styles()); diff --git a/inc/checkout/signup-fields/class-signup-field-products.php b/inc/checkout/signup-fields/class-signup-field-products.php index 8c9261b..ca2f49e 100644 --- a/inc/checkout/signup-fields/class-signup-field-products.php +++ b/inc/checkout/signup-fields/class-signup-field-products.php @@ -32,6 +32,7 @@ class Signup_Field_Products extends Base_Signup_Field { return 'products'; } + /** * Returns if this field should be present on the checkout flow or not. * @@ -80,6 +81,7 @@ class Signup_Field_Products extends Base_Signup_Field { 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'); } + /** * Returns the icon to be used on the selector. * diff --git a/inc/checkout/signup-fields/class-signup-field-shortcode.php b/inc/checkout/signup-fields/class-signup-field-shortcode.php index 71a8310..e5d77d6 100644 --- a/inc/checkout/signup-fields/class-signup-field-shortcode.php +++ b/inc/checkout/signup-fields/class-signup-field-shortcode.php @@ -32,6 +32,7 @@ class Signup_Field_Shortcode extends Base_Signup_Field { return 'shortcode'; } + /** * Returns if this field should be present on the checkout flow or not. * @@ -80,6 +81,7 @@ class Signup_Field_Shortcode extends Base_Signup_Field { 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'); } + /** * Returns the icon to be used on the selector. * 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 0beaa36..3c9c05c 100644 --- a/inc/checkout/signup-fields/class-signup-field-site-url.php +++ b/inc/checkout/signup-fields/class-signup-field-site-url.php @@ -32,6 +32,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field { return 'site_url'; } + /** * Returns if this field should be present on the checkout flow or not. * @@ -41,6 +42,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field { return false; } + /** * Defines if this field/element is related to site creation or not. * @@ -89,6 +91,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field { return __('Adds a Site URL field. This is used to set the URL of the site being created.', 'wp-ultimo'); } + /** * Returns the icon to be used on the selector. * @@ -362,6 +365,7 @@ class Signup_Field_Site_Url extends Base_Signup_Field { return $checkout_fields; } + /** * Get the domain options. * diff --git a/inc/checkout/signup-fields/class-signup-field-steps.php b/inc/checkout/signup-fields/class-signup-field-steps.php index e4a93d3..8d81b2f 100644 --- a/inc/checkout/signup-fields/class-signup-field-steps.php +++ b/inc/checkout/signup-fields/class-signup-field-steps.php @@ -33,6 +33,7 @@ class Signup_Field_Steps extends Base_Signup_Field { return 'steps'; } + /** * Returns if this field should be present on the checkout flow or not. * @@ -81,6 +82,7 @@ class Signup_Field_Steps extends Base_Signup_Field { return __('Adds a list of the steps.', 'wp-ultimo'); } + /** * Returns the icon to be used on the selector. * 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 7115eae..a393457 100644 --- a/inc/checkout/signup-fields/class-signup-field-template-selection.php +++ b/inc/checkout/signup-fields/class-signup-field-template-selection.php @@ -34,6 +34,7 @@ class Signup_Field_Template_Selection extends Base_Signup_Field { return 'template_selection'; } + /** * Returns if this field should be present on the checkout flow or not. * @@ -82,6 +83,7 @@ class Signup_Field_Template_Selection extends Base_Signup_Field { 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'); } + /** * Returns the icon to be used on the selector. * @@ -375,15 +377,15 @@ class Signup_Field_Template_Selection extends Base_Signup_Field { $selection_type = wu_get_isset($attributes, 'template_selection_type', 'name'); - if ($selection_type === 'name') { + if ('name' === $selection_type) { return explode(',', $attributes['template_selection_sites']); } - if ($selection_type === 'all') { + if ('all' === $selection_type) { return wu_get_site_templates(['fields' => 'blog_id']); } - if ($selection_type === 'categories') { + if ('categories' === $selection_type) { return array_column( \WP_Ultimo\Models\Site::get_all_by_categories( $attributes['template_selection_categories'], 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 acfe9c6..69f9587 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,6 +29,7 @@ class Base_Field_Template { * @var string */ protected $id; + /** * @var array */ @@ -92,6 +93,7 @@ class Base_Field_Template { return __('Description', 'wp-ultimo'); } + /** * The preview image of the field template. * diff --git a/inc/class-ajax.php b/inc/class-ajax.php index 71354e5..2ba78ae 100644 --- a/inc/class-ajax.php +++ b/inc/class-ajax.php @@ -42,6 +42,7 @@ class Ajax { */ add_action('wp_ajax_wu_list_table_fetch_ajax_results', [$this, 'refresh_list_table']); } + /** * Reverts the name of the table being processed. * @@ -301,6 +302,7 @@ class Ajax { wp_send_json($data); } + /** * Search for WP Multisite WaaS settings to help customers find them. * diff --git a/inc/class-api.php b/inc/class-api.php index e249be7..bb26170 100644 --- a/inc/class-api.php +++ b/inc/class-api.php @@ -92,7 +92,7 @@ class API { public function maybe_bypass_wp_auth($result) { // Another plugin already bypass this request - if ($result === true) { + if (true === $result) { return $result; } @@ -411,7 +411,7 @@ class API { $api_secret = wu_get_isset($params, 'api_secret', wu_get_isset($params, 'api-secret')); } - if ($api_key === false) { + if (false === $api_key) { return false; } diff --git a/inc/class-async-calls.php b/inc/class-async-calls.php index af15055..9c398fc 100644 --- a/inc/class-async-calls.php +++ b/inc/class-async-calls.php @@ -224,7 +224,7 @@ class Async_Calls { foreach ($results as $result) { $status = wu_get_isset($result, 'success', false); - if ($status === false) { + if (false === $status) { return $result; } } diff --git a/inc/class-dashboard-widgets.php b/inc/class-dashboard-widgets.php index ae75df9..4cbd29f 100644 --- a/inc/class-dashboard-widgets.php +++ b/inc/class-dashboard-widgets.php @@ -70,7 +70,7 @@ class Dashboard_Widgets { global $pagenow; - if ( ! $pagenow || $pagenow !== 'index.php') { + if ( ! $pagenow || 'index.php' !== $pagenow) { return; } diff --git a/inc/class-domain-mapping.php b/inc/class-domain-mapping.php index bf6ef34..c3b0224 100644 --- a/inc/class-domain-mapping.php +++ b/inc/class-domain-mapping.php @@ -88,7 +88,7 @@ class Domain_Mapping { $is_enabled = (bool) wu_get_setting_early('enable_domain_mapping'); - if ($is_enabled === false) { + if (false === $is_enabled) { return; } @@ -241,6 +241,7 @@ class Domain_Mapping { return [$nowww, $www]; } + /** * Checks if we have a site associated with the domain being accessed * @@ -468,7 +469,7 @@ class Domain_Mapping { */ public function replace_url($url, $current_mapping = null) { - if ($current_mapping === null) { + if (null === $current_mapping) { $current_mapping = $this->current_mapping; } @@ -509,7 +510,7 @@ class Domain_Mapping { $current_mapping = $this->current_mapping; - if (empty($current_mapping) || $site_id !== $current_mapping->get_site_id()) { + if (empty($current_mapping) || $current_mapping->get_site_id() !== $site_id) { return $url; } diff --git a/inc/class-geolocation.php b/inc/class-geolocation.php index 1a8196d..626a6f4 100644 --- a/inc/class-geolocation.php +++ b/inc/class-geolocation.php @@ -69,6 +69,7 @@ class Geolocation { private static function supports_geolite2(): bool { return false; // version_compare( PHP_VERSION, '5.4.0', '>=' ); } + /** * Check if geolocation is enabled. * @@ -144,6 +145,7 @@ class Geolocation { } elseif ( isset( $_SERVER['REMOTE_ADDR'] ) ) { // @codingStandardsIgnoreLine return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ); // @codingStandardsIgnoreLine } + return ''; } @@ -289,6 +291,7 @@ class Geolocation { wp_clear_scheduled_hook( 'wu_geoip_updater' ); wp_schedule_event( strtotime( 'first tuesday of next month' ), 'monthly', 'wu_geoip_updater' ); } + // Delete temp file regardless of success. $wp_filesystem->delete( $tmp_database_path ); } else { diff --git a/inc/class-logger.php b/inc/class-logger.php index 455e3cd..d95d959 100644 --- a/inc/class-logger.php +++ b/inc/class-logger.php @@ -55,11 +55,11 @@ class Logger extends AbstractLogger { $allowed_log_level = wu_get_setting('error_logging_level', 'default'); - if ($allowed_log_level === 'disabled') { + if ('disabled' === $allowed_log_level) { return; } - if ($allowed_log_level === 'default') { + if ('default' === $allowed_log_level) { /** * Get from default php reporting level * @@ -96,7 +96,7 @@ class Logger extends AbstractLogger { if ( ! in_array($log_level, $current_log_levels, true) && ($reporting_level & ~E_ALL)) { return; } - } elseif ($allowed_log_level === 'errors' && $log_level !== LogLevel::ERROR && $log_level !== LogLevel::CRITICAL) { + } elseif ('errors' === $allowed_log_level && LogLevel::ERROR !== $log_level && LogLevel::CRITICAL !== $log_level) { return; } diff --git a/inc/class-requirements.php b/inc/class-requirements.php index 13e7925..e76e9a6 100644 --- a/inc/class-requirements.php +++ b/inc/class-requirements.php @@ -128,6 +128,7 @@ class Requirements { public static function is_unit_test() { return defined('WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE; } + /** * Check if the PHP version requirements are met * @@ -143,6 +144,7 @@ class Requirements { return true; } + /** * Check if the WordPress version requirements are met * @@ -217,6 +219,7 @@ class Requirements { return true; } + /** * Check if the install is a Multisite install * @@ -232,6 +235,7 @@ class Requirements { return true; } + /** * Check if WP Multisite WaaS is network active. * diff --git a/inc/class-session-cookie.php b/inc/class-session-cookie.php index 2bd6bbc..3a64ee1 100644 --- a/inc/class-session-cookie.php +++ b/inc/class-session-cookie.php @@ -35,6 +35,7 @@ class Session_Cookie implements Session { * @var boolean */ protected $loaded = false; + /** * @var string */ @@ -91,6 +92,7 @@ class Session_Cookie implements Session { return is_array($this->data) && isset($this->data[ $key ]) ? $this->data[ $key ] : null; } + /** * Set the value of a session key. * @@ -105,6 +107,7 @@ class Session_Cookie implements Session { return true; } + /** * Appends values to a given key, instead of replacing it. * @@ -121,6 +124,7 @@ class Session_Cookie implements Session { return true; } + /** * Writes to the session and closes the connection. * @@ -129,7 +133,7 @@ class Session_Cookie implements Session { */ public function commit($expire = null): bool { - if ($expire === null) { + if (null === $expire) { $expire = HOUR_IN_SECONDS; } diff --git a/inc/class-settings.php b/inc/class-settings.php index 05bc11d..39056e0 100644 --- a/inc/class-settings.php +++ b/inc/class-settings.php @@ -87,7 +87,7 @@ class Settings { global $current_site; - if ($network_id !== $current_site->id) { + if ($current_site->id !== $network_id) { return $status; } @@ -110,7 +110,7 @@ class Settings { global $current_site; - if ($network_id !== $current_site->id) { + if ($current_site->id !== $network_id) { return $status; } @@ -131,7 +131,7 @@ class Settings { global $current_site; - if ($network_id !== $current_site->id || is_bool($status)) { + if ($current_site->id !== $network_id || is_bool($status)) { return $status; } @@ -249,7 +249,7 @@ class Settings { /** * 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 (wu_request('tab', 'general') === $section_slug && $field->type === 'toggle' && ! isset($settings_to_save[ $field_slug ])) { $new_value = false; } @@ -298,6 +298,7 @@ class Settings { if ( $this->sections ) { return $this->sections; } + $this->default_sections(); $this->sections = apply_filters( 'wu_settings_get_sections', @@ -455,14 +456,14 @@ class Settings { $model_name = wu_get_isset($atts['html_attr'], 'data-model'); if ($model_name) { - if (function_exists("wu_get_{$model_name}") || $model_name === 'page') { + if (function_exists("wu_get_{$model_name}") || 'page' === $model_name) { $original_html_attr = $atts['html_attr']; $atts['html_attr'] = function () use ($field_slug, $model_name, $atts, $original_html_attr) { $value = wu_get_setting($field_slug); - if ($model_name === 'page') { + if ('page' === $model_name) { $new_attrs['data-selected'] = get_post($value); } else { $data_selected = call_user_func("wu_get_{$model_name}", $value); diff --git a/inc/class-sunrise.php b/inc/class-sunrise.php index 505d3d7..cbfe9fe 100644 --- a/inc/class-sunrise.php +++ b/inc/class-sunrise.php @@ -291,7 +291,7 @@ class Sunrise { return true; } - if ($sunrise_found === false) { + if (false === $sunrise_found) { $error = [ 'message' => __('File not found.', 'wp-ultimo'), ]; @@ -425,9 +425,9 @@ class Sunrise { $is_active = isset($meta['active']) && $meta['active']; - if ($is_active && $mode === 'activating') { + if ($is_active && 'activating' === $mode) { return false; - } elseif ( ! $is_active && $mode === 'deactivating') { + } elseif ( ! $is_active && 'deactivating' === $mode) { return false; } @@ -457,10 +457,10 @@ class Sunrise { ] ); - if ($mode === 'activating') { + if ('activating' === $mode) { $to_save['active'] = true; $to_save['last_activated'] = $now; - } elseif ($mode === 'deactivating') { + } elseif ('deactivating' === $mode) { $to_save['active'] = false; $to_save['last_deactivated'] = $now; } else { diff --git a/inc/class-user-switching.php b/inc/class-user-switching.php index 2c0f40b..ed7add2 100644 --- a/inc/class-user-switching.php +++ b/inc/class-user-switching.php @@ -30,6 +30,7 @@ class User_Switching { add_action('plugins_loaded', [$this, 'register_forms']); } + /** * Check if Plugin User Switching is activated * diff --git a/inc/compat/class-general-compat.php b/inc/compat/class-general-compat.php index da6e613..751f4ed 100644 --- a/inc/compat/class-general-compat.php +++ b/inc/compat/class-general-compat.php @@ -441,7 +441,7 @@ class General_Compat { $file_path = get_parent_theme_file_path('includes/lib/inc/functions.php'); - if ($theme === 'avada' && file_exists($file_path)) { + if ('avada' === $theme && file_exists($file_path)) { require_once get_parent_theme_file_path('includes/lib/inc/functions.php'); diff --git a/inc/compat/class-legacy-shortcodes.php b/inc/compat/class-legacy-shortcodes.php index 619a807..5fb5f4e 100644 --- a/inc/compat/class-legacy-shortcodes.php +++ b/inc/compat/class-legacy-shortcodes.php @@ -375,14 +375,14 @@ class Legacy_Shortcodes { 'required' => true, 'pricing_table_products' => implode(',', wu_get_plans($search_arguments)), 'pricing_table_template' => $layout, - 'element_classes' => $layout === 'legacy' ? 'wu-content-plan' : '', + 'element_classes' => 'legacy' === $layout ? 'wu-content-plan' : '', ]; /** * If not using the legacy checkout, * we'll need a submit field. */ - if ($layout !== 'legacy') { + if ('legacy' !== $layout) { $fields[] = [ 'step' => 'checkout', 'name' => __('Get Started →', 'wp-ultimo'), @@ -528,7 +528,7 @@ class Legacy_Shortcodes { 'template_selection_sites' => implode(',', $templates ?: wu_get_site_templates($search_arguments)), 'template_selection_template' => $layout, 'cols' => $atts['cols'], - 'element_classes' => $layout === 'legacy' ? 'wu-content-templates' : '', + 'element_classes' => 'legacy' === $layout ? 'wu-content-templates' : '', ]; $steps = [ @@ -589,6 +589,7 @@ class Legacy_Shortcodes { ] ); } + /** * Makes sure we don't return any invalid values. * diff --git a/inc/compat/class-multiple-accounts-compat.php b/inc/compat/class-multiple-accounts-compat.php index a65a587..5be3141 100644 --- a/inc/compat/class-multiple-accounts-compat.php +++ b/inc/compat/class-multiple-accounts-compat.php @@ -224,7 +224,7 @@ class Multiple_Accounts_Compat { * belong to the sub-site in question, so we unset the user * currently logged in. */ - if ($has_user === false) { + if (false === $has_user) { wu_x_header('X-Ultimo-Multiple-Accounts: user-unset'); $current_user = null; @@ -305,7 +305,7 @@ class Multiple_Accounts_Compat { */ public function add_column_content($null, $column, $user_id): void { - if ($column === 'multiple_accounts') { + if ('multiple_accounts' === $column) { // Get user email $user = get_user_by('ID', $user_id); @@ -399,6 +399,7 @@ class Multiple_Accounts_Compat { // If nothing was found return false; return $has_user; } + /** * Gets the right user when logging-in. * @@ -457,6 +458,7 @@ class Multiple_Accounts_Compat { return $can; } + /** * Gets the right user for a given domain. * @@ -477,7 +479,7 @@ 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); + $conditions = false == $password ? true : wp_check_password($password, $user_with_email->user_pass, $user_with_email->ID); // Check for the pertinence of that user in this site if ($conditions && $this->user_can_for_blog($user_with_email, get_current_blog_id(), 'read')) { diff --git a/inc/country/class-country.php b/inc/country/class-country.php index e8b4250..2c73dc5 100644 --- a/inc/country/class-country.php +++ b/inc/country/class-country.php @@ -100,11 +100,11 @@ abstract class Country { $placeholder_option = []; - if ($placeholder !== false && $options) { + if (false !== $placeholder && $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); + $placeholder_option[''] = '' !== $placeholder ? $placeholder : sprintf(__('Select your %s', 'wp-ultimo'), $division_name); } return array_merge($placeholder_option, $options); @@ -161,8 +161,8 @@ abstract class Country { $placeholder_option = []; - if ($placeholder !== false && $options) { - $placeholder_option[''] = $placeholder !== '' ? $placeholder : __('Select your city', 'wp-ultimo'); + if (false !== $placeholder && $options) { + $placeholder_option[''] = '' !== $placeholder ? $placeholder : __('Select your city', 'wp-ultimo'); } $options = array_combine($options, $options); diff --git a/inc/database/checkout-forms/class-checkout-forms-table.php b/inc/database/checkout-forms/class-checkout-forms-table.php index 59d775d..f7c7698 100644 --- a/inc/database/checkout-forms/class-checkout-forms-table.php +++ b/inc/database/checkout-forms/class-checkout-forms-table.php @@ -86,6 +86,7 @@ final class Checkout_Forms_Table extends Table { date_modified datetime DEFAULT NULL, PRIMARY KEY (id)"; } + /** * Fixes the datetime columns to accept null. * diff --git a/inc/database/discount-codes/class-discount-codes-table.php b/inc/database/discount-codes/class-discount-codes-table.php index 3c354b4..729dc46 100644 --- a/inc/database/discount-codes/class-discount-codes-table.php +++ b/inc/database/discount-codes/class-discount-codes-table.php @@ -93,6 +93,7 @@ final class Discount_Codes_Table extends Table { date_modified datetime NULL, PRIMARY KEY (id)"; } + /** * Fixes the datetime columns to accept null. * diff --git a/inc/database/domains/class-domain-stage.php b/inc/database/domains/class-domain-stage.php index 2e4bf3a..d3c862c 100644 --- a/inc/database/domains/class-domain-stage.php +++ b/inc/database/domains/class-domain-stage.php @@ -27,9 +27,13 @@ class Domain_Stage extends Enum { const __default = 'checking-dns'; // phpcs:ignore const FAILED = 'failed'; + const CHECKING_DNS = 'checking-dns'; + const CHECKING_SSL = 'checking-ssl-cert'; + const DONE_WITHOUT_SSL = 'done-without-ssl'; + const DONE = 'done'; /** diff --git a/inc/database/domains/class-domains-table.php b/inc/database/domains/class-domains-table.php index 015b0ae..684abd1 100644 --- a/inc/database/domains/class-domains-table.php +++ b/inc/database/domains/class-domains-table.php @@ -88,6 +88,7 @@ final class Domains_Table extends Table { KEY blog_id (blog_id,domain,active), KEY domain (domain)"; } + /** * Fixes the datetime columns to accept null. * diff --git a/inc/database/engine/class-enum.php b/inc/database/engine/class-enum.php index e175d3f..0a14138 100644 --- a/inc/database/engine/class-enum.php +++ b/inc/database/engine/class-enum.php @@ -23,6 +23,7 @@ abstract class Enum { * The default value. */ const __default = false; + // phpcs:ignore /** * The options available. @@ -31,10 +32,12 @@ abstract class Enum { * @var array */ static $options = []; + /** * @var string */ private $value = ''; + /** * Constructor method. Takes the value you want to set. * @@ -54,6 +57,7 @@ abstract class Enum { * @return array */ abstract protected function classes(); + /** * Returns an array with values => labels. * @@ -61,6 +65,7 @@ abstract class Enum { * @return void */ abstract protected function labels(); + /** * Returns an array with values => labels. * @@ -186,7 +191,7 @@ abstract class Enum { static $instance; - if ($instance === null) { + if (null === $instance) { $instance = new static(); } diff --git a/inc/database/engine/class-table.php b/inc/database/engine/class-table.php index 5f0aa5f..bbafd8c 100644 --- a/inc/database/engine/class-table.php +++ b/inc/database/engine/class-table.php @@ -51,11 +51,7 @@ abstract class Table extends \BerlinDB\Database\Table { return false; } - if ( ! is_main_site()) { - return false; - } - - return true; + return (bool) is_main_site(); } /** diff --git a/inc/database/events/class-events-table.php b/inc/database/events/class-events-table.php index fcb5f1b..dd2beff 100644 --- a/inc/database/events/class-events-table.php +++ b/inc/database/events/class-events-table.php @@ -89,6 +89,7 @@ final class Events_Table extends Table { KEY author_id (author_id), KEY initiator (initiator)"; } + /** * Fixes the datetime columns to accept null. * diff --git a/inc/database/memberships/class-membership-status.php b/inc/database/memberships/class-membership-status.php index ab0d073..2941bea 100644 --- a/inc/database/memberships/class-membership-status.php +++ b/inc/database/memberships/class-membership-status.php @@ -27,10 +27,15 @@ class Membership_Status extends Enum { const __default = 'pending'; // phpcs:ignore const PENDING = 'pending'; + const ACTIVE = 'active'; + const TRIALING = 'trialing'; + const EXPIRED = 'expired'; + const ON_HOLD = 'on-hold'; + const CANCELLED = 'cancelled'; /** diff --git a/inc/database/memberships/class-memberships-table.php b/inc/database/memberships/class-memberships-table.php index a51e300..3582867 100644 --- a/inc/database/memberships/class-memberships-table.php +++ b/inc/database/memberships/class-memberships-table.php @@ -112,6 +112,7 @@ final class Memberships_Table extends Table { KEY status (status), KEY disabled (disabled)"; } + /** * Fixes the datetime columns to accept null. * diff --git a/inc/database/payments/class-payment-status.php b/inc/database/payments/class-payment-status.php index 810838d..d047c46 100644 --- a/inc/database/payments/class-payment-status.php +++ b/inc/database/payments/class-payment-status.php @@ -27,11 +27,17 @@ class Payment_Status extends Enum { const __default = 'pending'; // phpcs:ignore const PENDING = 'pending'; + const COMPLETED = 'completed'; + const REFUND = 'refunded'; + const PARTIAL_REFUND = 'partially-refunded'; + const PARTIAL = 'partially-paid'; + const FAILED = 'failed'; + const CANCELLED = 'cancelled'; /** diff --git a/inc/database/payments/class-payments-table.php b/inc/database/payments/class-payments-table.php index 910a752..fcb40e9 100644 --- a/inc/database/payments/class-payments-table.php +++ b/inc/database/payments/class-payments-table.php @@ -155,6 +155,7 @@ final class Payments_Table extends Table { // Return success/fail return $this->is_success($result); } + /** * Fixes the datetime columns to accept null. * diff --git a/inc/database/posts/class-posts-table.php b/inc/database/posts/class-posts-table.php index d58455c..33ff879 100644 --- a/inc/database/posts/class-posts-table.php +++ b/inc/database/posts/class-posts-table.php @@ -88,6 +88,7 @@ final class Posts_Table extends Table { status varchar(100) NOT NULL default 'draft', PRIMARY KEY (id)"; } + /** * Fixes the datetime columns to accept null. * diff --git a/inc/database/products/class-product-type.php b/inc/database/products/class-product-type.php index 73111cc..371241f 100644 --- a/inc/database/products/class-product-type.php +++ b/inc/database/products/class-product-type.php @@ -27,7 +27,9 @@ class Product_Type extends Enum { const __default = 'plan'; // phpcs:ignore const PLAN = 'plan'; + const PACKAGE = 'package'; + const SERVICE = 'service'; /** diff --git a/inc/database/products/class-products-table.php b/inc/database/products/class-products-table.php index 68cc2ea..fb319bb 100644 --- a/inc/database/products/class-products-table.php +++ b/inc/database/products/class-products-table.php @@ -154,6 +154,7 @@ final class Products_Table extends Table { // Return success/fail return $this->is_success($result); } + /** * Fixes the datetime columns to accept null. * diff --git a/inc/database/sites/class-site-type.php b/inc/database/sites/class-site-type.php index 65914be..a53d61d 100644 --- a/inc/database/sites/class-site-type.php +++ b/inc/database/sites/class-site-type.php @@ -27,10 +27,15 @@ class Site_Type extends Enum { const __default = 'default'; // phpcs:ignore const REGULAR = 'default'; + const SITE_TEMPLATE = 'site_template'; + const CUSTOMER_OWNED = 'customer_owned'; + const PENDING = 'pending'; + const EXTERNAL = 'external'; + const MAIN = 'main'; /** diff --git a/inc/database/webhooks/class-webhooks-table.php b/inc/database/webhooks/class-webhooks-table.php index ca946db..7c99e1f 100644 --- a/inc/database/webhooks/class-webhooks-table.php +++ b/inc/database/webhooks/class-webhooks-table.php @@ -94,6 +94,7 @@ final class Webhooks_Table extends Table { // phpcs:enable } + /** * Fixes the datetime columns to accept null. * diff --git a/inc/debug/class-debug.php b/inc/debug/class-debug.php index c7a7662..37ee3f6 100644 --- a/inc/debug/class-debug.php +++ b/inc/debug/class-debug.php @@ -718,7 +718,7 @@ class Debug { ); } - if ($result === false) { + if (false === $result) { throw new \Exception("Error $table"); } } diff --git a/inc/deprecated/deprecated.php b/inc/deprecated/deprecated.php index f391157..1d694f8 100644 --- a/inc/deprecated/deprecated.php +++ b/inc/deprecated/deprecated.php @@ -570,6 +570,7 @@ class WU_Util { return $signups; } + /** * Deprecated: users_on_trial * @@ -656,9 +657,9 @@ class WU_Logger { $alternative = "\\WP_Ultimo\\Logger::$method_name"; - if ($method_name === 'add') { + if ('add' === $method_name) { $alternative = 'wu_log_add'; - } elseif ($method_name === 'clear') { + } elseif ('clear' === $method_name) { $alternative = 'wu_log_clear'; } @@ -873,7 +874,7 @@ class WU_Coupon extends \WP_Ultimo\Models\Discount_Code { */ public function after_set($key, $value): void { - if ($key === 'title') { + if ('title' === $key) { $this->set_code($value); $this->set_name($value); @@ -931,7 +932,7 @@ class WU_Plan extends \WP_Ultimo\Models\Product { */ public function __get($key) { - if ($key === 'price_1') { + if ('price_1' === $key) { return $this->get_amount(); } @@ -952,7 +953,7 @@ class WU_Plan extends \WP_Ultimo\Models\Product { */ public function after_set($key, $value): void { - if ($key === 'price_1') { + if ('price_1' === $key) { $this->set_amount($value); } } @@ -1147,9 +1148,10 @@ class WU_Transactions { $date = new \DateTime(); - return $type === 'mysql' ? $date->format('Y-m-d H:i:s') : $date->format('U'); + return 'mysql' === $type ? $date->format('Y-m-d H:i:s') : $date->format('U'); } } + /* * Functions */ @@ -1216,6 +1218,7 @@ function wu_get_plan_by_slug($plan_slug) { return wu_get_product_by_slug($plan_slug); } + /** * Deprecated: Returns a subscription object based on the user. * @@ -1234,6 +1237,7 @@ function wu_get_subscription($user_id) { return wu_get_membership_by('user_id', $user_id); } + /** * Deprecated: Returns a subscription object based on the integration key. * @@ -1248,6 +1252,7 @@ function wu_get_subscription_by_integration_key($integration_key) { return wu_get_membership_by('gateway_subscription_id', $integration_key); } + /** * Deprecated: Return a subscription object based on the current user. * @@ -1280,7 +1285,7 @@ function wu_is_active_subscriber($user_id = false) { _deprecated_function(__FUNCTION__, '2.0.0'); - if ($user_id === false) { + if (false === $user_id) { $membership = wu_get_current_site()->get_membership(); } else { $membership = wu_get_membership_by('user_id', get_current_user_id()); @@ -1335,6 +1340,7 @@ function wu_get_active_gateway() { return reset($active_gateways); } + /** * Deprecated: Generates the price description. * diff --git a/inc/development/class-toolkit.php b/inc/development/class-toolkit.php index cfed71a..d4f6836 100644 --- a/inc/development/class-toolkit.php +++ b/inc/development/class-toolkit.php @@ -123,7 +123,7 @@ class Toolkit { $class_name = str_replace('_', '-', strtolower($path)); - $args = $manager->get_arguments_schema($context === 'update'); + $args = $manager->get_arguments_schema('update' === $context); file_put_contents(wu_path("/mpb/data/endpoint/.endpoint-$class_name-$context"), json_encode($args)); // phpcs:ignore } @@ -214,7 +214,7 @@ class Toolkit { */ public function die($should_die = true): void { - if ($should_die === true) { + if (true === $should_die) { $should_die = is_admin() ? 'admin_enqueue_scripts' : 'wp_enqueue_scripts'; } @@ -234,9 +234,9 @@ class Toolkit { $listener = wu_request(self::LISTENER_PARAM, 'no-dev-param'); - if ($listener === 'no-dev-param') { + if ('no-dev-param' === $listener) { return current($arguments); - } elseif ($listener === '') { + } elseif ('' === $listener) { $listener = 'index'; } diff --git a/inc/domain-mapping/class-helper.php b/inc/domain-mapping/class-helper.php index 8b65d47..ec0463d 100644 --- a/inc/domain-mapping/class-helper.php +++ b/inc/domain-mapping/class-helper.php @@ -62,6 +62,7 @@ class Helper { */ return apply_filters('wu_is_development_mode', $is_development_mode, $site_url); } + /** * Gets the local IP address of the network. * @@ -137,6 +138,7 @@ class Helper { */ return apply_filters('wu_get_network_public_ip', $_ip_address, false); } + /** * Checks if a given domain name has a valid associated SSL certificate. * diff --git a/inc/domain-mapping/class-primary-domain.php b/inc/domain-mapping/class-primary-domain.php index a5f381f..f496aca 100644 --- a/inc/domain-mapping/class-primary-domain.php +++ b/inc/domain-mapping/class-primary-domain.php @@ -139,7 +139,7 @@ class Primary_Domain { $redirect_settings = wu_get_setting('force_admin_redirect', 'both'); - if ($redirect_settings === 'both') { + if ('both' === $redirect_settings) { return; } @@ -159,11 +159,11 @@ class Primary_Domain { $redirect_url = false; - if ($redirect_settings === 'force_map' && $current_url_to_compare !== $mapped_url_to_compare) { + if ('force_map' === $redirect_settings && $current_url_to_compare !== $mapped_url_to_compare) { $redirect_url = Domain_Mapping::get_instance()->replace_url(wu_get_current_url(), $mapped_domain); $query_args = array_map(fn($value) => Domain_Mapping::get_instance()->replace_url($value, $mapped_domain), $query_args); - } elseif ($redirect_settings === 'force_network' && $current_url_to_compare === $mapped_url_to_compare) { + } elseif ('force_network' === $redirect_settings && $current_url_to_compare === $mapped_url_to_compare) { $redirect_url = wu_restore_original_url(wu_get_current_url(), $site->get_id()); $query_args = array_map(fn($value) => wu_restore_original_url($value, $site->get_id()), $query_args); diff --git a/inc/duplication/data.php b/inc/duplication/data.php index be5b81c..e4eb144 100644 --- a/inc/duplication/data.php +++ b/inc/duplication/data.php @@ -78,7 +78,7 @@ if ( ! class_exists('MUCD_Data') ) { $schema = DB_NAME; // Get sources Tables - if ($from_site_id == MUCD_PRIMARY_SITE_ID) { + if (MUCD_PRIMARY_SITE_ID == $from_site_id) { $from_site_table = self::get_primary_tables($from_site_prefix); } else { $sql_query = $wpdb->prepare('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = \'%s\' AND TABLE_NAME LIKE \'%s\'', $schema, $from_site_prefix_like . '%'); @@ -319,10 +319,11 @@ if ( ! class_exists('MUCD_Data') ) { $new = $val; if (is_string($val)) { $pos = strpos($val, $to_string); - if ($pos === false) { + if (false === $pos) { $new = str_replace($from_string, $to_string, $val); } } + return $new; } @@ -398,6 +399,7 @@ if ( ! class_exists('MUCD_Data') ) { } else { $row[ $field ] = self::replace($row[ $field ], $from_string, $to_string); } + return $row[ $field ]; } diff --git a/inc/duplication/duplicate.php b/inc/duplication/duplicate.php index 397cf81..bcfb56d 100644 --- a/inc/duplication/duplicate.php +++ b/inc/duplication/duplicate.php @@ -77,7 +77,7 @@ if ( ! class_exists('MUCD_Duplicate') ) { self::bypass_server_limit(); // Copy Site - File - if ($copy_file == 'yes') { + if ('yes' == $copy_file) { do_action('mucd_before_copy_files', $from_site_id, $to_site_id); $result = MUCD_Files::copy_files($from_site_id, $to_site_id); do_action('mucd_after_copy_files', $from_site_id, $to_site_id); @@ -89,7 +89,7 @@ if ( ! class_exists('MUCD_Duplicate') ) { do_action('mucd_after_copy_data', $from_site_id, $to_site_id); // Copy Site - Users - if ($keep_users == 'yes') { + if ('yes' == $keep_users) { do_action('mucd_before_copy_users', $from_site_id, $to_site_id); $result = self::copy_users($from_site_id, $to_site_id); do_action('mucd_after_copy_users', $from_site_id, $to_site_id); @@ -190,6 +190,7 @@ if ( ! class_exists('MUCD_Duplicate') ) { continue; } } + update_user_meta($user->ID, $to_site_prefix . $raw_meta_name, maybe_unserialize($metavalue)); } } @@ -211,8 +212,9 @@ if ( ! class_exists('MUCD_Duplicate') ) { if (isset($data['log-path']) && ! empty($data['log-path'])) { $log_name = @date('Y_m_d_His') . '-' . $data['domain'] . '.log'; if (! str_ends_with((string) $data['log-path'], '/')) { - $data['log-path'] = $data['log-path'] . '/'; + $data['log-path'] .= '/'; } + self::$log = new MUCD_Log(true, $data['log-path'], $log_name); } } else { @@ -273,6 +275,7 @@ if ( ! class_exists('MUCD_Duplicate') ) { if (self::log() !== false) { return self::$log->file_url(); } + return false; } diff --git a/inc/duplication/files.php b/inc/duplication/files.php index a585053..41a146f 100644 --- a/inc/duplication/files.php +++ b/inc/duplication/files.php @@ -16,7 +16,7 @@ if ( ! class_exists('MUCD_Files') ) { switch_to_blog($from_site_id); $wp_upload_info = wp_upload_dir(); $from_dir['path'] = $wp_upload_info['basedir']; - $from_site_id == MUCD_PRIMARY_SITE_ID ? $from_dir['exclude'] = MUCD_Option::get_primary_dir_exclude() : $from_dir['exclude'] = []; + MUCD_PRIMARY_SITE_ID == $from_site_id ? $from_dir['exclude'] = MUCD_Option::get_primary_dir_exclude() : $from_dir['exclude'] = []; // Switch to Destination site and get uploads info switch_to_blog($to_site_id); @@ -38,6 +38,7 @@ if ( ! class_exists('MUCD_Files') ) { if (isset($dir['to_dir_path']) && ! self::init_dir($dir['to_dir_path'])) { self::mkdir_error($dir['to_dir_path']); } + MUCD_Duplicate::write_log('Copy files from ' . $dir['from_dir_path'] . ' to ' . $dir['to_dir_path']); self::recurse_copy($dir['from_dir_path'], $dir['to_dir_path'], $dir['exclude_dirs']); } @@ -59,7 +60,7 @@ if ( ! class_exists('MUCD_Files') ) { $dir = opendir($src); @mkdir($dst); while (false !== ($file = readdir($dir)) ) { - if (($file != '.') && ($file != '..')) { + if (('.' != $file) && ('..' != $file)) { if ( is_dir($src . '/' . $file) ) { if ( ! in_array($file, $exclude_dirs)) { self::recurse_copy($src . '/' . $file, $dst . '/' . $file); @@ -69,6 +70,7 @@ if ( ! class_exists('MUCD_Files') ) { } } } + closedir($dir); } @@ -88,6 +90,7 @@ if ( ! class_exists('MUCD_Files') ) { if ( ! is_writable($path)) { return chmod($path, 0777); } + return true; } @@ -106,7 +109,7 @@ if ( ! class_exists('MUCD_Files') ) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { - if ($object != '.' && $object != '..') { + if ('.' != $object && '..' != $object) { if (filetype($dir . '/' . $object) == 'dir') { self::rrmdir($dir . '/' . $object); } else { @@ -114,6 +117,7 @@ if ( ! class_exists('MUCD_Files') ) { } } } + reset($objects); rmdir($dir); } @@ -135,6 +139,7 @@ if ( ! class_exists('MUCD_Files') ) { if ( $log_url = MUCD_Duplicate::log_url() ) { echo '' . MUCD_NETWORK_PAGE_DUPLICATE_VIEW_LOG . ''; } + MUCD_Functions::remove_blog(self::$to_site_id); wp_die(); } diff --git a/inc/duplication/functions.php b/inc/duplication/functions.php index 6b48bc4..44c418f 100644 --- a/inc/duplication/functions.php +++ b/inc/duplication/functions.php @@ -15,8 +15,9 @@ if ( ! class_exists('MUCD_Functions') ) { if (strpos($path, ':') == 1 && preg_match('/[a-zA-Z]/', $path[0])) { $tmp = substr($path, 2); $bool = preg_match('/^[^*?"<>|:]*$/', $tmp); - return ($bool == 1); // so that it will return only true and false + return (1 == $bool); // so that it will return only true and false } + return false; } @@ -30,7 +31,7 @@ if ( ! class_exists('MUCD_Functions') ) { public static function valid_unix_dir_path($path) { $reg = '/^(\/([a-zA-Z0-9+$_.-])+)*\/?$/'; $bool = preg_match($reg, $path); - return ($bool == 1); + return (1 == $bool); } /** @@ -74,10 +75,7 @@ if ( ! class_exists('MUCD_Functions') ) { return true; } - if ( get_blog_option($blog_id, 'mucd_duplicable', 'no') == 'yes') { - return true; - } - return false; + return get_blog_option($blog_id, 'mucd_duplicable', 'no') == 'yes'; } /** @@ -109,10 +107,11 @@ if ( ! class_exists('MUCD_Functions') ) { */ public static function value_in_array($value, $array, $key): bool { foreach ($array as $row) { - if (isset($row[ $key ]) && $value == $row[ $key ]) { + if (isset($row[ $key ]) && $row[ $key ] == $value) { return true; } } + return false; } @@ -194,6 +193,7 @@ if ( ! class_exists('MUCD_Functions') ) { foreach ($sites as $key => $site) { $sites[ $key ] = (array) $site; } + return $sites; } else { $defaults = ['limit' => MUCD_MAX_NUMBER_OF_SITE]; diff --git a/inc/duplication/log.php b/inc/duplication/log.php index 67819e6..f21e1e4 100644 --- a/inc/duplication/log.php +++ b/inc/duplication/log.php @@ -8,20 +8,24 @@ if ( ! class_exists('MUCD_Log') ) { * @readonly */ private string $log_file_path; + /** * @readonly */ private string $log_file_url; private $fp; + /** * @var boolean */ public $mod; + /** * @var string */ private $log_dir_path = ''; + /** * @var string */ @@ -43,7 +47,7 @@ if ( ! class_exists('MUCD_Log') ) { $this->log_file_url = str_replace(ABSPATH, get_site_url(1, '/'), $log_dir_path) . $log_file_name; - if ( $mod !== false) { + if ( false !== $mod) { $this->init_file(); } } @@ -119,9 +123,11 @@ if ( ! class_exists('MUCD_Log') ) { if ( ! $this->fp = @fopen($this->log_file_path, 'a') ) { return false; } + chmod($this->log_file_path, 0777); return true; } + return false; } @@ -138,6 +144,7 @@ if ( ! class_exists('MUCD_Log') ) { fwrite($this->fp, "$time $message" . "\r\n"); return true; } + return false; } diff --git a/inc/duplication/option.php b/inc/duplication/option.php index 5e6f20d..ad6c648 100644 --- a/inc/duplication/option.php +++ b/inc/duplication/option.php @@ -19,6 +19,7 @@ if ( ! class_exists('MUCD_Option') ) { $blog_id = $blog['blog_id']; add_blog_option($blog_id, 'mucd_duplicable', $blogs_value); } + add_site_option('mucd_duplicables', $network_value); } @@ -34,6 +35,7 @@ if ( ! class_exists('MUCD_Option') ) { $blog_id = $blog['blog_id']; delete_blog_option($blog_id, 'mucd_duplicable'); } + delete_site_option('mucd_duplicables'); } diff --git a/inc/functions/array-helpers.php b/inc/functions/array-helpers.php index 46c561f..f652622 100644 --- a/inc/functions/array-helpers.php +++ b/inc/functions/array-helpers.php @@ -114,7 +114,7 @@ function wu_array_recursive_diff($array1, $array2, $to_keep = []) { if (count($array_recursive_diff)) { $arr_return[ $key ] = $array_recursive_diff; } - } elseif ((! is_null($value) && $value != $array2[ $key ]) || ($value && $array2[ $key ] && in_array($key, $to_keep, true))) { + } elseif ((! is_null($value) && $array2[ $key ] != $value) || ($value && $array2[ $key ] && in_array($key, $to_keep, true))) { // phpcs:ignore $arr_return[ $key ] = $value; @@ -126,6 +126,7 @@ function wu_array_recursive_diff($array1, $array2, $to_keep = []) { return $arr_return; } + /** * Array map implementation to deal with keys. * diff --git a/inc/functions/checkout-form.php b/inc/functions/checkout-form.php index b2f1129..4b86f46 100644 --- a/inc/functions/checkout-form.php +++ b/inc/functions/checkout-form.php @@ -37,6 +37,7 @@ function wu_get_checkout_forms($query = []) { return \WP_Ultimo\Models\Checkout_Form::query($query); } + /** * Returns a checkout_form based on slug. * @@ -56,7 +57,7 @@ function wu_get_checkout_form_by_slug($checkout_form_slug) { * * @see wu_checkout_form_membership_change_form_fields filter. */ - if ($checkout_form_slug === 'wu-checkout') { + if ('wu-checkout' === $checkout_form_slug) { $checkout_form = new \WP_Ultimo\Models\Checkout_Form(); $checkout_fields = Checkout_Form::membership_change_form_fields(); @@ -64,7 +65,7 @@ function wu_get_checkout_form_by_slug($checkout_form_slug) { $checkout_form->set_settings($checkout_fields); return $checkout_form; - } elseif ($checkout_form_slug === 'wu-add-new-site') { + } elseif ('wu-add-new-site' === $checkout_form_slug) { $checkout_form = new \WP_Ultimo\Models\Checkout_Form(); $checkout_fields = Checkout_Form::add_new_site_form_fields(); @@ -72,7 +73,7 @@ function wu_get_checkout_form_by_slug($checkout_form_slug) { $checkout_form->set_settings($checkout_fields); return $checkout_form; - } elseif ($checkout_form_slug === 'wu-finish-checkout') { + } elseif ('wu-finish-checkout' === $checkout_form_slug) { $checkout_form = new \WP_Ultimo\Models\Checkout_Form(); $checkout_fields = Checkout_Form::finish_checkout_form_fields(); @@ -84,6 +85,7 @@ function wu_get_checkout_form_by_slug($checkout_form_slug) { return \WP_Ultimo\Models\Checkout_Form::get_by('slug', $checkout_form_slug); } + /** * Creates a new checkout form. * diff --git a/inc/functions/checkout.php b/inc/functions/checkout.php index 3d41371..c65fc44 100644 --- a/inc/functions/checkout.php +++ b/inc/functions/checkout.php @@ -97,12 +97,12 @@ function wu_create_checkout_fields($fields = []) { */ $visibility = wu_get_isset($field, 'logged', 'always'); - if ($visibility !== 'always') { - if ($visibility === 'guests_only' && is_user_logged_in()) { + if ('always' !== $visibility) { + if ('guests_only' === $visibility && is_user_logged_in()) { continue; } - if ($visibility === 'logged_only' && ! is_user_logged_in()) { + if ('logged_only' === $visibility && ! is_user_logged_in()) { continue; } } @@ -174,6 +174,7 @@ function wu_get_registration_url($path = false) { return $url . $path; } + /** * Returns the URL for the login page. * diff --git a/inc/functions/customer.php b/inc/functions/customer.php index bc4f6ca..c581ffe 100644 --- a/inc/functions/customer.php +++ b/inc/functions/customer.php @@ -23,6 +23,7 @@ function wu_get_customer($customer_id) { return \WP_Ultimo\Models\Customer::get_by_id($customer_id); } + /** * Returns a single customer defined by a particular column and value. * @@ -36,6 +37,7 @@ function wu_get_customer_by($column, $value) { return \WP_Ultimo\Models\Customer::get_by($column, $value); } + /** * Gets a customer based on the hash. * @@ -83,6 +85,7 @@ function wu_get_customers($query = []) { return \WP_Ultimo\Models\Customer::query($query); } + /** * Returns a customer based on user_id. * @@ -95,6 +98,7 @@ function wu_get_customer_by_user_id($user_id) { return \WP_Ultimo\Models\Customer::get_by('user_id', $user_id); } + /** * Returns the current customer. * @@ -105,6 +109,7 @@ function wu_get_current_customer() { return wu_get_customer_by_user_id(get_current_user_id()); } + /** * Creates a new customer. * @@ -154,7 +159,7 @@ function wu_create_customer($customer_data) { return $user_id; } - if ($user_id === false) { + if (false === $user_id) { return new \WP_Error('user', __('We were not able to create a new user with the provided username and email address combination.', 'wp-ultimo'), $customer_data); } } else { diff --git a/inc/functions/date.php b/inc/functions/date.php index cd55995..f3d9cea 100644 --- a/inc/functions/date.php +++ b/inc/functions/date.php @@ -127,6 +127,7 @@ function wu_filter_duration_unit($unit, $length) { return $new_unit; } + /** * Get the human time diff. * @@ -148,7 +149,7 @@ function wu_human_time_diff($from, $limit = '-5 days', $to = false): string { return sprintf(__('on %s', 'wp-ultimo'), date_i18n(get_option('date_format'), $timestamp_from)); } - if ($to === false) { + if (false === $to) { $to = wu_get_current_time('timestamp'); // phpcs:ignore } diff --git a/inc/functions/discount-code.php b/inc/functions/discount-code.php index abe0d6c..46af9a3 100644 --- a/inc/functions/discount-code.php +++ b/inc/functions/discount-code.php @@ -23,6 +23,7 @@ function wu_get_discount_code_by_code($coupon_code) { return \WP_Ultimo\Models\Discount_Code::get_by('code', $coupon_code); } + /** * Gets a discount code based on the ID. * @@ -48,6 +49,7 @@ function wu_get_discount_codes($query = []) { return \WP_Ultimo\Models\Discount_Code::query($query); } + /** * Calculates the discounted price after running it through the discount code. * @@ -61,9 +63,9 @@ function wu_get_discount_codes($query = []) { */ function wu_get_discounted_price($base_price, $amount, $type, $format = true) { - if ($type === 'percentage') { + if ('percentage' === $type) { $discounted_price = $base_price - ($base_price * ($amount / 100)); - } elseif ($type === 'absolute') { + } elseif ('absolute' === $type) { $discounted_price = $base_price - $amount; } @@ -73,6 +75,7 @@ function wu_get_discounted_price($base_price, $amount, $type, $format = true) { return number_format((float) $discounted_price, 2); } + /** * Creates a new discount code. * diff --git a/inc/functions/domain.php b/inc/functions/domain.php index 4afae31..8cdf29d 100644 --- a/inc/functions/domain.php +++ b/inc/functions/domain.php @@ -36,6 +36,7 @@ function wu_get_domains($query = []) { return \WP_Ultimo\Models\Domain::query($query); } + /** * Returns a domain based on domain. * @@ -48,6 +49,7 @@ function wu_get_domain_by_domain($domain) { return \WP_Ultimo\Models\Domain::get_by('domain', $domain); } + /** * Creates a new domain. * diff --git a/inc/functions/event.php b/inc/functions/event.php index e3ae64e..6a241e9 100644 --- a/inc/functions/event.php +++ b/inc/functions/event.php @@ -95,6 +95,7 @@ function wu_get_events($query = []) { return \WP_Ultimo\Models\Event::query($query); } + /** * Gets a event on the ID. * @@ -107,6 +108,7 @@ function wu_get_event($event_id) { return \WP_Ultimo\Models\Event::get_by_id($event_id); } + /** * Returns a event based on slug. * @@ -119,6 +121,7 @@ function wu_get_event_by_slug($event_slug) { return \WP_Ultimo\Models\Event::get_by('slug', $event_slug); } + /** * Creates a new event. * @@ -199,7 +202,7 @@ function wu_generate_event_payload($model_name, $model = false): array { } } - if ($model_name === 'customer') { + if ('customer' === $model_name) { $payload = $model->to_search_results(); $payload = [ @@ -217,7 +220,7 @@ function wu_generate_event_payload($model_name, $model = false): array { ] ), ]; - } elseif ($model_name === 'membership') { + } elseif ('membership' === $model_name) { $payload = $model->to_search_results(); $p = $payload; @@ -241,7 +244,7 @@ function wu_generate_event_payload($model_name, $model = false): array { ] ), ]; - } elseif ($model_name === 'product') { + } elseif ('product' === $model_name) { $payload = $model->to_search_results(); $payload = [ @@ -260,7 +263,7 @@ function wu_generate_event_payload($model_name, $model = false): array { ] ), ]; - } elseif ($model_name === 'payment') { + } elseif ('payment' === $model_name) { $payload = $model->to_search_results(); $payload = [ @@ -285,7 +288,7 @@ function wu_generate_event_payload($model_name, $model = false): array { ] ), ]; - } elseif ($model_name === 'site') { + } elseif ('site' === $model_name) { $payload = $model->to_search_results(); $payload = [ @@ -301,7 +304,7 @@ function wu_generate_event_payload($model_name, $model = false): array { ] ), ]; - } elseif ($model_name === 'domain') { + } elseif ('domain' === $model_name) { $payload = $model->to_search_results(); $payload = [ diff --git a/inc/functions/fs.php b/inc/functions/fs.php index c76918a..ce45a4a 100644 --- a/inc/functions/fs.php +++ b/inc/functions/fs.php @@ -61,7 +61,7 @@ function wu_maybe_create_folder($folder, ...$path) { if ( ! file_exists($htaccess)) { $fp = @fopen($htaccess, 'w'); - @fputs($fp, 'deny from all'); // phpcs:ignore + @fwrite($fp, 'deny from all'); // phpcs:ignore @fclose($fp); // phpcs:ignore } @@ -72,7 +72,7 @@ function wu_maybe_create_folder($folder, ...$path) { if ( ! file_exists($index)) { $fp = @fopen($index, 'w'); - @fputs($fp, ''); // phpcs:ignore + @fwrite($fp, ''); // phpcs:ignore @fclose($fp); // phpcs:ignore } diff --git a/inc/functions/gateway.php b/inc/functions/gateway.php index 24cdacc..8fdacff 100644 --- a/inc/functions/gateway.php +++ b/inc/functions/gateway.php @@ -100,7 +100,7 @@ function wu_get_gateway_as_options() { foreach (wu_get_gateways() as $gateway_slug => $gateway) { $instance = class_exists($gateway['class_name']) ? new $gateway['class_name']() : false; - if ($instance === false || $gateway['hidden']) { + if (false === $instance || $gateway['hidden']) { continue; } @@ -123,7 +123,7 @@ function wu_get_active_gateway_as_options() { foreach (wu_get_active_gateways() as $gateway_slug => $gateway) { $instance = class_exists($gateway['class_name']) ? new $gateway['class_name']() : false; - if ($instance === false || $gateway['hidden']) { + if (false === $instance || $gateway['hidden']) { continue; } diff --git a/inc/functions/helper.php b/inc/functions/helper.php index 96f8b5c..b32f529 100644 --- a/inc/functions/helper.php +++ b/inc/functions/helper.php @@ -98,6 +98,7 @@ function wu_slugify($term) { return "wp-ultimo_$term"; } + /** * Returns the full path to the plugin folder. * @@ -168,7 +169,7 @@ function wu_are_code_comments_available() { static $res; - if ($res === null) { + if (null === $res) { $res = (bool) (new \ReflectionFunction(__FUNCTION__))->getDocComment(); } @@ -184,7 +185,7 @@ function wu_are_code_comments_available() { */ function wu_path_join(...$parts): string { - if (sizeof($parts) === 0) { + if (count($parts) === 0) { return ''; } @@ -255,6 +256,7 @@ function wu_get_function_caller($depth = 1) { return $caller; } + /** * Checks if a particular plugin is skipped in a CLI context. * diff --git a/inc/functions/legacy.php b/inc/functions/legacy.php index 3dc9c17..6c1b387 100644 --- a/inc/functions/legacy.php +++ b/inc/functions/legacy.php @@ -382,8 +382,7 @@ function wu_print_signup_field($field_slug, $field, $results) { case 'checkbox': $checked = isset($field['check_if']) && isset($result[$field['check_if']]) || (isset($field['check_if']) && isset($_POST[$field['check_if']]) && $_POST[$field['check_if']]) - || (isset($field['checked']) && $field['checked']) - ? true : false; + || (isset($field['checked']) && $field['checked']); ?>

diff --git a/inc/functions/markup-helpers.php b/inc/functions/markup-helpers.php index decf888..51e2ef9 100644 --- a/inc/functions/markup-helpers.php +++ b/inc/functions/markup-helpers.php @@ -54,6 +54,7 @@ function wu_remove_empty_p($content): ?string { return preg_replace('#

(\s| )*+()*(\s| )*

#i', '', $content); } + /** * Generates a string containing html attributes to be used inside html tags. * @@ -107,6 +108,7 @@ function wu_tooltip($tooltip, $icon = 'dashicons-editor-help') { return $markup; } + /** * Adds a tooltip to a HTML element. Needs to be echo'ed. * @@ -118,6 +120,7 @@ function wu_tooltip_text($tooltip): string { return sprintf('role="tooltip" aria-label="%s"', esc_attr($tooltip)); } + /** * Adds a preview tag that displays the image passed on hover. * diff --git a/inc/functions/membership.php b/inc/functions/membership.php index ca32deb..6b3afb7 100644 --- a/inc/functions/membership.php +++ b/inc/functions/membership.php @@ -26,6 +26,7 @@ function wu_get_membership($membership_id) { return Membership::get_by_id($membership_id); } + /** * Returns a single membership defined by a particular column and value. * @@ -39,6 +40,7 @@ function wu_get_membership_by($column, $value) { return Membership::get_by($column, $value); } + /** * Gets a membership based on the hash. * @@ -79,6 +81,7 @@ function wu_get_memberships($query = []) { return Membership::query($query); } + /** * Creates a new membership. * @@ -165,6 +168,7 @@ function wu_get_membership_customers($product_id) { return $results; } + /** * Returns a membership based on the customer gateway ID. * @@ -267,6 +271,7 @@ function wu_get_membership_product_price($membership, $product_id, $quantity, $o return $temp_payment->get_total(); } + /** * Creates a new payment for a membership. * diff --git a/inc/functions/model.php b/inc/functions/model.php index bfac1dd..b630865 100644 --- a/inc/functions/model.php +++ b/inc/functions/model.php @@ -81,7 +81,7 @@ function wu_model_get_required_fields($class_name) { $validation_rules = (new $class_name())->validation_rules(); foreach ($validation_rules as $field => $validation_rule) { - if (str_contains((string) $validation_rule, 'required|') || $validation_rule === 'required') { + if (str_contains((string) $validation_rule, 'required|') || 'required' === $validation_rule) { $required_fields[] = $field; } } diff --git a/inc/functions/pages.php b/inc/functions/pages.php index 4bfba78..1db80d4 100644 --- a/inc/functions/pages.php +++ b/inc/functions/pages.php @@ -119,7 +119,7 @@ function wu_is_login_page() { $is_login_element_present = \WP_Ultimo\UI\Login_Form_Element::get_instance()->is_actually_loaded(); - $is_default_wp_login = $pagenow === 'wp-login.php'; + $is_default_wp_login = 'wp-login.php' === $pagenow; return $is_login_element_present || $is_default_wp_login; } diff --git a/inc/functions/payment.php b/inc/functions/payment.php index 96946b5..a4b9e80 100644 --- a/inc/functions/payment.php +++ b/inc/functions/payment.php @@ -59,6 +59,7 @@ function wu_get_line_item($line_item_id, $payment_id) { return wu_get_isset($line_items, $line_item_id, false); } + /** * Gets a payment based on the hash. * @@ -71,6 +72,7 @@ function wu_get_payment_by_hash($hash) { return \WP_Ultimo\Models\Payment::get_by_hash($hash); } + /** * Returns a single payment defined by a particular column and value. * @@ -84,6 +86,7 @@ function wu_get_payment_by($column, $value) { return \WP_Ultimo\Models\Payment::get_by($column, $value); } + /** * Creates a new payment. * diff --git a/inc/functions/product.php b/inc/functions/product.php index fe7c25b..56b9cbd 100644 --- a/inc/functions/product.php +++ b/inc/functions/product.php @@ -91,6 +91,7 @@ function wu_get_product_by_slug($product_slug) { return Product::get_by('slug', $product_slug); } + /** * Returns a single product defined by a particular column and value. * @@ -151,6 +152,7 @@ function wu_create_product($product_data) { return is_wp_error($saved) ? $saved : $product; } + /** * Returns a list of available product groups. * diff --git a/inc/functions/rest.php b/inc/functions/rest.php index 8f4de91..ab6d281 100644 --- a/inc/functions/rest.php +++ b/inc/functions/rest.php @@ -58,7 +58,7 @@ function wu_rest_get_endpoint_schema($class_name, $context = 'create', $force_ge $from_cache = true; } - if (empty($schema) && $from_cache === false && $force_generate) { + if (empty($schema) && false === $from_cache && $force_generate) { $schema = wu_rest_generate_schema($class_name, $context); } @@ -83,7 +83,7 @@ function wu_rest_generate_schema($class_name, $context = 'create') { foreach ($schema as $argument_name => &$argument) { $argument['type'] = wu_rest_treat_argument_type($argument['type']); - $argument['required'] = $context === 'create' ? in_array($argument_name, $required_fields, true) : false; + $argument['required'] = 'create' === $context ? in_array($argument_name, $required_fields, true) : false; $schema[ $argument_name ] = $argument; } @@ -103,11 +103,11 @@ function wu_rest_treat_argument_type($type) { $type = (string) $type; - if ($type === 'bool') { + if ('bool' === $type) { $type = 'boolean'; - } elseif ($type === 'int') { + } elseif ('int' === $type) { $type = 'integer'; - } elseif ($type === 'float') { + } elseif ('float' === $type) { $type = 'number'; } diff --git a/inc/functions/settings.php b/inc/functions/settings.php index 7406e90..c400c2e 100644 --- a/inc/functions/settings.php +++ b/inc/functions/settings.php @@ -100,7 +100,7 @@ function wu_register_settings_field($section_slug, $field_slug, $atts, $priority */ function wu_register_settings_side_panel($section_slug, $atts) { - if (wu_request('tab', 'general') !== $section_slug && $section_slug !== 'all') { + if (wu_request('tab', 'general') !== $section_slug && 'all' !== $section_slug) { return; } diff --git a/inc/functions/site.php b/inc/functions/site.php index 2c5d0ed..ea8e6a7 100644 --- a/inc/functions/site.php +++ b/inc/functions/site.php @@ -32,6 +32,7 @@ function wu_get_site($id) { return \WP_Ultimo\Models\Site::get_by_id($id); } + /** * Gets a site based on the hash. * @@ -116,6 +117,7 @@ function wu_handle_site_domain($domain) { return (object) $parsed; } + /** * Creates a new site. * diff --git a/inc/functions/tax.php b/inc/functions/tax.php index 223026e..73c4eaf 100644 --- a/inc/functions/tax.php +++ b/inc/functions/tax.php @@ -52,6 +52,7 @@ function wu_get_tax_category($tax_category = 'default') { ] ); } + /** * Returns the tax categories as a slug => name array. * @@ -61,6 +62,7 @@ function wu_get_tax_categories_as_options(): array { return array_map(fn($item) => $item['name'], wu_get_tax_categories()); } + /** * Calculates the tax value. * @@ -80,7 +82,7 @@ function wu_get_tax_amount($base_price, $amount, $type, $format = true, $inclusi */ $tax_total = $amount; - if ($type === 'percentage') { + if ('percentage' === $type) { if ( ! $inclusive) { /** @@ -159,14 +161,14 @@ function wu_get_applicable_tax_rates($country, $tax_category = 'default', $state /* * Step 1: The country. */ - if ($key === 'country' && $rate['country'] === $country) { + if ('country' === $key && $rate['country'] === $country) { $priority += 10; } /* * Step 2: The state / province */ - if ($key === 'state' && $state !== '*') { + if ('state' === $key && '*' !== $state) { if (in_array($state, $value, true)) { $priority += 1; } elseif (empty($value) || in_array('*', $value, true)) { @@ -177,7 +179,7 @@ function wu_get_applicable_tax_rates($country, $tax_category = 'default', $state /* * Step 3: The city */ - if ($key === 'city' && $city !== '*') { + if ('city' === $key && '*' !== $city) { if (in_array($city, $value, true)) { /* * If it's a full match, gives 1 point. diff --git a/inc/gateways/class-base-gateway.php b/inc/gateways/class-base-gateway.php index a004bbd..ac9e20f 100644 --- a/inc/gateways/class-base-gateway.php +++ b/inc/gateways/class-base-gateway.php @@ -167,7 +167,7 @@ abstract class Base_Gateway { */ public function set_order($order): void { - if ($order === null) { + if (null === $order) { return; } @@ -784,7 +784,7 @@ abstract class Base_Gateway { */ public function trigger_payment_processed($payment, $membership = null): void { - if ($membership === null) { + if (null === $membership) { $membership = $payment->get_membership(); } diff --git a/inc/gateways/class-base-stripe-gateway.php b/inc/gateways/class-base-stripe-gateway.php index 5ffd5ca..6fcc9c1 100644 --- a/inc/gateways/class-base-stripe-gateway.php +++ b/inc/gateways/class-base-stripe-gateway.php @@ -1313,7 +1313,7 @@ class Base_Stripe_Gateway extends Base_Gateway { /* * Skip recurring items */ - if ($line_item->is_recurring() && $include_recurring_products === false) { + if ($line_item->is_recurring() && false === $include_recurring_products) { continue; } @@ -1626,21 +1626,21 @@ class Base_Stripe_Gateway extends Base_Gateway { // Legacy WP Multisite WaaS uses user_id $user_id = (int) $subscription->metadata['user_id']; - if ($customer_id === 0 && $user_id === 0) { + if (0 === $customer_id && 0 === $user_id) { continue; } - if ($customer_id !== $this->customer->get_id() && $user_id !== $this->customer->get_user_id()) { + if ($this->customer->get_id() !== $customer_id && $this->customer->get_user_id() !== $user_id) { continue; } $membership_id = (int) $subscription->metadata['membership_id']; - if ($allow_multiple_membership && $membership_id !== $this->membership->get_id()) { + if ($allow_multiple_membership && $this->membership->get_id() !== $membership_id) { continue; } - if ($membership_id === 0 && $customer_id === 0) { + if (0 === $membership_id && 0 === $customer_id) { /** * If we do not have a $membership_id it can be a legacy subscription. * The best way to check this is checking if the plan in Stripe haves @@ -1666,7 +1666,7 @@ class Base_Stripe_Gateway extends Base_Gateway { } // Check if membership exist and is from this customer before delete subscription - if ($membership_id !== 0 && $membership_id !== $this->membership->get_id()) { + if (0 !== $membership_id && $this->membership->get_id() !== $membership_id) { $membership_from_s = wu_get_membership($membership_id); if ( ! $membership_from_s || $membership_from_s->get_customer_id() !== $customer_id) { @@ -2214,14 +2214,14 @@ class Base_Stripe_Gateway extends Base_Gateway { $old_subtotal = $payment_data['subtotal']; - if ($type === 'percentage') { + if ('percentage' === $type) { $payment_data['subtotal'] = $old_subtotal / (1 - ($discount_code->get_value() / 100)); $discount_total = $payment_data['subtotal'] - $old_subtotal; - } elseif ($type === 'absolute') { + } elseif ('absolute' === $type) { $discount_total = $discount_code->get_value(); - $payment_data['subtotal'] = $payment_data['subtotal'] - $discount_total; + $payment_data['subtotal'] -= $discount_total; } // Now we apply this discount to the line items. @@ -2773,7 +2773,7 @@ class Base_Stripe_Gateway extends Base_Gateway { */ function maybe_create_price($title, $amount, $currency, $quantity = 1, $duration = false, $duration_unit = false, $tax_behavior = '') { - $name = $quantity === 1 ? $title : "x$quantity $title"; + $name = 1 === $quantity ? $title : "x$quantity $title"; $currency = strtolower($currency); $s_amount = round($amount * wu_stripe_get_currency_multiplier()); diff --git a/inc/gateways/class-free-gateway.php b/inc/gateways/class-free-gateway.php index 677f6ed..c0c2453 100644 --- a/inc/gateways/class-free-gateway.php +++ b/inc/gateways/class-free-gateway.php @@ -66,7 +66,7 @@ class Free_Gateway extends Base_Gateway { $membership->set_gateway($this->get_id()); $membership->set_auto_renew(false); - if ($type === 'downgrade' && ($membership_status === Membership_Status::ACTIVE || $membership_status === Membership_Status::TRIALING)) { + if ('downgrade' === $type && (Membership_Status::ACTIVE === $membership_status || Membership_Status::TRIALING === $membership_status)) { /* * When downgrading, we need to schedule a swap for the end of the * current expiration date. @@ -79,7 +79,7 @@ class Free_Gateway extends Base_Gateway { $status = $membership->save(); return; - } elseif ($type === 'upgrade' || $type === 'downgrade' || $type === 'addon') { + } elseif ('upgrade' === $type || 'downgrade' === $type || 'addon' === $type) { /* * A change to another free membership * is a upgrade and if membership is not diff --git a/inc/gateways/class-manual-gateway.php b/inc/gateways/class-manual-gateway.php index d010167..f8fe4b8 100644 --- a/inc/gateways/class-manual-gateway.php +++ b/inc/gateways/class-manual-gateway.php @@ -215,13 +215,13 @@ class Manual_Gateway extends Base_Gateway { * simply throw a exception and WP Multisite WaaS will * catch it and rollback any changes. */ - if ($type === 'new') { + if ('new' === $type) { // Your logic here. - } elseif ($type === 'renewal') { + } elseif ('renewal' === $type) { // Your logic here. - } elseif ($type === 'downgrade') { + } elseif ('downgrade' === $type) { /* * When downgrading, we need to schedule a swap for the end of the * current expiration date. @@ -238,7 +238,7 @@ class Manual_Gateway extends Base_Gateway { * Saves the membership with the changes. */ $status = $membership->save(); - } elseif ($type === 'upgrade' || $type === 'addon') { + } elseif ('upgrade' === $type || 'addon' === $type) { /* * After everything is said and done, * we need to swap the membership to the new products diff --git a/inc/gateways/class-paypal-gateway.php b/inc/gateways/class-paypal-gateway.php index e608191..9e23755 100644 --- a/inc/gateways/class-paypal-gateway.php +++ b/inc/gateways/class-paypal-gateway.php @@ -27,14 +27,17 @@ class PayPal_Gateway extends Base_Gateway { * @var string */ public $error_message; + /** * @var string */ public $webhook_event_id; + /** * @var \WP_Ultimo\Models\Payment */ public $payment; + /** * Holds the ID of a given gateway. * @@ -517,7 +520,7 @@ class PayPal_Gateway extends Base_Gateway { $recurring_total_format = wu_format_currency($recurring_total, $cart->get_currency()); if ($recurring_total !== $cart_total) { - if ($type === 'downgrade') { + if ('downgrade' === $type) { if ($is_trial_setup) { $notes[] = sprintf(__('Your updated membership will start on $1$s, from that date you will be billed %2$s every month.', 'wp-ultimo'), $date, $recurring_total_format); } else { @@ -561,8 +564,8 @@ class PayPal_Gateway extends Base_Gateway { "L_PAYMENTREQUEST_0_TAXAMT{$product_index}" => $tax_amount, ]; - $args['PAYMENTREQUEST_0_ITEMAMT'] = $args['PAYMENTREQUEST_0_ITEMAMT'] + $sub_total; - $args['PAYMENTREQUEST_0_TAXAMT'] = $args['PAYMENTREQUEST_0_TAXAMT'] + $tax_amount; + $args['PAYMENTREQUEST_0_ITEMAMT'] += $sub_total; + $args['PAYMENTREQUEST_0_TAXAMT'] += $tax_amount; $args['PAYMENTREQUEST_0_AMT'] = $args['PAYMENTREQUEST_0_AMT'] + $sub_total + $tax_amount; $args = array_merge($args, $product_args); @@ -584,8 +587,8 @@ class PayPal_Gateway extends Base_Gateway { ] ); - $args['PAYMENTREQUEST_0_ITEMAMT'] = $args['PAYMENTREQUEST_0_ITEMAMT'] + $discounts_total; - $args['PAYMENTREQUEST_0_AMT'] = $args['PAYMENTREQUEST_0_AMT'] + $discounts_total; + $args['PAYMENTREQUEST_0_ITEMAMT'] += $discounts_total; + $args['PAYMENTREQUEST_0_AMT'] += $discounts_total; ++$product_index; } @@ -731,7 +734,7 @@ class PayPal_Gateway extends Base_Gateway { 'INVOICEID' => $payment->get_hash(), ]; - if ($refund_type === 'Partial') { + if ('Partial' === $refund_type) { $args['AMT'] = $amount_formatted; } @@ -773,6 +776,7 @@ class PayPal_Gateway extends Base_Gateway { throw new \Exception(__('Something went wrong.', 'wp-ultimo')); } + /** * Adds additional fields to the checkout form for a particular gateway. * @@ -890,6 +894,7 @@ class PayPal_Gateway extends Base_Gateway { $this->confirmation_form(); } } + /** * Process webhooks * @@ -936,7 +941,7 @@ class PayPal_Gateway extends Base_Gateway { $amount = isset($posted['mc_gross']) ? wu_to_float($posted['mc_gross']) : false; - if ($amount !== false) { + if (false !== $amount) { $payment_data['amount'] = $amount; } @@ -1278,7 +1283,7 @@ class PayPal_Gateway extends Base_Gateway { // If TRANSACTIONID is not passed we need to wait for webhook $payment_status = Payment_Status::PENDING; - if ( ! empty($transaction_id) || $profile_status === 'ActiveProfile' || $is_trial_setup) { + if ( ! empty($transaction_id) || 'ActiveProfile' === $profile_status || $is_trial_setup) { $payment_status = Payment_Status::COMPLETED; } @@ -1311,7 +1316,7 @@ class PayPal_Gateway extends Base_Gateway { $membership->set_gateway_customer_id($details['PAYERID']); $membership->set_gateway('paypal'); - if ($payment_status === Payment_Status::COMPLETED) { + if (Payment_Status::COMPLETED === $payment_status) { $membership->add_to_times_billed(1); /* @@ -1547,6 +1552,7 @@ class PayPal_Gateway extends Base_Gateway { ] ); } + /** * Get checkout details. * diff --git a/inc/gateways/class-stripe-checkout-gateway.php b/inc/gateways/class-stripe-checkout-gateway.php index 946810c..9020379 100644 --- a/inc/gateways/class-stripe-checkout-gateway.php +++ b/inc/gateways/class-stripe-checkout-gateway.php @@ -389,6 +389,7 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { exit; } } + /** * Add credit card fields. * diff --git a/inc/gateways/class-stripe-gateway.php b/inc/gateways/class-stripe-gateway.php index c8bf4fe..690f893 100644 --- a/inc/gateways/class-stripe-gateway.php +++ b/inc/gateways/class-stripe-gateway.php @@ -271,9 +271,9 @@ class Stripe_Gateway extends Base_Stripe_Gateway { * Here, we just need to make sure we process * a membership swap. */ - if ($type === 'upgrade' || $type === 'addon') { + if ('upgrade' === $type || 'addon' === $type) { $this->membership->swap($this->order); - } elseif ($type === 'downgrade') { + } elseif ('downgrade' === $type) { $this->membership->schedule_swap($this->order); } @@ -611,7 +611,7 @@ class Stripe_Gateway extends Base_Stripe_Gateway { $membership->add_to_times_billed(1); $membership->should_auto_renew(); - if ($type !== 'downgrade') { + if ('downgrade' !== $type) { $membership_status = $cart->has_trial() ? Membership_Status::TRIALING : Membership_Status::ACTIVE; $renewal_date = new \DateTime(); diff --git a/inc/helpers/class-arr.php b/inc/helpers/class-arr.php index d8addc1..b2c9d83 100644 --- a/inc/helpers/class-arr.php +++ b/inc/helpers/class-arr.php @@ -60,7 +60,7 @@ class Arr { ); if ($flag) { - $result = $flag === self::RESULTS_FIRST ? reset($result) : end($result); + $result = self::RESULTS_FIRST === $flag ? reset($result) : end($result); } return $result; diff --git a/inc/helpers/class-screenshot.php b/inc/helpers/class-screenshot.php index 96af87d..b930970 100644 --- a/inc/helpers/class-screenshot.php +++ b/inc/helpers/class-screenshot.php @@ -31,6 +31,7 @@ class Screenshot { public static function api_url($domain): string { return 'https://image.thum.io/get/' . $domain; } + /** * Takes in a URL and creates it as an attachment. * @@ -45,6 +46,7 @@ class Screenshot { return self::save_image_from_url($url); } + /** * Downloads the image from the URL. * diff --git a/inc/helpers/class-wp-config.php b/inc/helpers/class-wp-config.php index a698500..2ec4782 100644 --- a/inc/helpers/class-wp-config.php +++ b/inc/helpers/class-wp-config.php @@ -34,7 +34,7 @@ class WP_Config { $config_path = $this->get_wp_config_path(); - if ( ! is_writeable($config_path)) { + if ( ! is_writable($config_path)) { // translators: %s is the file name. return new \WP_Error('not-writeable', sprintf(__('The file %s is not writable', 'wp-ultimo'), $config_path)); @@ -46,12 +46,12 @@ class WP_Config { $content = str_pad(sprintf("define( '%s', '%s' );", $constant, $value), 50) . '// Automatically injected by WP Multisite WaaS;'; - if ($line === false) { + if (false === $line) { // no defined, we just need to inject $hook_line = $this->find_reference_hook_line($config); - if ($hook_line === false) { + if (false === $hook_line) { return new \WP_Error('unknown-wpconfig', __("WP Multisite WaaS can't recognize your wp-config.php, please revert it to original state for further process.", 'wp-ultimo')); } @@ -61,7 +61,7 @@ class WP_Config { } else { [$value, $line] = $line; - if ($value !== true) { + if (true !== $value) { $config[ $line ] = $content . PHP_EOL; return file_put_contents($config_path, implode('', $config), LOCK_EX); @@ -177,7 +177,7 @@ class WP_Config { $config_path = $this->get_wp_config_path(); - if ( ! is_writeable($config_path)) { + if ( ! is_writable($config_path)) { // translators: %s is the file name. return new \WP_Error('not-writeable', sprintf(__('The file %s is not writable', 'wp-ultimo'), $config_path)); @@ -187,14 +187,14 @@ class WP_Config { $line = $this->find_injected_line($config, $constant); - if ($line === false) { + if (false === $line) { return; } else { $value = $line[0]; $line = $line[1]; - if ($value === 'true' || $value === '1') { + if ('true' === $value || '1' === $value) { // value is true, we will remove this unset($config[ $line ]); @@ -204,6 +204,7 @@ class WP_Config { } } } + /** * Checks for the injected line inside of the wp-config.php file. * diff --git a/inc/helpers/validation-rules/class-city.php b/inc/helpers/validation-rules/class-city.php index b53758b..77977d4 100644 --- a/inc/helpers/validation-rules/class-city.php +++ b/inc/helpers/validation-rules/class-city.php @@ -28,6 +28,7 @@ class City extends Rule { * @var array */ protected $fillableParams = ['country', 'state']; + /** * Performs the actual check. * diff --git a/inc/helpers/validation-rules/class-unique.php b/inc/helpers/validation-rules/class-unique.php index f2d74ad..a00b8c6 100644 --- a/inc/helpers/validation-rules/class-unique.php +++ b/inc/helpers/validation-rules/class-unique.php @@ -84,6 +84,7 @@ class Unique extends Rule { if ( ! $existing) { return true; } + if ( $existing instanceof \WP_User) { $id = $existing->ID; } else { diff --git a/inc/installers/class-core-installer.php b/inc/installers/class-core-installer.php index ff2c13f..bb03b4a 100644 --- a/inc/installers/class-core-installer.php +++ b/inc/installers/class-core-installer.php @@ -114,7 +114,7 @@ class Core_Installer extends Base_Installer { $success = $table->install(); - if ($success === false) { + if (false === $success) { // translators: %s is the name of a database table, e.g. wu_memberships. $error_message = sprintf(__('Installation of the table %s failed', 'wp-ultimo'), $table->get_name()); diff --git a/inc/installers/class-migrator.php b/inc/installers/class-migrator.php index 6144ee3..c6c9e3e 100644 --- a/inc/installers/class-migrator.php +++ b/inc/installers/class-migrator.php @@ -217,6 +217,7 @@ class Migrator extends Base_Installer { */ return ! self::is_migration_done(); } + /** * Returns the list of errors detected. * @@ -226,6 +227,7 @@ class Migrator extends Base_Installer { return array_unique((array) $this->errors); } + /** * Returns the list of _backtraces detected. * @@ -409,7 +411,7 @@ class Migrator extends Base_Installer { */ $set_memory_limit = @ini_set('memory_limit', '-1'); // phpcs:ignore - if ($set_memory_limit === false) { + if (false === $set_memory_limit) { $error->add('memory_limit', sprintf($message, 'memory_limit')); } @@ -418,7 +420,7 @@ class Migrator extends Base_Installer { */ $set_time_limit = @set_time_limit(0); // phpcs:ignore - if ($set_time_limit === false) { + if (false === $set_time_limit) { $error->add('time_limit', sprintf($message, 'time_limit')); } @@ -1153,7 +1155,7 @@ class Migrator extends Base_Installer { $site_template_enabled = true; $force_template = false; - if ($has_template_selection_options === false) { + if (false === $has_template_selection_options) { $force_template = get_post_meta($plan->ID, 'wpu_site_template', true); if ($force_template && wu_get_site($force_template)) { @@ -1181,7 +1183,7 @@ class Migrator extends Base_Installer { $behavior = $has_custom_template_list ? 'not_available' : 'available'; - if ($site_template_id === absint($force_template)) { + if (absint($force_template) === $site_template_id) { $behavior = 'pre_selected'; } elseif (in_array($site_template_id, $templates)) { // phpcs:ignore; @@ -1258,7 +1260,7 @@ class Migrator extends Base_Installer { $post_types_limit = []; foreach ($quotas as $post_type => $quota) { - if ($post_type === 'users' && ! $unlimited_users) { + if ('users' === $post_type && ! $unlimited_users) { $user_roles = get_editable_roles(); $roles_limit = []; @@ -1274,17 +1276,17 @@ class Migrator extends Base_Installer { 'limit' => $roles_limit, 'enabled' => true, ]; - } elseif ($post_type === 'upload') { + } elseif ('upload' === $post_type) { $limitations_modules['disk_space'] = [ 'limit' => absint($quota), 'enabled' => true, ]; - } elseif ($post_type === 'visits') { + } elseif ('visits' === $post_type) { $limitations_modules['visits'] = [ 'limit' => $quota ? absint($quota) : '', 'enabled' => true, ]; - } elseif ($post_type === 'sites') { + } elseif ('sites' === $post_type) { $limitations_modules['sites'] = [ 'limit' => absint($quota), 'enabled' => true, @@ -2201,6 +2203,7 @@ class Migrator extends Base_Installer { } } } + /** * Convert hard-coded thumbnail urls into v2 thumbnails. * @@ -2451,7 +2454,7 @@ class Migrator extends Base_Installer { $style = get_post_meta($broadcast->ID, 'wpu_style', true); - $new_type = $old_type === 'message' ? 'broadcast_notice' : 'broadcast_email'; + $new_type = 'message' === $old_type ? 'broadcast_notice' : 'broadcast_email'; $customer_targets = (array) get_post_meta($broadcast->ID, 'wpu_target_users', true); $product_targets = (array) get_post_meta($broadcast->ID, 'wpu_target_plans', true); diff --git a/inc/integrations/host-providers/class-base-host-provider.php b/inc/integrations/host-providers/class-base-host-provider.php index 237b650..3903a3f 100644 --- a/inc/integrations/host-providers/class-base-host-provider.php +++ b/inc/integrations/host-providers/class-base-host-provider.php @@ -429,7 +429,7 @@ abstract class Base_Host_Provider { /* * If any constant fail, bail. */ - if ($all_set === false) { + if (false === $all_set) { return false; } } diff --git a/inc/integrations/host-providers/class-cloudflare-host-provider.php b/inc/integrations/host-providers/class-cloudflare-host-provider.php index c48d67e..b029dce 100644 --- a/inc/integrations/host-providers/class-cloudflare-host-provider.php +++ b/inc/integrations/host-providers/class-cloudflare-host-provider.php @@ -134,6 +134,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { return $dns_records; } + /** * Picks up on tips that a given host provider is being used. * @@ -358,6 +359,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { wu_log_add('integration-cloudflare', sprintf('Removed sub-domain "%s" to Cloudflare.', $subdomain)); } } + /** * Sends an API call to Cloudflare. * @@ -378,7 +380,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { $endpoint_url, [ 'method' => $method, - 'body' => $method === 'GET' ? $data : wp_json_encode($data), + 'body' => 'GET' === $method ? $data : wp_json_encode($data), 'data_format' => 'body', 'headers' => [ 'Authorization' => sprintf('Bearer %s', defined('WU_CLOUDFLARE_API_KEY') ? WU_CLOUDFLARE_API_KEY : ''), diff --git a/inc/integrations/host-providers/class-cloudways-host-provider.php b/inc/integrations/host-providers/class-cloudways-host-provider.php index 36ee6b8..9572960 100644 --- a/inc/integrations/host-providers/class-cloudways-host-provider.php +++ b/inc/integrations/host-providers/class-cloudways-host-provider.php @@ -123,6 +123,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider { wu_log_add('integration-cloudways', '[SSL]' . print_r($ssl_response, true)); } } + /** * Picks up on tips that a given host provider is being used. * @@ -248,6 +249,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider { wu_log_add('integration-cloudways', '[Alias]' . print_r($alias_response, true)); } } + /** * Returns an array of valid SSL domains to be used with the Cloudways API based on a list of domains. * @@ -279,6 +281,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider { return array_values(array_unique(array_filter($ssl_valid_domains))); } + /** * Returns an array of all domains that should be added to Cloudways. * @@ -469,7 +472,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider { $endpoint_url = "https://api.cloudways.com/api/v1$endpoint"; - if ($method === 'GET') { + if ('GET' === $method) { $endpoint_url = add_query_arg( [ 'server_id' => defined('WU_CLOUDWAYS_SERVER_ID') ? WU_CLOUDWAYS_SERVER_ID : '', diff --git a/inc/integrations/host-providers/class-cpanel-host-provider.php b/inc/integrations/host-providers/class-cpanel-host-provider.php index 0b0fe3d..45f1a9c 100644 --- a/inc/integrations/host-providers/class-cpanel-host-provider.php +++ b/inc/integrations/host-providers/class-cpanel-host-provider.php @@ -255,6 +255,7 @@ class CPanel_Host_Provider extends Base_Host_Provider { return $this->api; } + /** * Returns the Site URL. * @@ -276,7 +277,7 @@ class CPanel_Host_Provider extends Base_Host_Provider { */ public function get_subdomain($domain, $mapped_domain = true) { - if ($mapped_domain === false) { + if (false === $mapped_domain) { $domain_parts = explode('.', $domain); return array_shift($domain_parts); diff --git a/inc/integrations/host-providers/class-runcloud-host-provider.php b/inc/integrations/host-providers/class-runcloud-host-provider.php index 12e6ece..8b28579 100644 --- a/inc/integrations/host-providers/class-runcloud-host-provider.php +++ b/inc/integrations/host-providers/class-runcloud-host-provider.php @@ -307,6 +307,7 @@ class Runcloud_Host_Provider extends Base_Host_Provider { return false; } + /** * Checks if RunCloud has a SSL cert installed or not, and returns the ID. * diff --git a/inc/integrations/host-providers/class-serverpilot-host-provider.php b/inc/integrations/host-providers/class-serverpilot-host-provider.php index 99b1efc..3e4e0a9 100644 --- a/inc/integrations/host-providers/class-serverpilot-host-provider.php +++ b/inc/integrations/host-providers/class-serverpilot-host-provider.php @@ -152,7 +152,7 @@ class ServerPilot_Host_Provider extends Base_Host_Provider { /** * Removes the current domain fromt he domain list */ - $current_domain_list = array_filter($current_domain_list, fn($remote_domain) => $remote_domain !== $domain && $remote_domain !== 'www.' . $domain); + $current_domain_list = array_filter($current_domain_list, fn($remote_domain) => $remote_domain !== $domain && 'www.' . $domain !== $remote_domain); $this->send_server_pilot_api_request( '', diff --git a/inc/integrations/host-providers/cpanel-api/class-cpanel-api.php b/inc/integrations/host-providers/cpanel-api/class-cpanel-api.php index 6a723ef..3a888e9 100644 --- a/inc/integrations/host-providers/cpanel-api/class-cpanel-api.php +++ b/inc/integrations/host-providers/cpanel-api/class-cpanel-api.php @@ -55,22 +55,27 @@ class CPanel_API { * @var string|null */ private ?string $ex_page = null; + /** * @var string */ private $username; + /** * @var string */ private $password; + /** * @var string */ private $host; + /** * @var integer */ private $port = 2083; + /** * @var boolean */ @@ -212,6 +217,7 @@ class CPanel_API { return (@gzdecode($answer)) ? gzdecode($answer) : $answer; // phpcs:ignore } + /** * Get the base URL to make the calls. * diff --git a/inc/limitations/class-limit-post-types.php b/inc/limitations/class-limit-post-types.php index dc234ac..418729c 100644 --- a/inc/limitations/class-limit-post-types.php +++ b/inc/limitations/class-limit-post-types.php @@ -70,7 +70,7 @@ class Limit_Post_Types extends Limit_Subtype { $post_count = wp_count_posts($post_type); - $statuses = $post_type === 'attachment' ? ['inherit'] : ['publish', 'private']; + $statuses = 'attachment' === $post_type ? ['inherit'] : ['publish', 'private']; /** * Allow plugin developers to change which post status should be counted diff --git a/inc/limitations/class-limit.php b/inc/limitations/class-limit.php index f44ec69..39cf6f2 100644 --- a/inc/limitations/class-limit.php +++ b/inc/limitations/class-limit.php @@ -134,7 +134,7 @@ abstract class Limit implements \JsonSerializable { /* * Sets the own limit flag, if necessary. */ - if ($current_limit === 'not-set' || $current_limit === '') { + if ('not-set' === $current_limit || '' === $current_limit) { $this->has_own_limit = false; } diff --git a/inc/limits/class-theme-limits.php b/inc/limits/class-theme-limits.php index 44ed2aa..5ceb084 100644 --- a/inc/limits/class-theme-limits.php +++ b/inc/limits/class-theme-limits.php @@ -115,7 +115,7 @@ class Theme_Limits { $pending_theme_switch = $context['manager']->is_theme_active() === false; - if ($pending_theme_switch === false) { + if (false === $pending_theme_switch) { return $data; } @@ -157,7 +157,7 @@ class Theme_Limits { return; } - if ($pagenow !== 'themes.php') { + if ('themes.php' !== $pagenow) { return; } diff --git a/inc/list-tables/class-base-list-table.php b/inc/list-tables/class-base-list-table.php index 5c3c325..1e2f34b 100644 --- a/inc/list-tables/class-base-list-table.php +++ b/inc/list-tables/class-base-list-table.php @@ -249,7 +249,7 @@ class Base_List_Table extends \WP_List_Table { foreach ($extra_query_args as $extra_query_arg) { $query = wu_request($extra_query_arg, 'all'); - if ($query !== 'all') { + if ('all' !== $query) { $query_args[ $extra_query_arg ] = $query; } } @@ -403,7 +403,7 @@ class Base_List_Table extends \WP_List_Table { 'wu_list_table', [ 'base_url' => wu_get_form_url('bulk_actions'), - 'model' => strchr($this->get_table_id(), '_', true), + 'model' => strstr($this->get_table_id(), '_', true), 'i18n' => [ 'confirm' => __('Confirm Action', 'wp-ultimo'), ], @@ -647,9 +647,9 @@ class Base_List_Table extends \WP_List_Table { $model = wu_request('model'); - if ($model === 'checkout') { + if ('checkout' === $model) { $model = 'checkout_form'; - } elseif ($model === 'discount') { + } elseif ('discount' === $model) { $model = 'discount_code'; } diff --git a/inc/list-tables/class-broadcast-list-table.php b/inc/list-tables/class-broadcast-list-table.php index 30df928..4c5497c 100644 --- a/inc/list-tables/class-broadcast-list-table.php +++ b/inc/list-tables/class-broadcast-list-table.php @@ -78,28 +78,29 @@ class Broadcast_List_Table extends Base_List_Table { $class = 'wu-bg-gray-200'; - if ($type === 'broadcast_email') { + if ('broadcast_email' === $type) { $label = __('Email', 'wp-ultimo'); } - if ($type === 'broadcast_notice') { + if ('broadcast_notice' === $type) { $status = $item->get_notice_type(); $label = __('Notice', 'wp-ultimo'); - if ($status === 'info') { + if ('info' === $status) { $class = 'wu-bg-blue-200'; - } elseif ($status === 'success') { + } elseif ('success' === $status) { $class = 'wu-bg-green-200'; - } elseif ($status === 'warning') { + } elseif ('warning' === $status) { $class = 'wu-bg-orange-200'; - } elseif ($status === 'error') { + } elseif ('error' === $status) { $class = 'wu-bg-red-200'; } } return "{$label}"; } + /** * Displays the name of the broadcast. * @@ -428,6 +429,7 @@ class Broadcast_List_Table extends Base_List_Table { return $columns; } + /** * Returns the filters for this page. * diff --git a/inc/list-tables/class-checkout-form-list-table.php b/inc/list-tables/class-checkout-form-list-table.php index efa270c..9b091ee 100644 --- a/inc/list-tables/class-checkout-form-list-table.php +++ b/inc/list-tables/class-checkout-form-list-table.php @@ -46,6 +46,7 @@ class Checkout_Form_List_Table extends Base_List_Table { ] ); } + /** * Displays the content of the product column. * @@ -97,6 +98,7 @@ class Checkout_Form_List_Table extends Base_List_Table { return "{$slug}"; } + /** * Displays the number pof steps and fields. * @@ -108,6 +110,7 @@ class Checkout_Form_List_Table extends Base_List_Table { return sprintf(__('%1$d Step(s) and %2$d Field(s)', 'wp-ultimo'), $item->get_step_count(), $item->get_field_count()); } + /** * Displays the form shortcode. * @@ -138,7 +141,7 @@ class Checkout_Form_List_Table extends Base_List_Table { $bulk_action = $this->current_action(); - if ($bulk_action === 'duplicate') { + if ('duplicate' === $bulk_action) { $checkout_form_id = wu_request('id'); $checkout_form = wu_get_checkout_form($checkout_form_id); @@ -199,6 +202,7 @@ class Checkout_Form_List_Table extends Base_List_Table { return $columns; } + /** * Returns the filters for this page. * diff --git a/inc/list-tables/class-customer-list-table.php b/inc/list-tables/class-customer-list-table.php index 607fe23..afb55ab 100644 --- a/inc/list-tables/class-customer-list-table.php +++ b/inc/list-tables/class-customer-list-table.php @@ -102,6 +102,7 @@ class Customer_List_Table extends Base_List_Table { return $_filter_fields; } + /** * Displays the content of the name column. * @@ -202,6 +203,7 @@ class Customer_List_Table extends Base_List_Table { return $html; } + /** * Returns the number of memberships owned by this customer. * diff --git a/inc/list-tables/class-discount-code-list-table.php b/inc/list-tables/class-discount-code-list-table.php index 818a725..a9bfc7a 100644 --- a/inc/list-tables/class-discount-code-list-table.php +++ b/inc/list-tables/class-discount-code-list-table.php @@ -46,6 +46,7 @@ class Discount_Code_List_Table extends Base_List_Table { ] ); } + /** * Displays the content of the name column. * @@ -195,6 +196,7 @@ class Discount_Code_List_Table extends Base_List_Table { return $columns; } + /** * Returns the filters for this page. * diff --git a/inc/list-tables/class-domain-list-table.php b/inc/list-tables/class-domain-list-table.php index 4f7f8c1..54fec5d 100644 --- a/inc/list-tables/class-domain-list-table.php +++ b/inc/list-tables/class-domain-list-table.php @@ -66,6 +66,7 @@ class Domain_List_Table extends Base_List_Table { return $_filter_fields; } + /** * Displays the content of the domain column. * @@ -169,6 +170,7 @@ class Domain_List_Table extends Base_List_Table { return $columns; } + /** * Returns the filters for this page. * diff --git a/inc/list-tables/class-email-list-table.php b/inc/list-tables/class-email-list-table.php index cdfbb08..33e9219 100644 --- a/inc/list-tables/class-email-list-table.php +++ b/inc/list-tables/class-email-list-table.php @@ -73,7 +73,7 @@ class Email_List_Table extends Base_List_Table { $target = wu_request('target'); - if ($target && $target !== 'all') { + if ($target && 'all' !== $target) { $query['meta_query'] = [ 'type' => [ 'key' => 'wu_target', @@ -86,6 +86,7 @@ class Email_List_Table extends Base_List_Table { return wu_get_emails($query); } + /** * Displays the title of the email. * @@ -212,7 +213,7 @@ class Email_List_Table extends Base_List_Table { $bulk_action = $this->current_action(); - if ($bulk_action === 'duplicate') { + if ('duplicate' === $bulk_action) { $email_id = wu_request('id'); $email = wu_get_email($email_id); @@ -280,6 +281,7 @@ class Email_List_Table extends Base_List_Table { exit; } } + /** * Returns the filters for this page. * diff --git a/inc/list-tables/class-event-list-table.php b/inc/list-tables/class-event-list-table.php index 740c109..fe15d86 100644 --- a/inc/list-tables/class-event-list-table.php +++ b/inc/list-tables/class-event-list-table.php @@ -78,7 +78,7 @@ class Event_List_Table extends Base_List_Table { $object_label_tooltip = substr($object_severity_label, 0, 1); - if ($object_initiator === 'system') { + if ('system' === $object_initiator) { $avatar = ''; $system_text = ucfirst($object_initiator); @@ -97,7 +97,7 @@ class Event_List_Table extends Base_List_Table { "; // phpcs:enable - } elseif ($object_initiator === 'manual') { + } elseif ('manual' === $object_initiator) { $avatar = get_avatar( $item->get_author_id(), 32, @@ -164,6 +164,7 @@ class Event_List_Table extends Base_List_Table { return "{$object_slug}"; } + /** * Returns the markup for the message column. * @@ -216,6 +217,7 @@ class Event_List_Table extends Base_List_Table { return apply_filters('wu_events_list_table_get_columns', $columns, $this); } + /** * Returns the filters for this page. * diff --git a/inc/list-tables/class-inside-events-list-table.php b/inc/list-tables/class-inside-events-list-table.php index 07b1e28..290960f 100644 --- a/inc/list-tables/class-inside-events-list-table.php +++ b/inc/list-tables/class-inside-events-list-table.php @@ -59,9 +59,9 @@ class Inside_Events_List_Table extends Event_List_Table { $object_initiator = $item->get_initiator(); - if ($object_initiator === 'system') { + if ('system' === $object_initiator) { $value = sprintf('%s', __('Automatically processed by WP Multisite WaaS', 'wp-ultimo')); - } elseif ($object_initiator === 'manual') { + } elseif ('manual' === $object_initiator) { $avatar = get_avatar( $item->get_author_id(), 16, diff --git a/inc/list-tables/class-membership-list-table-widget.php b/inc/list-tables/class-membership-list-table-widget.php index eca6d8d..7e92329 100644 --- a/inc/list-tables/class-membership-list-table-widget.php +++ b/inc/list-tables/class-membership-list-table-widget.php @@ -112,6 +112,7 @@ class Membership_List_Table_Widget extends Base_List_Table { return $_filter_fields; } + /** * Displays the membership reference code. * @@ -269,6 +270,7 @@ class Membership_List_Table_Widget extends Base_List_Table { return $columns; } + /** * Overrides the parent method to include the custom ajax functionality for WP Multisite WaaS. * diff --git a/inc/list-tables/class-membership-list-table.php b/inc/list-tables/class-membership-list-table.php index 3144b57..c6f4099 100644 --- a/inc/list-tables/class-membership-list-table.php +++ b/inc/list-tables/class-membership-list-table.php @@ -198,7 +198,7 @@ class Membership_List_Table extends Base_List_Table { $date = $item->get_date_expiration(); - if (empty($date) || $date === '0000-00-00 00:00:00') { + if (empty($date) || '0000-00-00 00:00:00' === $date) { return sprintf('%s
%s', __('Lifetime', 'wp-ultimo'), __('It never expires', 'wp-ultimo')); } diff --git a/inc/list-tables/class-payment-list-table-widget.php b/inc/list-tables/class-payment-list-table-widget.php index f407890..7969366 100644 --- a/inc/list-tables/class-payment-list-table-widget.php +++ b/inc/list-tables/class-payment-list-table-widget.php @@ -95,6 +95,7 @@ class Payment_List_Table_Widget extends Base_List_Table { return $query; } + /** * Displays the payment reference code. * @@ -193,6 +194,7 @@ class Payment_List_Table_Widget extends Base_List_Table { return $html; } + /** * Displays the column for the total amount of the payment. * diff --git a/inc/list-tables/class-product-list-table.php b/inc/list-tables/class-product-list-table.php index 211c2e8..300728a 100644 --- a/inc/list-tables/class-product-list-table.php +++ b/inc/list-tables/class-product-list-table.php @@ -195,7 +195,7 @@ class Product_List_Table extends Base_List_Table { $bulk_action = $this->current_action(); - if ($bulk_action === 'duplicate') { + if ('duplicate' === $bulk_action) { $product = wu_request('id'); $product = wu_get_product($product); diff --git a/inc/list-tables/class-site-list-table.php b/inc/list-tables/class-site-list-table.php index d98a969..b10cfe4 100644 --- a/inc/list-tables/class-site-list-table.php +++ b/inc/list-tables/class-site-list-table.php @@ -66,7 +66,7 @@ class Site_List_Table extends Base_List_Table { $type = wu_request('type'); - if ($type === 'pending') { + if ('pending' === $type) { $pending_sites = \WP_Ultimo\Models\Site::get_all_by_type('pending'); return $count ? count($pending_sites) : $pending_sites; @@ -79,7 +79,7 @@ class Site_List_Table extends Base_List_Table { 'search' => wu_request('s'), ]; - if ($type && $type !== 'all') { + if ($type && 'all' !== $type) { $query['meta_query'] = [ 'type' => [ 'key' => 'wu_type', @@ -92,6 +92,7 @@ class Site_List_Table extends Base_List_Table { return wu_get_sites($query); } + /** * Render the bulk edit checkbox. * @@ -105,6 +106,7 @@ class Site_List_Table extends Base_List_Table { return sprintf('', $item->get_id()); } + /** * Displays the content of the name column. * @@ -185,6 +187,7 @@ class Site_List_Table extends Base_List_Table { return $title . sprintf('%s', make_clickable($item->get_active_site_url())) . $this->row_actions($actions); } + /** * Returns the date of the customer registration. * @@ -228,6 +231,7 @@ class Site_List_Table extends Base_List_Table { return "{$label}"; } + /** * Column for the domains associated with this site. * @@ -295,6 +299,7 @@ class Site_List_Table extends Base_List_Table { ] ); } + /** * Returns the filters for this page. * @@ -387,7 +392,7 @@ class Site_List_Table extends Base_List_Table { $action = $this->current_action(); - if ($action === 'duplicate') { + if ('duplicate' === $action) { $site_id = wu_request('id'); $site = wu_get_site($site_id); diff --git a/inc/list-tables/class-webhook-list-table.php b/inc/list-tables/class-webhook-list-table.php index 3f3ca49..78e1a9d 100644 --- a/inc/list-tables/class-webhook-list-table.php +++ b/inc/list-tables/class-webhook-list-table.php @@ -46,6 +46,7 @@ class Webhook_List_Table extends Base_List_Table { ] ); } + /** * Displays the content of the name column. * @@ -115,6 +116,7 @@ class Webhook_List_Table extends Base_List_Table { return "{$event}"; } + /** * Displays the content of the count column. * @@ -132,6 +134,7 @@ class Webhook_List_Table extends Base_List_Table { return $count . $this->row_actions($actions); } + /** * Displays the content of the integration column. * @@ -178,6 +181,7 @@ class Webhook_List_Table extends Base_List_Table { return $columns; } + /** * Returns the filters for this page. * diff --git a/inc/managers/class-broadcast-manager.php b/inc/managers/class-broadcast-manager.php index d62ad7f..7e7db07 100644 --- a/inc/managers/class-broadcast-manager.php +++ b/inc/managers/class-broadcast-manager.php @@ -134,7 +134,7 @@ class Broadcast_Manager extends Base_Manager { $args['type'] = $broadcast_type; - if ($broadcast_type === 'broadcast_notice') { + if ('broadcast_notice' === $broadcast_type) { $targets = [ 'customers' => $target_customers, 'products' => $target_products, diff --git a/inc/managers/class-customer-manager.php b/inc/managers/class-customer-manager.php index 40fbb4e..35791a0 100644 --- a/inc/managers/class-customer-manager.php +++ b/inc/managers/class-customer-manager.php @@ -163,7 +163,7 @@ class Customer_Manager extends Base_Manager { */ public function transition_customer_email_verification($old_status, $new_status, $customer_id): void { - if ($new_status !== 'pending') { + if ('pending' !== $new_status) { return; } @@ -317,7 +317,7 @@ class Customer_Manager extends Base_Manager { $is_already_user = is_user_member_of_blog($user_id, wu_get_main_site_id()); - if ($is_already_user === false) { + if (false === $is_already_user) { $role = wu_get_setting('main_site_default_role', 'subscriber'); add_user_to_blog(wu_get_main_site_id(), $user_id, $role); diff --git a/inc/managers/class-domain-manager.php b/inc/managers/class-domain-manager.php index e2f5e65..b9d0289 100644 --- a/inc/managers/class-domain-manager.php +++ b/inc/managers/class-domain-manager.php @@ -381,6 +381,7 @@ class Domain_Manager extends Base_Manager { ] ); } + /** * Returns the default instructions for domain mapping. * @@ -481,7 +482,7 @@ class Domain_Manager extends Base_Manager { // translators: %s is the domain name wu_log_add("domain-{$domain_url}", sprintf(__('Starting Check for %s', 'wp-ultimo'), $domain_url)); - if ($stage === 'checking-dns') { + if ('checking-dns' === $stage) { if ($domain->has_correct_dns()) { $domain->set_stage('checking-ssl-cert'); @@ -540,7 +541,7 @@ class Domain_Manager extends Base_Manager { return; } - } elseif ($stage === 'checking-ssl-cert') { + } elseif ('checking-ssl-cert' === $stage) { if ($domain->has_valid_ssl_certificate()) { $domain->set_stage('done'); @@ -685,7 +686,7 @@ class Domain_Manager extends Base_Manager { ); } - if ($result === false) { + if (false === $result) { wp_send_json_error(new \WP_Error('error', __('Not able to fetch DNS entries.', 'wp-ultimo'))); } diff --git a/inc/managers/class-event-manager.php b/inc/managers/class-event-manager.php index 78b0603..98d51b0 100644 --- a/inc/managers/class-event-manager.php +++ b/inc/managers/class-event-manager.php @@ -98,7 +98,7 @@ class Event_Manager extends Base_Manager { */ public function log_transitions($model, $data, $data_unserialized, $object) { - if ($model === 'event') { + if ('event' === $model) { return; } @@ -143,7 +143,7 @@ class Event_Manager extends Base_Manager { foreach ($diff as $key => $new_value) { $old_value = wu_get_isset($original, $key, ''); - if ($key === 'id' && intval($old_value) === 0) { + if ('id' === $key && intval($old_value) === 0) { return; } @@ -561,7 +561,7 @@ class Event_Manager extends Base_Manager { } if (method_exists($obj, 'get_billing_address') || method_exists($obj, 'get_membership')) { - if ($model_object) { + if (null !== $model_object) { $payload = method_exists($obj, 'get_billing_address') ? array_merge( $payload, diff --git a/inc/managers/class-limitation-manager.php b/inc/managers/class-limitation-manager.php index 61c0cfd..9582143 100644 --- a/inc/managers/class-limitation-manager.php +++ b/inc/managers/class-limitation-manager.php @@ -75,9 +75,9 @@ class Limitation_Manager { switch_to_blog($site_id); - if ($action === 'activate') { + if ('activate' === $action) { $results = activate_plugins($plugins, '', $network_wide, $silent); - } elseif ($action === 'deactivate') { + } elseif ('deactivate' === $action) { $results = deactivate_plugins($plugins, $silent, $network_wide); } @@ -820,6 +820,7 @@ class Limitation_Manager { return $listed_plugins; } + /** * Returns a list of all themes available as options, after filtering. * diff --git a/inc/managers/class-membership-manager.php b/inc/managers/class-membership-manager.php index 624f23b..4d58b15 100644 --- a/inc/managers/class-membership-manager.php +++ b/inc/managers/class-membership-manager.php @@ -114,6 +114,7 @@ class Membership_Manager extends Base_Manager { exit; // Just exit the request } + /** * Processes a delayed site publish action. * @@ -169,6 +170,7 @@ class Membership_Manager extends Base_Manager { exit; } + /** * Processes a membership swap. * @@ -279,7 +281,7 @@ class Membership_Manager extends Base_Manager { */ public function mark_cancelled_date($old_value, $new_value, $item_id): void { - if ($new_value === 'cancelled' && $new_value !== $old_value) { + if ('cancelled' === $new_value && $new_value !== $old_value) { $membership = wu_get_membership($item_id); $membership->set_date_cancellation(wu_get_current_time('mysql', true)); diff --git a/inc/managers/class-notes-manager.php b/inc/managers/class-notes-manager.php index 324ff45..0422e80 100644 --- a/inc/managers/class-notes-manager.php +++ b/inc/managers/class-notes-manager.php @@ -474,7 +474,7 @@ class Notes_Manager extends Base_Manager { $status = $object->delete_note($note_id); - if (is_wp_error($status) || $status === false) { + if (is_wp_error($status) || false === $status) { wp_send_json_error(new \WP_Error('not-found', __('Note not found', 'wp-ultimo'))); } diff --git a/inc/managers/class-notification-manager.php b/inc/managers/class-notification-manager.php index 6e6a714..2b40692 100644 --- a/inc/managers/class-notification-manager.php +++ b/inc/managers/class-notification-manager.php @@ -73,11 +73,11 @@ class Notification_Manager { $cleaner = [$this, 'clear_callback_list']; if (wu_get_isset($wp_filter, 'admin_notices')) { - $wp_filter['admin_notices']->callbacks = array_filter($wp_filter['admin_notices']->callbacks, $cleaner ?? fn($v, $k): bool => ! empty($v), $cleaner === null ? ARRAY_FILTER_USE_BOTH : 0); + $wp_filter['admin_notices']->callbacks = array_filter($wp_filter['admin_notices']->callbacks, $cleaner ?? fn($v, $k): bool => ! empty($v), null === $cleaner ? ARRAY_FILTER_USE_BOTH : 0); } if (wu_get_isset($wp_filter, 'all_admin_notices')) { - $wp_filter['all_admin_notices']->callbacks = array_filter($wp_filter['all_admin_notices']->callbacks, $cleaner ?? fn($v, $k): bool => ! empty($v), $cleaner === null ? ARRAY_FILTER_USE_BOTH : 0); + $wp_filter['all_admin_notices']->callbacks = array_filter($wp_filter['all_admin_notices']->callbacks, $cleaner ?? fn($v, $k): bool => ! empty($v), null === $cleaner ? ARRAY_FILTER_USE_BOTH : 0); } } diff --git a/inc/managers/class-site-manager.php b/inc/managers/class-site-manager.php index 0249b4d..7413347 100644 --- a/inc/managers/class-site-manager.php +++ b/inc/managers/class-site-manager.php @@ -124,7 +124,7 @@ class Site_Manager extends Base_Manager { * if so, we remove it and re-validate with our custom rule * which is the same, but also allows for hyphens. */ - if ( ! empty($blogname_errors) && $error_key !== false) { + if ( ! empty($blogname_errors) && false !== $error_key) { unset($result['errors']->errors['blogname'][ $error_key ]); if (empty($result['errors']->errors['blogname'])) { @@ -284,14 +284,14 @@ class Site_Manager extends Base_Manager { $status = $membership ? $membership->get_status() : false; - $is_cancelled = $status === Membership_Status::CANCELLED; + $is_cancelled = Membership_Status::CANCELLED === $status; - $is_inactive = $status && ! $membership->is_active() && $status !== Membership_Status::TRIALING; + $is_inactive = $status && ! $membership->is_active() && Membership_Status::TRIALING !== $status; if ($is_cancelled || ($is_inactive && wu_get_setting('block_frontend', false))) { // If membership is cancelled we do not add the grace period - $grace_period = $status !== Membership_Status::CANCELLED ? (int) wu_get_setting('block_frontend_grace_period', 0) : 0; + $grace_period = Membership_Status::CANCELLED !== $status ? (int) wu_get_setting('block_frontend_grace_period', 0) : 0; $expiration_time = wu_date($membership->get_date_expiration())->getTimestamp() + $grace_period * DAY_IN_SECONDS; @@ -305,7 +305,7 @@ class Site_Manager extends Base_Manager { } } - if ($can_access === false) { + if (false === $can_access) { if ($redirect_url) { wp_redirect($redirect_url); @@ -678,7 +678,7 @@ class Site_Manager extends Base_Manager { */ public function filter_illegal_search_keys($search_and_replace): array { - return array_filter($search_and_replace, fn($k) => ! is_null($k) && $k !== false && ! empty($k), ARRAY_FILTER_USE_KEY); + return array_filter($search_and_replace, fn($k) => ! is_null($k) && false !== $k && ! empty($k), ARRAY_FILTER_USE_KEY); } /** diff --git a/inc/models/class-base-model.php b/inc/models/class-base-model.php index 95794e6..704fee7 100644 --- a/inc/models/class-base-model.php +++ b/inc/models/class-base-model.php @@ -208,12 +208,7 @@ abstract class Base_Model implements \JsonSerializable { $vars = get_object_vars($object); $this->attributes($vars); - - if (empty($this->id)) { - return false; - } - - return true; + return !empty($this->id); } /** @@ -227,7 +222,7 @@ abstract class Base_Model implements \JsonSerializable { public function attributes($atts) { foreach ($atts as $key => $value) { - if ($key === 'meta' && is_array($value)) { + if ('meta' === $key && is_array($value)) { $this->meta = is_array($this->meta) ? array_merge($this->meta, $value) : $value; } @@ -691,14 +686,8 @@ abstract class Base_Model implements \JsonSerializable { return false; } - if ( ! $this->get_id() && ! $this->_mocked) { - - // _doing_it_wrong(__METHOD__, __('Model metadata only works for already saved models.', 'wp-ultimo'), '2.0.0'); - - return false; - } - - return true; + // _doing_it_wrong(__METHOD__, __('Model metadata only works for already saved models.', 'wp-ultimo'), '2.0.0'); + return !(! $this->get_id() && ! $this->_mocked); } /** @@ -1075,7 +1064,7 @@ abstract class Base_Model implements \JsonSerializable { public function hydrate(): void { $attributes = get_object_vars($this); - $attributes = array_filter($attributes, fn ($value) => $value === null); + $attributes = array_filter($attributes, fn ($value) => null === $value); unset($attributes['meta']); diff --git a/inc/models/class-checkout-form.php b/inc/models/class-checkout-form.php index 040e4bf..037557b 100644 --- a/inc/models/class-checkout-form.php +++ b/inc/models/class-checkout-form.php @@ -26,6 +26,7 @@ class Checkout_Form extends Base_Model { * @var array|array */ public $meta; + /** * The name of the checkout form. * @@ -274,6 +275,7 @@ class Checkout_Form extends Base_Model { $this->settings = $settings; } + /** * Returns a specific step by the step name. * @@ -289,7 +291,7 @@ class Checkout_Form extends Base_Model { $step_key = array_search($step_name, array_column($settings, 'id'), true); - $step = $step_key !== false ? $settings[ $step_key ] : false; + $step = false !== $step_key ? $settings[ $step_key ] : false; if ($step) { $step = wp_parse_args( @@ -303,6 +305,7 @@ class Checkout_Form extends Base_Model { return $step; } + /** * Returns the steps to show in current form * @@ -336,11 +339,11 @@ class Checkout_Form extends Base_Model { foreach ($steps as $key => $step) { $logged = wu_get_isset($step, 'logged', 'always'); - $show = $logged === 'always'; + $show = 'always' === $logged; - if ($logged === 'guests_only' && ! $user_exists) { + if ('guests_only' === $logged && ! $user_exists) { $show = true; - } elseif ($logged === 'logged_only' && $user_exists) { + } elseif ('logged_only' === $logged && $user_exists) { $show = true; } @@ -369,6 +372,7 @@ class Checkout_Form extends Base_Model { return $final_steps; } + /** * Returns a specific field by the step name and field name. * @@ -388,7 +392,7 @@ class Checkout_Form extends Base_Model { $field_key = array_search($field_name, array_column($step['fields'], 'id'), true); - return $field_key !== false ? $step['fields'][ $field_key ] : false; + return false !== $field_key ? $step['fields'][ $field_key ] : false; } /** @@ -488,6 +492,7 @@ class Checkout_Form extends Base_Model { return is_array($fields) ? count($fields) : 0; } + /** * Returns the shortcode that needs to be placed to embed this form. * @@ -510,11 +515,11 @@ class Checkout_Form extends Base_Model { $fields = []; - if ($template === 'multi-step') { + if ('multi-step' === $template) { $fields = $this->get_multi_step_template(); $this->set_settings($fields); - } elseif ($template === 'single-step') { + } elseif ('single-step' === $template) { $fields = $this->get_single_step_template(); } @@ -811,7 +816,7 @@ class Checkout_Form extends Base_Model { /** * Deal with special cases. */ - if ($step_id === 'plan') { + if ('plan' === $step_id) { $products_list = wu_get_plans( [ 'fields' => 'ids', @@ -873,7 +878,7 @@ class Checkout_Form extends Base_Model { /** * Deal with special cases. */ - if ($step_id === 'template' && wu_get_isset($old_settings, 'allow_template', true)) { + if ('template' === $step_id && wu_get_isset($old_settings, 'allow_template', true)) { $templates = []; foreach (wu_get_site_templates() as $site) { @@ -965,7 +970,7 @@ class Checkout_Form extends Base_Model { $field['type'] = 'submit_button'; $field['id'] = 'submit_button'; - if ($step_id === 'account') { + if ('account' === $step_id) { $field['name'] = __('Continue to the Next Step', 'wp-ultimo'); } diff --git a/inc/models/class-customer.php b/inc/models/class-customer.php index 63d6b8b..99d6752 100644 --- a/inc/models/class-customer.php +++ b/inc/models/class-customer.php @@ -747,7 +747,7 @@ class Customer extends Base_Model { static $sum; - if ($sum === null) { + if (null === $sum) { $sum = $wpdb->get_var( $wpdb->prepare( "SELECT SUM(total) FROM {$wpdb->base_prefix}wu_payments WHERE parent_id = 0 AND customer_id = %d", @@ -779,7 +779,7 @@ class Customer extends Base_Model { $minutes_interval += $interval->h * 60; $minutes_interval += $interval->i; - return $minutes_interval <= apply_filters('wu_is_online_minutes_interval', 3) ? true : false; + return $minutes_interval <= apply_filters('wu_is_online_minutes_interval', 3); } /** @@ -796,6 +796,7 @@ class Customer extends Base_Model { return $this->update_meta('wu_verification_key', $hash); } + /** * Returns the saved verification key. * @@ -817,6 +818,7 @@ class Customer extends Base_Model { return $this->update_meta('wu_verification_key', false); } + /** * Returns the link of the email verification endpoint. * diff --git a/inc/models/class-discount-code.php b/inc/models/class-discount-code.php index f984fb1..9686e00 100644 --- a/inc/models/class-discount-code.php +++ b/inc/models/class-discount-code.php @@ -514,7 +514,7 @@ class Discount_Code extends Base_Model { $allowed = $this->get_limit_products() && in_array($product_id, $this->get_allowed_products()); // phpcs:ignore - if ($allowed === false) { + if (false === $allowed) { return new \WP_Error('discount_code', __('This coupon code is not valid.', 'wp-ultimo')); } } @@ -621,6 +621,7 @@ class Discount_Code extends Base_Model { $this->date_created = $date_created; } + /** * Returns a text describing the discount code values. * diff --git a/inc/models/class-domain.php b/inc/models/class-domain.php index 7b20a54..14a73d6 100644 --- a/inc/models/class-domain.php +++ b/inc/models/class-domain.php @@ -151,6 +151,7 @@ class Domain extends Base_Model { $this->domain = strtolower($domain); } + /** * Gets the URL with schema and all. * @@ -200,6 +201,7 @@ class Domain extends Base_Model { return $this->get_blog_id(); } + /** * Get the site object for this particular mapping. * @@ -323,6 +325,7 @@ class Domain extends Base_Model { $this->stage = $stage; } + /** * Check if this domain is on a inactive stage. * @@ -498,6 +501,7 @@ class Domain extends Base_Model { return $results; } + /** * Delete the model from the database. * @@ -559,7 +563,7 @@ class Domain extends Base_Model { // Check cache first $mappings = wp_cache_get('id:' . $site, 'domain_mapping'); - if ($mappings === 'none') { + if ('none' === $mappings) { return false; } @@ -610,14 +614,14 @@ class Domain extends Base_Model { foreach ($domains as $domain) { $data = wp_cache_get('domain:' . $domain, 'domain_mappings'); - if ( ! empty($data) && $data !== 'notexists') { + if ( ! empty($data) && 'notexists' !== $data) { return new static($data); - } elseif ($data === 'notexists') { + } elseif ('notexists' === $data) { ++$not_exists; } } - if ($not_exists === count($domains)) { + if (count($domains) === $not_exists) { // Every domain we checked was found in the cache, but doesn't exist // so skip the query diff --git a/inc/models/class-email.php b/inc/models/class-email.php index 959b0a1..9792ba4 100644 --- a/inc/models/class-email.php +++ b/inc/models/class-email.php @@ -198,6 +198,7 @@ class Email extends Post_Base_Model { return $this->title; } + /** * Get style of the email * @@ -381,7 +382,7 @@ class Email extends Post_Base_Model { * @param string $type The type being set. * @return void */ - public function set_type($type) { + public function set_type($type): void { if ( ! in_array($type, $this->allowed_types, true)) { $type = 'system_email'; @@ -567,9 +568,9 @@ class Email extends Post_Base_Model { $target_type = $this->get_target(); - if ($target_type === 'admin') { + if ('admin' === $target_type) { $target_list = self::get_super_admin_targets(); - } elseif ($target_type === 'customer') { + } elseif ('customer' === $target_type) { if ( ! wu_get_isset($payload, 'customer_id')) { return []; } diff --git a/inc/models/class-event.php b/inc/models/class-event.php index 97f7ed0..0949366 100644 --- a/inc/models/class-event.php +++ b/inc/models/class-event.php @@ -22,9 +22,13 @@ defined('ABSPATH') || exit; class Event extends Base_Model { const SEVERITY_SUCCESS = 1; + const SEVERITY_NEUTRAL = 2; + const SEVERITY_INFO = 3; + const SEVERITY_WARNING = 4; + const SEVERITY_FATAL = 5; /** @@ -253,6 +257,7 @@ class Event extends Base_Model { return $this->interpolate_message($message, $this->get_payload()); } + /** * Interpolates the value of a message and its placeholders with the contents of the payload. * @@ -419,6 +424,7 @@ class Event extends Base_Model { return false; } + /** * Polyfill for the get_object method. * @@ -429,12 +435,13 @@ class Event extends Base_Model { $object_type = $this->get_object_type(); - if ($object_type !== 'membership') { + if ('membership' !== $object_type) { return false; } return $this->get_object(); } + /** * Polyfill for the get_object method. * @@ -445,12 +452,13 @@ class Event extends Base_Model { $object_type = $this->get_object_type(); - if ($object_type !== 'product') { + if ('product' !== $object_type) { return false; } return $this->get_object(); } + /** * Polyfill for the get_object method. * @@ -461,12 +469,13 @@ class Event extends Base_Model { $object_type = $this->get_object_type(); - if ($object_type !== 'site') { + if ('site' !== $object_type) { return false; } return $this->get_object(); } + /** * Polyfill for the get_object method. * @@ -477,12 +486,13 @@ class Event extends Base_Model { $object_type = $this->get_object_type(); - if ($object_type !== 'customer') { + if ('customer' !== $object_type) { return false; } return $this->get_object(); } + /** * Polyfill for the get_object method. * @@ -493,7 +503,7 @@ class Event extends Base_Model { $object_type = $this->get_object_type(); - if ($object_type !== 'payment') { + if ('payment' !== $object_type) { return false; } diff --git a/inc/models/class-membership.php b/inc/models/class-membership.php index 65e7e49..ac6b235 100644 --- a/inc/models/class-membership.php +++ b/inc/models/class-membership.php @@ -534,6 +534,7 @@ class Membership extends Base_Model { return ! empty($this->get_addons()); } + /** * Gets a list of product ids for addons. * @@ -558,7 +559,7 @@ class Membership extends Base_Model { $has_product = wu_get_isset($this->addon_products, $product_id); if ($has_product && $this->addon_products[ $product_id ] >= 0) { - $this->addon_products[ $product_id ] = $this->addon_products[ $product_id ] + $quantity; + $this->addon_products[ $product_id ] += $quantity; } else { $this->addon_products[ $product_id ] = $quantity; } @@ -582,7 +583,7 @@ class Membership extends Base_Model { $has_product = wu_get_isset($this->addon_products, $product_id); if ($has_product && $this->addon_products[ $product_id ] >= 0) { - $this->addon_products[ $product_id ] = $this->addon_products[ $product_id ] - $quantity; + $this->addon_products[ $product_id ] -= $quantity; } if ($this->addon_products[ $product_id ] <= 0) { @@ -725,6 +726,7 @@ class Membership extends Base_Model { */ return $this; } + /** * Schedule a swap for the membership. * @@ -836,6 +838,7 @@ class Membership extends Base_Model { return $description; } + /** * Returns the times billed in a human-friendly way. * @@ -854,6 +857,7 @@ class Membership extends Base_Model { return sprintf($description, $this->get_times_billed(), $this->get_billing_cycles()); } + /** * Returns the membership price structure in a way human can understand it. * @@ -1329,6 +1333,7 @@ class Membership extends Base_Model { $this->auto_renew = (bool) $auto_renew; } + /** * Get the discount code applied if exist. * @@ -1755,6 +1760,7 @@ class Membership extends Base_Model { return wu_get_payments($query); } + /** * Returns the last pending payment for a membership. * @@ -1870,6 +1876,7 @@ class Membership extends Base_Model { return $this->update_meta('pending_site', $site); } + /** * Returns the pending site, if any. * @@ -2056,7 +2063,7 @@ class Membership extends Base_Model { static $sum; - if ($sum === null) { + if (null === $sum) { $sum = $wpdb->get_var( $wpdb->prepare( "SELECT SUM(total) FROM {$wpdb->base_prefix}wu_payments WHERE parent_id = 0 AND membership_id = %d", @@ -2364,7 +2371,7 @@ class Membership extends Base_Model { ]; foreach ($this->_gateway_info as $key => $value) { - if ($value !== $current_gateway[ $key ]) { + if ($current_gateway[ $key ] !== $value) { $has_change = true; break; @@ -2390,7 +2397,7 @@ class Membership extends Base_Model { return PHP_INT_MAX; } - $limit = $limit === '' ? 1 : $limit; + $limit = '' === $limit ? 1 : $limit; return $limit - count($this->get_sites()); } @@ -2416,6 +2423,7 @@ class Membership extends Base_Model { return $this->get_date_trial_end() > gmdate('Y-m-d 23:59:59'); } + /** * Save (create or update) the model on the database. * @@ -2497,6 +2505,7 @@ class Membership extends Base_Model { return parent::save(); } + /** * Delete the model from the database. * diff --git a/inc/models/class-payment.php b/inc/models/class-payment.php index 2a10db1..53e4e90 100644 --- a/inc/models/class-payment.php +++ b/inc/models/class-payment.php @@ -266,6 +266,7 @@ class Payment extends Base_Model { $this->customer_id = absint($customer_id); } + /** * Gets the membership object associated with this payment. * diff --git a/inc/models/class-product.php b/inc/models/class-product.php index ebe2972..13a001f 100644 --- a/inc/models/class-product.php +++ b/inc/models/class-product.php @@ -487,7 +487,7 @@ class Product extends Base_Model { $this->pricing_type = $pricing_type; - if ($pricing_type === 'free' || $pricing_type === 'contact_us') { + if ('free' === $pricing_type || 'contact_us' === $pricing_type) { $this->set_amount(0); $this->set_recurring(false); @@ -1210,11 +1210,11 @@ class Product extends Base_Model { return $this; } - if ($duration !== $this->get_duration() || $duration_unit !== $this->get_duration_unit()) { + if ($this->get_duration() !== $duration || $this->get_duration_unit() !== $duration_unit) { $price_variation = $this->get_price_variation($duration, $duration_unit); } - if (absint($duration) === $this->get_duration() && $duration_unit === $this->get_duration_unit()) { + if (absint($duration) === $this->get_duration() && $this->get_duration_unit() === $duration_unit) { $price_variation = [ 'amount' => $this->get_amount(), ]; @@ -1297,7 +1297,7 @@ class Product extends Base_Model { $price_variations = $this->get_price_variations(); if ( ! empty($price_variations)) { - if (absint($duration) === 12 && $duration_unit === 'month') { + if (absint($duration) === 12 && 'month' === $duration_unit) { $duration = 1; $duration_unit = 'year'; diff --git a/inc/models/class-site.php b/inc/models/class-site.php index 3af99bc..8f098fa 100644 --- a/inc/models/class-site.php +++ b/inc/models/class-site.php @@ -368,6 +368,7 @@ class Site extends Base_Model { return $this->featured_image_id; } + /** * Get featured image url. * @@ -420,6 +421,7 @@ class Site extends Base_Model { return Template_Previewer::get_instance()->get_preview_url($this->get_id()); } + /** * Get the preview URL attrs. * @@ -496,6 +498,7 @@ class Site extends Base_Model { $this->site_id = $site_id; } + /** * Get title of the site.. * @@ -593,6 +596,7 @@ class Site extends Base_Model { $this->domain = $domain; } + /** * Get path of the site. Used when in sub-directory mode.. * @@ -1044,6 +1048,7 @@ class Site extends Base_Model { return false; } + /** * Get template ID. * @@ -1172,6 +1177,7 @@ class Site extends Base_Model { $this->type = $type; } + /** * Get the primary mapped domain for this site. * @@ -1421,6 +1427,7 @@ class Site extends Base_Model { return absint($primary_site_id) === absint($this->get_id()); } + /** * Delete the model from the database. * @@ -1580,7 +1587,7 @@ class Site extends Base_Model { $error = $saved; $saved = get_blog_id_from_url($domain, $this->get_path()); - if ($saved === 0 || $saved === wu_get_main_site_id()) { + if (0 === $saved || wu_get_main_site_id() === $saved) { return $error; } } @@ -1744,7 +1751,7 @@ class Site extends Base_Model { global $wpdb; - if ($type === 'pending') { + if ('pending' === $type) { $table_name = "{$wpdb->base_prefix}wu_membershipmeta"; $customer_id = (int) wu_get_isset($query_args, 'customer_id'); diff --git a/inc/models/traits/trait-limitable.php b/inc/models/traits/trait-limitable.php index 6c99ce6..f27f7e8 100644 --- a/inc/models/traits/trait-limitable.php +++ b/inc/models/traits/trait-limitable.php @@ -53,7 +53,7 @@ trait Limitable { * If this is a site, and it's not a customer owned site, we don't have limitations. * This is because we don't want to limit sites other than the customer owned ones. */ - if ($this->model === 'site' && $this->get_type() !== Site_Type::CUSTOMER_OWNED) { + if ('site' === $this->model && $this->get_type() !== Site_Type::CUSTOMER_OWNED) { return new Limitations([]); } diff --git a/inc/models/traits/trait-notable.php b/inc/models/traits/trait-notable.php index fb5af15..8ffa20d 100644 --- a/inc/models/traits/trait-notable.php +++ b/inc/models/traits/trait-notable.php @@ -104,7 +104,7 @@ trait Notable { $column_name = "wu_{$model}_id"; - if ($model === 'site') { + if ('site' === $model) { $table_name = "{$wpdb->base_prefix}blogmeta"; $column_name = 'blog_id'; @@ -120,7 +120,7 @@ trait Notable { $status = delete_metadata_by_mid("wu_{$model}", $mid['meta_id']); - if ($model === 'site') { + if ('site' === $model) { $status = delete_metadata_by_mid('blog', $mid['meta_id']); } diff --git a/inc/objects/class-billing-address.php b/inc/objects/class-billing-address.php index fab3cd7..b0f8927 100644 --- a/inc/objects/class-billing-address.php +++ b/inc/objects/class-billing-address.php @@ -111,6 +111,7 @@ class Billing_Address { $this->attributes[ $name ] = $value; } + /** * Returns the validation rules for the billing address fields. * @@ -168,6 +169,7 @@ class Billing_Address { return $address_array; } + /** * Returns a string representation of the billing address. * diff --git a/inc/objects/class-limitations.php b/inc/objects/class-limitations.php index a9c201d..c1bb242 100644 --- a/inc/objects/class-limitations.php +++ b/inc/objects/class-limitations.php @@ -82,7 +82,7 @@ class Limitations { $module = wu_get_isset($this->modules, $name, false); - if ($module === false) { + if (false === $module) { $repo = self::repository(); $class_name = wu_get_isset($repo, $name, false); @@ -145,6 +145,7 @@ class Limitations { return $this; } + /** * Build a module, based on the data. * @@ -315,23 +316,23 @@ class Limitations { $original_value = wu_get_isset($array1, $key); // If the value is 0 or '' it can be a unlimited value - $is_unlimited = (is_numeric($value) || $value === '') && (int) $value === 0; + $is_unlimited = (is_numeric($value) || '' === $value) && (int) $value === 0; - if ($should_sum && ($original_value === '' || $original_value === 0)) { + if ($should_sum && ('' === $original_value || 0 === $original_value)) { /** * We use values 0 or '' as unlimited in our limits */ continue; } elseif (isset($array1[ $key ]) && is_numeric($array1[ $key ]) && is_numeric($value) && $should_sum && ! $is_unlimited) { $array1[ $key ] = ((int) $array1[ $key ]) + $value; - } elseif ($key === 'visibility' && isset($array1[ $key ]) && $should_sum) { + } elseif ('visibility' === $key && isset($array1[ $key ]) && $should_sum) { $key_priority = [ 'hidden' => 0, 'visible' => 1, ]; $array1[ $key ] = $key_priority[ $value ] > $key_priority[ $array1[ $key ] ] ? $value : $array1[ $key ]; - } elseif ($key === 'behavior' && isset($array1[ $key ]) && $should_sum) { + } elseif ('behavior' === $key && isset($array1[ $key ]) && $should_sum) { $key_priority_list = [ 'plugins' => [ 'default' => 10, @@ -358,13 +359,14 @@ class Limitations { } else { // Avoid change true values - $array1[ $key ] = $original_value !== true || ! $should_sum ? $value : true; + $array1[ $key ] = true !== $original_value || ! $should_sum ? $value : true; - $array1[ $key ] = $original_value !== true || ! $should_sum ? $value : true; + $array1[ $key ] = true !== $original_value || ! $should_sum ? $value : true; } } } } + /** * Converts the limitations list to an array. * @@ -392,7 +394,7 @@ class Limitations { * Reset the slug and prefixes * for the native tables of blogs. */ - if ($slug === 'site') { + if ('site' === $slug) { $slug = 'blog'; $wu_prefix = ''; @@ -447,7 +449,7 @@ class Limitations { * Site apis are already available, * so no need to use low-level sql calls. */ - if ($slug === 'site') { + if ('site' === $slug) { $wu_prefix = ''; $slug = 'blog'; diff --git a/inc/objects/class-note.php b/inc/objects/class-note.php index 6bbe01b..bd8f84c 100644 --- a/inc/objects/class-note.php +++ b/inc/objects/class-note.php @@ -168,6 +168,7 @@ class Note { return $address_array; } + /** * Returns the contents of the note. * diff --git a/inc/objects/class-visits.php b/inc/objects/class-visits.php index 3509ae0..2738d75 100644 --- a/inc/objects/class-visits.php +++ b/inc/objects/class-visits.php @@ -23,6 +23,7 @@ class Visits { * Key to save on the database. */ const KEY = 'wu_visits'; + /** * @var int */ @@ -38,6 +39,7 @@ class Visits { public function __construct($site_id) { $this->site_id = $site_id; } + /** * Returns the meta key to save visits. * diff --git a/inc/site-templates/class-template-placeholders.php b/inc/site-templates/class-template-placeholders.php index c6434b9..bdd68b9 100644 --- a/inc/site-templates/class-template-placeholders.php +++ b/inc/site-templates/class-template-placeholders.php @@ -125,6 +125,7 @@ class Template_Placeholders { return "{{{$tag}}}"; } + /** * Replace the contents with the placeholders. * diff --git a/inc/sso/class-sso-broker.php b/inc/sso/class-sso-broker.php index 9df4937..b009bff 100644 --- a/inc/sso/class-sso-broker.php +++ b/inc/sso/class-sso-broker.php @@ -30,6 +30,7 @@ class SSO_Broker extends Broker { public function is_must_redirect_call(): bool { return $this->getVerificationCode() === 'must-redirect'; } + /** * Get URL to attach session at SSO server. * diff --git a/inc/sso/class-sso-session-handler.php b/inc/sso/class-sso-session-handler.php index 2b6c04d..60671f9 100644 --- a/inc/sso/class-sso-session-handler.php +++ b/inc/sso/class-sso-session-handler.php @@ -46,6 +46,7 @@ class SSO_Session_Handler implements SessionInterface { public function __construct(\WP_Ultimo\SSO\SSO $sso_manager = null) { $this->sso_manager = $sso_manager; } + /** * Returns the session id. * @@ -54,6 +55,7 @@ class SSO_Session_Handler implements SessionInterface { public function getId(): string { // phpcs:ignore return $this->sso_manager->input('broker'); } + /** * Start a new session. * @@ -74,6 +76,7 @@ class SSO_Session_Handler implements SessionInterface { set_site_transient("sso-{$site_hash}-{$id}", get_current_user_id(), 180); } + /** * Resume an existing session. * @@ -94,6 +97,7 @@ class SSO_Session_Handler implements SessionInterface { $this->sso_manager->set_target_user_id($user_id); } } + /** * Check if a session is active. (status PHP_SESSION_ACTIVE). * diff --git a/inc/sso/class-sso.php b/inc/sso/class-sso.php index 8ef5b78..a67c308 100644 --- a/inc/sso/class-sso.php +++ b/inc/sso/class-sso.php @@ -470,7 +470,7 @@ class SSO { status_header($response_code); exit; - } elseif ($response_type === 'redirect') { + } elseif ('redirect' === $response_type) { $args = [ 'sso_verify' => $verification_code ?: 'invalid', ]; @@ -548,7 +548,7 @@ class SSO { exit(); } - if ($response_type === 'jsonp') { + if ('jsonp' === $response_type) { echo '// Nothing to see here.'; exit; @@ -658,6 +658,7 @@ class SSO { * @throws NotAttachedException */ } + return $current_user_id; } @@ -859,6 +860,7 @@ class SSO { if ( ! $action) { $action = $this->input($sso_path, 'done') !== 'done' ? $sso_path : ''; } + if ( ! $action) { $action = $this->input("$sso_path-grant", 'done') !== 'done' ? "$sso_path-grant" : ''; } @@ -1046,6 +1048,7 @@ class SSO { public function get_target_user_id() { return $this->target_user_id; } + /** * Get the url path for SSO. * diff --git a/inc/tax/class-tax.php b/inc/tax/class-tax.php index 9ceb862..8d8168d 100644 --- a/inc/tax/class-tax.php +++ b/inc/tax/class-tax.php @@ -47,13 +47,13 @@ class Tax { $country = wu_request('country', 'not-present'); - if ($country === 'not-present') { + if ('not-present' === $country) { return; } - if ($model === 'state') { + if ('state' === $model) { $results = wu_get_country_states($country, 'slug', 'name'); - } elseif ($model === 'city') { + } elseif ('city' === $model) { $states = explode(',', (string) wu_request('state', '')); $results = wu_get_country_cities($country, $states, 'slug', 'name'); diff --git a/inc/traits/trait-wp-ultimo-coupon-deprecated.php b/inc/traits/trait-wp-ultimo-coupon-deprecated.php index 070133d..6e12a32 100644 --- a/inc/traits/trait-wp-ultimo-coupon-deprecated.php +++ b/inc/traits/trait-wp-ultimo-coupon-deprecated.php @@ -52,7 +52,7 @@ trait WP_Ultimo_Coupon_Deprecated { $value = $this->get_meta('wpu_' . $key, false, true); } - if ($value === null) { + if (null === $value) { // translators: the placeholder is the key. $message = sprintf(__('Discount Codes do not have a %s parameter', 'wp-ultimo'), $key); diff --git a/inc/traits/trait-wp-ultimo-plan-deprecated.php b/inc/traits/trait-wp-ultimo-plan-deprecated.php index dd50ff7..412be71 100644 --- a/inc/traits/trait-wp-ultimo-plan-deprecated.php +++ b/inc/traits/trait-wp-ultimo-plan-deprecated.php @@ -183,7 +183,7 @@ trait WP_Ultimo_Plan_Deprecated { $value = $is_unlimited ? __('Unlimited', 'wp-ultimo') : $this->get_limitations()->post_types->{$pt_slug}->number; // Add Line - $label = $value == 1 ? $post_type->labels->singular_name : $post_type->labels->name; + $label = 1 == $value ? $post_type->labels->singular_name : $post_type->labels->name; $pricing_table_lines[ 'wu_product_limit_post_type_' . $pt_slug ] = sprintf('%s %s', $value, $label); } @@ -272,11 +272,11 @@ trait WP_Ultimo_Plan_Deprecated { */ public function get_quota($quota_name) { - if ($quota_name === 'visits') { + if ('visits' === $quota_name) { $limit = (float) $this->get_limitations()->visits->get_limit(); - } elseif ($quota_name === 'disk_space') { + } elseif ('disk_space' === $quota_name) { $limit = (float) $this->get_limitations()->disk_space->get_limit(); - } elseif ($quota_name === 'sites') { + } elseif ('sites' === $quota_name) { $limit = (float) $this->get_limitations()->sites->get_limit(); } else { $limit = (float) $this->get_limitations()->post_types->{$quota_name}->number; diff --git a/inc/traits/trait-wp-ultimo-settings-deprecated.php b/inc/traits/trait-wp-ultimo-settings-deprecated.php index 39f72c0..b71b8e6 100644 --- a/inc/traits/trait-wp-ultimo-settings-deprecated.php +++ b/inc/traits/trait-wp-ultimo-settings-deprecated.php @@ -45,7 +45,7 @@ trait WP_Ultimo_Settings_Deprecated { $sections = apply_filters_deprecated('wu_settings_sections', [[]], '2.0.0', 'wu_register_settings_section()'); foreach ($sections as $section_key => $section) { - if ($section_key === 'activation') { + if ('activation' === $section_key) { continue; // No activation stuff; } diff --git a/inc/ui/class-account-summary-element.php b/inc/ui/class-account-summary-element.php index 972a84b..eb918ad 100644 --- a/inc/ui/class-account-summary-element.php +++ b/inc/ui/class-account-summary-element.php @@ -88,7 +88,7 @@ class Account_Summary_Element extends Base_Element { */ public function get_icon($context = 'block') { - if ($context === 'elementor') { + if ('elementor' === $context) { return 'eicon-call-to-action'; } diff --git a/inc/ui/class-base-element.php b/inc/ui/class-base-element.php index 91151a4..1dae854 100644 --- a/inc/ui/class-base-element.php +++ b/inc/ui/class-base-element.php @@ -528,7 +528,7 @@ abstract class Base_Element { */ protected function maybe_extract_arguments($content, $type = 'shortcode') { - if ($type === 'shortcode') { + if ('shortcode' === $type) { /** * Tries to parse the shortcode out of the content @@ -539,7 +539,7 @@ abstract class Base_Element { preg_match_all('/' . $shortcode_regex . '/', $content, $matches, PREG_SET_ORDER); return ! empty($matches) ? shortcode_parse_atts($matches[0][3]) : false; - } elseif ($type === 'block') { + } elseif ('block' === $type) { /** * Next, try to parse attrs from blocks @@ -818,7 +818,7 @@ abstract class Base_Element { $value = wu_get_isset($saved_settings, $field_slug, null); - if ($value !== null) { + if (null !== $value) { $field['value'] = $value; } } @@ -886,7 +886,7 @@ abstract class Base_Element { foreach ($fields as $field_slug => $field) { $setting = wu_request($field_slug, false); - if ($setting !== false || $field['type'] === 'toggle') { + if (false !== $setting || $field['type'] === 'toggle') { $settings[ $field_slug ] = $setting; } } @@ -1055,7 +1055,7 @@ abstract class Base_Element { $screen = get_current_screen(); - if ( ! $screen || $screen_id !== $screen->id) { + if ( ! $screen || $screen->id !== $screen_id) { return; } diff --git a/inc/ui/class-billing-info-element.php b/inc/ui/class-billing-info-element.php index ccbc0ef..57bf74b 100644 --- a/inc/ui/class-billing-info-element.php +++ b/inc/ui/class-billing-info-element.php @@ -71,7 +71,7 @@ class Billing_Info_Element extends Base_Element { */ public function get_icon($context = 'block'): string { - if ($context === 'elementor') { + if ('elementor' === $context) { return 'eicon-info-circle-o'; } diff --git a/inc/ui/class-checkout-element.php b/inc/ui/class-checkout-element.php index 9bab239..94ea272 100644 --- a/inc/ui/class-checkout-element.php +++ b/inc/ui/class-checkout-element.php @@ -89,7 +89,7 @@ class Checkout_Element extends Base_Element { */ public function get_icon($context = 'block'): string { - if ($context === 'elementor') { + if ('elementor' === $context) { return 'eicon-cart-medium'; } @@ -325,7 +325,7 @@ class Checkout_Element extends Base_Element { return is_string($bypass) ? $bypass : ''; } - if ($customer && $membership && $slug !== 'wu-finish-checkout') { + if ($customer && $membership && 'wu-finish-checkout' !== $slug) { $published_sites = $membership->get_published_sites(); $pending_payment = $membership ? $membership->get_last_pending_payment() : false; @@ -493,7 +493,7 @@ class Checkout_Element extends Base_Element { $message .= "$button_text"; } - if ($limitation !== 'sites' || wu_get_setting('enable_multiple_sites')) { + if ('sites' !== $limitation || wu_get_setting('enable_multiple_sites')) { $update_link = ''; $checkout_pages = \WP_Ultimo\Checkout\Checkout_Pages::get_instance(); @@ -536,7 +536,7 @@ class Checkout_Element extends Base_Element { } } } - } elseif ( ! $customer && $slug === 'wu-finish-checkout') { + } elseif ( ! $customer && 'wu-finish-checkout' === $slug) { if (is_user_logged_in()) { $message = __('You need to be the account owner to complete this payment.', 'wp-ultimo'); } else { @@ -774,10 +774,12 @@ class Mocked_Signup { * @var string */ public $step; + /** * @var array */ public $steps; + /** * Constructs the class. * @@ -801,6 +803,7 @@ class Mocked_Signup { return $this->steps; } + /** * Deprecated: returns the prev step link. * diff --git a/inc/ui/class-current-membership-element.php b/inc/ui/class-current-membership-element.php index b97a1a8..ef149ca 100644 --- a/inc/ui/class-current-membership-element.php +++ b/inc/ui/class-current-membership-element.php @@ -101,6 +101,7 @@ class Current_Membership_Element extends Base_Element { add_wubox(); } + /** * The icon of the UI element. * e.g. return fa fa-search @@ -110,7 +111,7 @@ class Current_Membership_Element extends Base_Element { */ public function get_icon($context = 'block'): string { - if ($context === 'elementor') { + if ('elementor' === $context) { return 'eicon-info-circle-o'; } diff --git a/inc/ui/class-current-site-element.php b/inc/ui/class-current-site-element.php index 0991739..6bdf708 100644 --- a/inc/ui/class-current-site-element.php +++ b/inc/ui/class-current-site-element.php @@ -71,7 +71,7 @@ class Current_Site_Element extends Base_Element { */ public function get_icon($context = 'block'): string { - if ($context === 'elementor') { + if ('elementor' === $context) { return 'eicon-info-circle-o'; } diff --git a/inc/ui/class-domain-mapping-element.php b/inc/ui/class-domain-mapping-element.php index d44ec93..d1c8258 100644 --- a/inc/ui/class-domain-mapping-element.php +++ b/inc/ui/class-domain-mapping-element.php @@ -75,7 +75,7 @@ class Domain_Mapping_Element extends Base_Element { */ public function get_icon($context = 'block'): string { - if ($context === 'elementor') { + if ('elementor' === $context) { return 'eicon-url'; } @@ -404,7 +404,7 @@ class Domain_Mapping_Element extends Base_Element { $current_site = wu_get_site($current_site_id); - if ( ! is_super_admin() && (! $current_site || $current_user_id !== $current_site->get_customer()->get_user_id())) { + if ( ! is_super_admin() && (! $current_site || $current_site->get_customer()->get_user_id() !== $current_user_id)) { wp_send_json_error( new \WP_Error('no-permissions', __('You do not have permissions to perform this action.', 'wp-ultimo')) ); diff --git a/inc/ui/class-field.php b/inc/ui/class-field.php index a85406b..10654f3 100644 --- a/inc/ui/class-field.php +++ b/inc/ui/class-field.php @@ -243,27 +243,27 @@ class Field implements \JsonSerializable { $attr = call_user_func($attr, $this); } - if ($att === 'wrapper_classes' && isset($this->atts['wrapper_html_attr']['v-show'])) { - $this->atts['wrapper_classes'] = $this->atts['wrapper_classes'] . ' wu-requires-other'; + if ('wrapper_classes' === $att && isset($this->atts['wrapper_html_attr']['v-show'])) { + $this->atts['wrapper_classes'] .= ' wu-requires-other'; } - if ($att === 'type' && $this->atts[ $att ] === 'submit') { - $this->atts['wrapper_classes'] = $this->atts['wrapper_classes'] . ' wu-submit-field'; + if ('type' === $att && $this->atts[ $att ] === 'submit') { + $this->atts['wrapper_classes'] .= ' wu-submit-field'; } - if ($att === 'type' && $this->atts[ $att ] === 'tab-select') { - $this->atts['wrapper_classes'] = $this->atts['wrapper_classes'] . ' wu-tab-field'; + if ('type' === $att && $this->atts[ $att ] === 'tab-select') { + $this->atts['wrapper_classes'] .= ' wu-tab-field'; } - if ($att === 'wrapper_classes' && is_a($this->form, '\\WP_Ultimo\\UI\\Form')) { + if ('wrapper_classes' === $att && is_a($this->form, '\\WP_Ultimo\\UI\\Form')) { return $this->form->field_wrapper_classes . ' ' . $this->atts['wrapper_classes']; } - if ($att === 'classes' && is_a($this->form, '\\WP_Ultimo\\UI\\Form')) { + if ('classes' === $att && is_a($this->form, '\\WP_Ultimo\\UI\\Form')) { return $this->form->field_classes . ' ' . $this->atts['classes']; } - if ($att === 'title' && $attr === false && isset($this->atts['name'])) { + if ('title' === $att && false === $attr && isset($this->atts['name'])) { $attr = $this->atts['name']; } @@ -342,6 +342,7 @@ class Field implements \JsonSerializable { $this->value = call_user_func($sanitize_method, $this->value); } } + /** * Sanitization callback for fields of type number. * diff --git a/inc/ui/class-invoices-element.php b/inc/ui/class-invoices-element.php index 04898d0..060d38b 100644 --- a/inc/ui/class-invoices-element.php +++ b/inc/ui/class-invoices-element.php @@ -64,7 +64,7 @@ class Invoices_Element extends Base_Element { */ public function get_icon($context = 'block') { - if ($context === 'elementor') { + if ('elementor' === $context) { return 'eicon-price-list'; } diff --git a/inc/ui/class-jumper.php b/inc/ui/class-jumper.php index 7c41f0b..28109e6 100644 --- a/inc/ui/class-jumper.php +++ b/inc/ui/class-jumper.php @@ -237,6 +237,7 @@ class Jumper { return $links; } + /** * Get the trigger key defined by the user. * @@ -355,6 +356,7 @@ class Jumper { ] ); } + /** * Get the full page URL for admin pages. * diff --git a/inc/ui/class-limits-element.php b/inc/ui/class-limits-element.php index 8be1d9a..4d1dd67 100644 --- a/inc/ui/class-limits-element.php +++ b/inc/ui/class-limits-element.php @@ -63,7 +63,7 @@ class Limits_Element extends Base_Element { */ public function get_icon($context = 'block'): string { - if ($context === 'elementor') { + if ('elementor' === $context) { return 'eicon-skill-bar'; } diff --git a/inc/ui/class-login-form-element.php b/inc/ui/class-login-form-element.php index 19dc6b2..8167c01 100644 --- a/inc/ui/class-login-form-element.php +++ b/inc/ui/class-login-form-element.php @@ -78,7 +78,7 @@ class Login_Form_Element extends Base_Element { */ public function get_icon($context = 'block'): string { - if ($context === 'elementor') { + if ('elementor' === $context) { return 'eicon-lock-user'; } @@ -505,16 +505,16 @@ class Login_Form_Element extends Base_Element { $redirect_type = wu_request('wu_login_form_redirect_type', 'default'); // If some condition match, force user redirection to the URL - if ($redirect_type === 'query_redirect') { + if ('query_redirect' === $redirect_type) { // query_redirect is the default wp behaviour return $redirect_to; - } elseif ($redirect_type === 'customer_site') { + } elseif ('customer_site' === $redirect_type) { $user_site = get_active_blog_for_user($user->ID); wp_redirect($user_site->siteurl . $requested_redirect_to); exit; - } elseif ($redirect_type === 'main_site') { + } elseif ('main_site' === $redirect_type) { wp_redirect(network_site_url($requested_redirect_to)); exit; } diff --git a/inc/ui/class-my-sites-element.php b/inc/ui/class-my-sites-element.php index c7fbffd..4955cf9 100644 --- a/inc/ui/class-my-sites-element.php +++ b/inc/ui/class-my-sites-element.php @@ -73,7 +73,7 @@ class My_Sites_Element extends Base_Element { */ public function get_icon($context = 'block') { - if ($context === 'elementor') { + if ('elementor' === $context) { return 'eicon-info-circle-o'; } @@ -361,7 +361,7 @@ class My_Sites_Element extends Base_Element { ); } - if ($show === 'all') { + if ('all' === $show) { $wp_user_sites = get_blogs_of_user(get_current_user_id()); $user_sites = array_reduce( @@ -372,6 +372,7 @@ class My_Sites_Element extends Base_Element { $wu_site->set_membership_id(0); $user_sites[ $wp_site->userblog_id ] = $wu_site; } + return $user_sites; } ); @@ -401,11 +402,11 @@ class My_Sites_Element extends Base_Element { */ public function get_manage_url($site_id, $type = 'default', $custom_page_id = 0) { - if ($type === 'wp_admin') { + if ('wp_admin' === $type) { return get_admin_url($site_id); } - if ($type === 'custom_page') { + if ('custom_page' === $type) { $custom_page = get_page_link($custom_page_id); $url_param = \WP_Ultimo\Current::param_key('site'); diff --git a/inc/ui/class-payment-methods-element.php b/inc/ui/class-payment-methods-element.php index d519a3e..9a2f9fb 100644 --- a/inc/ui/class-payment-methods-element.php +++ b/inc/ui/class-payment-methods-element.php @@ -48,7 +48,7 @@ class Payment_Methods_Element extends Base_Element { */ public function get_icon($context = 'block') { - if ($context === 'elementor') { + if ('elementor' === $context) { return 'eicon-info-circle-o'; } diff --git a/inc/ui/class-simple-text-element.php b/inc/ui/class-simple-text-element.php index 06535de..c264d11 100644 --- a/inc/ui/class-simple-text-element.php +++ b/inc/ui/class-simple-text-element.php @@ -64,7 +64,7 @@ class Simple_Text_Element extends Base_Element { */ public function get_icon($context = 'block') { - if ($context === 'elementor') { + if ('elementor' === $context) { return 'eicon-lock-user'; } diff --git a/inc/ui/class-site-actions-element.php b/inc/ui/class-site-actions-element.php index 3434b03..34d6bda 100644 --- a/inc/ui/class-site-actions-element.php +++ b/inc/ui/class-site-actions-element.php @@ -75,6 +75,7 @@ class Site_Actions_Element extends Base_Element { add_wubox(); } + /** * The icon of the UI element. * e.g. return fa fa-search @@ -84,7 +85,7 @@ class Site_Actions_Element extends Base_Element { */ public function get_icon($context = 'block'): string { - if ($context === 'elementor') { + if ('elementor' === $context) { return 'eicon-info-circle-o'; } diff --git a/inc/ui/class-site-maintenance-element.php b/inc/ui/class-site-maintenance-element.php index 1a0ffb2..bcac46e 100644 --- a/inc/ui/class-site-maintenance-element.php +++ b/inc/ui/class-site-maintenance-element.php @@ -69,7 +69,7 @@ class Site_Maintenance_Element extends Base_Element { */ public function get_icon($context = 'block') { - if ($context === 'elementor') { + if ('elementor' === $context) { return 'eicon-lock-user'; } diff --git a/inc/ui/class-template-previewer.php b/inc/ui/class-template-previewer.php index c0dcc15..601f1b0 100644 --- a/inc/ui/class-template-previewer.php +++ b/inc/ui/class-template-previewer.php @@ -415,7 +415,7 @@ class Template_Previewer { $settings = $this->get_settings(); foreach ($settings as $setting => $value) { - if ($setting === 'logo_url') { + if ('logo_url' === $setting) { $settings['logo_url'] = wu_get_network_logo(); continue; diff --git a/inc/ui/class-template-switching-element.php b/inc/ui/class-template-switching-element.php index 2ff7d20..cb92ffc 100644 --- a/inc/ui/class-template-switching-element.php +++ b/inc/ui/class-template-switching-element.php @@ -67,7 +67,7 @@ class Template_Switching_Element extends Base_Element { */ public function get_icon($context = 'block'): string { - if ($context === 'elementor') { + if ('elementor' === $context) { return 'eicon-cart-medium'; } diff --git a/inc/ui/class-thank-you-element.php b/inc/ui/class-thank-you-element.php index a66f397..69d918b 100644 --- a/inc/ui/class-thank-you-element.php +++ b/inc/ui/class-thank-you-element.php @@ -71,7 +71,7 @@ class Thank_You_Element extends Base_Element { */ public function get_icon($context = 'block'): string { - if ($context === 'elementor') { + if ('elementor' === $context) { return 'eicon-info-circle-o'; } diff --git a/views/admin-pages/fields/field-repeater.php b/views/admin-pages/fields/field-repeater.php index 2568d11..e3d8142 100644 --- a/views/admin-pages/fields/field-repeater.php +++ b/views/admin-pages/fields/field-repeater.php @@ -77,7 +77,7 @@ if (is_array($field->values)) { foreach ($field->values as $key => $value) { $field_id = esc_attr($field->id); - $field_id .= $position !== $field_len - 1 ? $key : ''; + $field_id .= $field_len - 1 !== $position ? $key : ''; ++$position; ?>
  • options as $option_value => $option_label) : ?> -
  • diff --git a/views/checkout/templates/period-selection/legacy.php b/views/checkout/templates/period-selection/legacy.php index 1407bd9..3bed1f1 100644 --- a/views/checkout/templates/period-selection/legacy.php +++ b/views/checkout/templates/period-selection/legacy.php @@ -27,7 +27,7 @@ defined('ABSPATH') || exit; $period_option) : ?>
  • - +
  • diff --git a/views/checkout/templates/pricing-table/legacy.php b/views/checkout/templates/pricing-table/legacy.php index 356d929..b6526a9 100644 --- a/views/checkout/templates/pricing-table/legacy.php +++ b/views/checkout/templates/pricing-table/legacy.php @@ -19,7 +19,7 @@ $first_recurring_product = array_reduce( $products_to_reduce, function ($chosen_product, $product) { - if ($product && $product->is_recurring() && $chosen_product == false) { + if ($product && $product->is_recurring() && false == $chosen_product) { $chosen_product = $product; } // end if; @@ -58,7 +58,7 @@ wp_add_inline_script( 'after' ); -if ($first_recurring_product !== null) { +if (null !== $first_recurring_product) { wp_add_inline_script( 'wu-checkout', sprintf( @@ -318,7 +318,7 @@ if ($first_recurring_product !== null) { $extra_check_for_annual = ''; - if ($freq === 12) { + if (12 === $freq) { $extra_check_for_annual = ' || (duration == "1" && duration_unit == "year")'; } // end if; diff --git a/views/checkout/templates/pricing-table/list.php b/views/checkout/templates/pricing-table/list.php index 2df2350..1303cba 100644 --- a/views/checkout/templates/pricing-table/list.php +++ b/views/checkout/templates/pricing-table/list.php @@ -13,7 +13,7 @@ foreach ($products as $index => &$_product) { $product_variation = $_product->get_as_variation($duration, $duration_unit); - if ($product_variation === false && ! $force_different_durations) { + if (false === $product_variation && ! $force_different_durations) { unset($products[ $index ]); $_product = $product_variation; diff --git a/views/dashboard-statistics/widget-countries.php b/views/dashboard-statistics/widget-countries.php index af5de8b..37c5dbf 100644 --- a/views/dashboard-statistics/widget-countries.php +++ b/views/dashboard-statistics/widget-countries.php @@ -83,7 +83,7 @@ $page->render_csv_button( $state_count) : - $_state_count = $_state_count + $state_count; + $_state_count += $state_count; ?> diff --git a/views/dashboard-widgets/current-site.php b/views/dashboard-widgets/current-site.php index 19e2436..84a0132 100644 --- a/views/dashboard-widgets/current-site.php +++ b/views/dashboard-widgets/current-site.php @@ -72,7 +72,7 @@ -
    +
    id == $plan->get_id() ? __('This is your current plan', 'wp-ultimo') : __('Select Plan', 'wp-ultimo'); + $button_label = null != $current_plan && $current_plan->id == $plan->get_id() ? __('This is your current plan', 'wp-ultimo') : __('Select Plan', 'wp-ultimo'); $button_label = apply_filters('wu_plan_select_button_label', $button_label, $plan, $current_plan); ?> diff --git a/views/legacy/signup/pricing-table/pricing-table.php b/views/legacy/signup/pricing-table/pricing-table.php index 1b18889..1592d3f 100644 --- a/views/legacy/signup/pricing-table/pricing-table.php +++ b/views/legacy/signup/pricing-table/pricing-table.php @@ -91,7 +91,7 @@ if (empty($plans)) { */ $count = count($plans); - $columns = $count == 5 ? '2-4' : 12 / $count; + $columns = 5 == $count ? '2-4' : 12 / $count; foreach ($plans as $plan) { wu_get_template( diff --git a/views/legacy/signup/signup-steps-navigation.php b/views/legacy/signup/signup-steps-navigation.php index 50fa543..93b5ca5 100644 --- a/views/legacy/signup/signup-steps-navigation.php +++ b/views/legacy/signup/signup-steps-navigation.php @@ -48,7 +48,7 @@ $percent = 100 / $count; */ $class = ''; - if ($step_key === $signup->step) { + if ($signup->step === $step_key) { $class = 'active'; } elseif (array_search($signup->step, array_keys($signup->steps)) > array_search($step_key, array_keys($signup->steps))) { $class = 'done'; diff --git a/views/settings/fields/field-multi_checkbox.php b/views/settings/fields/field-multi_checkbox.php index c1ee4a9..5363027 100644 --- a/views/settings/fields/field-multi_checkbox.php +++ b/views/settings/fields/field-multi_checkbox.php @@ -14,7 +14,7 @@ // Check if it was selected $settings = wu_get_setting($field_slug); - if ($settings === false) { + if (false === $settings) { $settings = $field['default'] ?? false; }