Bundled theme: Add preconnect to fonts.gstatic.com in 2012-15 themes.
Add preconnect hinting for `https://fonts.gstatic.com` in the bundled themes using Google fonts. WordPress versions 4.7+ include a crossorigin attribute, earlier versions will not. Props leobaiano, swissspidy, peterwilsoncc. Fixes #37171. Built from https://develop.svn.wordpress.org/trunk@38870 git-svn-id: http://core.svn.wordpress.org/trunk@38813 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f7e8a74604
commit
6cadfb3a0a
|
@ -157,6 +157,31 @@ function twentytwelve_scripts_styles() {
|
|||
}
|
||||
add_action( 'wp_enqueue_scripts', 'twentytwelve_scripts_styles' );
|
||||
|
||||
/**
|
||||
* Add preconnect for Google Fonts.
|
||||
*
|
||||
* @since Twenty Twelve 2.2
|
||||
*
|
||||
* @param array $urls URLs to print for resource hints.
|
||||
* @param string $relation_type The relation type the URLs are printed.
|
||||
* @return array URLs to print for resource hints.
|
||||
*/
|
||||
function twentytwelve_resource_hints( $urls, $relation_type ) {
|
||||
if ( wp_style_is( 'twentytwelve-fonts', 'queue' ) && 'preconnect' === $relation_type ) {
|
||||
if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '>=' ) ) {
|
||||
$urls[] = array(
|
||||
'href' => 'https://fonts.gstatic.com',
|
||||
'crossorigin',
|
||||
);
|
||||
} else {
|
||||
$urls[] = 'https://fonts.gstatic.com';
|
||||
}
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
add_filter( 'wp_resource_hints', 'twentytwelve_resource_hints', 10, 2 );
|
||||
|
||||
/**
|
||||
* Filter TinyMCE CSS path to include Google Fonts.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue