From 4d6a3abf9fc3c49e630346eee4898a469880347c Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Fri, 3 Dec 2021 23:56:06 +0000 Subject: [PATCH 1/3] Replace user key with custom --- blockbase/inc/customizer/wp-customize-colors.php | 4 ++-- blockbase/inc/customizer/wp-customize-fonts.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/blockbase/inc/customizer/wp-customize-colors.php b/blockbase/inc/customizer/wp-customize-colors.php index 13b43cfd09..1063f79dfc 100644 --- a/blockbase/inc/customizer/wp-customize-colors.php +++ b/blockbase/inc/customizer/wp-customize-colors.php @@ -73,8 +73,8 @@ 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']; } // Combine theme settings with user settings. diff --git a/blockbase/inc/customizer/wp-customize-fonts.php b/blockbase/inc/customizer/wp-customize-fonts.php index 2f9bdf396e..c2e8d091fe 100644 --- a/blockbase/inc/customizer/wp-customize-fonts.php +++ b/blockbase/inc/customizer/wp-customize-fonts.php @@ -319,8 +319,8 @@ function initialize( $wp_customize ) { return; } - if ( array_key_exists( 'user', $merged_json['settings']['typography']['fontFamilies'] ) ) { - $merged_font_families = $merged_json['settings']['typography']['fontFamilies']['user']; + 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"; } ); From 1572dce94162700052ea3aeb29ea1fd6008ca5bd Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Mon, 6 Dec 2021 14:30:27 +0000 Subject: [PATCH 2/3] Rename user to custom in functions.php --- blockbase/functions.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/blockbase/functions.php b/blockbase/functions.php index 136802ea1f..87ffd56bba 100644 --- a/blockbase/functions.php +++ b/blockbase/functions.php @@ -115,8 +115,8 @@ function blockbase_fonts_url() { } $font_families = []; - if ( ! empty( $theme_data['typography']['fontFamilies']['user'] ) ) { - foreach( $theme_data['typography']['fontFamilies']['user'] as $font ) { + if ( ! empty( $theme_data['typography']['fontFamilies']['custom'] ) ) { + foreach( $theme_data['typography']['fontFamilies']['custom'] as $font ) { if ( ! empty( $font['google'] ) ) { $font_families[] = $font['google']; } @@ -181,4 +181,3 @@ static function () { * Block Patterns. */ require get_template_directory() . '/inc/block-patterns.php'; - From a0b11a3d7bd2c7726f3f4611b0bf3b845f63cead Mon Sep 17 00:00:00 2001 From: Jason Crist Date: Mon, 6 Dec 2021 11:49:23 -0500 Subject: [PATCH 3/3] Added stopgap so that the solution will work with both < and > Gutenberg version 12.1 --- blockbase/functions.php | 10 ++++++++++ blockbase/inc/customizer/wp-customize-colors.php | 6 ++++++ blockbase/inc/customizer/wp-customize-fonts.php | 16 ++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/blockbase/functions.php b/blockbase/functions.php index 87ffd56bba..e4ba3929cd 100644 --- a/blockbase/functions.php +++ b/blockbase/functions.php @@ -121,6 +121,16 @@ function blockbase_fonts_url() { $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 ) { diff --git a/blockbase/inc/customizer/wp-customize-colors.php b/blockbase/inc/customizer/wp-customize-colors.php index 1063f79dfc..e83c7063bc 100644 --- a/blockbase/inc/customizer/wp-customize-colors.php +++ b/blockbase/inc/customizer/wp-customize-colors.php @@ -77,6 +77,12 @@ function build_user_color_palette() { $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 c2e8d091fe..564d53b7cc 100644 --- a/blockbase/inc/customizer/wp-customize-fonts.php +++ b/blockbase/inc/customizer/wp-customize-fonts.php @@ -330,6 +330,22 @@ function initialize( $wp_customize ) { 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"; + } ); + $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 ); + // End Gutenberg < 12.1 compatibility patch + } else { $body_font_selected = $body_font_default; $heading_font_selected = $heading_font_default;