Make WordPress Core

Changeset 61433


Ignore:
Timestamp:
01/05/2026 05:39:38 AM (2 months ago)
Author:
westonruter
Message:

Code Modernization: Customize: 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 [61432], [61431], [61430], [61429], [61424], [61404], [61403].

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

Location:
trunk/src/wp-includes
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-nav-menus.php

    r60909 r61433  
    12521252                    <?php endif; ?>
    12531253                <?php endif; ?>
    1254                 <ul class="available-menu-items-list" data-type="<?php echo esc_attr( $available_item_type['type'] ); ?>" data-object="<?php echo esc_attr( $available_item_type['object'] ); ?>" data-type_label="<?php echo esc_attr( isset( $available_item_type['type_label'] ) ? $available_item_type['type_label'] : $available_item_type['type'] ); ?>"></ul>
     1254                <ul class="available-menu-items-list" data-type="<?php echo esc_attr( $available_item_type['type'] ); ?>" data-object="<?php echo esc_attr( $available_item_type['object'] ); ?>" data-type_label="<?php echo esc_attr( $available_item_type['type_label'] ?? $available_item_type['type'] ); ?>"></ul>
    12551255            </div>
    12561256        </div>
  • trunk/src/wp-includes/class-wp-customize-setting.php

    r61387 r61433  
    942942    final protected function multidimensional_get( $root, $keys, $default_value = null ) {
    943943        if ( empty( $keys ) ) { // If there are no keys, test the root.
    944             return isset( $root ) ? $root : $default_value;
     944            return $root ?? $default_value;
    945945        }
    946946
  • trunk/src/wp-includes/class-wp-customize-widgets.php

    r60909 r61433  
    925925                        <?php
    926926                        $panel       = $this->manager->get_panel( 'widgets' );
    927                         $panel_title = isset( $panel->title ) ? $panel->title : __( 'Widgets' );
     927                        $panel_title = $panel->title ?? __( 'Widgets' );
    928928                        /* translators: &#9656; is the unicode right-pointing triangle. %s: Section title in the Customizer. */
    929929                        printf( __( 'Customizing &#9656; %s' ), esc_html( $panel_title ) );
     
    11241124                $available_widget,
    11251125                array(
    1126                     'temp_id'      => isset( $args['_temp_id'] ) ? $args['_temp_id'] : null,
     1126                    'temp_id'      => $args['_temp_id'] ?? null,
    11271127                    'is_multi'     => $is_multi_widget,
    11281128                    'control_tpl'  => $control_tpl,
  • trunk/src/wp-includes/customize/class-wp-customize-header-image-setting.php

    r56193 r61433  
    4141            require_once ABSPATH . 'wp-admin/includes/class-custom-image-header.php';
    4242            $args                   = get_theme_support( 'custom-header' );
    43             $admin_head_callback    = isset( $args[0]['admin-head-callback'] ) ? $args[0]['admin-head-callback'] : null;
    44             $admin_preview_callback = isset( $args[0]['admin-preview-callback'] ) ? $args[0]['admin-preview-callback'] : null;
     43            $admin_head_callback    = $args[0]['admin-head-callback'] ?? null;
     44            $admin_preview_callback = $args[0]['admin-preview-callback'] ?? null;
    4545            $custom_image_header    = new Custom_Image_Header( $admin_head_callback, $admin_preview_callback );
    4646        }
  • trunk/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php

    r60815 r61433  
    253253        if ( is_array( $value ) ) {
    254254            $value_obj               = (object) $value;
    255             $value['type_label']     = isset( $type_label ) ? $type_label : $this->get_type_label( $value_obj );
     255            $value['type_label']     = $type_label ?? $this->get_type_label( $value_obj );
    256256            $value['original_title'] = $this->get_original_title( $value_obj );
    257257        }
Note: See TracChangeset for help on using the changeset viewer.