Everywhere yoda conditions are
This commit is contained in:
inc
admin-pages
class-base-admin-page.phpclass-base-customer-facing-admin-page.phpclass-broadcast-edit-admin-page.phpclass-broadcast-list-admin-page.phpclass-checkout-form-edit-admin-page.phpclass-discount-code-edit-admin-page.phpclass-domain-edit-admin-page.phpclass-edit-admin-page.phpclass-email-edit-admin-page.phpclass-event-view-admin-page.phpclass-list-admin-page.phpclass-membership-edit-admin-page.phpclass-payment-edit-admin-page.phpclass-product-edit-admin-page.phpclass-settings-admin-page.phpclass-setup-wizard-admin-page.phpclass-site-edit-admin-page.phpclass-site-list-admin-page.phpclass-system-info-admin-page.phpclass-view-logs-admin-page.phpclass-webhook-edit-admin-page.php
customer-panel
api
checkout
class-cart.phpclass-checkout-pages.phpclass-checkout.phpclass-legacy-checkout.phpclass-line-item.php
class-ajax.phpclass-api.phpclass-async-calls.phpclass-dashboard-widgets.phpclass-domain-mapping.phpclass-geolocation.phpclass-logger.phpclass-requirements.phpclass-session-cookie.phpclass-settings.phpclass-sunrise.phpclass-user-switching.phpsignup-fields
class-base-signup-field.phpclass-signup-field-checkbox.phpclass-signup-field-order-summary.phpclass-signup-field-period-selection.phpclass-signup-field-pricing-table.phpclass-signup-field-products.phpclass-signup-field-shortcode.phpclass-signup-field-site-url.phpclass-signup-field-steps.phpclass-signup-field-template-selection.php
field-templates
compat
country
database
checkout-forms
discount-codes
domains
engine
events
memberships
payments
posts
products
sites
webhooks
debug
deprecated
development
domain-mapping
duplication
functions
array-helpers.phpcheckout-form.phpcheckout.phpcustomer.phpdate.phpdiscount-code.phpdomain.phpevent.phpfs.phpgateway.phphelper.phplegacy.phpmarkup-helpers.phpmembership.phpmodel.phppages.phppayment.phpproduct.phprest.phpsettings.phpsite.phptax.php
gateways
class-base-gateway.phpclass-base-stripe-gateway.phpclass-free-gateway.phpclass-manual-gateway.phpclass-paypal-gateway.phpclass-stripe-checkout-gateway.phpclass-stripe-gateway.php
helpers
installers
integrations
host-providers
limitations
limits
list-tables
class-base-list-table.phpclass-broadcast-list-table.phpclass-checkout-form-list-table.phpclass-customer-list-table.phpclass-discount-code-list-table.phpclass-domain-list-table.phpclass-email-list-table.phpclass-event-list-table.phpclass-inside-events-list-table.phpclass-membership-list-table-widget.phpclass-membership-list-table.phpclass-payment-list-table-widget.phpclass-product-list-table.phpclass-site-list-table.phpclass-webhook-list-table.php
managers
class-broadcast-manager.phpclass-customer-manager.phpclass-domain-manager.phpclass-event-manager.phpclass-limitation-manager.phpclass-membership-manager.phpclass-notes-manager.phpclass-notification-manager.phpclass-site-manager.php
models
class-base-model.phpclass-checkout-form.phpclass-customer.phpclass-discount-code.phpclass-domain.phpclass-email.phpclass-event.phpclass-membership.phpclass-payment.phpclass-product.phpclass-site.php
traits
objects
site-templates
sso
tax
traits
trait-wp-ultimo-coupon-deprecated.phptrait-wp-ultimo-plan-deprecated.phptrait-wp-ultimo-settings-deprecated.php
ui
class-account-summary-element.phpclass-base-element.phpclass-billing-info-element.phpclass-checkout-element.phpclass-current-membership-element.phpclass-current-site-element.phpclass-domain-mapping-element.phpclass-field.phpclass-invoices-element.phpclass-jumper.phpclass-limits-element.phpclass-login-form-element.phpclass-my-sites-element.phpclass-payment-methods-element.phpclass-simple-text-element.phpclass-site-actions-element.phpclass-site-maintenance-element.phpclass-template-previewer.phpclass-template-switching-element.phpclass-thank-you-element.php
views
admin-pages
checkout
templates
order-bump
order-summary
period-selection
pricing-table
dashboard-statistics
dashboard-widgets
legacy
signup
settings
fields
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -195,7 +195,7 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
</div>";
|
||||
|
||||
break;
|
||||
case $targets_count === 1:
|
||||
case 1 === $targets_count:
|
||||
$customer = wu_get_customer($targets[0]);
|
||||
|
||||
$url_atts = [
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -623,6 +623,7 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
return $this->object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Discount_Codes have titles.
|
||||
*
|
||||
|
@@ -511,6 +511,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
return $this->object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Domains have titles.
|
||||
*
|
||||
|
@@ -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',
|
||||
|
@@ -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');
|
||||
|
||||
|
@@ -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.
|
||||
*
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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.
|
||||
*
|
||||
|
@@ -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.
|
||||
*
|
||||
|
@@ -1050,6 +1050,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
return $this->object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Products have titles.
|
||||
*
|
||||
|
@@ -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'] = [];
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -738,6 +738,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
return $this->object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sites have titles.
|
||||
*
|
||||
|
@@ -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 {
|
||||
|
@@ -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 = '#(?<browser>' . join('|', $known) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
|
||||
$pattern = '#(?<browser>' . implode('|', $known) . ')[/ ]+(?<version>[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
|
||||
*/
|
||||
|
@@ -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) {
|
||||
|
@@ -367,6 +367,7 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
return new Webhook();
|
||||
}
|
||||
|
||||
/**
|
||||
* Webhooks have titles.
|
||||
*
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user