diff --git a/blockbase/functions.php b/blockbase/functions.php index 136802ea1f..e4ba3929cd 100644 --- a/blockbase/functions.php +++ b/blockbase/functions.php @@ -115,12 +115,22 @@ function blockbase_fonts_url() { } $font_families = []; - if ( ! empty( $theme_data['typography']['fontFamilies']['user'] ) ) { + if ( ! empty( $theme_data['typography']['fontFamilies']['custom'] ) ) { + foreach( $theme_data['typography']['fontFamilies']['custom'] as $font ) { + if ( ! empty( $font['google'] ) ) { + $font_families[] = $font['google']; + } + } + + // NOTE: This should be removed once Gutenberg 12.1 lands stably in all environments + } else if ( ! empty( $theme_data['typography']['fontFamilies']['user'] ) ) { foreach( $theme_data['typography']['fontFamilies']['user'] as $font ) { if ( ! empty( $font['google'] ) ) { $font_families[] = $font['google']; } } + // End Gutenberg < 12.1 compatibility patch + } else { if ( ! empty( $theme_data['typography']['fontFamilies']['theme'] ) ) { foreach( $theme_data['typography']['fontFamilies']['theme'] as $font ) { @@ -181,4 +191,3 @@ static function () { * Block Patterns. */ require get_template_directory() . '/inc/block-patterns.php'; - diff --git a/blockbase/inc/customizer/wp-customize-colors.php b/blockbase/inc/customizer/wp-customize-colors.php index 13b43cfd09..e83c7063bc 100644 --- a/blockbase/inc/customizer/wp-customize-colors.php +++ b/blockbase/inc/customizer/wp-customize-colors.php @@ -73,10 +73,16 @@ function build_user_color_palette() { $combined_color_palette = $theme_json['settings']['color']['palette']['theme']; $user_color_palette = null; - if ( isset( $theme_json['settings']['color']['palette']['user'] ) ) { - $user_color_palette = $theme_json['settings']['color']['palette']['user']; + if ( isset( $theme_json['settings']['color']['palette']['custom'] ) ) { + $user_color_palette = $theme_json['settings']['color']['palette']['custom']; } + // NOTE: This should be removed once Gutenberg 12.1 lands stably in all environments + else if ( isset( $theme_json['settings']['color']['palette']['user'] ) ) { + $user_color_palette = $theme_json['settings']['color']['palette']['user']; + } + // End Gutenberg < 12.1 compatibility patch + // Combine theme settings with user settings. foreach ( $combined_color_palette as $key => $palette_item ) { //make theme color value the default diff --git a/blockbase/inc/customizer/wp-customize-fonts.php b/blockbase/inc/customizer/wp-customize-fonts.php index 2f9bdf396e..564d53b7cc 100644 --- a/blockbase/inc/customizer/wp-customize-fonts.php +++ b/blockbase/inc/customizer/wp-customize-fonts.php @@ -319,8 +319,22 @@ function initialize( $wp_customize ) { return; } - if ( array_key_exists( 'user', $merged_json['settings']['typography']['fontFamilies'] ) ) { + if ( array_key_exists( 'custom', $merged_json['settings']['typography']['fontFamilies'] ) ) { + $merged_font_families = $merged_json['settings']['typography']['fontFamilies']['custom']; + $body_font_selected_array = array_filter( $merged_font_families, function( $font_family ) { + return $font_family['slug'] === "body-font"; + } ); + $body_font_selected = array_shift( $body_font_selected_array ); + + $heading_font_selected_array = array_filter( $merged_font_families, function( $font_family ) { + return $font_family['slug'] === "heading-font"; + } ); + $heading_font_selected = array_shift( $heading_font_selected_array ); + + // NOTE: This should be removed once Gutenberg 12.1 lands stably in all environments + } else if ( array_key_exists( 'user', $merged_json['settings']['typography']['fontFamilies'] ) ) { $merged_font_families = $merged_json['settings']['typography']['fontFamilies']['user']; + $body_font_selected_array = array_filter( $merged_font_families, function( $font_family ) { return $font_family['slug'] === "body-font"; } ); @@ -330,6 +344,8 @@ function initialize( $wp_customize ) { return $font_family['slug'] === "heading-font"; } ); $heading_font_selected = array_shift( $heading_font_selected_array ); + // End Gutenberg < 12.1 compatibility patch + } else { $body_font_selected = $body_font_default; $heading_font_selected = $heading_font_default;