Adding Adobe Fonts to GeneratePress

black gaming keyboard
Photo by Aidan Granberry on Unsplash

GeneratePress is a great WordPress theme, and its blocks are super powerful, albeit incredibly simple.

While developing a site, I wanted to use Adobe Fonts with the GeneratePress customizer. I use the following plugin:

Here is the code I used to add Adobe Fonts to the GeneratePress customizer.

/**
 * Compatibility with: https://wordpress.org/plugins/custom-typekit-fonts/
 * Would be nice to be able to categorize fonts: https://docs.generatepress.com/article/generate_typography_default_fonts/
 */
add_filter( 'generate_typography_default_fonts', 'mr_custom_add_typekit_fonts' );
function mr_custom_add_typekit_fonts( $fonts ) {
	// Add Typekit Fonts.
	if ( defined( 'CUSTOM_TYPEKIT_FONTS_FILE' ) ) {
		$adobe_fonts = get_option( 'custom-typekit-fonts', array() );
		if ( isset( $adobe_fonts['custom-typekit-font-details'] ) ) {
			foreach ( $adobe_fonts['custom-typekit-font-details'] as $font_name => $font_details ) {
				$fonts[] = $font_name;
			}
		}
	}
	return $fonts;
}Code language: PHP (php)