Make WordPress Core


Ignore:
Timestamp:
01/05/2026 05:51:15 AM (9 months ago)
Author:
westonruter
Message:

Code Modernization: Comments: 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 [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/comment.php

    r61387 r61434  
    22162216         * @param string $comment_agent The comment author's browser user agent.
    22172217         */
    2218         $commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' ) );
     2218        $commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( $commentdata['comment_agent'] ?? '' ) );
    22192219        /** This filter is documented in wp-includes/comment.php */
    22202220        $commentdata['comment_author'] = apply_filters( 'pre_comment_author_name', $commentdata['comment_author'] );
    … …  
    23342334
    23352335        if ( ! isset( $commentdata['comment_agent'] ) ) {
    2336                 $commentdata['comment_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
     2336                $commentdata['comment_agent'] = $_SERVER['HTTP_USER_AGENT'] ?? '';
    23372337        }
    23382338
    … …  
    26332633        $filter_comment = false;
    26342634        if ( ! has_filter( 'pre_comment_content', 'wp_filter_kses' ) ) {
    2635                 $filter_comment = ! user_can( isset( $comment['user_id'] ) ? $comment['user_id'] : 0, 'unfiltered_html' );
     2635                $filter_comment = ! user_can( $comment['user_id'] ?? 0, 'unfiltered_html' );
    26362636        }
    26372637
Note: See TracChangeset for help on using the changeset viewer.