Commit a8fcabc917 for wordpress.org
commit a8fcabc917a8e0a8a660a40b4522dec2e855a38f
Author: peterwilsoncc <peterwilsoncc@git.wordpress.org>
Date: Tue Oct 6 03:52:54 2026 +0000
Editor: Ensure CSS variable names are generated consistently.
This ensures that CSS variable names generated for responsive styles are consistent with those output by `WP_Theme_JSON`.
Previously a CSS variable name in responsive styles did not match any Theme JSON preset property, and therefore the theme's preset property value was not being applied.
`wp_normalize_state_preset_vars()` now kebab-cases the preset slug, mirroring the existing logic in `WP_Theme_JSON::convert_custom_properties()` so that the CSS variable names are the same.
Developed in https://github.com/WordPress/wordpress-develop/pull/13215
Props hbhalodia, arkaprabhachowdhury, wildworks.
Fixes #65927.
Built from https://develop.svn.wordpress.org/trunk@64117
git-svn-id: http://core.svn.wordpress.org/trunk@63273 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/block-supports/states.php b/wp-includes/block-supports/states.php
index 23e171ebd8..147f770855 100644
--- a/wp-includes/block-supports/states.php
+++ b/wp-includes/block-supports/states.php
@@ -35,8 +35,21 @@ function wp_normalize_state_preset_vars( $value ) {
return $value;
}
- $unwrapped_name = str_replace( '|', '--', substr( $value, strlen( 'var:' ) ) );
- return "var(--wp--$unwrapped_name)";
+ $parts = explode( '|', substr( $value, strlen( 'var:' ) ) );
+
+ /*
+ * The slug is kebab-cased when the preset's custom property is generated,
+ * so a reference has to be converted the same way or it points at a
+ * property that does not exist (`--wp--preset--font-size--3xl` for a preset
+ * generated as `--wp--preset--font-size--3-xl`). Mirrors
+ * `WP_Theme_JSON::convert_custom_properties()` and the JavaScript style
+ * engine's `getCSSValueFromRawStyle()`.
+ */
+ if ( 3 === count( $parts ) ) {
+ $parts[2] = _wp_to_kebab_case( $parts[2] );
+ }
+
+ return 'var(--wp--' . implode( '--', $parts ) . ')';
}
/**
diff --git a/wp-includes/version.php b/wp-includes/version.php
index cfafca75b9..efe0949ae7 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-alpha-64116';
+$wp_version = '7.2-alpha-64117';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.