Last active
September 13, 2019 19:08
-
-
Save hmbashar/a0d3b57c4bc4640e223de87850068155 to your computer and use it in GitHub Desktop.
google font enqueue for wordpress theme and plugins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
wp_enqueue_style( 'prefix-google-font', finestudio_get_google_font_url() ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Google Fonts | |
function finestudio_get_google_font_url() { | |
$font_url = ''; | |
/* Translators: If there are characters in your language that are not | |
* supported by Arizonia, translate this to 'off'. Do not translate | |
* into your own language. | |
*/ | |
$Lato = _x( 'on', 'Lato font: on or off', 'massive' ); | |
/* Translators: If there are characters in your language that are not | |
* supported by Source Sans Pro, translate this to 'off'. Do not translate | |
* into your own language. | |
*/ | |
$Montserrat = _x( 'on', 'Montserrat font: on or off', 'massive' ); | |
if ( 'off' !== $arizonia || 'off' !== $Montserrat ) { | |
$font_families = array(); | |
if ( 'off' !== $Lato ) { | |
$font_families[] = 'Lato'; | |
} | |
if ( 'off' !== $Montserrat ) { | |
$font_families[] = 'Montserrat:300,300i,400,400i,500,500i,600,600i,700'; | |
} | |
$query_args = array( | |
'family' => urlencode( implode( '|', $font_families ) ), | |
'subset' => urlencode( 'latin,latin-ext' ), | |
); | |
$font_url = add_query_arg( $query_args, '//fonts.googleapis.com/css' ); | |
} | |
return esc_url_raw( $font_url ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment