Commit 799568c55b for wordpress.org
commit 799568c55b2728b623119f9f004500231e8d4c04
Author: wildworks <wildworks@git.wordpress.org>
Date: Mon Nov 9 09:08:54 2026 +0000
Code Modernization: Simplify duotone and theme.json defaults
Replaces guards that assign a value only when one is not already set with the null coalescing assignment operator (`??=`) in duotone color parsing and block style variation metadata.
Developed in https://github.com/WordPress/wordpress-develop/pull/15354
Props mukesh27, shailu25, wildworks.
See #65823.
Built from https://develop.svn.wordpress.org/trunk@65344
git-svn-id: http://core.svn.wordpress.org/trunk@64484 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/class-wp-duotone.php b/wp-includes/class-wp-duotone.php
index 3b90f36cc5..49cf221c11 100644
--- a/wp-includes/class-wp-duotone.php
+++ b/wp-includes/class-wp-duotone.php
@@ -325,9 +325,7 @@ class WP_Duotone {
* of the array, so we add them manually to make things easier later.
*/
for ( $i = 1; $i <= 8; $i++ ) {
- if ( ! isset( $match[ $i ] ) ) {
- $match[ $i ] = '';
- }
+ $match[ $i ] ??= '';
}
if ( $match[2] !== $match[4] || $match[4] !== $match[6] ) {
@@ -489,9 +487,7 @@ class WP_Duotone {
* of the array, so we add them manually to make things easier later.
*/
for ( $i = 1; $i <= 6; $i++ ) {
- if ( ! isset( $match[ $i ] ) ) {
- $match[ $i ] = '';
- }
+ $match[ $i ] ??= '';
}
$hsla = self::colord_clamp_hsla(
diff --git a/wp-includes/class-wp-theme-json.php b/wp-includes/class-wp-theme-json.php
index 86842aee6f..15d08fba45 100644
--- a/wp-includes/class-wp-theme-json.php
+++ b/wp-includes/class-wp-theme-json.php
@@ -1949,9 +1949,7 @@ class WP_Theme_JSON {
$style_selectors = $block_metadata['styleVariations'] ?? array();
foreach ( $registered_styles[ $block_name ] as $block_style ) {
- if ( ! isset( $style_selectors[ $block_style['name'] ] ) ) {
- $style_selectors[ $block_style['name'] ] = static::get_block_style_variation_selector( $block_style['name'], $block_metadata['selector'] );
- }
+ $style_selectors[ $block_style['name'] ] ??= static::get_block_style_variation_selector( $block_style['name'], $block_metadata['selector'] );
}
static::$blocks_metadata[ $block_name ]['styleVariations'] = $style_selectors;
diff --git a/wp-includes/version.php b/wp-includes/version.php
index c88fbec3ce..f668a608bb 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-beta4-65343';
+$wp_version = '7.2-beta4-65344';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.