Last active
October 9, 2018 11:11
-
-
Save shehabkhan013/c15e22722d549f5d424e9746ac2e6afd to your computer and use it in GitHub Desktop.
Wordpress google fonts Dynamic
This file contains 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
//Refarence themeshaper | |
function theme_name_fonts_url() { | |
$fonts_url = ''; | |
$OpenSans = _x( 'on', 'OpenSans font: on or off', 'theme-slug' ); | |
$Montserrat = _x( 'on', 'Montserrat font: on or off', 'theme-slug' ); | |
if ( 'off' !== $OpenSans || 'off' !== $Montserrat ) { | |
$font_families = array(); | |
if ( 'off' !== $OpenSans ) { | |
$font_families[] = 'Open+Sans:300i,400,400i,600,700,800'; | |
} | |
if ( 'off' !== $Montserrat ) { | |
$font_families[] = 'Montserrat:200,300,400,500,600,700,800,900'; | |
} | |
$query_args = array( | |
'family' => urlencode( implode( '|', $font_families ) ), | |
'subset' => urlencode( 'cyrillic-ext,cyrillic,vietnamese,latin-ext,latin,greek-ext,greek') | |
); | |
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); | |
} | |
return $fonts_url; | |
} | |
//wp_enqueue_style( 'theme-slug-fonts', theme_name_fonts_url(), array(), null ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment