Astra_Fonts::preconnect_google_fonts( array $urls, string $relation_type )
Add preconnect resource hints for Google Fonts.
Description
Uses the wp_resource_hints filter (fires at wp_head priority 2) to add preconnect hints for fonts.googleapis.com and fonts.gstatic.com when Google Fonts are loaded remotely (not self-hosted).
Parameters
- $urls
-
(array) (Required) URLs to print for resource hints.
- $relation_type
-
(string) (Required) The relation type the URLs are printed for (dns-prefetch, preconnect, etc).
Return
(array) Modified URLs array.
Source
File: inc/customizer/class-astra-fonts.php
public static function preconnect_google_fonts( $urls, $relation_type ) {
if ( 'preconnect' !== $relation_type ) {
return $urls;
}
$urls[] = array(
'href' => 'https://fonts.googleapis.com',
);
$urls[] = array(
'href' => 'https://fonts.gstatic.com',
'crossorigin' => 'anonymous',
);
return $urls;
}
Expand full source code Collapse full source code View on Trac
Changelog
| Version | Description |
|---|---|
| 4.12.6 | Introduced. |