More yoda conditions

This commit is contained in:
David Stone
2025-02-09 12:30:02 -07:00
parent d9122a410d
commit 0a4c81c105
97 changed files with 323 additions and 289 deletions

View File

@ -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',
];
}

View File

@ -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),
]
);
}

View File

@ -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;
}

View File

@ -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();

View File

@ -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'),

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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();

View File

@ -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, '');

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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;
}