@@ -525,17 +525,23 @@ public static function get_user_data() {
525525 /**
526526 * Returns the data merged from multiple origins.
527527 *
528- * There are three sources of data (origins) for a site:
529- * default, theme, and custom. The custom's has higher priority
530- * than the theme's, and the theme's higher than default's.
528+ * There are four sources of data (origins) for a site:
529+ *
530+ * - default => WordPress
531+ * - blocks => each one of the blocks provides data for itself
532+ * - theme => the active theme
533+ * - custom => data provided by the user
534+ *
535+ * The custom's has higher priority than the theme's, the theme's higher than blocks',
536+ * and block's higher than default's.
531537 *
532538 * Unlike the getters
533539 * {@link https://developer.wordpress.org/reference/classes/wp_theme_json_resolver/get_core_data/ get_core_data},
534540 * {@link https://developer.wordpress.org/reference/classes/wp_theme_json_resolver/get_theme_data/ get_theme_data},
535541 * and {@link https://developer.wordpress.org/reference/classes/wp_theme_json_resolver/get_user_data/ get_user_data},
536542 * this method returns data after it has been merged with the previous origins.
537543 * This means that if the same piece of data is declared in different origins
538- * (user, theme, and core ), the last origin overrides the previous.
544+ * (default, blocks, theme, custom ), the last origin overrides the previous.
539545 *
540546 * For example, if the user has set a background color
541547 * for the paragraph block, and the theme has done it as well,
@@ -546,8 +552,8 @@ public static function get_user_data() {
546552 * added the `$origin` parameter.
547553 * @since 6.1.0 Added block data and generation of spacingSizes array.
548554 *
549- * @param string $origin Optional. To what level should we merge data.
550- * Valid values are 'theme' or 'custom'. Default 'custom' .
555+ * @param string $origin Optional. To what level should we merge data: 'default', 'blocks', 'theme' or 'custom' .
556+ * 'custom' is used as default value as well as fallback value if the origin is unknown .
551557 * @return WP_Theme_JSON
552558 */
553559 public static function get_merged_data ( $ origin = 'custom ' ) {
@@ -556,14 +562,23 @@ public static function get_merged_data( $origin = 'custom' ) {
556562 }
557563
558564 $ result = static ::get_core_data ();
565+ if ( 'default ' === $ origin ) {
566+ $ result ->set_spacing_sizes ();
567+ return $ result ;
568+ }
569+
559570 $ result ->merge ( static ::get_block_data () );
560- $ result ->merge ( static ::get_theme_data () );
571+ if ( 'blocks ' === $ origin ) {
572+ return $ result ;
573+ }
561574
562- if ( 'custom ' === $ origin ) {
563- $ result ->merge ( static ::get_user_data () );
575+ $ result ->merge ( static ::get_theme_data () );
576+ if ( 'theme ' === $ origin ) {
577+ $ result ->set_spacing_sizes ();
578+ return $ result ;
564579 }
565580
566- // Generate the default spacingSizes array based on the merged spacingScale settings.
581+ $ result -> merge ( static :: get_user_data () );
567582 $ result ->set_spacing_sizes ();
568583
569584 return $ result ;
0 commit comments