More yoda conditions
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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';
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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'];
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user