@@ -151,6 +151,13 @@ final class ReaderThemeSupportFeatures implements Service, Registerable {
151
151
*/
152
152
const KEY_CUSTOM_SPACING_SIZE = 'customSpacingSize ' ;
153
153
154
+ /**
155
+ * Key for `defaultSpacingSizes` boolean in theme.json (v3).
156
+ *
157
+ * @var string
158
+ */
159
+ const KEY_DEFAULT_SPACING_SIZES = 'defaultSpacingSizes ' ;
160
+
154
161
/**
155
162
* Action fired when the cached primary_theme_support should be updated.
156
163
*
@@ -496,10 +503,23 @@ private function print_editor_gradient_presets_styles( array $gradient_presets )
496
503
* Print spacing sizes custom properties.
497
504
*/
498
505
private function print_spacing_sizes_custom_properties () {
499
- $ custom_properties = [];
500
- $ spacing_sizes = wp_get_global_settings ( [ self ::KEY_SPACING , self ::KEY_SPACING_SIZES ], self ::KEY_THEME );
501
- $ is_wp_generating_spacing_sizes = 0 !== wp_get_global_settings ( [ self ::KEY_SPACING , self ::KEY_SPACING_SCALE ], self ::KEY_THEME )[ self ::KEY_STEPS ];
502
- $ custom_spacing_size = wp_get_global_settings ( [ self ::KEY_SPACING , self ::KEY_CUSTOM_SPACING_SIZE ], self ::KEY_THEME );
506
+ $ custom_properties = [];
507
+ $ spacing = wp_get_global_settings ( [ self ::KEY_SPACING ], self ::KEY_THEME );
508
+ $ spacing_sizes = $ spacing [ self ::KEY_SPACING_SIZES ] ?? [];
509
+ $ custom_spacing_size = $ spacing [ self ::KEY_CUSTOM_SPACING_SIZE ] ?? false ;
510
+ $ spacing_scale = $ spacing [ self ::KEY_SPACING_SCALE ] ?? [];
511
+
512
+ /**
513
+ * By default check for `defaultSpacingSizes` boolean introduced in theme.json (v3)
514
+ * and if it's false, then check for `steps` in `spacingScale` which is v2 default.
515
+ *
516
+ * @see <https://github.com/WordPress/gutenberg/pull/58409#issuecomment-2078077477>.
517
+ */
518
+ $ is_wp_generating_spacing_sizes = $ spacing [ self ::KEY_DEFAULT_SPACING_SIZES ] ?? false ;
519
+
520
+ if ( array_key_exists ( self ::KEY_STEPS , $ spacing_scale ) ) {
521
+ $ is_wp_generating_spacing_sizes = 0 !== $ spacing_scale [ self ::KEY_STEPS ];
522
+ }
503
523
504
524
if ( ! $ is_wp_generating_spacing_sizes && $ custom_spacing_size ) {
505
525
if ( isset ( $ spacing_sizes [ self ::KEY_THEME ] ) ) {
0 commit comments