Astra_Fonts::render_fonts()
Renders the <link> tag for all fonts in the $fonts array.
Description
Return
(void)
Source
File: inc/customizer/class-astra-fonts.php
public static function render_fonts() {
$font_list = apply_filters( 'astra_render_fonts', self::get_fonts() );
$google_fonts = array();
$font_subset = array();
$system_fonts = Astra_Font_Families::get_system_fonts();
foreach ( $font_list as $name => $font ) {
if ( ! empty( $name ) && ! isset( $system_fonts[ $name ] ) ) {
// Add font variants.
$google_fonts[ $name ] = $font['variants'];
// Add Subset.
$subset = apply_filters( 'astra_font_subset', '', $name );
if ( ! empty( $subset ) ) {
$font_subset[] = $subset;
}
}
}
$google_font_url = self::google_fonts_url( $google_fonts, $font_subset );
// Do not load Google font remote or local font asset if not any font selected.
if ( '' === $google_font_url ) {
return;
}
/**
* Support self hosted Google Fonts.
*
* @since 3.6.0
*/
if ( astra_get_option( 'load-google-fonts-locally' ) && ! is_customize_preview() && ! is_admin() ) {
if ( astra_get_option( 'preload-local-fonts' ) ) {
ast_load_preload_local_fonts( $google_font_url );
}
wp_enqueue_style( 'astra-google-fonts', ast_get_webfont_url( $google_font_url ), array(), ASTRA_THEME_VERSION, 'all' );
} else {
wp_enqueue_style( 'astra-google-fonts', $google_font_url, array(), ASTRA_THEME_VERSION, 'all' );
}
}
Expand full source code Collapse full source code View on Trac
Changelog
| Version | Description |
|---|---|
| 1.0.16 | Added the filter 'astra_render_fonts' to support custom fonts. |
| 1.0.0 | Introduced. |