Commit 964bcaf172 for wordpress.org
commit 964bcaf172201a43de7915aff140b4104bd5c1a0
Author: Weston Ruter <weston@xwp.co>
Date: Sun Jan 11 06:50:42 2026 +0000
Code Modernization: Replace `if` statements with null coalescing operator.
Developed in https://github.com/WordPress/wordpress-develop/pull/10703
Follow-up to [61464], [61463], [61457], [61456], [61455], [61454], [61453], [61445], [61444], [61443], [61442], [61436], [61435], [61434], [61403], [61433], [61432], [61431], [61430], [61429], [61424], [61404], [61403].
Props soean, westonruter, mukesh27.
See #58874.
Fixes #64488.
Built from https://develop.svn.wordpress.org/trunk@61470
git-svn-id: http://core.svn.wordpress.org/trunk@60782 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-admin/includes/class-wp-list-table.php b/wp-admin/includes/class-wp-list-table.php
index 12432e0140..45849eb595 100644
--- a/wp-admin/includes/class-wp-list-table.php
+++ b/wp-admin/includes/class-wp-list-table.php
@@ -344,12 +344,7 @@ class WP_List_Table {
if ( 'page' === $key ) {
return $this->get_pagenum();
}
-
- if ( isset( $this->_pagination_args[ $key ] ) ) {
- return $this->_pagination_args[ $key ];
- }
-
- return 0;
+ return $this->_pagination_args[ $key ] ?? 0;
}
/**
diff --git a/wp-admin/includes/class-wp-screen.php b/wp-admin/includes/class-wp-screen.php
index 62b29d51bd..6bb8681cc6 100644
--- a/wp-admin/includes/class-wp-screen.php
+++ b/wp-admin/includes/class-wp-screen.php
@@ -554,10 +554,7 @@ final class WP_Screen {
return null;
}
if ( $key ) {
- if ( isset( $this->_options[ $option ][ $key ] ) ) {
- return $this->_options[ $option ][ $key ];
- }
- return null;
+ return $this->_options[ $option ][ $key ] ?? null;
}
return $this->_options[ $option ];
}
diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php
index a3e5742d00..610125b252 100644
--- a/wp-admin/includes/file.php
+++ b/wp-admin/includes/file.php
@@ -1097,11 +1097,7 @@ function wp_handle_upload( &$file, $overrides = false, $time = null ) {
* $_POST['action'] must be set and its value must equal $overrides['action']
* or this:
*/
- $action = 'wp_handle_upload';
- if ( isset( $overrides['action'] ) ) {
- $action = $overrides['action'];
- }
-
+ $action = $overrides['action'] ?? 'wp_handle_upload';
return _wp_handle_upload( $file, $overrides, $time, $action );
}
@@ -1128,11 +1124,7 @@ function wp_handle_sideload( &$file, $overrides = false, $time = null ) {
* $_POST['action'] must be set and its value must equal $overrides['action']
* or this:
*/
- $action = 'wp_handle_sideload';
- if ( isset( $overrides['action'] ) ) {
- $action = $overrides['action'];
- }
-
+ $action = $overrides['action'] ?? 'wp_handle_sideload';
return _wp_handle_upload( $file, $overrides, $time, $action );
}
diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php
index a9ca5553ad..460874ca52 100644
--- a/wp-admin/includes/plugin.php
+++ b/wp-admin/includes/plugin.php
@@ -1971,44 +1971,25 @@ function get_admin_page_parent( $parent_page = '' ) {
$plugin_page, $_wp_real_parent_file, $_wp_menu_nopriv, $_wp_submenu_nopriv;
if ( ! empty( $parent_page ) && 'admin.php' !== $parent_page ) {
- if ( isset( $_wp_real_parent_file[ $parent_page ] ) ) {
- $parent_page = $_wp_real_parent_file[ $parent_page ];
- }
-
- return $parent_page;
+ return $_wp_real_parent_file[ $parent_page ] ?? $parent_page;
}
if ( 'admin.php' === $pagenow && isset( $plugin_page ) ) {
foreach ( (array) $menu as $parent_menu ) {
if ( $parent_menu[2] === $plugin_page ) {
$parent_file = $plugin_page;
-
- if ( isset( $_wp_real_parent_file[ $parent_file ] ) ) {
- $parent_file = $_wp_real_parent_file[ $parent_file ];
- }
-
- return $parent_file;
+ return $_wp_real_parent_file[ $parent_file ] ?? $parent_file;
}
}
if ( isset( $_wp_menu_nopriv[ $plugin_page ] ) ) {
$parent_file = $plugin_page;
-
- if ( isset( $_wp_real_parent_file[ $parent_file ] ) ) {
- $parent_file = $_wp_real_parent_file[ $parent_file ];
- }
-
- return $parent_file;
+ return $_wp_real_parent_file[ $parent_file ] ?? $parent_file;
}
}
if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $pagenow ][ $plugin_page ] ) ) {
$parent_file = $pagenow;
-
- if ( isset( $_wp_real_parent_file[ $parent_file ] ) ) {
- $parent_file = $_wp_real_parent_file[ $parent_file ];
- }
-
- return $parent_file;
+ return $_wp_real_parent_file[ $parent_file ] ?? $parent_file;
}
foreach ( array_keys( (array) $submenu ) as $parent_page ) {
diff --git a/wp-includes/class-wp-block-styles-registry.php b/wp-includes/class-wp-block-styles-registry.php
index 60c7998985..9efdb30157 100644
--- a/wp-includes/class-wp-block-styles-registry.php
+++ b/wp-includes/class-wp-block-styles-registry.php
@@ -170,10 +170,7 @@ final class WP_Block_Styles_Registry {
* @return array[] Array whose keys are block style names and whose values are block style properties.
*/
public function get_registered_styles_for_block( $block_name ) {
- if ( isset( $this->registered_block_styles[ $block_name ] ) ) {
- return $this->registered_block_styles[ $block_name ];
- }
- return array();
+ return $this->registered_block_styles[ $block_name ] ?? array();
}
/**
diff --git a/wp-includes/class-wp-comment.php b/wp-includes/class-wp-comment.php
index b42523da37..db5ebcd2cf 100644
--- a/wp-includes/class-wp-comment.php
+++ b/wp-includes/class-wp-comment.php
@@ -323,11 +323,7 @@ final class WP_Comment {
* @return WP_Comment|false Returns the comment object if found, otherwise false.
*/
public function get_child( $child_id ) {
- if ( isset( $this->children[ $child_id ] ) ) {
- return $this->children[ $child_id ];
- }
-
- return false;
+ return $this->children[ $child_id ] ?? false;
}
/**
diff --git a/wp-includes/class-wp-dependencies.php b/wp-includes/class-wp-dependencies.php
index c3dc40bc88..a3182c8697 100644
--- a/wp-includes/class-wp-dependencies.php
+++ b/wp-includes/class-wp-dependencies.php
@@ -477,10 +477,7 @@ class WP_Dependencies {
switch ( $status ) {
case 'registered':
case 'scripts': // Back compat.
- if ( isset( $this->registered[ $handle ] ) ) {
- return $this->registered[ $handle ];
- }
- return false;
+ return $this->registered[ $handle ] ?? false;
case 'enqueued':
case 'queue': // Back compat.
diff --git a/wp-includes/class-wp-plugin-dependencies.php b/wp-includes/class-wp-plugin-dependencies.php
index e4dc4b0f40..67110a8fd2 100644
--- a/wp-includes/class-wp-plugin-dependencies.php
+++ b/wp-includes/class-wp-plugin-dependencies.php
@@ -200,11 +200,7 @@ class WP_Plugin_Dependencies {
* @return array An array of dependency plugin slugs.
*/
public static function get_dependencies( $plugin_file ) {
- if ( isset( self::$dependencies[ $plugin_file ] ) ) {
- return self::$dependencies[ $plugin_file ];
- }
-
- return array();
+ return self::$dependencies[ $plugin_file ] ?? array();
}
/**
@@ -354,12 +350,7 @@ class WP_Plugin_Dependencies {
*/
public static function get_dependency_data( $slug ) {
$dependency_api_data = self::get_dependency_api_data();
-
- if ( isset( $dependency_api_data[ $slug ] ) ) {
- return $dependency_api_data[ $slug ];
- }
-
- return false;
+ return $dependency_api_data[ $slug ] ?? false;
}
/**
diff --git a/wp-includes/class-wp-query.php b/wp-includes/class-wp-query.php
index ad2dda7827..8edcf80b54 100644
--- a/wp-includes/class-wp-query.php
+++ b/wp-includes/class-wp-query.php
@@ -1860,11 +1860,7 @@ class WP_Query {
* @return mixed Contents of the query variable.
*/
public function get( $query_var, $default_value = '' ) {
- if ( isset( $this->query_vars[ $query_var ] ) ) {
- return $this->query_vars[ $query_var ];
- }
-
- return $default_value;
+ return $this->query_vars[ $query_var ] ?? $default_value;
}
/**
@@ -4066,12 +4062,7 @@ class WP_Query {
*/
public function get_queried_object_id() {
$this->get_queried_object();
-
- if ( isset( $this->queried_object_id ) ) {
- return $this->queried_object_id;
- }
-
- return 0;
+ return $this->queried_object_id ?? 0;
}
/**
diff --git a/wp-includes/class-wp-user-meta-session-tokens.php b/wp-includes/class-wp-user-meta-session-tokens.php
index ecbb23d4e8..0a3961803a 100644
--- a/wp-includes/class-wp-user-meta-session-tokens.php
+++ b/wp-includes/class-wp-user-meta-session-tokens.php
@@ -60,12 +60,7 @@ class WP_User_Meta_Session_Tokens extends WP_Session_Tokens {
*/
protected function get_session( $verifier ) {
$sessions = $this->get_sessions();
-
- if ( isset( $sessions[ $verifier ] ) ) {
- return $sessions[ $verifier ];
- }
-
- return null;
+ return $sessions[ $verifier ] ?? null;
}
/**
diff --git a/wp-includes/class-wp-user-query.php b/wp-includes/class-wp-user-query.php
index d704dc7034..3815023924 100644
--- a/wp-includes/class-wp-user-query.php
+++ b/wp-includes/class-wp-user-query.php
@@ -910,11 +910,7 @@ class WP_User_Query {
* @return mixed
*/
public function get( $query_var ) {
- if ( isset( $this->query_vars[ $query_var ] ) ) {
- return $this->query_vars[ $query_var ];
- }
-
- return null;
+ return $this->query_vars[ $query_var ] ?? null;
}
/**
diff --git a/wp-includes/css/dist/index.php b/wp-includes/css/dist/index.php
index 1b98c542ab..e49e19cbd2 100644
--- a/wp-includes/css/dist/index.php
+++ b/wp-includes/css/dist/index.php
@@ -7,24 +7,19 @@
*/
return array(
- array(
- 'handle' => 'wp-nux',
- 'path' => 'nux/style',
- 'dependencies' => array('wp-components'),
- ),
array(
'handle' => 'wp-preferences',
'path' => 'preferences/style',
'dependencies' => array('wp-components'),
),
array(
- 'handle' => 'wp-list-reusable-blocks',
- 'path' => 'list-reusable-blocks/style',
+ 'handle' => 'wp-nux',
+ 'path' => 'nux/style',
'dependencies' => array('wp-components'),
),
array(
- 'handle' => 'wp-commands',
- 'path' => 'commands/style',
+ 'handle' => 'wp-list-reusable-blocks',
+ 'path' => 'list-reusable-blocks/style',
'dependencies' => array('wp-components'),
),
array(
@@ -32,19 +27,19 @@ 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',
'dependencies' => array('wp-block-editor', 'wp-components'),
),
array(
- 'handle' => 'wp-format-library',
- 'path' => 'format-library/style',
+ 'handle' => 'wp-commands',
+ 'path' => 'commands/style',
+ 'dependencies' => array('wp-components'),
+ ),
+ array(
+ 'handle' => 'wp-widgets',
+ 'path' => 'widgets/style',
'dependencies' => array('wp-block-editor', 'wp-components'),
),
array(
@@ -53,30 +48,35 @@ return array(
'dependencies' => array(),
),
array(
- 'handle' => 'wp-media-utils',
- 'path' => 'media-utils/style',
- 'dependencies' => array('wp-components'),
+ 'handle' => 'wp-format-library',
+ 'path' => 'format-library/style',
+ 'dependencies' => array('wp-block-editor', 'wp-components'),
),
array(
'handle' => 'wp-block-directory',
'path' => 'block-directory/style',
'dependencies' => array('wp-block-editor', 'wp-components', 'wp-editor'),
),
+ array(
+ 'handle' => 'wp-media-utils',
+ 'path' => 'media-utils/style',
+ 'dependencies' => array('wp-components'),
+ ),
array(
'handle' => 'wp-customize-widgets',
'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',
@@ -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/global-styles-and-settings.php b/wp-includes/global-styles-and-settings.php
index 9027856763..938648ad47 100644
--- a/wp-includes/global-styles-and-settings.php
+++ b/wp-includes/global-styles-and-settings.php
@@ -384,10 +384,7 @@ function wp_get_block_name_from_theme_json_path( $path ) {
}
)
);
- if ( isset( $result[0] ) ) {
- return $result[0];
- }
- return '';
+ return $result[0] ?? '';
}
/**
diff --git a/wp-includes/http.php b/wp-includes/http.php
index b343bb69f5..643efc0a16 100644
--- a/wp-includes/http.php
+++ b/wp-includes/http.php
@@ -266,11 +266,7 @@ function wp_remote_retrieve_header( $response, $header ) {
return '';
}
- if ( isset( $response['headers'][ $header ] ) ) {
- return $response['headers'][ $header ];
- }
-
- return '';
+ return $response['headers'][ $header ] ?? '';
}
/**
diff --git a/wp-includes/js/dist/script-modules/index.php b/wp-includes/js/dist/script-modules/index.php
index 8497ba890e..71e217c231 100644
--- a/wp-includes/js/dist/script-modules/index.php
+++ b/wp-includes/js/dist/script-modules/index.php
@@ -17,15 +17,25 @@ return array(
'path' => 'interactivity-router/full-page',
'asset' => 'interactivity-router/full-page.min.asset.php',
),
+ array(
+ 'id' => '@wordpress/interactivity',
+ 'path' => 'interactivity/index',
+ 'asset' => 'interactivity/index.min.asset.php',
+ ),
+ array(
+ 'id' => '@wordpress/core-abilities',
+ 'path' => 'core-abilities/index',
+ 'asset' => 'core-abilities/index.min.asset.php',
+ ),
array(
'id' => '@wordpress/a11y',
'path' => 'a11y/index',
'asset' => 'a11y/index.min.asset.php',
),
array(
- 'id' => '@wordpress/interactivity',
- 'path' => 'interactivity/index',
- 'asset' => 'interactivity/index.min.asset.php',
+ 'id' => '@wordpress/abilities',
+ 'path' => 'abilities/index',
+ 'asset' => 'abilities/index.min.asset.php',
),
array(
'id' => '@wordpress/latex-to-mathml',
@@ -37,16 +47,6 @@ return array(
'path' => 'latex-to-mathml/loader',
'asset' => 'latex-to-mathml/loader.min.asset.php',
),
- array(
- 'id' => '@wordpress/core-abilities',
- 'path' => 'core-abilities/index',
- 'asset' => 'core-abilities/index.min.asset.php',
- ),
- array(
- 'id' => '@wordpress/abilities',
- 'path' => 'abilities/index',
- 'asset' => 'abilities/index.min.asset.php',
- ),
array(
'id' => '@wordpress/route',
'path' => 'route/index',
diff --git a/wp-includes/nav-menu.php b/wp-includes/nav-menu.php
index dc6de5c70c..0b9d4038ed 100644
--- a/wp-includes/nav-menu.php
+++ b/wp-includes/nav-menu.php
@@ -148,10 +148,7 @@ function register_nav_menu( $location, $description ) {
*/
function get_registered_nav_menus() {
global $_wp_registered_nav_menus;
- if ( isset( $_wp_registered_nav_menus ) ) {
- return $_wp_registered_nav_menus;
- }
- return array();
+ return $_wp_registered_nav_menus ?? array();
}
/**
diff --git a/wp-includes/option.php b/wp-includes/option.php
index ec6ddd9372..7979c119a9 100644
--- a/wp-includes/option.php
+++ b/wp-includes/option.php
@@ -547,10 +547,7 @@ function wp_set_options_autoload( array $options, $autoload ) {
*/
function wp_set_option_autoload( $option, $autoload ) {
$result = wp_set_option_autoload_values( array( $option => $autoload ) );
- if ( isset( $result[ $option ] ) ) {
- return $result[ $option ];
- }
- return false;
+ return $result[ $option ] ?? false;
}
/**
diff --git a/wp-includes/post.php b/wp-includes/post.php
index ae9900a704..e8f37ecc34 100644
--- a/wp-includes/post.php
+++ b/wp-includes/post.php
@@ -2322,12 +2322,7 @@ function remove_post_type_support( $post_type, $feature ) {
*/
function get_all_post_type_supports( $post_type ) {
global $_wp_post_type_features;
-
- if ( isset( $_wp_post_type_features[ $post_type ] ) ) {
- return $_wp_post_type_features[ $post_type ];
- }
-
- return array();
+ return $_wp_post_type_features[ $post_type ] ?? array();
}
/**
diff --git a/wp-includes/theme.php b/wp-includes/theme.php
index da44810d4b..44343569a6 100644
--- a/wp-includes/theme.php
+++ b/wp-includes/theme.php
@@ -3042,10 +3042,7 @@ function get_theme_support( $feature, ...$args ) {
case 'custom-logo':
case 'custom-header':
case 'custom-background':
- if ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) ) {
- return $_wp_theme_features[ $feature ][0][ $args[0] ];
- }
- return false;
+ return $_wp_theme_features[ $feature ][0][ $args[0] ] ?? false;
default:
return $_wp_theme_features[ $feature ];
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 6fb6079e7f..4d2bd53726 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.0-alpha-61469';
+$wp_version = '7.0-alpha-61470';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.