Make WordPress Core


Ignore:
Timestamp:
01/06/2026 06:05:20 AM (4 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/class-wp.php

    r61111 r61445  
    168168            $this->did_permalink = true;
    169169
    170             $pathinfo         = isset( $_SERVER['PATH_INFO'] ) ? $_SERVER['PATH_INFO'] : '';
     170            $pathinfo         = $_SERVER['PATH_INFO'] ?? '';
    171171            list( $pathinfo ) = explode( '?', $pathinfo );
    172172            $pathinfo         = str_replace( '%', '%25', $pathinfo );
     
    540540
    541541        if ( is_singular() ) {
    542             $post = isset( $wp_query->post ) ? $wp_query->post : null;
     542            $post = $wp_query->post ?? null;
    543543
    544544            // Only set X-Pingback for single posts that allow pings.
     
    670670        $GLOBALS['query_string'] = $this->query_string;
    671671        $GLOBALS['posts']        = & $wp_query->posts;
    672         $GLOBALS['post']         = isset( $wp_query->post ) ? $wp_query->post : null;
     672        $GLOBALS['post']         = $wp_query->post ?? null;
    673673        $GLOBALS['request']      = $wp_query->request;
    674674
     
    756756
    757757            if ( is_singular() ) {
    758                 $post = isset( $wp_query->post ) ? $wp_query->post : null;
     758                $post = $wp_query->post ?? null;
    759759                $next = '<!--nextpage-->';
    760760
Note: See TracChangeset for help on using the changeset viewer.