Commit c14a2c926d for wordpress.org
commit c14a2c926db6094c5f56107f3da933b778b1680c
Author: Weston Ruter <weston@xwp.co>
Date: Mon Jan 5 05:53:29 2026 +0000
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.
Built from https://develop.svn.wordpress.org/trunk@61434
git-svn-id: http://core.svn.wordpress.org/trunk@60746 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php
index 8a004b5226..29ec964924 100644
--- a/wp-admin/edit-comments.php
+++ b/wp-admin/edit-comments.php
@@ -337,7 +337,7 @@ if ( isset( $_REQUEST['approved'] )
}
if ( $spammed > 0 ) {
- $ids = isset( $_REQUEST['ids'] ) ? $_REQUEST['ids'] : 0;
+ $ids = $_REQUEST['ids'] ?? 0;
$messages[] = sprintf(
/* translators: %s: Number of comments. */
@@ -359,7 +359,7 @@ if ( isset( $_REQUEST['approved'] )
}
if ( $trashed > 0 ) {
- $ids = isset( $_REQUEST['ids'] ) ? $_REQUEST['ids'] : 0;
+ $ids = $_REQUEST['ids'] ?? 0;
$messages[] = sprintf(
/* translators: %s: Number of comments. */
diff --git a/wp-admin/includes/class-wp-comments-list-table.php b/wp-admin/includes/class-wp-comments-list-table.php
index 29343f78a0..d51c9655e9 100644
--- a/wp-admin/includes/class-wp-comments-list-table.php
+++ b/wp-admin/includes/class-wp-comments-list-table.php
@@ -49,7 +49,7 @@ class WP_Comments_List_Table extends WP_List_Table {
'plural' => 'comments',
'singular' => 'comment',
'ajax' => true,
- 'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
+ 'screen' => $args['screen'] ?? null,
)
);
}
@@ -93,7 +93,7 @@ class WP_Comments_List_Table extends WP_List_Table {
$mode = get_user_setting( 'posts_list_mode', 'list' );
}
- $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
+ $comment_status = $_REQUEST['comment_status'] ?? 'all';
if ( ! in_array( $comment_status, array( 'all', 'mine', 'moderated', 'approved', 'spam', 'trash' ), true ) ) {
$comment_status = 'all';
@@ -144,7 +144,7 @@ class WP_Comments_List_Table extends WP_List_Table {
);
$args = array(
- 'status' => isset( $status_map[ $comment_status ] ) ? $status_map[ $comment_status ] : $comment_status,
+ 'status' => $status_map[ $comment_status ] ?? $comment_status,
'search' => $search,
'user_id' => $user_id,
'offset' => $start,
diff --git a/wp-includes/comment.php b/wp-includes/comment.php
index 03fed10fa2..70d78ed33c 100644
--- a/wp-includes/comment.php
+++ b/wp-includes/comment.php
@@ -2215,7 +2215,7 @@ function wp_filter_comment( $commentdata ) {
*
* @param string $comment_agent The comment author's browser user agent.
*/
- $commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' ) );
+ $commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( $commentdata['comment_agent'] ?? '' ) );
/** This filter is documented in wp-includes/comment.php */
$commentdata['comment_author'] = apply_filters( 'pre_comment_author_name', $commentdata['comment_author'] );
/**
@@ -2333,7 +2333,7 @@ function wp_new_comment( $commentdata, $wp_error = false ) {
}
if ( ! isset( $commentdata['comment_agent'] ) ) {
- $commentdata['comment_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
+ $commentdata['comment_agent'] = $_SERVER['HTTP_USER_AGENT'] ?? '';
}
/**
@@ -2632,7 +2632,7 @@ function wp_update_comment( $commentarr, $wp_error = false ) {
$filter_comment = false;
if ( ! has_filter( 'pre_comment_content', 'wp_filter_kses' ) ) {
- $filter_comment = ! user_can( isset( $comment['user_id'] ) ? $comment['user_id'] : 0, 'unfiltered_html' );
+ $filter_comment = ! user_can( $comment['user_id'] ?? 0, 'unfiltered_html' );
}
if ( $filter_comment ) {
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 58e69d8b81..3555e4be20 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.0-alpha-61433';
+$wp_version = '7.0-alpha-61434';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.