Make WordPress Core


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

Code Modernization: Taxonomy, Posts/Post Types, Options/Meta APIs, Query, General: 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 [61444], [61443], [61442], [61436], [61435], [61434], [61403], [61433], [61432], [61431], [61430], [61429], [61424], [61404], [61403].

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

File:
1 edited

Legend:

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

    r61411 r61445  
    953953            if ( $headers ) {
    954954                $len           = isset( $headers['Content-Length'] ) ? (int) $headers['Content-Length'] : 0;
    955                 $type          = isset( $headers['Content-Type'] ) ? $headers['Content-Type'] : '';
     955                $type          = $headers['Content-Type'] ?? '';
    956956                $allowed_types = array( 'video', 'audio' );
    957957
     
    36913691        );
    36923692
    3693         $redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
     3693        $redirect_to = $_REQUEST['redirect_to'] ?? '';
    36943694
    36953695        $html  = $title;
     
    61406140 */
    61416141function is_lighttpd_before_150() {
    6142     $server_parts    = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '' );
    6143     $server_parts[1] = isset( $server_parts[1] ) ? $server_parts[1] : '';
     6142    $server_parts    = explode( '/', $_SERVER['SERVER_SOFTWARE'] ?? '' );
     6143    $server_parts[1] = $server_parts[1] ?? '';
    61446144
    61456145    return ( 'lighttpd' === $server_parts[0] && -1 === version_compare( $server_parts[1], '1.5.0' ) );
     
    71227122        $tortoise
    71237123    &&
    7124         ( $evanescent_hare = isset( $override[ $hare ] ) ? $override[ $hare ] : call_user_func_array( $callback, array_merge( array( $hare ), $callback_args ) ) )
     7124        ( $evanescent_hare = $override[ $hare ] ?? call_user_func_array( $callback, array_merge( array( $hare ), $callback_args ) ) )
    71257125    &&
    7126         ( $hare = isset( $override[ $evanescent_hare ] ) ? $override[ $evanescent_hare ] : call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) )
     7126        ( $hare = $override[ $evanescent_hare ] ?? call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) )
    71277127    ) {
    71287128        if ( $_return_loop ) {
     
    71387138
    71397139        // Increment tortoise by one step.
    7140         $tortoise = isset( $override[ $tortoise ] ) ? $override[ $tortoise ] : call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) );
     7140        $tortoise = $override[ $tortoise ] ?? call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) );
    71417141    }
    71427142
     
    72677267                $caller[] = "{$call['function']}('{$call['args'][0]}')";
    72687268            } elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ), true ) ) {
    7269                 $filename = isset( $call['args'][0] ) ? $call['args'][0] : '';
     7269                $filename = $call['args'][0] ?? '';
    72707270                $caller[] = $call['function'] . "('" . str_replace( $truncate_paths, '', wp_normalize_path( $filename ) ) . "')";
    72717271            } else {
Note: See TracChangeset for help on using the changeset viewer.