Commit beeb0e2d84 for wordpress.org
commit beeb0e2d84372890e4bea272fcee73ca9c21bfd7
Author: Weston Ruter <weston@xwp.co>
Date: Mon Jan 5 05:41:32 2026 +0000
Code Modernization: Customize: 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 [61432], [61431], [61430], [61429], [61424], [61404], [61403].
Props costdev, westonruter.
See #58874, #63430.
Built from https://develop.svn.wordpress.org/trunk@61433
git-svn-id: http://core.svn.wordpress.org/trunk@60745 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/class-wp-customize-nav-menus.php b/wp-includes/class-wp-customize-nav-menus.php
index ff5581df79..201122adf3 100644
--- a/wp-includes/class-wp-customize-nav-menus.php
+++ b/wp-includes/class-wp-customize-nav-menus.php
@@ -1251,7 +1251,7 @@ final class WP_Customize_Nav_Menus {
</div>
<?php endif; ?>
<?php endif; ?>
- <ul class="available-menu-items-list" data-type="<?php echo esc_attr( $available_item_type['type'] ); ?>" data-object="<?php echo esc_attr( $available_item_type['object'] ); ?>" data-type_label="<?php echo esc_attr( isset( $available_item_type['type_label'] ) ? $available_item_type['type_label'] : $available_item_type['type'] ); ?>"></ul>
+ <ul class="available-menu-items-list" data-type="<?php echo esc_attr( $available_item_type['type'] ); ?>" data-object="<?php echo esc_attr( $available_item_type['object'] ); ?>" data-type_label="<?php echo esc_attr( $available_item_type['type_label'] ?? $available_item_type['type'] ); ?>"></ul>
</div>
</div>
<?php
diff --git a/wp-includes/class-wp-customize-setting.php b/wp-includes/class-wp-customize-setting.php
index de2dbdadeb..7f2ea62c4e 100644
--- a/wp-includes/class-wp-customize-setting.php
+++ b/wp-includes/class-wp-customize-setting.php
@@ -941,7 +941,7 @@ class WP_Customize_Setting {
*/
final protected function multidimensional_get( $root, $keys, $default_value = null ) {
if ( empty( $keys ) ) { // If there are no keys, test the root.
- return isset( $root ) ? $root : $default_value;
+ return $root ?? $default_value;
}
$result = $this->multidimensional( $root, $keys );
diff --git a/wp-includes/class-wp-customize-widgets.php b/wp-includes/class-wp-customize-widgets.php
index 6420e22028..e894613c11 100644
--- a/wp-includes/class-wp-customize-widgets.php
+++ b/wp-includes/class-wp-customize-widgets.php
@@ -924,7 +924,7 @@ final class WP_Customize_Widgets {
<span class="customize-action">
<?php
$panel = $this->manager->get_panel( 'widgets' );
- $panel_title = isset( $panel->title ) ? $panel->title : __( 'Widgets' );
+ $panel_title = $panel->title ?? __( 'Widgets' );
/* translators: ▸ is the unicode right-pointing triangle. %s: Section title in the Customizer. */
printf( __( 'Customizing ▸ %s' ), esc_html( $panel_title ) );
?>
@@ -1123,7 +1123,7 @@ final class WP_Customize_Widgets {
$available_widget = array_merge(
$available_widget,
array(
- 'temp_id' => isset( $args['_temp_id'] ) ? $args['_temp_id'] : null,
+ 'temp_id' => $args['_temp_id'] ?? null,
'is_multi' => $is_multi_widget,
'control_tpl' => $control_tpl,
'multi_number' => ( 'multi' === $args['_add'] ) ? $args['_multi_num'] : false,
diff --git a/wp-includes/customize/class-wp-customize-header-image-setting.php b/wp-includes/customize/class-wp-customize-header-image-setting.php
index 80333a5412..0834b378d3 100644
--- a/wp-includes/customize/class-wp-customize-header-image-setting.php
+++ b/wp-includes/customize/class-wp-customize-header-image-setting.php
@@ -40,8 +40,8 @@ final class WP_Customize_Header_Image_Setting extends WP_Customize_Setting {
if ( empty( $custom_image_header ) ) {
require_once ABSPATH . 'wp-admin/includes/class-custom-image-header.php';
$args = get_theme_support( 'custom-header' );
- $admin_head_callback = isset( $args[0]['admin-head-callback'] ) ? $args[0]['admin-head-callback'] : null;
- $admin_preview_callback = isset( $args[0]['admin-preview-callback'] ) ? $args[0]['admin-preview-callback'] : null;
+ $admin_head_callback = $args[0]['admin-head-callback'] ?? null;
+ $admin_preview_callback = $args[0]['admin-preview-callback'] ?? null;
$custom_image_header = new Custom_Image_Header( $admin_head_callback, $admin_preview_callback );
}
diff --git a/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php b/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
index 07159e0d54..1d4c8610a7 100644
--- a/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
+++ b/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
@@ -252,7 +252,7 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
// These properties are read-only and are part of the setting for use in the Customizer UI.
if ( is_array( $value ) ) {
$value_obj = (object) $value;
- $value['type_label'] = isset( $type_label ) ? $type_label : $this->get_type_label( $value_obj );
+ $value['type_label'] = $type_label ?? $this->get_type_label( $value_obj );
$value['original_title'] = $this->get_original_title( $value_obj );
}
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 9bb766580a..58e69d8b81 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.0-alpha-61432';
+$wp_version = '7.0-alpha-61433';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.