Commit 3bcf7be566 for wordpress.org
commit 3bcf7be5664942a6d3895f4bc5b1da184ec142a5
Author: Weston Ruter <weston@xwp.co>
Date: Tue Jan 6 05:57:56 2026 +0000
Code Modernization: Site Health, Permalinks, I18N, Users, Multisite: 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 [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@61444
git-svn-id: http://core.svn.wordpress.org/trunk@60756 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-admin/includes/class-wp-debug-data.php b/wp-admin/includes/class-wp-debug-data.php
index 9823396dd4..ceae392fd2 100644
--- a/wp-admin/includes/class-wp-debug-data.php
+++ b/wp-admin/includes/class-wp-debug-data.php
@@ -373,8 +373,8 @@ class WP_Debug_Data {
);
$fields['httpd_software'] = array(
'label' => __( 'Web server' ),
- 'value' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : __( 'Unable to determine what web server software is used' ) ),
- 'debug' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : 'unknown' ),
+ 'value' => $_SERVER['SERVER_SOFTWARE'] ?? __( 'Unable to determine what web server software is used' ),
+ 'debug' => $_SERVER['SERVER_SOFTWARE'] ?? 'unknown',
);
$fields['php_version'] = array(
'label' => __( 'PHP version' ),
diff --git a/wp-admin/includes/class-wp-ms-sites-list-table.php b/wp-admin/includes/class-wp-ms-sites-list-table.php
index f2df9b43fe..9214927bee 100644
--- a/wp-admin/includes/class-wp-ms-sites-list-table.php
+++ b/wp-admin/includes/class-wp-ms-sites-list-table.php
@@ -44,7 +44,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
parent::__construct(
array(
'plural' => 'sites',
- 'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
+ 'screen' => $args['screen'] ?? null,
)
);
}
@@ -135,7 +135,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
}
}
- $order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : '';
+ $order_by = $_REQUEST['orderby'] ?? '';
if ( 'registered' === $order_by ) {
// 'registered' is a valid field name.
} elseif ( 'lastupdated' === $order_by ) {
diff --git a/wp-admin/includes/class-wp-ms-themes-list-table.php b/wp-admin/includes/class-wp-ms-themes-list-table.php
index 70187f44d4..dd95834e91 100644
--- a/wp-admin/includes/class-wp-ms-themes-list-table.php
+++ b/wp-admin/includes/class-wp-ms-themes-list-table.php
@@ -48,11 +48,11 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
parent::__construct(
array(
'plural' => 'themes',
- 'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
+ 'screen' => $args['screen'] ?? null,
)
);
- $status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all';
+ $status = $_REQUEST['theme_status'] ?? 'all';
if ( ! in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken', 'auto-update-enabled', 'auto-update-disabled' ), true ) ) {
$status = 'all';
}
@@ -153,7 +153,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$themes[ $filter ][ $key ] = $themes['all'][ $key ];
$theme_data = array(
- 'update_supported' => isset( $theme->update_supported ) ? $theme->update_supported : true,
+ 'update_supported' => $theme->update_supported ?? true,
);
// Extra info if known. array_merge() ensures $theme_data has precedence if keys collide.
diff --git a/wp-admin/includes/class-wp-ms-users-list-table.php b/wp-admin/includes/class-wp-ms-users-list-table.php
index e7d0ad21ff..b4cbf8457a 100644
--- a/wp-admin/includes/class-wp-ms-users-list-table.php
+++ b/wp-admin/includes/class-wp-ms-users-list-table.php
@@ -41,7 +41,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
$users_per_page = $this->get_items_per_page( 'users_network_per_page' );
- $role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
+ $role = $_REQUEST['role'] ?? '';
$paged = $this->get_pagenum();
diff --git a/wp-admin/includes/class-wp-site-health.php b/wp-admin/includes/class-wp-site-health.php
index a5a8c7f4da..493928677b 100644
--- a/wp-admin/includes/class-wp-site-health.php
+++ b/wp-admin/includes/class-wp-site-health.php
@@ -150,9 +150,9 @@ class WP_Site_Health {
if ( is_string( $test['test'] ) ) {
$health_check_js_variables['site_status']['async'][] = array(
'test' => $test['test'],
- 'has_rest' => ( isset( $test['has_rest'] ) ? $test['has_rest'] : false ),
+ 'has_rest' => $test['has_rest'] ?? false,
'completed' => false,
- 'headers' => isset( $test['headers'] ) ? $test['headers'] : array(),
+ 'headers' => $test['headers'] ?? array(),
);
}
}
@@ -1052,10 +1052,10 @@ class WP_Site_Health {
$failures = array();
foreach ( $modules as $library => $module ) {
- $extension_name = ( isset( $module['extension'] ) ? $module['extension'] : null );
- $function_name = ( isset( $module['function'] ) ? $module['function'] : null );
- $constant_name = ( isset( $module['constant'] ) ? $module['constant'] : null );
- $class_name = ( isset( $module['class'] ) ? $module['class'] : null );
+ $extension_name = $module['extension'] ?? null;
+ $function_name = $module['function'] ?? null;
+ $constant_name = $module['constant'] ?? null;
+ $class_name = $module['class'] ?? null;
// If this module is a fallback for another function, check if that other function passed.
if ( isset( $module['fallback_for'] ) ) {
@@ -3023,7 +3023,7 @@ class WP_Site_Health {
'sig' => $sig,
'args' => $data['args'],
'schedule' => $data['schedule'],
- 'interval' => isset( $data['interval'] ) ? $data['interval'] : null,
+ 'interval' => $data['interval'] ?? null,
);
}
diff --git a/wp-admin/includes/class-wp-users-list-table.php b/wp-admin/includes/class-wp-users-list-table.php
index 8dfe3ce1a3..9a8709b438 100644
--- a/wp-admin/includes/class-wp-users-list-table.php
+++ b/wp-admin/includes/class-wp-users-list-table.php
@@ -46,7 +46,7 @@ class WP_Users_List_Table extends WP_List_Table {
array(
'singular' => 'user',
'plural' => 'users',
- 'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
+ 'screen' => $args['screen'] ?? null,
)
);
@@ -85,7 +85,7 @@ class WP_Users_List_Table extends WP_List_Table {
$usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
- $role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
+ $role = $_REQUEST['role'] ?? '';
$per_page = ( $this->is_site_users ) ? 'site_users_network_per_page' : 'users_per_page';
$users_per_page = $this->get_items_per_page( $per_page );
diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php
index f597cac132..fed01c36b2 100644
--- a/wp-admin/includes/user.php
+++ b/wp-admin/includes/user.php
@@ -62,7 +62,7 @@ function edit_user( $user_id = 0 ) {
wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 );
}
- $potential_role = isset( $wp_roles->role_objects[ $new_role ] ) ? $wp_roles->role_objects[ $new_role ] : false;
+ $potential_role = $wp_roles->role_objects[ $new_role ] ?? false;
/*
* Don't let anyone with 'promote_users' edit their own role to something without it.
diff --git a/wp-admin/my-sites.php b/wp-admin/my-sites.php
index be7f63bb76..71ebc3858e 100644
--- a/wp-admin/my-sites.php
+++ b/wp-admin/my-sites.php
@@ -17,7 +17,7 @@ if ( ! current_user_can( 'read' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ) );
}
-$action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash';
+$action = $_POST['action'] ?? 'splash';
$blogs = get_blogs_of_user( $current_user->ID );
diff --git a/wp-admin/network/site-themes.php b/wp-admin/network/site-themes.php
index 0f2ddd5da9..6276373f4d 100644
--- a/wp-admin/network/site-themes.php
+++ b/wp-admin/network/site-themes.php
@@ -29,7 +29,7 @@ $wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' );
$action = $wp_list_table->current_action();
-$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
+$s = $_REQUEST['s'] ?? '';
// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
$temp_args = array( 'enabled', 'disabled', 'error' );
diff --git a/wp-admin/network/themes.php b/wp-admin/network/themes.php
index 9794c08f8f..763a13712a 100644
--- a/wp-admin/network/themes.php
+++ b/wp-admin/network/themes.php
@@ -19,7 +19,7 @@ $pagenum = $wp_list_table->get_pagenum();
$action = $wp_list_table->current_action();
-$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
+$s = $_REQUEST['s'] ?? '';
// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
$temp_args = array(
diff --git a/wp-admin/network/upgrade.php b/wp-admin/network/upgrade.php
index f4e65b2e9b..24882234ae 100644
--- a/wp-admin/network/upgrade.php
+++ b/wp-admin/network/upgrade.php
@@ -47,7 +47,7 @@ if ( ! current_user_can( 'upgrade_network' ) ) {
echo '<div class="wrap">';
echo '<h1>' . __( 'Upgrade Network' ) . '</h1>';
-$action = isset( $_GET['action'] ) ? $_GET['action'] : 'show';
+$action = $_GET['action'] ?? 'show';
switch ( $action ) {
case 'upgrade':
diff --git a/wp-admin/site-health.php b/wp-admin/site-health.php
index 2117aa1a75..ac6dd1523e 100644
--- a/wp-admin/site-health.php
+++ b/wp-admin/site-health.php
@@ -36,7 +36,7 @@ $wrapper_classes = array(
'tab-count-' . count( $tabs ),
);
-$current_tab = ( isset( $_GET['tab'] ) ? $_GET['tab'] : '' );
+$current_tab = $_GET['tab'] ?? '';
$title = sprintf(
// translators: %s: The currently displayed tab.
diff --git a/wp-admin/users.php b/wp-admin/users.php
index 60cf94b6ff..6f41bacb8c 100644
--- a/wp-admin/users.php
+++ b/wp-admin/users.php
@@ -629,7 +629,7 @@ switch ( $wp_list_table->current_action() ) {
break;
case 'add':
$message = __( 'New user created.' );
- $user_id = isset( $_GET['id'] ) ? $_GET['id'] : false;
+ $user_id = $_GET['id'] ?? false;
if ( $user_id && current_user_can( 'edit_user', $user_id ) ) {
$message .= sprintf(
' <a href="%1$s">%2$s</a>',
diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php
index 80f203eb7c..c5f4099127 100644
--- a/wp-includes/capabilities.php
+++ b/wp-includes/capabilities.php
@@ -471,7 +471,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) {
$caps = map_meta_cap( "edit_{$object_type}", $user_id, $object_id );
- $meta_key = isset( $args[1] ) ? $args[1] : false;
+ $meta_key = $args[1] ?? false;
if ( $meta_key ) {
$allowed = ! is_protected_meta( $meta_key, $object_type );
diff --git a/wp-includes/css/dist/index.php b/wp-includes/css/dist/index.php
index ef33115729..79fcc9aba9 100644
--- a/wp-includes/css/dist/index.php
+++ b/wp-includes/css/dist/index.php
@@ -18,13 +18,13 @@ return array(
'dependencies' => array('wp-components'),
),
array(
- 'handle' => 'wp-commands',
- 'path' => 'commands/style',
+ 'handle' => 'wp-preferences',
+ 'path' => 'preferences/style',
'dependencies' => array('wp-components'),
),
array(
- 'handle' => 'wp-preferences',
- 'path' => 'preferences/style',
+ 'handle' => 'wp-commands',
+ 'path' => 'commands/style',
'dependencies' => array('wp-components'),
),
array(
@@ -37,46 +37,46 @@ return array(
'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-components',
'path' => 'components/style',
'dependencies' => array(),
),
array(
- 'handle' => 'wp-format-library',
- 'path' => 'format-library/style',
+ 'handle' => 'wp-patterns',
+ 'path' => 'patterns/style',
'dependencies' => array('wp-block-editor', 'wp-components'),
),
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',
diff --git a/wp-includes/js/dist/script-modules/index.php b/wp-includes/js/dist/script-modules/index.php
index 9438e8294f..29a8c0f931 100644
--- a/wp-includes/js/dist/script-modules/index.php
+++ b/wp-includes/js/dist/script-modules/index.php
@@ -32,16 +32,16 @@ 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/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',
diff --git a/wp-includes/pomo/po.php b/wp-includes/pomo/po.php
index a4e3cab4ef..de1bc92064 100644
--- a/wp-includes/pomo/po.php
+++ b/wp-includes/pomo/po.php
@@ -166,7 +166,7 @@ if ( ! class_exists( 'PO', false ) ) :
}
} else {
$previous_is_backslash = false;
- $unpoified .= isset( $escapes[ $char ] ) ? $escapes[ $char ] : $char;
+ $unpoified .= $escapes[ $char ] ?? $char;
}
}
}
diff --git a/wp-includes/pomo/translations.php b/wp-includes/pomo/translations.php
index 87ebcf2073..c4a9ba72d6 100644
--- a/wp-includes/pomo/translations.php
+++ b/wp-includes/pomo/translations.php
@@ -119,7 +119,7 @@ if ( ! class_exists( 'Translations', false ) ) :
* @return string|false Header if it exists, false otherwise.
*/
public function get_header( $header ) {
- return isset( $this->headers[ $header ] ) ? $this->headers[ $header ] : false;
+ return $this->headers[ $header ] ?? false;
}
/**
@@ -132,7 +132,7 @@ if ( ! class_exists( 'Translations', false ) ) :
*/
public function translate_entry( &$entry ) {
$key = $entry->key();
- return isset( $this->entries[ $key ] ) ? $this->entries[ $key ] : false;
+ return $this->entries[ $key ] ?? false;
}
/**
diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php
index 246846dc35..0a6b84b75e 100644
--- a/wp-includes/rewrite.php
+++ b/wp-includes/rewrite.php
@@ -577,7 +577,7 @@ function url_to_postid( $url ) {
} else {
// Chop off /path/to/blog.
$home_path = parse_url( home_url( '/' ) );
- $home_path = isset( $home_path['path'] ) ? $home_path['path'] : '';
+ $home_path = $home_path['path'] ?? '';
$url = preg_replace( sprintf( '#^%s#', preg_quote( $home_path ) ), '', trailingslashit( $url ) );
}
diff --git a/wp-includes/user.php b/wp-includes/user.php
index 9871f3b18c..7885efe531 100644
--- a/wp-includes/user.php
+++ b/wp-includes/user.php
@@ -2464,7 +2464,7 @@ function wp_insert_user( $userdata ) {
$meta['show_admin_bar_front'] = empty( $userdata['show_admin_bar_front'] ) ? 'true' : $userdata['show_admin_bar_front'];
- $meta['locale'] = isset( $userdata['locale'] ) ? $userdata['locale'] : '';
+ $meta['locale'] = $userdata['locale'] ?? '';
$compacted = compact( 'user_pass', 'user_nicename', 'user_email', 'user_url', 'user_registered', 'user_activation_key', 'display_name' );
$data = wp_unslash( $compacted );
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 4a5c1a57ba..54b40ee413 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.0-alpha-61443';
+$wp_version = '7.0-alpha-61444';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
diff --git a/wp-signup.php b/wp-signup.php
index dbf3dc1794..9fe36ebed9 100644
--- a/wp-signup.php
+++ b/wp-signup.php
@@ -976,7 +976,7 @@ if ( 'none' === $active_signup ) {
/* translators: %s: Login URL. */
printf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url );
} else {
- $stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default';
+ $stage = $_POST['stage'] ?? 'default';
switch ( $stage ) {
case 'validate-user-signup':
if ( 'all' === $active_signup
@@ -1000,7 +1000,7 @@ if ( 'none' === $active_signup ) {
break;
case 'default':
default:
- $user_email = isset( $_POST['user_email'] ) ? $_POST['user_email'] : '';
+ $user_email = $_POST['user_email'] ?? '';
/**
* Fires when the site sign-up form is sent.
*