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/post.php

    r61387 r61445  
    22022202
    22032203    if ( ! isset( $data_object->labels['name_admin_bar'] ) ) {
    2204         $data_object->labels['name_admin_bar'] =
    2205             isset( $data_object->labels['singular_name'] )
    2206             ? $data_object->labels['singular_name']
    2207             : $data_object->name;
     2204        $data_object->labels['name_admin_bar'] = $data_object->labels['singular_name'] ?? $data_object->name;
    22082205    }
    22092206
     
    28572854    $custom = get_post_custom( $post_id );
    28582855
    2859     return isset( $custom[ $key ] ) ? $custom[ $key ] : null;
     2856    return $custom[ $key ] ?? null;
    28602857}
    28612858
     
    47314728    // These variables are needed by compact() later.
    47324729    $post_content_filtered = $postarr['post_content_filtered'];
    4733     $post_author           = isset( $postarr['post_author'] ) ? $postarr['post_author'] : $user_id;
     4730    $post_author           = $postarr['post_author'] ?? $user_id;
    47344731    $ping_status           = empty( $postarr['ping_status'] ) ? get_default_comment_status( $post_type, 'pingback' ) : $postarr['ping_status'];
    47354732    $to_ping               = isset( $postarr['to_ping'] ) ? sanitize_trackback_urls( $postarr['to_ping'] ) : '';
    4736     $pinged                = isset( $postarr['pinged'] ) ? $postarr['pinged'] : '';
    4737     $import_id             = isset( $postarr['import_id'] ) ? $postarr['import_id'] : 0;
     4733    $pinged                = $postarr['pinged'] ?? '';
     4734    $import_id             = $postarr['import_id'] ?? 0;
    47384735
    47394736    /*
     
    47474744    }
    47484745
    4749     $post_password = isset( $postarr['post_password'] ) ? $postarr['post_password'] : '';
     4746    $post_password = $postarr['post_password'] ?? '';
    47504747    if ( 'private' === $post_status ) {
    47514748        $post_password = '';
     
    48164813
    48174814    // Don't unslash.
    4818     $post_mime_type = isset( $postarr['post_mime_type'] ) ? $postarr['post_mime_type'] : '';
     4815    $post_mime_type = $postarr['post_mime_type'] ?? '';
    48194816
    48204817    // Expected_slashed (everything!).
Note: See TracChangeset for help on using the changeset viewer.