Commit 38c632d25d for wordpress.org

commit 38c632d25d28085bd4ad071afc076aa781fae814
Author: Weston Ruter <weston@xwp.co>
Date:   Fri Jan 9 02:26:54 2026 +0000

    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.

    Built from https://develop.svn.wordpress.org/trunk@61453


    git-svn-id: http://core.svn.wordpress.org/trunk@60765 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-admin/includes/class-custom-image-header.php b/wp-admin/includes/class-custom-image-header.php
index d6a5e823c8..f95f9bc95d 100644
--- a/wp-admin/includes/class-custom-image-header.php
+++ b/wp-admin/includes/class-custom-image-header.php
@@ -1351,7 +1351,7 @@ endif;
 	 * @return int Attachment ID.
 	 */
 	final public function insert_attachment( $attachment, $cropped ) {
-		$parent_id = isset( $attachment['post_parent'] ) ? $attachment['post_parent'] : null;
+		$parent_id = $attachment['post_parent'] ?? null;
 		unset( $attachment['post_parent'] );

 		$attachment_id = wp_insert_attachment( $attachment, $cropped );
@@ -1584,8 +1584,8 @@ endif;

 		foreach ( $header_images as &$header_image ) {
 			$header_meta               = get_post_meta( $header_image['attachment_id'] );
-			$header_image['timestamp'] = isset( $header_meta[ $timestamp_key ] ) ? $header_meta[ $timestamp_key ] : '';
-			$header_image['alt_text']  = isset( $header_meta[ $alt_text_key ] ) ? $header_meta[ $alt_text_key ] : '';
+			$header_image['timestamp'] = $header_meta[ $timestamp_key ] ?? '';
+			$header_image['alt_text']  = $header_meta[ $alt_text_key ] ?? '';
 		}

 		return $header_images;
diff --git a/wp-admin/includes/class-wp-media-list-table.php b/wp-admin/includes/class-wp-media-list-table.php
index 197fd96a9c..2604c394be 100644
--- a/wp-admin/includes/class-wp-media-list-table.php
+++ b/wp-admin/includes/class-wp-media-list-table.php
@@ -47,7 +47,7 @@ class WP_Media_List_Table extends WP_List_Table {
 		parent::__construct(
 			array(
 				'plural' => 'media',
-				'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
+				'screen' => $args['screen'] ?? null,
 			)
 		);
 	}
diff --git a/wp-admin/includes/image-edit.php b/wp-admin/includes/image-edit.php
index e582628225..c933c2b7d2 100644
--- a/wp-admin/includes/image-edit.php
+++ b/wp-admin/includes/image-edit.php
@@ -109,8 +109,8 @@ function wp_image_editor( $post_id, $msg = false ) {
 			<input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" />
 			<input type="hidden" id="imgedit-undone-<?php echo $post_id; ?>" value="0" />
 			<input type="hidden" id="imgedit-selection-<?php echo $post_id; ?>" value="" />
-			<input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" />
-			<input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />
+			<input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo $meta['width'] ?? 0; ?>" />
+			<input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo $meta['height'] ?? 0; ?>" />

 			<div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap">
 			<div class="imgedit-crop-grid"></div>
@@ -154,10 +154,10 @@ function wp_image_editor( $post_id, $msg = false ) {
 							_e( 'scale height' );
 							?>
 							</label>
-							<input type="number" step="1" min="0" max="<?php echo isset( $meta['width'] ) ? $meta['width'] : ''; ?>" aria-describedby="imgedit-scale-warn-<?php echo $post_id; ?>"  id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" />
+							<input type="number" step="1" min="0" max="<?php echo $meta['width'] ?? ''; ?>" aria-describedby="imgedit-scale-warn-<?php echo $post_id; ?>"  id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" value="<?php echo $meta['width'] ?? 0; ?>" />
 							<span class="imgedit-separator" aria-hidden="true">&times;</span>
 							<label for="imgedit-scale-height-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'scale height' ); ?></label>
-							<input type="number" step="1" min="0" max="<?php echo isset( $meta['height'] ) ? $meta['height'] : ''; ?>" aria-describedby="imgedit-scale-warn-<?php echo $post_id; ?>" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />
+							<input type="number" step="1" min="0" max="<?php echo $meta['height'] ?? ''; ?>" aria-describedby="imgedit-scale-warn-<?php echo $post_id; ?>" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" value="<?php echo $meta['height'] ?? 0; ?>" />
 							<button id="imgedit-scale-button" type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button button-primary"><?php esc_html_e( 'Scale' ); ?></button>
 							</div>
 							<span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>"><span class="dashicons dashicons-warning" aria-hidden="true"></span><?php esc_html_e( 'Images cannot be scaled to a size larger than the original.' ); ?></span>
@@ -744,10 +744,10 @@ function image_edit_apply_changes( $image, $changes ) {
 					$w    = $size['width'];
 					$h    = $size['height'];

-					$scale = isset( $sel->r ) ? $sel->r : 1 / _image_get_preview_ratio( $w, $h ); // Discard preview scaling.
+					$scale = $sel->r ?? 1 / _image_get_preview_ratio( $w, $h ); // Discard preview scaling.
 					$image->crop( (int) ( $sel->x * $scale ), (int) ( $sel->y * $scale ), (int) ( $sel->w * $scale ), (int) ( $sel->h * $scale ) );
 				} else {
-					$scale = isset( $sel->r ) ? $sel->r : 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // Discard preview scaling.
+					$scale = $sel->r ?? 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // Discard preview scaling.
 					$image = _crop_image_resource( $image, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale );
 				}
 				break;
diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php
index 375c9c812d..f05b80e121 100644
--- a/wp-admin/includes/media.php
+++ b/wp-admin/includes/media.php
@@ -832,7 +832,7 @@ function media_upload_form_handler() {

 	if ( isset( $send_id ) ) {
 		$attachment = wp_unslash( $_POST['attachments'][ $send_id ] );
-		$html       = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
+		$html       = $attachment['post_title'] ?? '';

 		if ( ! empty( $attachment['url'] ) ) {
 			$rel = '';
@@ -1558,7 +1558,7 @@ function get_media_items( $post_id, $errors ) {
 			continue;
 		}

-		$item = get_media_item( $id, array( 'errors' => isset( $errors[ $id ] ) ? $errors[ $id ] : null ) );
+		$item = get_media_item( $id, array( 'errors' => $errors[ $id ] ?? null ) );

 		if ( $item ) {
 			$output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress hidden'><div class='bar'></div></div><div id='media-upload-error-$id' class='hidden'></div><div class='filename hidden'></div>$item\n</div>";
@@ -2103,8 +2103,8 @@ function media_upload_form( $errors = null ) {

 	$upload_action_url = admin_url( 'async-upload.php' );
 	$post_id           = isset( $_REQUEST['post_id'] ) ? (int) $_REQUEST['post_id'] : 0;
-	$_type             = isset( $type ) ? $type : '';
-	$_tab              = isset( $tab ) ? $tab : '';
+	$_type             = $type ?? '';
+	$_tab              = $tab ?? '';

 	$max_upload_size = wp_max_upload_size();
 	if ( ! $max_upload_size ) {
@@ -3656,7 +3656,7 @@ function wp_read_video_metadata( $file ) {

 	wp_add_id3_tag_data( $metadata, $data );

-	$file_format = isset( $metadata['fileformat'] ) ? $metadata['fileformat'] : null;
+	$file_format = $metadata['fileformat'] ?? null;

 	/**
 	 * Filters the array of metadata retrieved from a video.
@@ -3739,7 +3739,7 @@ function wp_read_audio_metadata( $file ) {

 	wp_add_id3_tag_data( $metadata, $data );

-	$file_format = isset( $metadata['fileformat'] ) ? $metadata['fileformat'] : null;
+	$file_format = $metadata['fileformat'] ?? null;

 	/**
 	 * Filters the array of metadata retrieved from an audio file.
diff --git a/wp-admin/upload.php b/wp-admin/upload.php
index 7043dc279c..1f42a287e4 100644
--- a/wp-admin/upload.php
+++ b/wp-admin/upload.php
@@ -87,7 +87,7 @@ if ( ! empty( $_GET['trashed'] ) && absint( $_GET['trashed'] ) ) {

 	$message .= sprintf(
 		' <a href="%1$s">%2$s</a>',
-		esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( isset( $_GET['ids'] ) ? $_GET['ids'] : '' ), 'bulk-media' ) ),
+		esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( $_GET['ids'] ?? '' ), 'bulk-media' ) ),
 		__( 'Undo' )
 	);

@@ -117,7 +117,7 @@ $messages[2] = __( 'Media file permanently deleted.' );
 $messages[3] = __( 'Error saving media file.' );
 $messages[4] = __( 'Media file moved to the Trash.' ) . sprintf(
 	' <a href="%1$s">%2$s</a>',
-	esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( isset( $_GET['ids'] ) ? $_GET['ids'] : '' ), 'bulk-media' ) ),
+	esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( $_GET['ids'] ?? '' ), 'bulk-media' ) ),
 	__( 'Undo' )
 );
 $messages[5] = __( 'Media file restored from the Trash.' );
diff --git a/wp-includes/css/dist/index.php b/wp-includes/css/dist/index.php
index 5dd8765436..77d1f53a44 100644
--- a/wp-includes/css/dist/index.php
+++ b/wp-includes/css/dist/index.php
@@ -7,6 +7,11 @@
  */

 return array(
+	array(
+		'handle' => 'wp-preferences',
+		'path' => 'preferences/style',
+		'dependencies' => array('wp-components'),
+	),
 	array(
 		'handle' => 'wp-list-reusable-blocks',
 		'path' => 'list-reusable-blocks/style',
@@ -17,11 +22,6 @@ return array(
 		'path' => 'nux/style',
 		'dependencies' => array('wp-components'),
 	),
-	array(
-		'handle' => 'wp-preferences',
-		'path' => 'preferences/style',
-		'dependencies' => array('wp-components'),
-	),
 	array(
 		'handle' => 'wp-commands',
 		'path' => 'commands/style',
@@ -32,11 +32,6 @@ return array(
 		'path' => 'reusable-blocks/style',
 		'dependencies' => array('wp-block-editor', 'wp-components'),
 	),
-	array(
-		'handle' => 'wp-widgets',
-		'path' => 'widgets/style',
-		'dependencies' => array('wp-block-editor', 'wp-components'),
-	),
 	array(
 		'handle' => 'wp-patterns',
 		'path' => 'patterns/style',
@@ -47,6 +42,11 @@ return array(
 		'path' => 'components/style',
 		'dependencies' => array(),
 	),
+	array(
+		'handle' => 'wp-widgets',
+		'path' => 'widgets/style',
+		'dependencies' => array('wp-block-editor', 'wp-components'),
+	),
 	array(
 		'handle' => 'wp-format-library',
 		'path' => 'format-library/style',
@@ -67,16 +67,16 @@ return array(
 		'path' => 'customize-widgets/style',
 		'dependencies' => array('wp-block-editor', 'wp-block-library', 'wp-components', 'wp-media-utils', 'wp-preferences', 'wp-widgets'),
 	),
-	array(
-		'handle' => 'wp-edit-widgets',
-		'path' => 'edit-widgets/style',
-		'dependencies' => array('wp-block-editor', 'wp-block-library', 'wp-components', 'wp-media-utils', 'wp-patterns', 'wp-preferences', 'wp-widgets'),
-	),
 	array(
 		'handle' => 'wp-edit-post',
 		'path' => 'edit-post/style',
 		'dependencies' => array('wp-block-editor', 'wp-block-library', 'wp-commands', 'wp-components', 'wp-editor', 'wp-preferences', 'wp-widgets'),
 	),
+	array(
+		'handle' => 'wp-edit-widgets',
+		'path' => 'edit-widgets/style',
+		'dependencies' => array('wp-block-editor', 'wp-block-library', 'wp-components', 'wp-media-utils', 'wp-patterns', 'wp-preferences', 'wp-widgets'),
+	),
 	array(
 		'handle' => 'wp-block-library',
 		'path' => 'block-library/style',
diff --git a/wp-includes/embed.php b/wp-includes/embed.php
index b7567024aa..c90d044a81 100644
--- a/wp-includes/embed.php
+++ b/wp-includes/embed.php
@@ -693,7 +693,7 @@ function get_oembed_response_data_for_url( $url, $args ) {
 		return false;
 	}

-	$width = isset( $args['width'] ) ? $args['width'] : 0;
+	$width = $args['width'] ?? 0;

 	$data = get_oembed_response_data( $post_id, $width );

diff --git a/wp-includes/js/dist/script-modules/index.php b/wp-includes/js/dist/script-modules/index.php
index eec05b8052..5092400493 100644
--- a/wp-includes/js/dist/script-modules/index.php
+++ b/wp-includes/js/dist/script-modules/index.php
@@ -12,6 +12,16 @@ return array(
 		'path' => 'interactivity/index',
 		'asset' => 'interactivity/index.min.asset.php',
 	),
+	array(
+		'id' => '@wordpress/a11y',
+		'path' => 'a11y/index',
+		'asset' => 'a11y/index.min.asset.php',
+	),
+	array(
+		'id' => '@wordpress/core-abilities',
+		'path' => 'core-abilities/index',
+		'asset' => 'core-abilities/index.min.asset.php',
+	),
 	array(
 		'id' => '@wordpress/interactivity-router',
 		'path' => 'interactivity-router/index',
@@ -22,6 +32,11 @@ return array(
 		'path' => 'interactivity-router/full-page',
 		'asset' => 'interactivity-router/full-page.min.asset.php',
 	),
+	array(
+		'id' => '@wordpress/abilities',
+		'path' => 'abilities/index',
+		'asset' => 'abilities/index.min.asset.php',
+	),
 	array(
 		'id' => '@wordpress/latex-to-mathml',
 		'path' => 'latex-to-mathml/index',
@@ -32,21 +47,6 @@ return array(
 		'path' => 'latex-to-mathml/loader',
 		'asset' => 'latex-to-mathml/loader.min.asset.php',
 	),
-	array(
-		'id' => '@wordpress/a11y',
-		'path' => 'a11y/index',
-		'asset' => 'a11y/index.min.asset.php',
-	),
-	array(
-		'id' => '@wordpress/abilities',
-		'path' => 'abilities/index',
-		'asset' => 'abilities/index.min.asset.php',
-	),
-	array(
-		'id' => '@wordpress/core-abilities',
-		'path' => 'core-abilities/index',
-		'asset' => 'core-abilities/index.min.asset.php',
-	),
 	array(
 		'id' => '@wordpress/route',
 		'path' => 'route/index',
diff --git a/wp-includes/media.php b/wp-includes/media.php
index f43ebc36ea..f35da615b5 100644
--- a/wp-includes/media.php
+++ b/wp-includes/media.php
@@ -1229,7 +1229,7 @@ function wp_get_attachment_image( $attachment_id, $size = 'thumbnail', $icon = f
  */
 function wp_get_attachment_image_url( $attachment_id, $size = 'thumbnail', $icon = false ) {
 	$image = wp_get_attachment_image_src( $attachment_id, $size, $icon );
-	return isset( $image[0] ) ? $image[0] : false;
+	return $image[0] ?? false;
 }

 /**
@@ -1410,7 +1410,7 @@ function wp_calculate_image_srcset( $size_array, $image_src, $image_meta, $attac
 		 * be compared against the image URL using the same port.
 		 */
 		$parsed = parse_url( $image_baseurl );
-		$domain = isset( $parsed['host'] ) ? $parsed['host'] : '';
+		$domain = $parsed['host'] ?? '';

 		if ( isset( $parsed['port'] ) ) {
 			$domain .= ':' . $parsed['port'];
@@ -2171,7 +2171,7 @@ function wp_img_tag_add_loading_optimization_attrs( $image, $context ) {
 		 */
 		$filtered_decoding_attr = apply_filters(
 			'wp_img_tag_add_decoding_attr',
-			isset( $optimization_attrs['decoding'] ) ? $optimization_attrs['decoding'] : false,
+			$optimization_attrs['decoding'] ?? false,
 			$image,
 			$context
 		);
@@ -2213,7 +2213,7 @@ function wp_img_tag_add_loading_optimization_attrs( $image, $context ) {
 		 */
 		$filtered_loading_attr = apply_filters(
 			'wp_img_tag_add_loading_attr',
-			isset( $optimization_attrs['loading'] ) ? $optimization_attrs['loading'] : false,
+			$optimization_attrs['loading'] ?? false,
 			$image,
 			$context
 		);
@@ -2232,7 +2232,7 @@ function wp_img_tag_add_loading_optimization_attrs( $image, $context ) {
 			 * is only intended for the specific scenario where the above filtered caused the problem.
 			 */
 			if ( isset( $optimization_attrs['fetchpriority'] ) && 'high' === $optimization_attrs['fetchpriority'] &&
-				( isset( $optimization_attrs['loading'] ) ? $optimization_attrs['loading'] : false ) !== $filtered_loading_attr &&
+				( $optimization_attrs['loading'] ?? false ) !== $filtered_loading_attr &&
 				'lazy' === $filtered_loading_attr
 			) {
 				_doing_it_wrong(
@@ -2380,7 +2380,7 @@ function wp_iframe_tag_add_loading_attr( $iframe, $context ) {
 		return $iframe;
 	}

-	$value = isset( $optimization_attrs['loading'] ) ? $optimization_attrs['loading'] : false;
+	$value = $optimization_attrs['loading'] ?? false;

 	/**
 	 * Filters the `loading` attribute value to add to an iframe. Default 'lazy'.
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 20928d6dae..b78b2f9a1f 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.0-alpha-61452';
+$wp_version = '7.0-alpha-61453';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.