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

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

View File

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

View File

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

View File

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