@@ -220,6 +220,7 @@ protected static function has_same_registered_blocks( $origin ) {
220
220
* @since 5.8.0
221
221
* @since 5.9.0 Theme supports have been inlined and the `$theme_support_data` argument removed.
222
222
* @since 6.0.0 Added an `$options` parameter to allow the theme data to be returned without theme supports.
223
+ * @since 6.6.0 Add support for 'default-font-sizes' and 'default-spacing-sizes' theme supports.
223
224
*
224
225
* @param array $deprecated Deprecated. Not used.
225
226
* @param array $options {
@@ -243,7 +244,7 @@ public static function get_theme_data( $deprecated = array(), $options = array()
243
244
$ theme_json_data = static ::read_json_file ( $ theme_json_file );
244
245
$ theme_json_data = static ::translate ( $ theme_json_data , $ wp_theme ->get ( 'TextDomain ' ) );
245
246
} else {
246
- $ theme_json_data = array ();
247
+ $ theme_json_data = array ( ' version ' => WP_Theme_JSON:: LATEST_SCHEMA );
247
248
}
248
249
249
250
/**
@@ -310,6 +311,32 @@ public static function get_theme_data( $deprecated = array(), $options = array()
310
311
}
311
312
$ theme_support_data ['settings ' ]['color ' ]['defaultGradients ' ] = $ default_gradients ;
312
313
314
+ if ( ! isset ( $ theme_support_data ['settings ' ]['typography ' ] ) ) {
315
+ $ theme_support_data ['settings ' ]['typography ' ] = array ();
316
+ }
317
+ $ default_font_sizes = false ;
318
+ if ( current_theme_supports ( 'default-font-sizes ' ) ) {
319
+ $ default_font_sizes = true ;
320
+ }
321
+ if ( ! isset ( $ theme_support_data ['settings ' ]['typography ' ]['fontSizes ' ] ) ) {
322
+ // If the theme does not have any font sizes, we still want to show the core one.
323
+ $ default_font_sizes = true ;
324
+ }
325
+ $ theme_support_data ['settings ' ]['typography ' ]['defaultFontSizes ' ] = $ default_font_sizes ;
326
+
327
+ if ( ! isset ( $ theme_support_data ['settings ' ]['spacing ' ] ) ) {
328
+ $ theme_support_data ['settings ' ]['spacing ' ] = array ();
329
+ }
330
+ $ default_spacing_sizes = false ;
331
+ if ( current_theme_supports ( 'default-spacing-sizes ' ) ) {
332
+ $ default_spacing_sizes = true ;
333
+ }
334
+ if ( ! isset ( $ theme_support_data ['settings ' ]['spacing ' ]['spacingSizes ' ] ) ) {
335
+ // If the theme does not have any spacing sizes, we still want to show the core one.
336
+ $ default_spacing_sizes = true ;
337
+ }
338
+ $ theme_support_data ['settings ' ]['spacing ' ]['defaultSpacingSizes ' ] = $ default_spacing_sizes ;
339
+
313
340
if ( ! isset ( $ theme_support_data ['settings ' ]['shadow ' ] ) ) {
314
341
$ theme_support_data ['settings ' ]['shadow ' ] = array ();
315
342
}
@@ -359,7 +386,7 @@ public static function get_block_data() {
359
386
return static ::$ blocks ;
360
387
}
361
388
362
- $ config = array ( 'version ' => 2 );
389
+ $ config = array ( 'version ' => WP_Theme_JSON:: LATEST_SCHEMA );
363
390
foreach ( $ blocks as $ block_name => $ block_type ) {
364
391
if ( isset ( $ block_type ->supports ['__experimentalStyle ' ] ) ) {
365
392
$ config ['styles ' ]['blocks ' ][ $ block_name ] = static ::remove_json_comments ( $ block_type ->supports ['__experimentalStyle ' ] );
@@ -494,6 +521,7 @@ public static function get_user_data_from_wp_global_styles( $theme, $create_post
494
521
* Returns the user's origin config.
495
522
*
496
523
* @since 5.9.0
524
+ * @since 6.6.0 The 'isGlobalStylesUserThemeJSON' flag is left on the user data.
497
525
*
498
526
* @return WP_Theme_JSON Entity that holds styles for user data.
499
527
*/
@@ -531,14 +559,18 @@ public static function get_user_data() {
531
559
isset ( $ decoded_data ['isGlobalStylesUserThemeJSON ' ] ) &&
532
560
$ decoded_data ['isGlobalStylesUserThemeJSON ' ]
533
561
) {
534
- unset( $ decoded_data ['isGlobalStylesUserThemeJSON ' ] );
535
562
$ config = $ decoded_data ;
536
563
}
537
564
}
538
565
539
566
/** This filter is documented in wp-includes/class-wp-theme-json-resolver.php */
540
- $ theme_json = apply_filters ( 'wp_theme_json_data_user ' , new WP_Theme_JSON_Data ( $ config , 'custom ' ) );
541
- static ::$ user = $ theme_json ->get_theme_json ();
567
+ $ theme_json = apply_filters ( 'wp_theme_json_data_user ' , new WP_Theme_JSON_Data ( $ config , 'custom ' ) );
568
+ $ config = $ theme_json ->get_data ();
569
+
570
+ // Needs to be set for schema migrations of user data.
571
+ $ config ['isGlobalStylesUserThemeJSON ' ] = true ;
572
+
573
+ static ::$ user = new WP_Theme_JSON ( $ config , 'custom ' );
542
574
543
575
return static ::$ user ;
544
576
}
@@ -586,7 +618,6 @@ public static function get_merged_data( $origin = 'custom' ) {
586
618
$ result = new WP_Theme_JSON ();
587
619
$ result ->merge ( static ::get_core_data () );
588
620
if ( 'default ' === $ origin ) {
589
- $ result ->set_spacing_sizes ();
590
621
return $ result ;
591
622
}
592
623
@@ -597,12 +628,10 @@ public static function get_merged_data( $origin = 'custom' ) {
597
628
598
629
$ result ->merge ( static ::get_theme_data () );
599
630
if ( 'theme ' === $ origin ) {
600
- $ result ->set_spacing_sizes ();
601
631
return $ result ;
602
632
}
603
633
604
634
$ result ->merge ( static ::get_user_data () );
605
- $ result ->set_spacing_sizes ();
606
635
607
636
return $ result ;
608
637
}
0 commit comments