Twenty Twelve: move Open Sans custom font loading to a body class to allow easier overriding, fixes #21694.

* Use wp_style_is() to check for the enqueued CSS file before adding the body class value.
 * Add a sample dequeue method in the comments as documentation for child themers and their ilk.

Props viniciusmassuchetto, nacin, and obenland.


git-svn-id: http://core.svn.wordpress.org/trunk@21668 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Lance Willett 2012-08-30 16:59:22 +00:00
parent 6231725926
commit 0c8e14a3ad
2 changed files with 14 additions and 1 deletions

View File

@ -102,6 +102,12 @@ function twentytwelve_scripts_styles() {
/*
* Loads our special font CSS file.
*
* To disable in a child theme, use wp_dequeue_style()
* function mytheme_dequeue_fonts() {
* wp_dequeue_style( 'twentytwelve-fonts' );
* }
* add_action( 'wp_enqueue_scripts', 'mytheme_dequeue_fonts', 11 );
*/
$protocol = is_ssl() ? 'https' : 'http';
wp_enqueue_style( 'twentytwelve-fonts', "$protocol://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700", array(), null );
@ -376,6 +382,10 @@ function twentytwelve_body_class( $classes ) {
elseif ( in_array( $background_color, array( 'fff', 'ffffff' ) ) )
$classes[] = 'custom-background-white';
// Enable custom font class only if the font CSS is queued to load.
if ( wp_style_is( 'twentytwelve-fonts', 'queue' ) )
$classes[] = 'custom-font-enabled';
return $classes;
}
add_filter( 'body_class', 'twentytwelve_body_class' );

View File

@ -437,10 +437,13 @@ html {
body {
font-size: 14px;
font-size: 1rem;
font-family: "Open Sans", Helvetica, Arial, sans-serif;
font-family: Helvetica, Arial, sans-serif;
text-rendering: optimizeLegibility;
color: #444;
}
body.custom-font-enabled {
font-family: "Open Sans", Helvetica, Arial, sans-serif;
}
a {
outline: none;
color: #21759b;