Make WordPress Core


Ignore:
Timestamp:
01/05/2026 05:32:00 AM (3 months ago)
Author:
westonruter
Message:

Code Modernization: Widgets: Use null coalescing operator instead of isset() ternaries.

Developed as a subset of https://github.com/WordPress/wordpress-develop/pull/10654
Initially developed in https://github.com/WordPress/wordpress-develop/pull/4886

Follow-up to [61431], [61430], [61429], [61424], [61404], [61403].

Props costdev, westonruter.
See #58874, #63430.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/widgets.php

    r60732 r61432  
    191191            }
    192192        } else {
    193             $_args['name'] = isset( $args['name'] ) ? $args['name'] : __( 'Sidebar' );
     193            $_args['name'] = $args['name'] ?? __( 'Sidebar' );
    194194        }
    195195
     
    14961496    // Sidebars_widgets settings from when this theme was previously active.
    14971497    $old_sidebars_widgets = get_theme_mod( 'sidebars_widgets' );
    1498     $old_sidebars_widgets = isset( $old_sidebars_widgets['data'] ) ? $old_sidebars_widgets['data'] : false;
     1498    $old_sidebars_widgets = $old_sidebars_widgets['data'] ?? false;
    14991499
    15001500    if ( is_array( $old_sidebars_widgets ) ) {
     
    17191719    $inputs         = wp_parse_args( $inputs, $default_inputs );
    17201720
    1721     $args['title'] = isset( $args['title'] ) ? $args['title'] : '';
    1722     $args['url']   = isset( $args['url'] ) ? $args['url'] : '';
     1721    $args['title'] = $args['title'] ?? '';
     1722    $args['url']   = $args['url'] ?? '';
    17231723    $args['items'] = isset( $args['items'] ) ? (int) $args['items'] : 0;
    17241724
Note: See TracChangeset for help on using the changeset viewer.