astra_load_preload_local_fonts( string $url, string $format = 'woff2' )
Get the file preloads.
Description
Parameters
- $url
-
(string) (Required) The URL of the remote webfont.
- $format
-
(string) (Optional) The font-format. If you need to support IE, change this to "woff".
Default value: 'woff2'
Source
File: inc/extras.php
function astra_load_preload_local_fonts( $url, $format = 'woff2' ) { // Check if cached font files data preset present or not. Basically avoiding 'Astra_WebFont_Loader' class rendering. $astra_local_font_files = get_site_option( 'astra_local_font_files', false ); if ( is_array( $astra_local_font_files ) && ! empty( $astra_local_font_files ) ) { $font_format = apply_filters( 'astra_local_google_fonts_format', $format ); foreach ( $astra_local_font_files as $key => $local_font ) { if ( $local_font ) { echo '<link rel="preload" href="' . esc_url( $local_font ) . '" as="font" type="font/' . esc_attr( $font_format ) . '" crossorigin>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } return; } // Now preload font data after processing it, as we didn't get stored data. $font = astra_webfont_loader_instance( $url ); $font->set_font_format( $format ); $font->preload_local_fonts(); }
Expand full source code Collapse full source code View on Trac