Make WordPress Core

Changeset 61436


Ignore:
Timestamp:
01/05/2026 06:02:34 AM (7 days ago)
Author:
westonruter
Message:

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

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

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

Legend:

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

    r61273 r61436  
    26432643        $tag               = strtolower( $tag_name );
    26442644        $is_single_tag     = in_array( $tag, $single_tags, true );
    2645         $pre_attribute_ws  = isset( $regex[4] ) ? $regex[4] : '';
    2646         $attributes        = trim( isset( $regex[5] ) ? $regex[5] : $regex[3] );
     2645        $pre_attribute_ws  = $regex[4] ?? '';
     2646        $attributes        = trim( $regex[5] ?? $regex[3] );
    26472647        $has_self_closer   = str_ends_with( $attributes, '/' );
    26482648
     
    52845284            if ( preg_match( '/^%(\d+)\$/', $fragment, $matches ) ) {
    52855285                $index    = $matches[1] - 1; // 0-based array vs 1-based sprintf() arguments.
    5286                 $arg      = isset( $args[ $index ] ) ? $args[ $index ] : '';
     5286                $arg      = $args[ $index ] ?? '';
    52875287                $fragment = str_replace( "%{$matches[1]}$", '%', $fragment );
    52885288            } else {
    5289                 $arg = isset( $args[ $arg_index ] ) ? $args[ $arg_index ] : '';
     5289                $arg = $args[ $arg_index ] ?? '';
    52905290                ++$arg_index;
    52915291            }
  • trunk/src/wp-includes/kses.php

    r61051 r61436  
    30343034    $upload_info = wp_upload_dir( null, false );
    30353035    $parsed_url  = wp_parse_url( $upload_info['url'] );
    3036     $upload_host = isset( $parsed_url['host'] ) ? $parsed_url['host'] : '';
     3036    $upload_host = $parsed_url['host'] ?? '';
    30373037    $upload_port = isset( $parsed_url['port'] ) ? ':' . $parsed_url['port'] : '';
    30383038
  • trunk/src/wp-includes/shortcodes.php

    r61139 r61436  
    430430    }
    431431
    432     $content = isset( $m[5] ) ? $m[5] : null;
     432    $content = $m[5] ?? null;
    433433
    434434    $output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];
Note: See TracChangeset for help on using the changeset viewer.