Hi Jake,
That filter is actually still in use.
https://github.com/tomusborne/generatepress/search?q=generate_typography_customize_list
Perhaps the code you’ve used didn’t have a priority value?
Hi @ejcabquina,
Thanks for the response! I don’t think I explained properly. Using the filter above does add the font to the list, so I don’t think it’s a priority issue. The problem is that the filter isn’t applied when GP fetches font variants, so it isn’t possible to import the font variants from Google. The 'generate_google_fonts_array' filter, however, is applied in the function generate_get_all_google_fonts function, which is called by generate_get_google_font_variation:
/**
* Wrapper function to find variants for chosen Google Fonts
* Example: generate_get_google_font_variation( 'Open Sans' )
*
* @since 1.3.0
*
* @param string $font The font to look up.
* @param string $key The option to look up.
*/
function generate_get_google_font_variants( $font, $key = '' ) {
// Don't need variants if we're using a system font.
if ( in_array( $font, generate_typography_default_fonts() ) ) {
return;
}
// Return if we have our variants saved.
if ( '' !== $key && get_theme_mod( $key . '_variants' ) ) {
return get_theme_mod( $key . '_variants' );
}
$defaults = generate_get_default_fonts();
if ( $defaults[ $key ] === $font ) {
return $defaults[ $key . '_variants' ];
}
// Grab all of our fonts.
// It's a big list, so hopefully we're not even still reading.
$fonts = generate_get_all_google_fonts();
// Get the ID from our font.
$id = strtolower( str_replace( ' ', '_', $font ) );
// If the ID doesn't exist within our fonts, we can bail.
if ( ! array_key_exists( $id, $fonts ) ) {
return;
}
// Grab all of the variants associated with our font.
$variants = $fonts[ $id ]['variants'];
// Loop through them and put them into an array, then turn them into a comma separated list.
$output = array();
if ( $variants ) {
foreach ( $variants as $variant ) {
$output[] = $variant;
}
return implode( ',', apply_filters( 'generate_typography_variants', $output ) );
}
}
Does that make sense or have I misunderstood?
Thanks!
-
This reply was modified 4 years, 8 months ago by
curiousjake.
Hi there,
can you share a link to the site with that font added and applied to the typography settings so we can see whats happening?