diff --git a/includes/Services/SiteGenService.php b/includes/Services/SiteGenService.php index 62e2652..b06076f 100644 --- a/includes/Services/SiteGenService.php +++ b/includes/Services/SiteGenService.php @@ -250,6 +250,30 @@ public static function complete( $active_homepage, $homepage_data ) { return true; } + /** + * Populates the the fonts in the Theme's styles. + * + * @param object $theme_styles Theme styles json data. + * @param object $homepage_styles Customized Homepage styles. + * @return object $theme_styles Updated theme styles. + */ + public static function populate_fonts_in_theme_styles( $theme_styles, $homepage_styles ) { + + if ( ! empty( $homepage_styles['blocks'] ) && isset( $homepage_styles['blocks'][0] ) ) { + $first_block = $homepage_styles['blocks'][0]; + + if ( isset( $first_block['core/heading'] ) && isset( $first_block['core/heading']['typography']['fontFamily'] ) ) { + $theme_styles['blocks']['core/heading']['typography']['fontFamily'] = $first_block['core/heading']['typography']['fontFamily']; + } + + if ( isset( $first_block['core/body'] ) && isset( $first_block['core/body']['typography']['fontFamily'] ) ) { + $theme_styles['typography']['fontFamily'] = $first_block['core/body']['typography']['fontFamily']; + } + } + + return $theme_styles; + } + /** * Generates a child theme for the sitegen flow. * @@ -292,6 +316,7 @@ public static function generate_child_theme( $data ) { $theme_json_data = json_decode( $theme_json, true ); $theme_json_data['settings']['color']['palette'] = $data['color']['palette']; + $theme_json_data['styles'] = self::populate_fonts_in_theme_styles( $theme_json_data['styles'], $data['styles'] ); if ( ! $theme_json_data ) { return new \WP_Error(