Skip to content

Instantly share code, notes, and snippets.

@shehabkhan013
Last active October 9, 2018 11:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shehabkhan013/c15e22722d549f5d424e9746ac2e6afd to your computer and use it in GitHub Desktop.
Save shehabkhan013/c15e22722d549f5d424e9746ac2e6afd to your computer and use it in GitHub Desktop.
Wordpress google fonts Dynamic
//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