diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index 3b5be7e..0a870b2 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -35,6 +35,7 @@ + diff --git a/inc/admin-pages/class-base-admin-page.php b/inc/admin-pages/class-base-admin-page.php index 5194ba6..a4bdcf0 100644 --- a/inc/admin-pages/class-base-admin-page.php +++ b/inc/admin-pages/class-base-admin-page.php @@ -23,6 +23,8 @@ defined('ABSPATH') || exit; abstract class Base_Admin_Page { /** + * In Edit mode + * * @var bool */ protected $edit; @@ -240,7 +242,7 @@ abstract class Base_Admin_Page { global $submenu; - if ($this->get_submenu_title() && 'menu' === $this->type && isset($submenu[ $this->id ]) && $submenu[ $this->id ][0][3] === $this->get_title()) { + if ($this->get_submenu_title() && 'menu' === $this->type && isset($submenu[ $this->id ]) && $this->get_title() === $submenu[ $this->id ][0][3]) { $submenu[ $this->id ][0][0] = $this->get_submenu_title(); } } @@ -256,7 +258,7 @@ abstract class Base_Admin_Page { global $plugin_page; - if ($this->highlight_menu_slug && isset($_GET['page']) && $_GET['page'] === $this->get_id()) { + if ($this->highlight_menu_slug && isset($_GET['page']) && $this->get_id() === $_GET['page']) { $plugin_page = $this->highlight_menu_slug; $file = $this->highlight_menu_slug; @@ -624,7 +626,7 @@ abstract class Base_Admin_Page { if (wu_get_documentation_url($this->get_id(), false)) { $this->action_links[] = [ 'url' => wu_get_documentation_url($this->get_id()), - 'label' => __('Documentation'), + 'label' => __('Documentation', 'wp-ultimo'), 'icon' => 'wu-open-book', ]; } 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 5dca316..99812e0 100644 --- a/inc/admin-pages/class-base-customer-facing-admin-page.php +++ b/inc/admin-pages/class-base-customer-facing-admin-page.php @@ -200,9 +200,11 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page { $this->save_page_settings($settings_to_save); + $referer = isset($_SERVER['HTTP_REFERER']) ? sanitize_url(wp_unslash($_SERVER['HTTP_REFERER'])) : ''; + wp_send_json_success( [ - 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']), + 'redirect_url' => add_query_arg('updated', 1, $referer), ] ); } 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 181908e..7e8ad23 100644 --- a/inc/admin-pages/class-checkout-form-edit-admin-page.php +++ b/inc/admin-pages/class-checkout-form-edit-admin-page.php @@ -1182,7 +1182,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { $new_fields = []; foreach ($fields as $index => $field) { - if ($field['type'] === 'header') { + if ('header' === $field['type']) { continue; } @@ -1491,7 +1491,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { */ public function get_object() { - if ($this->object !== null) { + if (null !== $this->object) { return $this->object; } diff --git a/inc/admin-pages/class-customer-edit-admin-page.php b/inc/admin-pages/class-customer-edit-admin-page.php index 5a0d9b6..b6313c9 100644 --- a/inc/admin-pages/class-customer-edit-admin-page.php +++ b/inc/admin-pages/class-customer-edit-admin-page.php @@ -451,11 +451,11 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { 'value' => wu_get_customer_meta($this->get_object()->get_id(), $key), ]; - if ($field_data['type'] === 'hidden') { + if ('hidden' === $field_data['type']) { $field_data['type'] = 'text'; } - if ($field_data['type'] === 'image') { + if ('image' === $field_data['type']) { $image_attributes = wp_get_attachment_image_src((int) $field_data['value'], 'full'); $field_data['img'] = $image_attributes ? $image_attributes[0] : ''; } @@ -1071,7 +1071,7 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { */ public function get_object() { - if ($this->object !== null) { + if (null !== $this->object) { return $this->object; } @@ -1108,7 +1108,7 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { */ public function handle_save(): void { - if ($_POST['submit_button'] === 'send_verification') { + if ('send_verification' === $_POST['submit_button']) { $customer = $this->get_object(); $customer->send_verification_email(); diff --git a/inc/admin-pages/class-dashboard-admin-page.php b/inc/admin-pages/class-dashboard-admin-page.php index 547647a..01c6681 100644 --- a/inc/admin-pages/class-dashboard-admin-page.php +++ b/inc/admin-pages/class-dashboard-admin-page.php @@ -134,7 +134,7 @@ class Dashboard_Admin_Page extends Base_Admin_Page { return; } - if ($page->id === 'wp-ultimo') { + if ('wp-ultimo' === $page->id) { $preset_options = [ 'last_7_days' => [ 'label' => __('Last 7 days', 'wp-ultimo'), 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 c571cd9..c20b9f1 100644 --- a/inc/admin-pages/class-discount-code-edit-admin-page.php +++ b/inc/admin-pages/class-discount-code-edit-admin-page.php @@ -599,7 +599,7 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page { */ public function get_object() { - if ($this->object !== null) { + if (null !== $this->object) { return $this->object; } diff --git a/inc/admin-pages/class-domain-edit-admin-page.php b/inc/admin-pages/class-domain-edit-admin-page.php index 61668e0..3c22026 100644 --- a/inc/admin-pages/class-domain-edit-admin-page.php +++ b/inc/admin-pages/class-domain-edit-admin-page.php @@ -493,7 +493,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page { */ public function get_object() { - if ($this->object !== null) { + if (null !== $this->object) { return $this->object; } diff --git a/inc/admin-pages/class-edit-admin-page.php b/inc/admin-pages/class-edit-admin-page.php index 71d5d34..5998550 100644 --- a/inc/admin-pages/class-edit-admin-page.php +++ b/inc/admin-pages/class-edit-admin-page.php @@ -62,7 +62,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { */ public function get_errors() { - if ($this->errors === null) { + if (null === $this->errors) { $this->errors = new \WP_Error(); } @@ -850,7 +850,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { 'updated' => 1, ]; - if ($this->edit === false) { + if (false === $this->edit) { $array_params['id'] = $object->get_id(); $array_params['wu-new-model'] = true; diff --git a/inc/admin-pages/class-membership-edit-admin-page.php b/inc/admin-pages/class-membership-edit-admin-page.php index 8f3b55e..8a4167b 100644 --- a/inc/admin-pages/class-membership-edit-admin-page.php +++ b/inc/admin-pages/class-membership-edit-admin-page.php @@ -1073,7 +1073,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { */ public function get_object() { - if ($this->object !== null) { + if (null !== $this->object) { return $this->object; } @@ -1156,7 +1156,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { 'updated' => 1, ]; - if ($this->edit === false) { + if (false === $this->edit) { $array_params['id'] = $object->get_id(); } diff --git a/inc/admin-pages/class-product-edit-admin-page.php b/inc/admin-pages/class-product-edit-admin-page.php index 585e4be..7673899 100644 --- a/inc/admin-pages/class-product-edit-admin-page.php +++ b/inc/admin-pages/class-product-edit-admin-page.php @@ -1026,7 +1026,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { */ public function get_object() { - if ($this->object !== null) { + if (null !== $this->object) { return $this->object; } diff --git a/inc/admin-pages/class-setup-wizard-admin-page.php b/inc/admin-pages/class-setup-wizard-admin-page.php index 727a88f..2919968 100644 --- a/inc/admin-pages/class-setup-wizard-admin-page.php +++ b/inc/admin-pages/class-setup-wizard-admin-page.php @@ -192,7 +192,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { */ public function is_migration() { - if ($this->is_migration === null) { + if (null === $this->is_migration) { $this->is_migration = Migrator::is_legacy_network(); } @@ -785,7 +785,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { */ public function handle_configuration(): void { - if ($_POST['submit'] === '1') { + if ('1' === $_POST['submit']) { $this->integration->setup_constants($_POST); $redirect_url = $this->get_next_section_link(); diff --git a/inc/admin-pages/class-shortcodes-admin-page.php b/inc/admin-pages/class-shortcodes-admin-page.php index 8094843..daa7b67 100644 --- a/inc/admin-pages/class-shortcodes-admin-page.php +++ b/inc/admin-pages/class-shortcodes-admin-page.php @@ -150,7 +150,7 @@ class Shortcodes_Admin_Page extends Base_Admin_Page { foreach ($elements as $element) { $defaults = $element->defaults(); - $params = array_filter($element->fields(), fn($el) => $el['type'] !== 'note' && $el['type'] !== 'header'); + $params = array_filter($element->fields(), fn($el) => 'note' !== $el['type'] && 'header' !== $el['type']); foreach ($params as $key => $value) { $params[ $key ]['default'] = wu_get_isset($defaults, $key, ''); diff --git a/inc/admin-pages/class-site-edit-admin-page.php b/inc/admin-pages/class-site-edit-admin-page.php index d15ebe0..07fc2fd 100644 --- a/inc/admin-pages/class-site-edit-admin-page.php +++ b/inc/admin-pages/class-site-edit-admin-page.php @@ -720,7 +720,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { */ public function get_object() { - if ($this->object !== null) { + if (null !== $this->object) { return $this->object; } diff --git a/inc/admin-pages/class-webhook-edit-admin-page.php b/inc/admin-pages/class-webhook-edit-admin-page.php index 76bd49b..3d5fd23 100644 --- a/inc/admin-pages/class-webhook-edit-admin-page.php +++ b/inc/admin-pages/class-webhook-edit-admin-page.php @@ -401,7 +401,7 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page { 'updated' => 1, ]; - if ($this->edit === false) { + if (false === $this->edit) { $array_params['id'] = $object->get_id(); } diff --git a/inc/admin-pages/customer-panel/class-add-new-site-admin-page.php b/inc/admin-pages/customer-panel/class-add-new-site-admin-page.php index a33d664..d4c6b2b 100644 --- a/inc/admin-pages/customer-panel/class-add-new-site-admin-page.php +++ b/inc/admin-pages/customer-panel/class-add-new-site-admin-page.php @@ -159,7 +159,7 @@ class Add_New_Site_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/builders/block-editor/class-block-editor-widget-manager.php b/inc/builders/block-editor/class-block-editor-widget-manager.php index 2e0a96d..d0e7ed0 100644 --- a/inc/builders/block-editor/class-block-editor-widget-manager.php +++ b/inc/builders/block-editor/class-block-editor-widget-manager.php @@ -147,7 +147,7 @@ class Block_Editor_Widget_Manager { * Deal with the group type. * On those, we need to loop the sub-fields. */ - if ($field['type'] === 'group') { + if ('group' === $field['type']) { foreach ($field['fields'] as &$sub_field) { foreach ($sub_field as $sub_item => &$sub_value) { if (in_array($sub_item, $callable_keys, true) && is_callable($sub_value)) { @@ -213,11 +213,11 @@ class Block_Editor_Widget_Manager { foreach ($fields as $field_id => $field) { $type = 'string'; - if ($field['type'] === 'toggle') { + if ('toggle' === $field['type']) { $type = 'boolean'; } - if ($field['type'] === 'number') { + if ('number' === $field['type']) { $type = 'integer'; } diff --git a/inc/checkout/class-cart.php b/inc/checkout/class-cart.php index 07a0031..6620143 100644 --- a/inc/checkout/class-cart.php +++ b/inc/checkout/class-cart.php @@ -626,7 +626,7 @@ class Cart implements \JsonSerializable { $product = $line_item->get_product(); if ($product) { - if ($product->is_recurring() && ($this->duration_unit !== $product->get_duration_unit() || $this->duration !== $product->get_duration())) { + if ($product->is_recurring() && ($product->get_duration_unit() !== $this->duration_unit || $product->get_duration() !== $this->duration)) { $product_variation = $product->get_as_variation($this->duration, $this->duration_unit); /* @@ -876,7 +876,7 @@ class Cart implements \JsonSerializable { */ $is_plan_change = false; - if ($membership->get_plan_id() !== $this->plan_id || $this->duration_unit !== $membership->get_duration_unit() || $this->duration !== $membership->get_duration()) { + if ($membership->get_plan_id() !== $this->plan_id || $membership->get_duration_unit() !== $this->duration_unit || $membership->get_duration() !== $this->duration) { $is_plan_change = true; } @@ -934,7 +934,7 @@ class Cart implements \JsonSerializable { * We'll probably never enter in this if, but we * hev it here to prevent bugs. */ - if ( ! $is_plan_change || ($this->get_plan_id() === $membership->get_plan_id() && $this->duration_unit === $membership->get_duration_unit() && $this->duration === $membership->get_duration())) { + if ( ! $is_plan_change || ($this->get_plan_id() === $membership->get_plan_id() && $membership->get_duration_unit() === $this->duration_unit && $membership->get_duration() === $this->duration)) { $this->products = []; $this->line_items = []; @@ -969,7 +969,7 @@ class Cart implements \JsonSerializable { $old_price_per_day = $days_in_old_cycle > 0 ? $membership->get_amount() / $days_in_old_cycle : $membership->get_amount(); $new_price_per_day = $days_in_new_cycle > 0 ? $this->get_recurring_total() / $days_in_new_cycle : $this->get_recurring_total(); - $is_same_product = $this->plan_id === $membership->get_plan_id(); + $is_same_product = $membership->get_plan_id() === $this->plan_id; /** * Here we search for variations of the plans @@ -1088,7 +1088,7 @@ class Cart implements \JsonSerializable { ]; } - if ($this->duration_unit && $this->duration && ($this->duration_unit !== $plan_b->get_duration_unit() || $this->duration !== $plan_b->get_duration())) { + if ($this->duration_unit && $this->duration && ($plan_b->get_duration_unit() !== $this->duration_unit || $plan_b->get_duration() !== $this->duration)) { $plan_a_variation = $plan_a->get_as_variation($this->duration, $this->duration_unit); if ( ! $plan_a_variation) { @@ -1511,7 +1511,7 @@ class Cart implements \JsonSerializable { } // Here we check if the product is recurring and if so, get the correct variation - if ($product->is_recurring() && ! empty($this->duration) && ($this->duration !== $product->get_duration() || $this->duration_unit !== $product->get_duration_unit())) { + if ($product->is_recurring() && ! empty($this->duration) && ($product->get_duration() !== $this->duration || $product->get_duration_unit() !== $this->duration_unit)) { $product = $product->get_as_variation($this->duration, $this->duration_unit); if ( ! $product) { @@ -1576,7 +1576,7 @@ class Cart implements \JsonSerializable { * the cart. */ if ($product->is_free() === false) { - if (absint($this->duration) !== $product->get_duration() || $this->duration_unit !== $product->get_duration_unit()) { + if (absint($this->duration) !== $product->get_duration() || $product->get_duration_unit() !== $this->duration_unit) { $price_variation = $product->get_price_variation($this->duration, $this->duration_unit); if ($price_variation) { @@ -2614,7 +2614,7 @@ class Cart implements \JsonSerializable { */ public function should_auto_renew() { - return $this->auto_renew === 'yes' || $this->auto_renew === true; + return 'yes' === $this->auto_renew || true === $this->auto_renew; } /** diff --git a/inc/checkout/class-checkout-pages.php b/inc/checkout/class-checkout-pages.php index 06f492d..7e159a2 100644 --- a/inc/checkout/class-checkout-pages.php +++ b/inc/checkout/class-checkout-pages.php @@ -437,7 +437,7 @@ class Checkout_Pages { return; } - if ($_SERVER['REQUEST_METHOD'] === 'POST') { + if ('POST' === $_SERVER['REQUEST_METHOD']) { return; } diff --git a/inc/checkout/class-checkout.php b/inc/checkout/class-checkout.php index 544aa8b..1276e64 100644 --- a/inc/checkout/class-checkout.php +++ b/inc/checkout/class-checkout.php @@ -367,7 +367,7 @@ class Checkout { $this->checkout_form = wu_get_checkout_form_by_slug($checkout_form_slug); - if ($this->session === null) { + if (null === $this->session) { $this->session = wu_get_session('signup'); } @@ -1434,7 +1434,7 @@ class Checkout { * to handle the status here as the payment is not * passed to process_checkout method in this case. */ - if ( ! $this->order->should_collect_payment() && $this->type === 'downgrade') { + if ( ! $this->order->should_collect_payment() && 'downgrade' === $this->type) { $payment_data['status'] = Payment_Status::COMPLETED; } @@ -1570,7 +1570,7 @@ class Checkout { if (empty($duration) && $this->steps) { foreach ($this->steps as $step) { foreach ($step['fields'] as $field) { - if ($field['type'] === 'period_selection') { + if ('period_selection' === $field['type']) { $duration = $field['period_options'][0]['duration']; $duration_unit = $field['period_options'][0]['duration_unit']; @@ -1723,7 +1723,7 @@ class Checkout { /* * Add rules for site when creating a new account. */ - if ($this->type === 'new') { + if ('new' === $this->type) { // char limit according https://datatracker.ietf.org/doc/html/rfc1034#section-3.1 $rules['site_title'] = 'min:4'; @@ -2293,7 +2293,7 @@ class Checkout { $value = $default; - if ($this->session !== null) { + if (null !== $this->session) { $session = $this->session->get('signup'); if (isset($session[ $key ])) { @@ -2348,7 +2348,7 @@ class Checkout { return true; } - return $this->step_name === array_shift($step_names); + return array_shift($step_names) === $this->step_name; } /** @@ -2386,7 +2386,7 @@ class Checkout { return true; } - return $this->step_name === array_pop($step_names); + return array_pop($step_names) === $this->step_name; } /** diff --git a/inc/checkout/class-legacy-checkout.php b/inc/checkout/class-legacy-checkout.php index 105631d..4b64b63 100644 --- a/inc/checkout/class-legacy-checkout.php +++ b/inc/checkout/class-legacy-checkout.php @@ -247,7 +247,7 @@ class Legacy_Checkout { wp_add_inline_style('legacy-signup', $this->get_legacy_dynamic_styles()); // Do not get the login if the first step - if ($this->step != 'plan') { + if ('plan' != $this->step) { wp_enqueue_style('login'); @@ -577,7 +577,7 @@ class Legacy_Checkout { /** * Set the errors */ - if ($this->results === null) { + if (null === $this->results) { $this->results = ['errors' => new \WP_Error()]; } @@ -979,7 +979,7 @@ class Legacy_Checkout { $params['customized'] = $_REQUEST['customized']; } - if (isset($_REQUEST['skip_plan']) && $_REQUEST['skip_plan'] == 1) { + if (isset($_REQUEST['skip_plan']) && 1 == $_REQUEST['skip_plan']) { unset($this->steps['plan']); unset($params['skip_plan']); } diff --git a/inc/checkout/class-line-item.php b/inc/checkout/class-line-item.php index 92405e8..70efa7e 100644 --- a/inc/checkout/class-line-item.php +++ b/inc/checkout/class-line-item.php @@ -387,7 +387,7 @@ class Line_Item implements \JsonSerializable { return false; } - if ($product->is_recurring() && ($this->duration_unit !== $product->get_duration_unit() || $this->duration !== $product->get_duration())) { + if ($product->is_recurring() && ($product->get_duration_unit() !== $this->duration_unit || $product->get_duration() !== $this->duration)) { $product_variation = $product->get_as_variation($this->duration, $this->duration_unit); /* 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 ef9a93f..9fc3d73 100644 --- a/inc/checkout/signup-fields/class-signup-field-order-summary.php +++ b/inc/checkout/signup-fields/class-signup-field-order-summary.php @@ -215,7 +215,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field { /* * Backwards compatibility with previous betas */ - if ($attributes['order_summary_template'] === 'simple') { + if ('simple' === $attributes['order_summary_template']) { $attributes['order_summary_template'] = 'clean'; } diff --git a/inc/class-ajax.php b/inc/class-ajax.php index 2ba78ae..45b73b4 100644 --- a/inc/class-ajax.php +++ b/inc/class-ajax.php @@ -138,7 +138,7 @@ class Ajax { /* * Deal with site */ - if ($args['model'] === 'site') { + if ('site' === $args['model']) { if (wu_get_isset($query, 'id__in')) { $query['blog_id__in'] = $query['id__in']; @@ -154,9 +154,9 @@ class Ajax { $results = []; - if ($args['model'] === 'user') { + if ('user' === $args['model']) { $results = $this->search_wordpress_users($query); - } elseif ($args['model'] === 'page') { + } elseif ('page' === $args['model']) { $results = get_posts( [ 'post_type' => 'page', @@ -165,7 +165,7 @@ class Ajax { 'exclude' => $query['id__not_in'] ?? '', ] ); - } elseif ($args['model'] === 'setting') { + } elseif ('setting' === $args['model']) { $results = $this->search_wp_ultimo_setting($query); } else { $model_func = 'wu_get_' . strtolower((string) $args['model']) . 's'; diff --git a/inc/class-async-calls.php b/inc/class-async-calls.php index 9c398fc..e410722 100644 --- a/inc/class-async-calls.php +++ b/inc/class-async-calls.php @@ -33,22 +33,23 @@ class Async_Calls { * * @var array */ - static $registry = []; + public static $registry = []; /** * Registers a new listener. * - * @since 2.0.7 - * * @param string $id The id of the listener. - * @param callable $callable A callback to be run. + * @param callable $callback A callback to be run. * @param mixed ...$args Arguments to be passed to the callback. + * * @return void + *@since 2.0.7 + * */ - public static function register_listener($id, $callable, ...$args): void { + public static function register_listener($id, $callback, ...$args): void { self::$registry[ $id ] = [ - 'callable' => $callable, + 'callable' => $callback, 'args' => $args, ]; } diff --git a/inc/class-autoloader.php b/inc/class-autoloader.php index 64653b7..4b82fde 100644 --- a/inc/class-autoloader.php +++ b/inc/class-autoloader.php @@ -51,7 +51,6 @@ class Autoloader { * @return boolean */ public static function is_debug() { - - return false; // return wu_is_debug(); + return false; } } diff --git a/inc/class-domain-mapping.php b/inc/class-domain-mapping.php index c3b0224..739e849 100644 --- a/inc/class-domain-mapping.php +++ b/inc/class-domain-mapping.php @@ -75,7 +75,7 @@ class Domain_Mapping { /* * Don't run during installation... */ - if (defined('WP_INSTALLING') && $_SERVER['SCRIPT_NAME'] !== '/wp-activate.php') { + if (defined('WP_INSTALLING') && '/wp-activate.php' !== $_SERVER['SCRIPT_NAME']) { return; } diff --git a/inc/class-session-cookie.php b/inc/class-session-cookie.php index 3a64ee1..31d6fcf 100644 --- a/inc/class-session-cookie.php +++ b/inc/class-session-cookie.php @@ -51,7 +51,7 @@ class Session_Cookie implements Session { public function __construct($realm_name) { $this->realm_name = $realm_name; - if ($this->loaded === true) { + if (true === $this->loaded) { return; } diff --git a/inc/class-settings.php b/inc/class-settings.php index 39056e0..df6d5d7 100644 --- a/inc/class-settings.php +++ b/inc/class-settings.php @@ -153,7 +153,7 @@ class Settings { $this->settings = wu_get_option(self::KEY); } - if ($this->settings === false || empty($this->settings)) { + if (false === $this->settings || empty($this->settings)) { if ( ! $this->saving) { $this->saving = true; $this->settings = $this->save_settings([], true); @@ -249,7 +249,7 @@ class Settings { /** * For the current tab, we need to assume toggle fields. */ - if (wu_request('tab', 'general') === $section_slug && $field->type === 'toggle' && ! isset($settings_to_save[ $field_slug ])) { + if (wu_request('tab', 'general') === $section_slug && 'toggle' === $field->type && ! isset($settings_to_save[ $field_slug ])) { $new_value = false; } @@ -503,7 +503,7 @@ class Settings { /* * Makes sure we install the default value if it is not set yet. */ - if (isset($atts['default']) && $atts['default'] !== null && ! isset($settings[ $field_slug ])) { + if (isset($atts['default']) && null !== $atts['default'] && ! isset($settings[ $field_slug ])) { $this->save_setting($field_slug, $atts['default']); } } diff --git a/inc/class-whitelabel.php b/inc/class-whitelabel.php index 3d66516..6cf4a75 100644 --- a/inc/class-whitelabel.php +++ b/inc/class-whitelabel.php @@ -120,7 +120,7 @@ class Whitelabel { */ public function replace_text($translation, $text, $domain) { - if ($this->allowed_domains === null) { + if (null === $this->allowed_domains) { $this->allowed_domains = apply_filters( 'wu_replace_text_allowed_domains', [ @@ -148,7 +148,7 @@ class Whitelabel { return $translation; } - if ($this->init === false) { + if (false === $this->init) { $search_and_replace = []; $site_plural = wu_get_setting('rename_site_plural'); @@ -343,7 +343,7 @@ class Whitelabel { $index = ''; foreach ($menu as $i => $menu_item) { - if ($menu_item[2] === 'sites.php') { + if ('sites.php' === $menu_item[2]) { $index = $i; continue; diff --git a/inc/compat/class-legacy-shortcodes.php b/inc/compat/class-legacy-shortcodes.php index 5fb5f4e..ace25a3 100644 --- a/inc/compat/class-legacy-shortcodes.php +++ b/inc/compat/class-legacy-shortcodes.php @@ -314,7 +314,7 @@ class Legacy_Shortcodes { /** * In the case of the legacy layout, we need to load extra styles. */ - if ($atts['layout'] === 'legacy') { + if ('legacy' === $atts['layout']) { wp_enqueue_style('legacy-signup', wu_get_asset('legacy-signup.css', 'css')); wp_add_inline_style('legacy-signup', \WP_Ultimo\Checkout\Legacy_Checkout::get_instance()->get_legacy_dynamic_styles()); @@ -324,7 +324,7 @@ class Legacy_Shortcodes { do_action('wu_setup_checkout'); - $atts['plan_id'] = is_string($atts['plan_id']) && $atts['plan_id'] !== 'all' ? explode(',', $atts['plan_id']) : false; + $atts['plan_id'] = is_string($atts['plan_id']) && 'all' !== $atts['plan_id'] ? explode(',', $atts['plan_id']) : false; $checkout_form = new \WP_Ultimo\Models\Checkout_Form(); @@ -504,7 +504,7 @@ class Legacy_Shortcodes { /** * In the case of the legacy layout, we need to load extra styles. */ - if ($atts['layout'] === 'legacy') { + if ('legacy' === $atts['layout']) { wp_enqueue_style('legacy-signup', wu_get_asset('legacy-signup.css', 'css')); wp_add_inline_style('legacy-signup', \WP_Ultimo\Checkout\Legacy_Checkout::get_instance()->get_legacy_dynamic_styles()); diff --git a/inc/database/engine/class-table.php b/inc/database/engine/class-table.php index bbafd8c..81a6e28 100644 --- a/inc/database/engine/class-table.php +++ b/inc/database/engine/class-table.php @@ -62,7 +62,7 @@ abstract class Table extends \BerlinDB\Database\Table { */ public function exists() { - if ($this->_exists === null) { + if (null === $this->_exists) { $this->_exists = parent::exists(); } diff --git a/inc/domain-mapping/class-primary-domain.php b/inc/domain-mapping/class-primary-domain.php index f496aca..7b3bc2f 100644 --- a/inc/domain-mapping/class-primary-domain.php +++ b/inc/domain-mapping/class-primary-domain.php @@ -99,7 +99,7 @@ class Primary_Domain { $primary_domain = $domains[0]; - if ($_SERVER['HTTP_HOST'] !== $primary_domain->get_domain() && $primary_domain->is_active()) { + if ($primary_domain->get_domain() !== $_SERVER['HTTP_HOST'] && $primary_domain->is_active()) { $url = wu_get_current_url(); $new_url = Domain_Mapping::get_instance()->replace_url($url, $primary_domain); @@ -118,7 +118,7 @@ class Primary_Domain { */ public function maybe_redirect_to_mapped_or_network_domain(): void { - if ($_SERVER['REQUEST_METHOD'] !== 'GET' || wp_doing_ajax()) { + if ('GET' !== $_SERVER['REQUEST_METHOD'] || wp_doing_ajax()) { return; } diff --git a/inc/duplication/data.php b/inc/duplication/data.php index e4eb144..fed12fb 100644 --- a/inc/duplication/data.php +++ b/inc/duplication/data.php @@ -443,7 +443,7 @@ if ( ! class_exists('MUCD_Data') ) { MUCD_Duplicate::write_log('Result :' . var_export($results, true)); } - if ($wpdb->last_error != '') { + if ('' != $wpdb->last_error) { self::sql_error($sql_query, $wpdb->last_error); } diff --git a/inc/duplication/duplicate.php b/inc/duplication/duplicate.php index bcfb56d..9cc48ae 100644 --- a/inc/duplication/duplicate.php +++ b/inc/duplication/duplicate.php @@ -208,7 +208,7 @@ if ( ! class_exists('MUCD_Duplicate') ) { */ public static function init_log($data): void { // INIT LOG AND SAVE OPTION - if (isset($data['log']) && $data['log'] == 'yes' ) { + if (isset($data['log']) && 'yes' == $data['log'] ) { 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'], '/')) { diff --git a/inc/duplication/log.php b/inc/duplication/log.php index 480c4bb..c137044 100644 --- a/inc/duplication/log.php +++ b/inc/duplication/log.php @@ -139,7 +139,7 @@ if ( ! class_exists('MUCD_Log') ) { * @return boolean True on success, False on failure */ public function write_log($message): bool { - if ($this->mod !== false && $this->can_write() ) { + if (false !== $this->mod && $this->can_write() ) { $time = @date('[d/M/Y:H:i:s]'); fwrite($this->fp, "$time $message" . "\r\n"); return true; diff --git a/inc/functions/checkout-form.php b/inc/functions/checkout-form.php index 4b86f46..df85c39 100644 --- a/inc/functions/checkout-form.php +++ b/inc/functions/checkout-form.php @@ -185,11 +185,11 @@ function wu_is_form_field_pre_selected($field_slug) { */ function wu_form_field_request_arg($field) { - if ($field['type'] === 'template_selection') { + if ('template_selection' === $field['type']) { return 'template_id'; } - if ($field['type'] === 'pricing_table') { + if ('pricing_table' === $field['type']) { return 'products'; } diff --git a/inc/functions/helper.php b/inc/functions/helper.php index b32f529..3f55072 100644 --- a/inc/functions/helper.php +++ b/inc/functions/helper.php @@ -189,7 +189,7 @@ function wu_path_join(...$parts): string { return ''; } - $prefix = ($parts[0] === DIRECTORY_SEPARATOR) ? DIRECTORY_SEPARATOR : ''; + $prefix = (DIRECTORY_SEPARATOR === $parts[0]) ? DIRECTORY_SEPARATOR : ''; $processed = array_filter(array_map(fn($part) => rtrim((string) $part, DIRECTORY_SEPARATOR), $parts), fn($part) => ! empty($part)); diff --git a/inc/functions/pages.php b/inc/functions/pages.php index 1db80d4..85478fa 100644 --- a/inc/functions/pages.php +++ b/inc/functions/pages.php @@ -30,7 +30,7 @@ function wu_guess_registration_page() { $maybe_register_page = get_page_by_path('register'); - if ($maybe_register_page && has_shortcode($maybe_register_page->post_content, 'wu_checkout') && $maybe_register_page->post_status === 'publish') { + if ($maybe_register_page && has_shortcode($maybe_register_page->post_content, 'wu_checkout') && 'publish' === $maybe_register_page->post_status) { wu_save_setting('default_registration_page', $maybe_register_page->ID); function_exists('flush_rewrite_rules') && flush_rewrite_rules(true); diff --git a/inc/functions/product.php b/inc/functions/product.php index 56b9cbd..48f7b17 100644 --- a/inc/functions/product.php +++ b/inc/functions/product.php @@ -190,7 +190,7 @@ function wu_segregate_products($products) { } } - if ($product->get_type() === 'plan' && $results[0] === false) { + if ($product->get_type() === 'plan' && false === $results[0]) { $results[0] = $product; } else { $results[1][] = $product; diff --git a/inc/gateways/class-base-stripe-gateway.php b/inc/gateways/class-base-stripe-gateway.php index 6fcc9c1..85a26c6 100644 --- a/inc/gateways/class-base-stripe-gateway.php +++ b/inc/gateways/class-base-stripe-gateway.php @@ -608,7 +608,7 @@ class Base_Stripe_Gateway extends Base_Gateway { * If already exists, checks for status */ if ($existing_webhook) { - if ($existing_webhook->status === 'disabled') { + if ('disabled' === $existing_webhook->status) { $status = Stripe\WebhookEndpoint::update( $existing_webhook->id, [ @@ -1779,7 +1779,7 @@ class Base_Stripe_Gateway extends Base_Gateway { try { $subscription = Stripe\Subscription::retrieve($subscription_id); - if ($subscription->status !== 'canceled') { + if ('canceled' !== $subscription->status) { $subscription->cancel(); } } catch (\Exception $e) { @@ -2054,7 +2054,7 @@ class Base_Stripe_Gateway extends Base_Gateway { * * First, we'll start customer subscription created. */ - if ($event->type === 'customer.subscription.created') { + if ('customer.subscription.created' === $event->type) { do_action('wu_webhook_recurring_payment_profile_created', $membership, $this); } @@ -2064,7 +2064,7 @@ class Base_Stripe_Gateway extends Base_Gateway { * On Stripe Checkout, we rely entirely on * the webhook call to change the status of things. */ - if ($event->type === 'checkout.session.completed') { + if ('checkout.session.completed' === $event->type) { $membership->set_gateway_customer_id($payment_event->customer); $membership->set_gateway_subscription_id($payment_event->subscription); @@ -2079,7 +2079,7 @@ class Base_Stripe_Gateway extends Base_Gateway { /* * Next, let's deal with charges that went through! */ - if ($event->type === 'charge.succeeded' || $event->type === 'invoice.payment_succeeded') { + if ('charge.succeeded' === $event->type || 'invoice.payment_succeeded' === $event->type) { /** * Here we need to handle invoice.payment_succeeded * events due subscriptions with trials and we need @@ -2092,7 +2092,7 @@ class Base_Stripe_Gateway extends Base_Gateway { 'gateway' => $this->get_id(), ]; - if ($event->type === 'charge.succeeded') { + if ('charge.succeeded' === $event->type) { /* * Successful one-time payment */ @@ -2178,7 +2178,7 @@ class Base_Stripe_Gateway extends Base_Gateway { $pending_payment->attributes($payment_data); $payment = $pending_payment; - } elseif ($event->type === 'charge.succeeded') { + } elseif ('charge.succeeded' === $event->type) { /** * These must be retrieved after the status * is set to active in order for upgrades to work properly @@ -2248,7 +2248,7 @@ class Base_Stripe_Gateway extends Base_Gateway { $this->payment = $payment; - if ($payment_event->object === 'charge' && ! $subscription && $this->get_id() === 'stripe') { + if ('charge' === $payment_event->object && ! $subscription && $this->get_id() === 'stripe') { $cart = $payment->get_meta('wu_original_cart'); $payment_intent_id = (string) $payment->get_meta('stripe_payment_intent_id'); @@ -2316,7 +2316,7 @@ class Base_Stripe_Gateway extends Base_Gateway { /* * Next, let's deal with charges that went through! */ - if ($event->type === 'charge.refunded') { + if ('charge.refunded' === $event->type) { $payment_data = [ 'gateway' => 'stripe', ]; @@ -2352,11 +2352,11 @@ class Base_Stripe_Gateway extends Base_Gateway { /* * Failed payments. */ - if ($event->type === 'invoice.payment_failed') { + if ('invoice.payment_failed' === $event->type) { $this->webhook_event_id = $event->id; // Make sure this invoice is tied to a subscription and is the user's current subscription. - if ( ! empty($event->data->object->subscription) && $event->data->object->subscription === $membership->get_gateway_subscription_id()) { + if ( ! empty($event->data->object->subscription) && $membership->get_gateway_subscription_id() === $event->data->object->subscription) { do_action('wu_recurring_payment_failed', $membership, $this); } @@ -2368,10 +2368,10 @@ class Base_Stripe_Gateway extends Base_Gateway { /* * Cancelled / failed subscription. */ - if ($event->type === 'customer.subscription.deleted') { + if ('customer.subscription.deleted' === $event->type) { wu_log_add('stripe', 'Processing Stripe customer.subscription.deleted webhook.'); - if ($payment_event->id === $membership->get_gateway_subscription_id()) { + if ($membership->get_gateway_subscription_id() === $payment_event->id) { /* * If this is a completed payment plan, * we can skip any cancellation actions. diff --git a/inc/helpers/class-arr.php b/inc/helpers/class-arr.php index b2c9d83..8bc0f6a 100644 --- a/inc/helpers/class-arr.php +++ b/inc/helpers/class-arr.php @@ -41,18 +41,19 @@ class Arr { /** * Filter an array by property or key. * - * @since 2.0.11 - * - * @param array $array The array to filter. + * @param array $array_to_filter The array to filter. * @param string $property The property to filter by. Dot notation is supported. * @param mixed $expected_value The expected value to filter by. * @param integer $flag The flag determining the return type. + * * @return mixed + *@since 2.0.11 + * */ - public static function filter_by_property($array, $property, $expected_value, $flag = 0) { + public static function filter_by_property($array_to_filter, $property, $expected_value, $flag = 0) { $result = self::filter( - $array, + $array_to_filter, function ($value) use ($property, $expected_value) { return Arr::get($value, $property, null) == $expected_value; // phpcs:ignore @@ -69,18 +70,19 @@ class Arr { /** * Filters an array using a callback. * - * @since 2.0.11 - * - * @param array $array The array to search inside. + * @param array $array_to_search The array to search inside. * @param callable $closure The closure function to call. + * * @return array + *@since 2.0.11 + * */ - public static function filter($array, $closure) { + public static function filter($array_to_search, $closure) { if ($closure) { $result = []; - foreach ($array as $key => $value) { + foreach ($array_to_search as $key => $value) { if (call_user_func($closure, $value, $key)) { $result[] = $value; } @@ -89,71 +91,74 @@ class Arr { return $result; } - return array_filter($array); + return array_filter($array_to_search); } /** * Get a nested value inside an array. Dot notation is supported. * - * @since 2.0.11 - * - * @param array $array The array to get the value from. + * @param array $array_target The array to get the value from. * @param string $key The array key to get. Supports dot notation. * @param mixed $default The value to return ibn the case the key does not exist. + * * @return mixed + *@since 2.0.11 + * */ - public static function get($array, $key, $default = null) { + public static function get($array_target, $key, $default = null) { if (is_null($key)) { - return $array; + return $array_target; } - if (isset($array[ $key ])) { - return $array[ $key ]; + if (isset($array_target[ $key ])) { + return $array_target[ $key ]; } foreach (explode('.', $key) as $segment) { - if ( ! is_array($array) || ! array_key_exists($segment, $array)) { + if ( ! is_array($array_target) || ! array_key_exists($segment, $array_target)) { return $default; } - $array = $array[ $segment ]; + $array_target = $array_target[ $segment ]; } - return $array; + return $array_target; } /** * Set a nested value inside an array. Dot notation is supported. * - * @since 2.0.11 - * - * @param array $array The array to modify. + * @param array $array_to_modify The array to modify. * @param string $key The array key to set. Supports dot notation. * @param mixed $value The value to set. + * * @return array + *@since 2.0.11 + * */ - public static function set(&$array, $key, $value) { + public static function set(&$array_to_modify, $key, $value) { if (is_null($key)) { - return $array = $value; // phpcs:ignore + return $array_to_modify = $value; // phpcs:ignore } - $keys = explode('.', $key); + $keys = explode('.', $key); + $keys_count = count($keys); - while (count($keys) > 1) { + while ($keys_count > 1) { $key = array_shift($keys); - if ( ! isset($array[ $key ]) || ! is_array($array[ $key ])) { - $array[ $key ] = []; + if ( ! isset($array_to_modify[ $key ]) || ! is_array($array_to_modify[ $key ])) { + $array_to_modify[ $key ] = []; } - $array =& $array[ $key ]; + $array_to_modify =& $array_to_modify[ $key ]; } - $array[ array_shift($keys) ] = $value; + $array_to_modify[ array_shift($keys) ] = $value; - return $array; + return $array_to_modify; } /** diff --git a/inc/installers/class-base-installer.php b/inc/installers/class-base-installer.php index 6449d55..736caa5 100644 --- a/inc/installers/class-base-installer.php +++ b/inc/installers/class-base-installer.php @@ -50,7 +50,7 @@ class Base_Installer { $all_done = true; foreach ($this->get_steps() as $step) { - if ($step['done'] === false) { + if (false === $step['done']) { $all_done = false; } } diff --git a/inc/installers/class-migrator.php b/inc/installers/class-migrator.php index c6c9e3e..6be3974 100644 --- a/inc/installers/class-migrator.php +++ b/inc/installers/class-migrator.php @@ -706,7 +706,7 @@ class Migrator extends Base_Installer { global $wpdb; - if ($this->settings !== null) { + if (null !== $this->settings) { return $this->settings; } @@ -1662,7 +1662,7 @@ class Migrator extends Base_Installer { if ($subscription->gateway) { $membership_data['gateway'] = $subscription->gateway; - if ($subscription->gateway === 'stripe') { + if ('stripe' === $subscription->gateway) { /** * Case Stripe. @@ -1672,7 +1672,7 @@ class Migrator extends Base_Installer { */ $membership_data['gateway_customer_id'] = $subscription->integration_key; $membership_data['gateway_subscription_id'] = $v1_subscription_meta->subscription_id; - } elseif ($subscription->gateway === 'paypal') { + } elseif ('paypal' === $subscription->gateway) { /** * Case PayPal. diff --git a/inc/integrations/host-providers/class-cpanel-host-provider.php b/inc/integrations/host-providers/class-cpanel-host-provider.php index 45f1a9c..08777f8 100644 --- a/inc/integrations/host-providers/class-cpanel-host-provider.php +++ b/inc/integrations/host-providers/class-cpanel-host-provider.php @@ -241,7 +241,7 @@ class CPanel_Host_Provider extends Base_Host_Provider { */ public function load_api() { - if ($this->api === null) { + if (null === $this->api) { $username = defined('WU_CPANEL_USERNAME') ? WU_CPANEL_USERNAME : ''; $password = defined('WU_CPANEL_PASSWORD') ? WU_CPANEL_PASSWORD : ''; $host = defined('WU_CPANEL_HOST') ? WU_CPANEL_HOST : ''; 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 e699ff8..fdcbc13 100644 --- a/inc/integrations/host-providers/cpanel-api/class-cpanel-api.php +++ b/inc/integrations/host-providers/cpanel-api/class-cpanel-api.php @@ -243,7 +243,7 @@ class CPanel_API { $reply = json_decode((string) $reply, true); - if (isset($reply['status']) && $reply['status'] == 1) { // phpcs:ignore + if (isset($reply['status']) && 1 == $reply['status']) { // phpcs:ignore $this->cpsess = $reply['security_token']; $this->homepage = $this->get_base_url() . $reply['redirect']; diff --git a/inc/internal/class-memory-trap.php b/inc/internal/class-memory-trap.php index a5f1a24..5d7fd95 100644 --- a/inc/internal/class-memory-trap.php +++ b/inc/internal/class-memory-trap.php @@ -99,7 +99,7 @@ class Memory_Trap { $message = sprintf(__('Your server\'s PHP and WordPress memory limits are too low to perform this check. You might need to contact your host provider and ask the PHP memory limit in particular to be raised.', 'wp-ultimo')); - if ($this->return_type === 'json') { + if ('json' === $this->return_type) { wp_send_json_error( [ 'message' => $message, diff --git a/inc/limitations/class-limit-customer-user-role.php b/inc/limitations/class-limit-customer-user-role.php index 0fff20d..f840314 100644 --- a/inc/limitations/class-limit-customer-user-role.php +++ b/inc/limitations/class-limit-customer-user-role.php @@ -71,6 +71,6 @@ class Limit_Customer_User_Role extends Limit { $default_value = wu_get_setting('default_role', 'administrator'); - return empty($this->limit) || $this->limit === 'default' ? $default_value : $this->limit; + return empty($this->limit) || 'default' === $this->limit ? $default_value : $this->limit; } } diff --git a/inc/limitations/class-limit-plugins.php b/inc/limitations/class-limit-plugins.php index 140951e..a219440 100644 --- a/inc/limitations/class-limit-plugins.php +++ b/inc/limitations/class-limit-plugins.php @@ -45,13 +45,13 @@ class Limit_Plugins extends Limit { $plugin = (object) $this->{$value_to_check}; $types = [ - 'visible' => $plugin->visibility === 'visible', - 'hidden' => $plugin->visibility === 'hidden', - 'default' => $plugin->behavior === 'default', - 'force_active' => $plugin->behavior === 'force_active', - 'force_inactive' => $plugin->behavior === 'force_inactive', - 'force_active_locked' => $plugin->behavior === 'force_active_locked', - 'force_inactive_locked' => $plugin->behavior === 'force_inactive_locked', + 'visible' => 'visible' === $plugin->visibility, + 'hidden' => 'hidden' === $plugin->visibility, + 'default' => 'default' === $plugin->behavior, + 'force_active' => 'force_active' === $plugin->behavior, + 'force_inactive' => 'force_inactive' === $plugin->behavior, + 'force_active_locked' => 'force_active_locked' === $plugin->behavior, + 'force_inactive_locked' => 'force_inactive_locked' === $plugin->behavior, ]; return wu_get_isset($types, $type, false); diff --git a/inc/limitations/class-limit-site-templates.php b/inc/limitations/class-limit-site-templates.php index c7d22b4..b2d01d1 100644 --- a/inc/limitations/class-limit-site-templates.php +++ b/inc/limitations/class-limit-site-templates.php @@ -87,9 +87,9 @@ class Limit_Site_Templates extends Limit { $template = (object) $this->{$value_to_check}; $types = [ - 'available' => $template->behavior === 'available', - 'not_available' => $template->behavior === 'not_available', - 'pre_selected' => $template->behavior === 'pre_selected', + 'available' => 'available' === $template->behavior, + 'not_available' => 'not_available' === $template->behavior, + 'pre_selected' => 'pre_selected' === $template->behavior, ]; return wu_get_isset($types, $type, true); @@ -178,7 +178,7 @@ class Limit_Site_Templates extends Limit { foreach ($limits as $site_id => $site_settings) { $site_settings = (object) $site_settings; - if ($site_settings->behavior === 'available' || $site_settings->behavior === 'pre_selected' || $this->mode === 'default') { + if ('available' === $site_settings->behavior || 'pre_selected' === $site_settings->behavior || 'default' === $this->mode) { $available[] = $site_id; } } @@ -205,7 +205,7 @@ class Limit_Site_Templates extends Limit { foreach ($limits as $site_id => $site_settings) { $site_settings = (object) $site_settings; - if ($site_settings->behavior === 'pre_selected') { + if ('pre_selected' === $site_settings->behavior) { $pre_selected_site_template = $site_id; } } diff --git a/inc/limitations/class-limit-themes.php b/inc/limitations/class-limit-themes.php index 48fa1ab..77816fd 100644 --- a/inc/limitations/class-limit-themes.php +++ b/inc/limitations/class-limit-themes.php @@ -53,10 +53,10 @@ class Limit_Themes extends Limit { $theme = (object) $this->{$value_to_check}; $types = [ - 'visible' => $theme->visibility === 'visible', - 'hidden' => $theme->visibility === 'hidden', - 'available' => $theme->behavior === 'available', - 'not_available' => $theme->behavior === 'not_available', + 'visible' => 'visible' === $theme->visibility, + 'hidden' => 'hidden' === $theme->visibility, + 'available' => 'available' === $theme->behavior, + 'not_available' => 'not_available' === $theme->behavior, ]; return wu_get_isset($types, $type, false); @@ -136,7 +136,7 @@ class Limit_Themes extends Limit { foreach ($limits as $theme_slug => $theme_settings) { $theme_settings = (object) $theme_settings; - if ($theme_settings->behavior === 'available') { + if ('available' === $theme_settings->behavior) { $available[] = $theme_slug; } } @@ -160,14 +160,14 @@ class Limit_Themes extends Limit { return $active_theme; } - if ($this->forced_active_theme !== null) { + if (null !== $this->forced_active_theme) { return $this->forced_active_theme; } foreach ($limits as $theme_slug => $theme_settings) { $theme_settings = (object) $theme_settings; - if ($theme_settings->behavior === 'force_active') { + if ('force_active' === $theme_settings->behavior) { $active_theme = $theme_slug; } } diff --git a/inc/limits/class-customer-user-role-limits.php b/inc/limits/class-customer-user-role-limits.php index 8271531..095673a 100644 --- a/inc/limits/class-customer-user-role-limits.php +++ b/inc/limits/class-customer-user-role-limits.php @@ -54,7 +54,7 @@ class Customer_User_Role_Limits { $screen = get_current_screen(); - if ( ! $screen || $screen->id !== 'user') { + if ( ! $screen || 'user' !== $screen->id) { return; } diff --git a/inc/limits/class-post-type-limits.php b/inc/limits/class-post-type-limits.php index 3e02668..dfd6022 100644 --- a/inc/limits/class-post-type-limits.php +++ b/inc/limits/class-post-type-limits.php @@ -112,7 +112,7 @@ class Post_Type_Limits { */ public function limit_restoring(): void { - if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'untrash') { + if (isset($_REQUEST['action']) && 'untrash' === $_REQUEST['action']) { $this->limit_posts(); } } @@ -170,7 +170,7 @@ class Post_Type_Limits { } - if (isset($data['post_status']) && $data['post_status'] !== 'publish') { + if (isset($data['post_status']) && 'publish' !== $data['post_status']) { return $data; } @@ -208,10 +208,10 @@ class Post_Type_Limits { $quota = wu_get_current_site()->get_limitations()->post_types->attachment->number; // This bit is for the flash uploader - if ($file['type'] === 'application/octet-stream' && isset($file['tmp_name'])) { + if ('application/octet-stream' === $file['type'] && isset($file['tmp_name'])) { $file_size = getimagesize($file['tmp_name']); - if (isset($file_size['error']) && $file_size['error'] !== 0) { + if (isset($file_size['error']) && 0 !== $file_size['error']) { $file['error'] = "Unexpected Error: {$file_size['error']}"; return $file; diff --git a/inc/limits/class-theme-limits.php b/inc/limits/class-theme-limits.php index 5ceb084..78f9f5c 100644 --- a/inc/limits/class-theme-limits.php +++ b/inc/limits/class-theme-limits.php @@ -330,7 +330,7 @@ class Theme_Limits { */ protected function get_forced_theme_stylesheet() { - if ($this->forced_theme_stylesheet === null) { + if (null === $this->forced_theme_stylesheet) { $this->forced_theme_stylesheet = wu_get_current_site()->get_limitations()->themes->get_forced_active_theme(); } @@ -346,7 +346,7 @@ class Theme_Limits { */ protected function get_forced_theme_template() { - if ($this->forced_theme_template === null) { + if (null === $this->forced_theme_template) { $stylesheet = $this->get_forced_theme_stylesheet(); $this->forced_theme_template = $stylesheet ? wp_get_theme($stylesheet)->get_template() : false; diff --git a/inc/list-tables/class-base-list-table.php b/inc/list-tables/class-base-list-table.php index 1e2f34b..fcdfea7 100644 --- a/inc/list-tables/class-base-list-table.php +++ b/inc/list-tables/class-base-list-table.php @@ -168,7 +168,7 @@ class Base_List_Table extends \WP_List_Table { */ protected function extra_tablenav($which) { - if ($this->current_mode === 'grid') { + if ('grid' === $this->current_mode) { printf( '', __('Select All', 'wp-ultimo') @@ -184,7 +184,7 @@ class Base_List_Table extends \WP_List_Table { */ public function set_list_mode(): void { - if ($this->context !== 'page') { + if ('page' !== $this->context) { $this->current_mode = 'list'; return; @@ -501,7 +501,7 @@ class Base_List_Table extends \WP_List_Table { /* * Any items at all? */ - if ( ! $this->has_items() && $this->context === 'page') { + if ( ! $this->has_items() && 'page' === $this->context) { echo wu_render_empty_state( [ 'message' => sprintf(__("You don't have any %s yet.", 'wp-ultimo'), $this->labels['plural']), @@ -1355,7 +1355,7 @@ class Base_List_Table extends \WP_List_Table { continue; } - if (isset($_REQUEST[ $field_name ]['before']) && isset($_REQUEST[ $field_name ]['after']) && $_REQUEST[ $field_name ]['before'] === '' && $_REQUEST[ $field_name ]['after'] === '') { + if (isset($_REQUEST[ $field_name ]['before']) && isset($_REQUEST[ $field_name ]['after']) && '' === $_REQUEST[ $field_name ]['before'] && '' === $_REQUEST[ $field_name ]['after']) { continue; } diff --git a/inc/list-tables/class-customer-list-table.php b/inc/list-tables/class-customer-list-table.php index afb55ab..1d232dc 100644 --- a/inc/list-tables/class-customer-list-table.php +++ b/inc/list-tables/class-customer-list-table.php @@ -293,7 +293,7 @@ class Customer_List_Table extends Base_List_Table { $filter_type = 'text'; $rule = 'is'; - if ($item->date_query === true) { + if (true === $item->date_query) { $filter_type = 'date'; $rule = 'is_after'; } elseif (in_array(strtolower((string) $item->name), ['smallint'], true)) { diff --git a/inc/managers/class-broadcast-manager.php b/inc/managers/class-broadcast-manager.php index 7e7db07..f84cbef 100644 --- a/inc/managers/class-broadcast-manager.php +++ b/inc/managers/class-broadcast-manager.php @@ -158,7 +158,7 @@ class Broadcast_Manager extends Base_Manager { ); } - if ($args['type'] === 'broadcast_email') { + if ('broadcast_email' === $args['type']) { $to = []; $bcc = []; @@ -272,7 +272,7 @@ class Broadcast_Manager extends Base_Manager { $broadcast = new Broadcast($broadcast_data); - if ($args['type'] === 'broadcast_notice') { + if ('broadcast_notice' === $args['type']) { $broadcast->set_notice_type($args['notice_type']); } diff --git a/inc/managers/class-event-manager.php b/inc/managers/class-event-manager.php index 98d51b0..1916850 100644 --- a/inc/managers/class-event-manager.php +++ b/inc/managers/class-event-manager.php @@ -236,7 +236,7 @@ class Event_Manager extends Base_Manager { 'hidden' => false, ]; - $types = array_filter($types, fn($item) => $item['hidden'] === false); + $types = array_filter($types, fn($item) => false === $item['hidden']); return $types; } diff --git a/inc/managers/class-field-templates-manager.php b/inc/managers/class-field-templates-manager.php index ff3b8ad..0895c5f 100644 --- a/inc/managers/class-field-templates-manager.php +++ b/inc/managers/class-field-templates-manager.php @@ -257,7 +257,7 @@ class Field_Templates_Manager extends Base_Manager { $holder_name = "instantiated_{$field_type}_templates"; - if ( ! isset($this->holders[ $holder_name ]) || $this->holders[ $holder_name ] === null) { + if ( ! isset($this->holders[ $holder_name ]) || null === $this->holders[ $holder_name ]) { $this->holders[ $holder_name ] = array_map([$this, 'instantiate_field_template'], $this->get_templates($field_type)); } diff --git a/inc/managers/class-gateway-manager.php b/inc/managers/class-gateway-manager.php index b2decab..fe7031b 100644 --- a/inc/managers/class-gateway-manager.php +++ b/inc/managers/class-gateway-manager.php @@ -377,7 +377,7 @@ class Gateway_Manager extends Base_Manager { $gateways = $this->get_registered_gateways(); - $gateways = array_filter($gateways, fn($item) => $item['hidden'] === false); + $gateways = array_filter($gateways, fn($item) => false === $item['hidden']); return $gateways; } diff --git a/inc/managers/class-limitation-manager.php b/inc/managers/class-limitation-manager.php index 9582143..8cf6579 100644 --- a/inc/managers/class-limitation-manager.php +++ b/inc/managers/class-limitation-manager.php @@ -313,7 +313,7 @@ class Limitation_Manager { ], ]; - if ($object->model !== 'product') { + if ('product' !== $object->model) { $sections['visits']['fields']['modules_visits_overwrite'] = $this->override_notice($object->get_limitations(false)->visits->has_own_enabled()); } @@ -332,7 +332,7 @@ class Limitation_Manager { ], ]; - if ($object->model !== 'product') { + if ('product' !== $object->model) { $sections['visits']['fields']['allowed_visits_overwrite'] = $this->override_notice($object->get_limitations(false)->visits->has_own_limit(), ['limit_visits']); } @@ -374,7 +374,7 @@ class Limitation_Manager { ], ]; - if ($object->model !== 'product') { + if ('product' !== $object->model) { $sections['users']['fields']['modules_user_overwrite'] = $this->override_notice($object->get_limitations(false)->users->has_own_enabled()); } @@ -401,7 +401,7 @@ class Limitation_Manager { ], ]; - if ($object->model !== 'product') { + if ('product' !== $object->model) { $sections['post_types']['fields']['post_quota_overwrite'] = $this->override_notice($object->get_limitations(false)->post_types->has_own_enabled()); } @@ -437,7 +437,7 @@ class Limitation_Manager { ], ]; - if ($object->model !== 'product') { + if ('product' !== $object->model) { $sections['limit_disk_space']['fields']['disk_space_modules_overwrite'] = $this->override_notice($object->get_limitations(false)->disk_space->has_own_enabled()); } @@ -454,7 +454,7 @@ class Limitation_Manager { ], ]; - if ($object->model !== 'product') { + if ('product' !== $object->model) { $sections['limit_disk_space']['fields']['disk_space_override'] = $this->override_notice($object->get_limitations(false)->disk_space->has_own_limit(), ['limit_disk_space']); } @@ -482,7 +482,7 @@ class Limitation_Manager { ], ]; - if ($object->model !== 'product') { + if ('product' !== $object->model) { $sections['custom_domain']['fields']['custom_domain_override'] = $this->override_notice($object->get_limitations(false)->domain_mapping->has_own_enabled(), ['allow_domain_mapping']); } @@ -620,7 +620,7 @@ class Limitation_Manager { /* * Add override notice. */ - if ($object->model !== 'product') { + if ('product' !== $object->model) { $sections['users']['fields'][ "override_{$user_role_slug}" ] = $this->override_notice($object->get_limitations(false)->users->exists($user_role_slug), ['limit_users']); } } @@ -678,7 +678,7 @@ class Limitation_Manager { /* * Add override notice. */ - if ($object->model !== 'product') { + if ('product' !== $object->model) { $sections['post_types']['fields'][ "override_{$post_type_slug}" ] = $this->override_notice( $object->get_limitations(false)->post_types->exists($post_type_slug), [ @@ -711,7 +711,7 @@ class Limitation_Manager { ], ]; - if ($object->model !== 'product') { + if ('product' !== $object->model) { $fields['sites_overwrite'] = $this->override_notice($object->get_limitations(false)->sites->has_own_enabled()); } @@ -741,7 +741,7 @@ class Limitation_Manager { ], ]; - if ($object->model !== 'product') { + if ('product' !== $object->model) { $fields['sites_overwrite_2'] = $this->override_notice($object->get_limitations(false)->sites->has_own_limit(), ["get_state_value('product_type', 'none') !== 'service' && limit_sites"]); } diff --git a/inc/managers/class-signup-fields-manager.php b/inc/managers/class-signup-fields-manager.php index 336691f..f6a5f4c 100644 --- a/inc/managers/class-signup-fields-manager.php +++ b/inc/managers/class-signup-fields-manager.php @@ -113,7 +113,7 @@ class Signup_Fields_Manager extends Base_Manager { */ public function get_instantiated_field_types() { - if ($this->instantiated_field_types === null) { + if (null === $this->instantiated_field_types) { $this->instantiated_field_types = array_map([$this, 'instantiate_field_type'], $this->get_field_types()); } diff --git a/inc/models/class-base-model.php b/inc/models/class-base-model.php index 704fee7..9a3885d 100644 --- a/inc/models/class-base-model.php +++ b/inc/models/class-base-model.php @@ -240,7 +240,7 @@ abstract class Base_Model implements \JsonSerializable { /* * Keeps the original. */ - if ($this->_original === null) { + if (null === $this->_original) { $original = get_object_vars($this); unset($original['_original']); diff --git a/inc/models/class-broadcast.php b/inc/models/class-broadcast.php index 31d79d2..0b38c71 100644 --- a/inc/models/class-broadcast.php +++ b/inc/models/class-broadcast.php @@ -125,7 +125,7 @@ class Broadcast extends Post_Base_Model { */ public function get_migrated_from_id() { - if ($this->migrated_from_id === null) { + if (null === $this->migrated_from_id) { $this->migrated_from_id = $this->get_meta('migrated_from_id', 0); } @@ -176,7 +176,7 @@ class Broadcast extends Post_Base_Model { */ public function get_notice_type() { - if ($this->notice_type === null) { + if (null === $this->notice_type) { $this->notice_type = $this->get_meta('notice_type', 'success'); } diff --git a/inc/models/class-checkout-form.php b/inc/models/class-checkout-form.php index 037557b..2497229 100644 --- a/inc/models/class-checkout-form.php +++ b/inc/models/class-checkout-form.php @@ -1089,7 +1089,7 @@ class Checkout_Form extends Base_Model { */ public function get_thank_you_page_id() { - if ($this->thank_you_page_id === null) { + if (null === $this->thank_you_page_id) { $this->thank_you_page_id = $this->get_meta('wu_thank_you_page_id', ''); } @@ -1118,7 +1118,7 @@ class Checkout_Form extends Base_Model { */ public function get_conversion_snippets() { - if ($this->conversion_snippets === null) { + if (null === $this->conversion_snippets) { $this->conversion_snippets = $this->get_meta('wu_conversion_snippets', ''); } diff --git a/inc/models/class-customer.php b/inc/models/class-customer.php index 99d6752..80d7b66 100644 --- a/inc/models/class-customer.php +++ b/inc/models/class-customer.php @@ -547,7 +547,7 @@ class Customer extends Base_Model { */ public function get_extra_information() { - if ($this->extra_information === null) { + if (null === $this->extra_information) { $extra_information = (array) $this->get_meta('wu_customer_extra_information'); $this->extra_information = array_filter($extra_information); diff --git a/inc/models/class-discount-code.php b/inc/models/class-discount-code.php index 9686e00..3b7c16c 100644 --- a/inc/models/class-discount-code.php +++ b/inc/models/class-discount-code.php @@ -709,7 +709,7 @@ class Discount_Code extends Base_Model { */ public function get_allowed_products() { - if ($this->allowed_products === null) { + if (null === $this->allowed_products) { $this->allowed_products = $this->get_meta('wu_allowed_products', []); } @@ -738,7 +738,7 @@ class Discount_Code extends Base_Model { */ public function get_limit_products() { - if ($this->limit_products === null) { + if (null === $this->limit_products) { $this->limit_products = $this->get_meta('wu_limit_products', false); } diff --git a/inc/models/class-email.php b/inc/models/class-email.php index 9792ba4..ceac91b 100644 --- a/inc/models/class-email.php +++ b/inc/models/class-email.php @@ -170,7 +170,7 @@ class Email extends Post_Base_Model { */ public function get_event() { - if ($this->event === null) { + if (null === $this->event) { $this->event = $this->get_meta('wu_system_email_event'); } @@ -209,7 +209,7 @@ class Email extends Post_Base_Model { $this->style = $this->get_meta('wu_style', 'html'); - if ($this->style === 'use_default') { + if ('use_default' === $this->style) { $this->style = wu_get_setting('email_template_type', 'html'); } @@ -249,7 +249,7 @@ class Email extends Post_Base_Model { */ public function has_schedule() { - if ($this->schedule === null) { + if (null === $this->schedule) { $this->schedule = $this->get_meta('wu_schedule', false); } @@ -532,7 +532,7 @@ class Email extends Post_Base_Model { */ public function get_target() { - if ($this->target === null) { + if (null === $this->target) { $this->target = $this->get_meta('wu_target', 'admin'); } @@ -633,7 +633,7 @@ class Email extends Post_Base_Model { */ public function get_send_copy_to_admin() { - if ($this->send_copy_to_admin === null) { + if (null === $this->send_copy_to_admin) { $this->send_copy_to_admin = $this->get_meta('wu_send_copy_to_admin', false); } @@ -662,7 +662,7 @@ class Email extends Post_Base_Model { */ public function is_active() { - if ($this->active === null) { + if (null === $this->active) { $this->active = $this->get_meta('wu_active', true); } @@ -691,7 +691,7 @@ class Email extends Post_Base_Model { */ public function is_legacy() { - if ($this->legacy === null) { + if (null === $this->legacy) { $this->legacy = $this->get_meta('wu_legacy', false); } diff --git a/inc/models/class-membership.php b/inc/models/class-membership.php index 38cfc1e..04c0af4 100644 --- a/inc/models/class-membership.php +++ b/inc/models/class-membership.php @@ -482,7 +482,7 @@ class Membership extends Base_Model { if ($plan && ($plan->get_duration() !== $this->get_duration() || $plan->get_duration_unit() !== $this->get_duration_unit())) { $variation = $plan->get_as_variation($this->get_duration(), $this->get_duration_unit()); - $plan = ($variation ? $variation : null) ?? $plan; + $plan = ($variation ?: null) ?? $plan; } return $plan; @@ -1342,7 +1342,7 @@ class Membership extends Base_Model { */ public function get_discount_code() { - if ($this->discount_code === null) { + if (null === $this->discount_code) { $this->discount_code = $this->get_meta('discount_code'); } diff --git a/inc/models/class-payment.php b/inc/models/class-payment.php index 53e4e90..9b2e3f0 100644 --- a/inc/models/class-payment.php +++ b/inc/models/class-payment.php @@ -597,7 +597,7 @@ class Payment extends Base_Model { */ public function get_line_items(): array { - if ($this->line_items === null) { + if (null === $this->line_items) { $line_items = (array) $this->get_meta('wu_line_items'); $this->line_items = array_filter($line_items); @@ -877,7 +877,7 @@ class Payment extends Base_Model { */ public function get_saved_invoice_number() { - if ($this->invoice_number === null) { + if (null === $this->invoice_number) { $this->invoice_number = $this->get_meta('wu_invoice_number', ''); } @@ -898,11 +898,11 @@ class Payment extends Base_Model { $provisional = false; - if ($this->invoice_number === null) { + if (null === $this->invoice_number) { $this->invoice_number = $this->get_meta('wu_invoice_number'); } - if ($this->invoice_number === false) { + if (false === $this->invoice_number) { $provisional = true; $this->invoice_number = wu_get_setting('next_invoice_number'); @@ -981,7 +981,7 @@ class Payment extends Base_Model { */ public function should_cancel_membership_on_refund() { - if ($this->cancel_membership_on_refund === null) { + if (null === $this->cancel_membership_on_refund) { $this->cancel_membership_on_refund = $this->get_meta('wu_cancel_membership_on_refund', false); } diff --git a/inc/models/class-product.php b/inc/models/class-product.php index 13a001f..ca8da91 100644 --- a/inc/models/class-product.php +++ b/inc/models/class-product.php @@ -334,7 +334,7 @@ class Product extends Base_Model { */ public function get_featured_image_id() { - if ($this->featured_image_id === null) { + if (null === $this->featured_image_id) { $this->featured_image_id = $this->get_meta('wu_featured_image_id'); } @@ -1055,7 +1055,7 @@ class Product extends Base_Model { */ public function get_tax_category() { - if ($this->tax_category === null) { + if (null === $this->tax_category) { $this->tax_category = $this->get_meta('tax_category', 'default'); } @@ -1085,7 +1085,7 @@ class Product extends Base_Model { */ public function get_contact_us_label() { - if ($this->contact_us_label === null) { + if (null === $this->contact_us_label) { $this->contact_us_label = $this->get_meta('wu_contact_us_label', ''); } @@ -1114,7 +1114,7 @@ class Product extends Base_Model { */ public function get_contact_us_link() { - if ($this->contact_us_link === null) { + if (null === $this->contact_us_link) { $this->contact_us_link = $this->get_meta('wu_contact_us_link', ''); } @@ -1143,7 +1143,7 @@ class Product extends Base_Model { */ public function get_feature_list() { - if ($this->feature_list === null) { + if (null === $this->feature_list) { $this->feature_list = $this->get_meta('feature_list'); } @@ -1172,7 +1172,7 @@ class Product extends Base_Model { */ public function get_customer_role() { - if ($this->customer_role === null) { + if (null === $this->customer_role) { $this->customer_role = $this->get_limitations()->customer_user_role->get_limit(); } @@ -1239,7 +1239,7 @@ class Product extends Base_Model { */ public function get_price_variations() { - if ($this->price_variations === null) { + if (null === $this->price_variations) { $this->price_variations = array_map( function ($price_variation) { /** @@ -1372,7 +1372,7 @@ class Product extends Base_Model { */ public function get_available_addons() { - if ($this->available_addons === null) { + if (null === $this->available_addons) { $this->available_addons = $this->get_meta('wu_available_addons', []); if (is_string($this->available_addons)) { @@ -1440,7 +1440,7 @@ class Product extends Base_Model { */ public function get_legacy_options() { - if ($this->legacy_options === null) { + if (null === $this->legacy_options) { $this->legacy_options = $this->get_meta('legacy_options', false); } diff --git a/inc/models/class-site.php b/inc/models/class-site.php index 8f098fa..325bbba 100644 --- a/inc/models/class-site.php +++ b/inc/models/class-site.php @@ -343,7 +343,7 @@ class Site extends Base_Model { */ public function get_categories() { - if ($this->categories === null) { + if (null === $this->categories) { $this->categories = $this->get_meta('wu_categories', []); } @@ -362,7 +362,7 @@ class Site extends Base_Model { */ public function get_featured_image_id() { - if ($this->featured_image_id === null) { + if (null === $this->featured_image_id) { return $this->get_meta('wu_featured_image_id'); } @@ -718,7 +718,7 @@ class Site extends Base_Model { */ public function is_active() { - if ($this->active === null) { + if (null === $this->active) { $this->active = $this->get_meta('wu_active', true); } @@ -885,7 +885,7 @@ class Site extends Base_Model { */ public function get_customer_id() { - if ($this->customer_id === null) { + if (null === $this->customer_id) { $this->customer_id = $this->get_meta('wu_customer_id'); } @@ -950,7 +950,7 @@ class Site extends Base_Model { */ public function get_membership_id() { - if ($this->membership_id === null) { + if (null === $this->membership_id) { $this->membership_id = $this->get_meta('wu_membership_id'); } @@ -1001,7 +1001,7 @@ class Site extends Base_Model { */ public function get_membership() { - if ($this->_membership !== null) { + if (null !== $this->_membership) { return $this->_membership; } @@ -1057,7 +1057,7 @@ class Site extends Base_Model { */ public function get_template_id() { - if ($this->template_id === null) { + if (null === $this->template_id) { $this->template_id = $this->get_meta('wu_template_id'); } @@ -1152,7 +1152,7 @@ class Site extends Base_Model { return 'main'; } - if ($this->type === null) { + if (null === $this->type) { $type = $this->get_meta('wu_type'); $this->type = $type ?: 'default'; @@ -1267,7 +1267,7 @@ class Site extends Base_Model { $details = get_blog_details($this->get_blog_id()); - if ($details && $this->title === null) { + if ($details && null === $this->title) { $this->set_title($details->blogname); } @@ -1289,7 +1289,7 @@ class Site extends Base_Model { */ public function get_transient() { - if ($this->transient === null) { + if (null === $this->transient) { $this->transient = $this->get_meta('wu_transient'); } diff --git a/inc/models/traits/trait-billable.php b/inc/models/traits/trait-billable.php index ef260a8..39b8233 100644 --- a/inc/models/traits/trait-billable.php +++ b/inc/models/traits/trait-billable.php @@ -43,7 +43,7 @@ trait Billable { */ public function get_billing_address() { - if ($this->billing_address === null) { + if (null === $this->billing_address) { $billing_address = $this->get_meta('wu_billing_address'); $this->billing_address = is_a($billing_address, '\WP_Ultimo\Objects\Billing_Address') ? $billing_address : $this->get_default_billing_address(); diff --git a/inc/models/traits/trait-limitable.php b/inc/models/traits/trait-limitable.php index f27f7e8..ce09b77 100644 --- a/inc/models/traits/trait-limitable.php +++ b/inc/models/traits/trait-limitable.php @@ -159,9 +159,9 @@ trait Limitable { $sites = []; - if ($this->model === 'site') { + if ('site' === $this->model) { $sites[] = $this; - } elseif ($this->model === 'membership') { + } elseif ('membership' === $this->model) { $sites = $this->get_sites(); } @@ -242,12 +242,12 @@ trait Limitable { } } - if ($this->model !== 'product') { + if ('product' !== $this->model) { /* * Set the new permissions, based on the diff. */ $limitations = wu_array_recursive_diff($modules_to_save, $current_limitations->to_array()); - } elseif ($this->model === 'product' && $this->get_type() !== 'plan') { + } elseif ('product' === $this->model && $this->get_type() !== 'plan') { $limitations = wu_array_recursive_diff($modules_to_save, Limitations::get_empty()->to_array()); } else { $limitations = $modules_to_save; @@ -264,15 +264,15 @@ trait Limitable { */ public function get_applicable_product_slugs() { - if ($this->model === 'product') { + if ('product' === $this->model) { return [$this->get_slug()]; } $slugs = []; - if ($this->model === 'membership') { + if ('membership' === $this->model) { $membership = $this; - } elseif ($this->model === 'site') { + } elseif ('site' === $this->model) { $membership = $this->get_membership(); } diff --git a/inc/models/traits/trait-notable.php b/inc/models/traits/trait-notable.php index 8ffa20d..30467b6 100644 --- a/inc/models/traits/trait-notable.php +++ b/inc/models/traits/trait-notable.php @@ -32,7 +32,7 @@ trait Notable { */ public function get_notes() { - if ($this->notes === null) { + if (null === $this->notes) { $this->notes = get_metadata($this->get_meta_data_table_name(), $this->get_id(), 'wu_note', false); } diff --git a/inc/traits/trait-wp-ultimo-plan-deprecated.php b/inc/traits/trait-wp-ultimo-plan-deprecated.php index 412be71..dd34b4b 100644 --- a/inc/traits/trait-wp-ultimo-plan-deprecated.php +++ b/inc/traits/trait-wp-ultimo-plan-deprecated.php @@ -93,7 +93,7 @@ trait WP_Ultimo_Plan_Deprecated { */ public function is_featured_plan() { - if ($this->featured_plan === null) { + if (null === $this->featured_plan) { $this->featured_plan = $this->get_meta('featured_plan', false); } diff --git a/inc/ui/class-base-element.php b/inc/ui/class-base-element.php index 1dae854..68b3ed4 100644 --- a/inc/ui/class-base-element.php +++ b/inc/ui/class-base-element.php @@ -284,7 +284,7 @@ abstract class Base_Element { $should_load = false; - if ($block['blockName'] === $this->get_id()) { + if ($this->get_id() === $block['blockName']) { $should_load = true; } @@ -386,7 +386,7 @@ abstract class Base_Element { */ public function setup_for_admin(): void { - if ($this->loaded === true) { + if (true === $this->loaded) { return; } @@ -548,7 +548,7 @@ abstract class Base_Element { $block_content = parse_blocks($content); foreach ($block_content as $block) { - if ($block['blockName'] === $this->get_id()) { + if ($this->get_id() === $block['blockName']) { return $block['attrs']; } } @@ -613,7 +613,7 @@ abstract class Base_Element { */ public function get_pre_loaded_attribute($name, $default = false) { - if ($this->pre_loaded_attributes === false || ! is_array($this->pre_loaded_attributes)) { + if (false === $this->pre_loaded_attributes || ! is_array($this->pre_loaded_attributes)) { return false; } @@ -682,7 +682,7 @@ abstract class Base_Element { $state = []; foreach ($fields as $field_slug => &$field) { - if ($field['type'] === 'header' || $field['type'] === 'note') { + if ('header' === $field['type'] || 'note' === $field['type']) { unset($fields[ $field_slug ]); continue; @@ -697,7 +697,7 @@ abstract class Base_Element { */ $additional_state = []; - if ($field['type'] === 'group') { + if ('group' === $field['type']) { foreach ($field['fields'] as $sub_field_slug => &$sub_field) { $sub_field['html_attr'] = [ 'v-model.lazy' => "attributes.{$sub_field_slug}", @@ -810,7 +810,7 @@ abstract class Base_Element { $state = array_merge($defaults, $saved_settings); foreach ($fields as $field_slug => &$field) { - if ($field['type'] === 'header') { + if ('header' === $field['type']) { unset($fields[ $field_slug ]); continue; @@ -886,7 +886,7 @@ abstract class Base_Element { foreach ($fields as $field_slug => $field) { $setting = wu_request($field_slug, false); - if (false !== $setting || $field['type'] === 'toggle') { + if (false !== $setting || 'toggle' === $field['type']) { $settings[ $field_slug ] = $setting; } } diff --git a/inc/ui/class-field.php b/inc/ui/class-field.php index 10654f3..6f998ca 100644 --- a/inc/ui/class-field.php +++ b/inc/ui/class-field.php @@ -178,7 +178,7 @@ class Field implements \JsonSerializable { /* * Back Compat for Select2 Fields */ - if ($this->type === 'select2') { + if ('select2' === $this->type) { $this->atts['html_attr']['data-selectize'] = 1; $this->atts['html_attr']['multiple'] = 1; } @@ -247,11 +247,11 @@ class Field implements \JsonSerializable { $this->atts['wrapper_classes'] .= ' wu-requires-other'; } - if ('type' === $att && $this->atts[ $att ] === 'submit') { + if ('type' === $att && 'submit' === $this->atts[ $att ]) { $this->atts['wrapper_classes'] .= ' wu-submit-field'; } - if ('type' === $att && $this->atts[ $att ] === 'tab-select') { + if ('type' === $att && 'tab-select' === $this->atts[ $att ]) { $this->atts['wrapper_classes'] .= ' wu-tab-field'; } @@ -402,12 +402,12 @@ class Field implements \JsonSerializable { unset($this->atts['html_attr']['class']); - if ($this->type === 'number') { - if ($this->min !== false) { + if ('number' === $this->type) { + if (false !== $this->min) { $attributes['min'] = $this->min; } - if ($this->max !== false) { + if (false !== $this->max) { $attributes['max'] = $this->max; } } @@ -415,7 +415,7 @@ class Field implements \JsonSerializable { /* * Adds money formatting and masking */ - if ($this->money !== false) { + if (false !== $this->money) { $attributes['v-bind'] = 'money_settings'; } diff --git a/inc/ui/class-form.php b/inc/ui/class-form.php index d889d63..3f41f96 100644 --- a/inc/ui/class-form.php +++ b/inc/ui/class-form.php @@ -213,12 +213,12 @@ class Form implements \JsonSerializable { unset($this->atts['html_attr']['class']); - if ($this->type === 'number') { - if ($this->min !== false) { + if ('number' === $this->type) { + if (false !== $this->min) { $attributes['min'] = $this->min; } - if ($this->max !== false) { + if (false !== $this->max) { $attributes['max'] = $this->max; } } diff --git a/inc/ui/class-login-form-element.php b/inc/ui/class-login-form-element.php index 8167c01..69269c2 100644 --- a/inc/ui/class-login-form-element.php +++ b/inc/ui/class-login-form-element.php @@ -423,7 +423,7 @@ class Login_Form_Element extends Base_Element { /* * Handles maintenance mode on Elementor. */ - if ($post && $post->ID === absint(wu_get_setting('default_login_page', 0))) { + if ($post && absint(wu_get_setting('default_login_page', 0)) === $post->ID) { add_filter('elementor/maintenance_mode/is_login_page', '__return_true'); } } @@ -749,9 +749,9 @@ class Login_Form_Element extends Base_Element { if (isset($_GET['redirect_to'])) { $atts['redirect_type'] = 'query_redirect'; $fields['redirect_to']['value'] = $_GET['redirect_to']; - } elseif ($atts['redirect_type'] === 'customer_site') { + } elseif ('customer_site' === $atts['redirect_type']) { $fields['redirect_to']['value'] = $atts['customer_redirect_path']; - } elseif ($atts['redirect_type'] === 'main_site') { + } elseif ('main_site' === $atts['redirect_type']) { $fields['redirect_to']['value'] = $atts['main_redirect_path']; } diff --git a/inc/ui/class-my-sites-element.php b/inc/ui/class-my-sites-element.php index 4955cf9..7f71f11 100644 --- a/inc/ui/class-my-sites-element.php +++ b/inc/ui/class-my-sites-element.php @@ -367,7 +367,7 @@ class My_Sites_Element extends Base_Element { $user_sites = array_reduce( $wp_user_sites, function ($user_sites, $wp_site) use ($customer_sites) { - if ( ! array_key_exists($wp_site->userblog_id, $customer_sites ?? []) && $wp_site->userblog_id !== get_main_site_id()) { + if ( ! array_key_exists($wp_site->userblog_id, $customer_sites ?? []) && get_main_site_id() !== $wp_site->userblog_id) { $wu_site = wu_get_site($wp_site->userblog_id); $wu_site->set_membership_id(0); $user_sites[ $wp_site->userblog_id ] = $wu_site; diff --git a/utils/rector/src/Rector/YodaConditionsRector.php b/utils/rector/src/Rector/YodaConditionsRector.php index d8406da..3c25425 100644 --- a/utils/rector/src/Rector/YodaConditionsRector.php +++ b/utils/rector/src/Rector/YodaConditionsRector.php @@ -34,7 +34,15 @@ final class YodaConditionsRector extends AbstractRector public function refactor(Node $node): ?Node { // Ensure the left operand is not a constant - if ($node->left instanceof Node\Expr\Variable && (! $node->right instanceof Node\Expr\Variable)) { + if (( + $node->left instanceof Node\Expr\Variable || + $node->left instanceof Node\Expr\PropertyFetch || + $node->left instanceof Node\Expr\ArrayDimFetch) && ( + $node->right instanceof Scalar || + $node->right instanceof ConstFetch || + $node->right instanceof Node\Expr\FuncCall || + $node->right instanceof Node\Expr\MethodCall + )) { // Swap the left and right operands $this->mirrorComments($node->right, $node->left); [$node->left, $node->right] = [$node->right, $node->left]; diff --git a/utils/rector/tests/Rector/YodaConditionsRector/Fixture/some_class.php.inc b/utils/rector/tests/Rector/YodaConditionsRector/Fixture/some_class.php.inc index e7956ba..8206f7e 100644 --- a/utils/rector/tests/Rector/YodaConditionsRector/Fixture/some_class.php.inc +++ b/utils/rector/tests/Rector/YodaConditionsRector/Fixture/some_class.php.inc @@ -2,6 +2,8 @@ namespace Rector\Tests\TypeDeclaration\Rector\YodaConditionsRector\Fixture; const A_CONST = 'x'; +$arr = array('x'=>1); +$obj = (object) $arr; $a = 'x'; if ($a === 'x') { $a = 'xx'; @@ -21,12 +23,20 @@ if (strlen($a) === 1) { if ($a === 0 || $a === rand()) { return $a; } +if ($obj->x === 1) { + echo $obj->x; +} +if ($arr['x'] === 1) { + echo $arr['x']; +} ?> ----- 1); +$obj = (object) $arr; $a = 'x'; if ('x' === $a) { $a = 'xx'; @@ -46,4 +56,10 @@ if (strlen($a) === 1) { if (0 === $a || rand() === $a) { return $a; } +if (1 === $obj->x) { + echo $obj->x; +} +if (1 === $arr['x']) { + echo $arr['x']; +} ?> diff --git a/views/admin-pages/fields/field-text-display.php b/views/admin-pages/fields/field-text-display.php index b52493b..5c22ae4 100644 --- a/views/admin-pages/fields/field-text-display.php +++ b/views/admin-pages/fields/field-text-display.php @@ -25,7 +25,7 @@ ?> - type === 'date' || $field->date === true) : ?> + type || true === $field->date) : ?> - type === 'date' || $field->date === true) : ?> + type || true === $field->date) : ?> value)) { - if ($field->display_value == false) { + if (false == $field->display_value) { echo __('No date', 'wp-ultimo'); } else { $date = $field->value; diff --git a/views/admin-pages/fields/field-text.php b/views/admin-pages/fields/field-text.php index fb9c8db..667147c 100644 --- a/views/admin-pages/fields/field-text.php +++ b/views/admin-pages/fields/field-text.php @@ -25,7 +25,7 @@ ?> - type === 'model') : ?> + type) : ?>
diff --git a/views/admin-pages/fields/field-toggle.php b/views/admin-pages/fields/field-toggle.php index ff3e440..c1ce0ff 100644 --- a/views/admin-pages/fields/field-toggle.php +++ b/views/admin-pages/fields/field-toggle.php @@ -37,7 +37,7 @@
- value == 1); ?> id="wu-tg-id); ?>" type="checkbox" name="" get_html_attributes(); ?> /> + value); ?> id="wu-tg-id); ?>" type="checkbox" name="" get_html_attributes(); ?> /> diff --git a/views/checkout/fields/field-products.php b/views/checkout/fields/field-products.php index 7601d0c..c65d6b1 100644 --- a/views/checkout/fields/field-products.php +++ b/views/checkout/fields/field-products.php @@ -27,7 +27,7 @@
- model !== 'product' && $object->get_limitations(false)->plugins->exists($plugin_path)) : ?> + model && $object->get_limitations(false)->plugins->exists($plugin_path)) : ?>

diff --git a/views/limitations/site-template-selector.php b/views/limitations/site-template-selector.php index 89ab309..94f8c04 100644 --- a/views/limitations/site-template-selector.php +++ b/views/limitations/site-template-selector.php @@ -61,9 +61,9 @@ name="modules[site_templates][limit][get_id()); ?>][behavior]" class="wu-w-full" > - - - + + +

diff --git a/views/limitations/theme-selector.php b/views/limitations/theme-selector.php index b409aeb..cb5ca4f 100644 --- a/views/limitations/theme-selector.php +++ b/views/limitations/theme-selector.php @@ -10,7 +10,7 @@ $theme_settings = $object->get_limitations()->themes->{$theme_path}; - if ($theme_settings->behavior === 'force_active') { + if ('force_active' === $theme_settings->behavior) { $section['state']['force_active_theme'] = $theme_path; } // end if; @@ -65,8 +65,8 @@

@@ -76,16 +76,16 @@

- model !== 'product' && $object->get_limitations(false)->themes->exists($theme_path)) : ?> + model && $object->get_limitations(false)->themes->exists($theme_path)) : ?>

diff --git a/views/system-info/system-info-table.php b/views/system-info/system-info-table.php index 9e21df6..5c6add3 100644 --- a/views/system-info/system-info-table.php +++ b/views/system-info/system-info-table.php @@ -33,11 +33,11 @@ $text_no = ''; - + - +