Commit de5f29a04a for wordpress.org
commit de5f29a04a8dfd97a4b9b30b177c5d82445aa387
Author: Weston Ruter <weston@xwp.co>
Date: Mon Jan 5 06:04:33 2026 +0000
Code Modernization: Formatting: 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 [61435], [61434], [61403], [61433], [61432], [61431], [61430], [61429], [61424], [61404], [61403].
Props costdev, westonruter.
See #58874, #63430.
Built from https://develop.svn.wordpress.org/trunk@61436
git-svn-id: http://core.svn.wordpress.org/trunk@60748 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php
index bd2d349fa2..f59f877775 100644
--- a/wp-includes/formatting.php
+++ b/wp-includes/formatting.php
@@ -2642,8 +2642,8 @@ function force_balance_tags( $text ) {
$tag_name = $regex[2];
$tag = strtolower( $tag_name );
$is_single_tag = in_array( $tag, $single_tags, true );
- $pre_attribute_ws = isset( $regex[4] ) ? $regex[4] : '';
- $attributes = trim( isset( $regex[5] ) ? $regex[5] : $regex[3] );
+ $pre_attribute_ws = $regex[4] ?? '';
+ $attributes = trim( $regex[5] ?? $regex[3] );
$has_self_closer = str_ends_with( $attributes, '/' );
$newtext .= $tagqueue;
@@ -5283,10 +5283,10 @@ function wp_sprintf( $pattern, ...$args ) {
// Find numbered arguments or take the next one in order.
if ( preg_match( '/^%(\d+)\$/', $fragment, $matches ) ) {
$index = $matches[1] - 1; // 0-based array vs 1-based sprintf() arguments.
- $arg = isset( $args[ $index ] ) ? $args[ $index ] : '';
+ $arg = $args[ $index ] ?? '';
$fragment = str_replace( "%{$matches[1]}$", '%', $fragment );
} else {
- $arg = isset( $args[ $arg_index ] ) ? $args[ $arg_index ] : '';
+ $arg = $args[ $arg_index ] ?? '';
++$arg_index;
}
diff --git a/wp-includes/kses.php b/wp-includes/kses.php
index 35327e1a01..1d77491c29 100644
--- a/wp-includes/kses.php
+++ b/wp-includes/kses.php
@@ -3033,7 +3033,7 @@ function _wp_kses_allow_pdf_objects( $url ) {
// If the URL host matches the current site's media URL, it's safe.
$upload_info = wp_upload_dir( null, false );
$parsed_url = wp_parse_url( $upload_info['url'] );
- $upload_host = isset( $parsed_url['host'] ) ? $parsed_url['host'] : '';
+ $upload_host = $parsed_url['host'] ?? '';
$upload_port = isset( $parsed_url['port'] ) ? ':' . $parsed_url['port'] : '';
if ( str_starts_with( $url, "http://$upload_host$upload_port/" )
diff --git a/wp-includes/shortcodes.php b/wp-includes/shortcodes.php
index 24c60b0021..01fed7244e 100644
--- a/wp-includes/shortcodes.php
+++ b/wp-includes/shortcodes.php
@@ -429,7 +429,7 @@ function do_shortcode_tag( $m ) {
return $return;
}
- $content = isset( $m[5] ) ? $m[5] : null;
+ $content = $m[5] ?? null;
$output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 8e17ec5911..eaec89ab64 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.0-alpha-61435';
+$wp_version = '7.0-alpha-61436';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.