Created
October 25, 2012 07:49
-
-
Save mfields/3951260 to your computer and use it in GitHub Desktop.
Twenty Twelve: Google fonts enqueue.
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
/** | |
* An Example of how Twenty Twelve Enqueues a Google font. | |
* | |
* This is interesting because it allows translators to disable the font | |
* as well as conditionally load subsets. | |
*/ | |
function test_theme_enqueue_opensans() { | |
/* translators: If there are characters in your language that are not supported | |
by Open Sans, translate this to 'off'. Do not translate into your own language. */ | |
if ( 'off' !== _x( 'on', 'Open Sans font: on or off', 'twentytwelve' ) ) { | |
$subsets = 'latin,latin-ext'; | |
/* translators: To add an additional Open Sans character subset specific to your language, translate | |
this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language. */ | |
$subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)', 'twentytwelve' ); | |
if ( 'cyrillic' == $subset ) | |
$subsets .= ',cyrillic,cyrillic-ext'; | |
elseif ( 'greek' == $subset ) | |
$subsets .= ',greek,greek-ext'; | |
elseif ( 'vietnamese' == $subset ) | |
$subsets .= ',vietnamese'; | |
$protocol = is_ssl() ? 'https' : 'http'; | |
$query_args = array( | |
'family' => 'Open+Sans:400italic,700italic,400,700', | |
'subset' => $subsets, | |
); | |
wp_enqueue_style( 'twentytwelve-fonts', add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ), array(), null ); | |
} | |
} | |
add_action( 'wp_enqueue_scripts', 'twentytwelve_scripts_styles' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment