Make WordPress Core


Ignore:
Timestamp:
01/09/2026 02:24:18 AM (10 months ago)
Author:
westonruter
Message:

Code Modernization: Media: 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 [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-admin/includes/media.php

    r61440 r61453  
    833833        if ( isset( $send_id ) ) {
    834834                $attachment = wp_unslash( $_POST['attachments'][ $send_id ] );
    835                 $html       = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
     835                $html       = $attachment['post_title'] ?? '';
    836836
    837837                if ( ! empty( $attachment['url'] ) ) {
    … …  
    15591559                }
    15601560
    1561                 $item = get_media_item( $id, array( 'errors' => isset( $errors[ $id ] ) ? $errors[ $id ] : null ) );
     1561                $item = get_media_item( $id, array( 'errors' => $errors[ $id ] ?? null ) );
    15621562
    15631563                if ( $item ) {
    … …  
    21042104        $upload_action_url = admin_url( 'async-upload.php' );
    21052105        $post_id           = isset( $_REQUEST['post_id'] ) ? (int) $_REQUEST['post_id'] : 0;
    2106         $_type             = isset( $type ) ? $type : '';
    2107         $_tab              = isset( $tab ) ? $tab : '';
     2106        $_type             = $type ?? '';
     2107        $_tab              = $tab ?? '';
    21082108
    21092109        $max_upload_size = wp_max_upload_size();
    … …  
    36573657        wp_add_id3_tag_data( $metadata, $data );
    36583658
    3659         $file_format = isset( $metadata['fileformat'] ) ? $metadata['fileformat'] : null;
     3659        $file_format = $metadata['fileformat'] ?? null;
    36603660
    36613661        /**
    … …  
    37403740        wp_add_id3_tag_data( $metadata, $data );
    37413741
    3742         $file_format = isset( $metadata['fileformat'] ) ? $metadata['fileformat'] : null;
     3742        $file_format = $metadata['fileformat'] ?? null;
    37433743
    37443744        /**
Note: See TracChangeset for help on using the changeset viewer.