Commit e9153b4657 for wordpress.org
commit e9153b4657641c4142357d1799a8ee7f5747196a
Author: Weston Ruter <weston@xwp.co>
Date: Sat Jan 10 05:03:50 2026 +0000
Code Modernization: Use null coalescing operator instead of `isset()` with `if`/`else` statements.
Developed in https://github.com/WordPress/wordpress-develop/pull/10711
Follow-up to [61457], [61456], [61455], [61454], [61453], [61445], [61444], [61443], [61442], [61436], [61435], [61434], [61403], [61433], [61432], [61431], [61430], [61429], [61424], [61404], [61403].
See #58874, #63430.
Built from https://develop.svn.wordpress.org/trunk@61463
git-svn-id: http://core.svn.wordpress.org/trunk@60775 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-admin/includes/class-wp-importer.php b/wp-admin/includes/class-wp-importer.php
index 8489919f8a..16b08bf42b 100644
--- a/wp-admin/includes/class-wp-importer.php
+++ b/wp-admin/includes/class-wp-importer.php
@@ -311,11 +311,7 @@ function get_cli_args( $param, $required = false ) {
$parts = explode( '=', $match[1] );
$key = preg_replace( '/[^a-z0-9]+/', '', $parts[0] );
- if ( isset( $parts[1] ) ) {
- $out[ $key ] = $parts[1];
- } else {
- $out[ $key ] = true;
- }
+ $out[ $key ] = $parts[1] ?? true;
$last_arg = $key;
} elseif ( (bool) preg_match( '/^-([a-zA-Z0-9]+)/', $args[ $i ], $match ) ) {
diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php
index e241989f5b..eb0029a556 100644
--- a/wp-admin/includes/post.php
+++ b/wp-admin/includes/post.php
@@ -122,11 +122,7 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
$post_data['post_status'] = 'pending';
}
- if ( isset( $post_data['ID'] ) ) {
- $post_id = $post_data['ID'];
- } else {
- $post_id = false;
- }
+ $post_id = $post_data['ID'] ?? false;
$previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false;
if ( isset( $post_data['post_status'] ) && 'private' === $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) {
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php
index 2eaf674543..9513095232 100644
--- a/wp-admin/includes/template.php
+++ b/wp-admin/includes/template.php
@@ -2296,12 +2296,7 @@ function _post_states( $post, $display = true ) {
*/
function get_post_states( $post ) {
$post_states = array();
-
- if ( isset( $_REQUEST['post_status'] ) ) {
- $post_status = $_REQUEST['post_status'];
- } else {
- $post_status = '';
- }
+ $post_status = $_REQUEST['post_status'] ?? '';
if ( ! empty( $post->post_password ) ) {
$post_states['protected'] = _x( 'Password protected', 'post status' );
diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php
index 5220f98de9..8fa5d06a16 100644
--- a/wp-admin/includes/theme.php
+++ b/wp-admin/includes/theme.php
@@ -400,11 +400,7 @@ function get_theme_feature_list( $api = true ) {
$wporg_features[ $feature_category ] = array();
foreach ( $feature_items as $feature ) {
- if ( isset( $features[ $feature_category ][ $feature ] ) ) {
- $wporg_features[ $feature_category ][ $feature ] = $features[ $feature_category ][ $feature ];
- } else {
- $wporg_features[ $feature_category ][ $feature ] = $feature;
- }
+ $wporg_features[ $feature_category ][ $feature ] = $features[ $feature_category ][ $feature ] ?? $feature;
}
}
diff --git a/wp-admin/upgrade.php b/wp-admin/upgrade.php
index 4847134a62..7db8d492cb 100644
--- a/wp-admin/upgrade.php
+++ b/wp-admin/upgrade.php
@@ -23,11 +23,7 @@ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
delete_site_transient( 'update_core' );
-if ( isset( $_GET['step'] ) ) {
- $step = $_GET['step'];
-} else {
- $step = 0;
-}
+$step = $_GET['step'] ?? 0;
// Do it. No output.
if ( 'upgrade_db' === $step ) {
diff --git a/wp-includes/class-wp-date-query.php b/wp-includes/class-wp-date-query.php
index 2dc1d244f5..62de2f2113 100644
--- a/wp-includes/class-wp-date-query.php
+++ b/wp-includes/class-wp-date-query.php
@@ -208,11 +208,7 @@ class WP_Date_Query {
continue;
}
- if ( isset( $parent_query[ $dkey ] ) ) {
- $queries[ $dkey ] = $parent_query[ $dkey ];
- } else {
- $queries[ $dkey ] = $dvalue;
- }
+ $queries[ $dkey ] = $parent_query[ $dkey ] ?? $dvalue;
}
// Validate the dates passed in the query.
diff --git a/wp-includes/class-wp-http-streams.php b/wp-includes/class-wp-http-streams.php
index 4ab23b813b..45a15a9565 100644
--- a/wp-includes/class-wp-http-streams.php
+++ b/wp-includes/class-wp-http-streams.php
@@ -77,11 +77,7 @@ class WP_Http_Streams {
}
if ( isset( $parsed_args['headers']['Host'] ) || isset( $parsed_args['headers']['host'] ) ) {
- if ( isset( $parsed_args['headers']['Host'] ) ) {
- $parsed_url['host'] = $parsed_args['headers']['Host'];
- } else {
- $parsed_url['host'] = $parsed_args['headers']['host'];
- }
+ $parsed_url['host'] = $parsed_args['headers']['Host'] ?? $parsed_args['headers']['host'];
unset( $parsed_args['headers']['Host'], $parsed_args['headers']['host'] );
}
diff --git a/wp-includes/class-wp-post-type.php b/wp-includes/class-wp-post-type.php
index 8812c21f1b..2f23edc733 100644
--- a/wp-includes/class-wp-post-type.php
+++ b/wp-includes/class-wp-post-type.php
@@ -655,11 +655,7 @@ final class WP_Post_Type {
$args['rewrite']['feeds'] = (bool) $args['has_archive'];
}
if ( ! isset( $args['rewrite']['ep_mask'] ) ) {
- if ( isset( $args['permalink_epmask'] ) ) {
- $args['rewrite']['ep_mask'] = $args['permalink_epmask'];
- } else {
- $args['rewrite']['ep_mask'] = EP_PERMALINK;
- }
+ $args['rewrite']['ep_mask'] = $args['permalink_epmask'] ?? EP_PERMALINK;
}
}
diff --git a/wp-includes/class-wp-styles.php b/wp-includes/class-wp-styles.php
index b41ba10239..ad5564124c 100644
--- a/wp-includes/class-wp-styles.php
+++ b/wp-includes/class-wp-styles.php
@@ -178,11 +178,7 @@ class WP_Styles extends WP_Dependencies {
}
}
- if ( isset( $obj->args ) ) {
- $media = $obj->args;
- } else {
- $media = 'all';
- }
+ $media = $obj->args ?? 'all';
// A single item may alias a set of items, by having dependencies, but no source.
if ( ! $src ) {
diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php
index 3b1870edf1..ce278a861c 100644
--- a/wp-includes/class-wp-xmlrpc-server.php
+++ b/wp-includes/class-wp-xmlrpc-server.php
@@ -3673,11 +3673,7 @@ class wp_xmlrpc_server extends IXR_Server {
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getComments', $args, $this );
- if ( isset( $struct['status'] ) ) {
- $status = $struct['status'];
- } else {
- $status = '';
- }
+ $status = $struct['status'] ?? '';
if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) {
return new IXR_Error( 401, __( 'Invalid comment status.' ) );
diff --git a/wp-includes/css/dist/index.php b/wp-includes/css/dist/index.php
index bc8ce6f5f1..08835e2e0f 100644
--- a/wp-includes/css/dist/index.php
+++ b/wp-includes/css/dist/index.php
@@ -7,11 +7,6 @@
*/
return array(
- array(
- 'handle' => 'wp-preferences',
- 'path' => 'preferences/style',
- 'dependencies' => array('wp-components'),
- ),
array(
'handle' => 'wp-list-reusable-blocks',
'path' => 'list-reusable-blocks/style',
@@ -23,13 +18,13 @@ return array(
'dependencies' => array('wp-components'),
),
array(
- 'handle' => 'wp-reusable-blocks',
- 'path' => 'reusable-blocks/style',
- 'dependencies' => array('wp-block-editor', 'wp-components'),
+ 'handle' => 'wp-preferences',
+ 'path' => 'preferences/style',
+ 'dependencies' => array('wp-components'),
),
array(
- 'handle' => 'wp-patterns',
- 'path' => 'patterns/style',
+ 'handle' => 'wp-reusable-blocks',
+ 'path' => 'reusable-blocks/style',
'dependencies' => array('wp-block-editor', 'wp-components'),
),
array(
@@ -37,6 +32,11 @@ return array(
'path' => 'commands/style',
'dependencies' => array('wp-components'),
),
+ array(
+ 'handle' => 'wp-patterns',
+ 'path' => 'patterns/style',
+ 'dependencies' => array('wp-block-editor', 'wp-components'),
+ ),
array(
'handle' => 'wp-widgets',
'path' => 'widgets/style',
@@ -87,14 +87,14 @@ return array(
'path' => 'editor/style',
'dependencies' => array('wp-block-editor', 'wp-commands', 'wp-components', 'wp-media-utils', 'wp-patterns', 'wp-preferences'),
),
- array(
- 'handle' => 'wp-edit-site',
- 'path' => 'edit-site/style',
- 'dependencies' => array('wp-block-editor', 'wp-block-library', 'wp-commands', 'wp-components', 'wp-editor', 'wp-patterns', 'wp-preferences', 'wp-widgets'),
- ),
array(
'handle' => 'wp-block-editor',
'path' => 'block-editor/style',
'dependencies' => array('wp-commands', 'wp-components', 'wp-preferences'),
),
+ array(
+ 'handle' => 'wp-edit-site',
+ 'path' => 'edit-site/style',
+ 'dependencies' => array('wp-block-editor', 'wp-block-library', 'wp-commands', 'wp-components', 'wp-editor', 'wp-patterns', 'wp-preferences', 'wp-widgets'),
+ ),
);
diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php
index ac5427e2ce..66d78c7a5b 100644
--- a/wp-includes/general-template.php
+++ b/wp-includes/general-template.php
@@ -1873,11 +1873,7 @@ function get_the_post_type_description() {
$post_type_obj = get_post_type_object( $post_type );
// Check if a description is set.
- if ( isset( $post_type_obj->description ) ) {
- $description = $post_type_obj->description;
- } else {
- $description = '';
- }
+ $description = $post_type_obj->description ?? '';
/**
* Filters the description for a post type archive.
diff --git a/wp-includes/js/dist/script-modules/index.php b/wp-includes/js/dist/script-modules/index.php
index daf7b17d24..73a9b0397f 100644
--- a/wp-includes/js/dist/script-modules/index.php
+++ b/wp-includes/js/dist/script-modules/index.php
@@ -7,16 +7,6 @@
*/
return array(
- 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',
'path' => 'interactivity/index',
@@ -47,6 +37,16 @@ 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/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 f35da615b5..6933ad6995 100644
--- a/wp-includes/media.php
+++ b/wp-includes/media.php
@@ -6036,11 +6036,7 @@ function wp_get_loading_optimization_attributes( $tag_name, $attr, $context ) {
* conflicting `decoding` attribute already present.
*/
if ( 'img' === $tag_name ) {
- if ( isset( $attr['decoding'] ) ) {
- $loading_attrs['decoding'] = $attr['decoding'];
- } else {
- $loading_attrs['decoding'] = 'async';
- }
+ $loading_attrs['decoding'] = $attr['decoding'] ?? 'async';
}
// For any resources, width and height must be provided, to avoid layout shifts.
diff --git a/wp-includes/meta.php b/wp-includes/meta.php
index d60bf5e875..5f53c12bc3 100644
--- a/wp-includes/meta.php
+++ b/wp-includes/meta.php
@@ -674,11 +674,7 @@ function get_metadata_raw( $meta_type, $object_id, $meta_key = '', $single = fal
if ( ! $meta_cache ) {
$meta_cache = update_meta_cache( $meta_type, array( $object_id ) );
- if ( isset( $meta_cache[ $object_id ] ) ) {
- $meta_cache = $meta_cache[ $object_id ];
- } else {
- $meta_cache = null;
- }
+ $meta_cache = $meta_cache[ $object_id ] ?? null;
}
if ( ! $meta_key ) {
diff --git a/wp-includes/rest-api/class-wp-rest-server.php b/wp-includes/rest-api/class-wp-rest-server.php
index 0a18be77cd..dbf605523d 100644
--- a/wp-includes/rest-api/class-wp-rest-server.php
+++ b/wp-includes/rest-api/class-wp-rest-server.php
@@ -364,11 +364,7 @@ class WP_REST_Server {
}
if ( empty( $path ) ) {
- if ( isset( $_SERVER['PATH_INFO'] ) ) {
- $path = $_SERVER['PATH_INFO'];
- } else {
- $path = '/';
- }
+ $path = $_SERVER['PATH_INFO'] ?? '/';
}
$request = new WP_REST_Request( $_SERVER['REQUEST_METHOD'], $path );
diff --git a/wp-includes/theme.php b/wp-includes/theme.php
index 4977972841..da44810d4b 100644
--- a/wp-includes/theme.php
+++ b/wp-includes/theme.php
@@ -1529,17 +1529,12 @@ function get_uploaded_header_images() {
$header_data = wp_get_attachment_metadata( $header->ID );
$header_index = $header->ID;
- $header_images[ $header_index ] = array();
- $header_images[ $header_index ]['attachment_id'] = $header->ID;
- $header_images[ $header_index ]['url'] = $url;
- $header_images[ $header_index ]['thumbnail_url'] = $url;
- $header_images[ $header_index ]['alt_text'] = get_post_meta( $header->ID, '_wp_attachment_image_alt', true );
-
- if ( isset( $header_data['attachment_parent'] ) ) {
- $header_images[ $header_index ]['attachment_parent'] = $header_data['attachment_parent'];
- } else {
- $header_images[ $header_index ]['attachment_parent'] = '';
- }
+ $header_images[ $header_index ] = array();
+ $header_images[ $header_index ]['attachment_id'] = $header->ID;
+ $header_images[ $header_index ]['url'] = $url;
+ $header_images[ $header_index ]['thumbnail_url'] = $url;
+ $header_images[ $header_index ]['alt_text'] = get_post_meta( $header->ID, '_wp_attachment_image_alt', true );
+ $header_images[ $header_index ]['attachment_parent'] = $header_data['attachment_parent'] ?? '';
if ( isset( $header_data['width'] ) ) {
$header_images[ $header_index ]['width'] = $header_data['width'];
diff --git a/wp-includes/version.php b/wp-includes/version.php
index c68a4d6844..ee0d98b94f 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.0-alpha-61462';
+$wp_version = '7.0-alpha-61463';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.