Make WordPress Core


Ignore:
Timestamp:
01/09/2026 02:38:07 AM (9 months ago)
Author:
westonruter
Message:

Code Modernization: Menus, Template, XML-RPC: 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 [61453], [61445], [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/author-template.php

    r61057 r61454  
    170170        if ( ! $user_id ) {
    171171                global $authordata;
    172                 $user_id = isset( $authordata->ID ) ? $authordata->ID : 0;
     172                $user_id = $authordata->ID ?? 0;
    173173        } else {
    174174                $authordata = get_userdata( $user_id );
    … …  
    179179        }
    180180
    181         $value = isset( $authordata->$field ) ? $authordata->$field : '';
     181        $value = $authordata->$field ?? '';
    182182
    183183        /**
    … …  
    503503
    504504        foreach ( $authors as $author_id ) {
    505                 $posts = isset( $post_counts[ $author_id ] ) ? $post_counts[ $author_id ] : 0;
     505                $posts = $post_counts[ $author_id ] ?? 0;
    506506
    507507                if ( ! $posts && $parsed_args['hide_empty'] ) {
Note: See TracChangeset for help on using the changeset viewer.