astra_get_webfont_url( string $url, string $format = 'woff2' )

Get a stylesheet URL for a webfont.


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'


Return

(string) Returns the CSS.


Source

File: inc/extras.php

function astra_get_webfont_url( $url, $format = 'woff2' ) {

	// Check if already Google font URL present or not. Basically avoiding 'Astra_WebFont_Loader' class rendering.
	/** @psalm-suppress InvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
	$astra_font_url = astra_get_option( 'astra_font_url', false );
	if ( $astra_font_url ) {
		return json_decode( $astra_font_url );
	}

	// Now create font URL if its not present.
	$font = astra_webfont_loader_instance( $url );
	$font->set_font_format( $format );
	return $font->get_url();
}

Changelog

Changelog
Version Description
3.6.0 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.