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:
parent
129f9b59e9
commit
5f54618427
|
@ -102,6 +102,12 @@ function twentytwelve_scripts_styles() {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Loads our special font CSS file.
|
* 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';
|
$protocol = is_ssl() ? 'https' : 'http';
|
||||||
wp_enqueue_style( 'twentytwelve-fonts', "$protocol://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700", array(), null );
|
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' ) ) )
|
elseif ( in_array( $background_color, array( 'fff', 'ffffff' ) ) )
|
||||||
$classes[] = 'custom-background-white';
|
$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;
|
return $classes;
|
||||||
}
|
}
|
||||||
add_filter( 'body_class', 'twentytwelve_body_class' );
|
add_filter( 'body_class', 'twentytwelve_body_class' );
|
||||||
|
|
|
@ -437,10 +437,13 @@ html {
|
||||||
body {
|
body {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
font-family: "Open Sans", Helvetica, Arial, sans-serif;
|
font-family: Helvetica, Arial, sans-serif;
|
||||||
text-rendering: optimizeLegibility;
|
text-rendering: optimizeLegibility;
|
||||||
color: #444;
|
color: #444;
|
||||||
}
|
}
|
||||||
|
body.custom-font-enabled {
|
||||||
|
font-family: "Open Sans", Helvetica, Arial, sans-serif;
|
||||||
|
}
|
||||||
a {
|
a {
|
||||||
outline: none;
|
outline: none;
|
||||||
color: #21759b;
|
color: #21759b;
|
||||||
|
|
Loading…
Reference in New Issue