Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blockbase: replace user key with custom #5147

Merged
merged 3 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions blockbase/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -181,4 +191,3 @@ static function () {
* Block Patterns.
*/
require get_template_directory() . '/inc/block-patterns.php';

10 changes: 8 additions & 2 deletions blockbase/inc/customizer/wp-customize-colors.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 17 additions & 1 deletion blockbase/inc/customizer/wp-customize-fonts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
} );
Expand All @@ -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;
Expand Down