WordPress.org

Make WordPress Core

Ticket #21694: 21694.3.diff

File 21694.3.diff, 1.6 KB (added by obenland, 20 months ago)

Adds oldskool example for dequeueing the fonts style

  • wp-content/themes/twentytwelve/style.css

     
    437437body { 
    438438        font-size: 14px; 
    439439        font-size: 1rem; 
    440         font-family: "Open Sans", Helvetica, Arial, sans-serif; 
     440        font-family: Helvetica, Arial, sans-serif; 
    441441        text-rendering: optimizeLegibility; 
    442442        color: #444; 
    443443} 
     444body.custom-font-enabled { 
     445        font-family: "Open Sans", Helvetica, Arial, sans-serif; 
     446} 
    444447a { 
    445448        outline: none; 
    446449        color: #21759b; 
  • wp-content/themes/twentytwelve/functions.php

     
    102102 
    103103        /* 
    104104         * Loads our special font CSS file. 
     105         *  
     106         * To disable use wp_dequeue_style(): 
     107         * function prefix_dequeue_fonts() { 
     108         *     wp_dequeue_style( 'twentytwelve-fonts' ); 
     109         * } 
     110         * add_action( 'wp_enqueue_scripts', 'prefix_dequeue_fonts', 11 ); 
    105111         */ 
    106112        $protocol = is_ssl() ? 'https' : 'http'; 
    107113        wp_enqueue_style( 'twentytwelve-fonts', "$protocol://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700", array(), null ); 
     
    376382        elseif ( in_array( $background_color, array( 'fff', 'ffffff' ) ) ) 
    377383                $classes[] = 'custom-background-white'; 
    378384 
     385        // Enable custom font class only if the font CSS is queued to load. 
     386        if ( wp_style_is( 'twentytwelve-fonts' ) ) 
     387                $classes[] = 'custom-font-enabled'; 
     388 
    379389        return $classes; 
    380390} 
    381391add_filter( 'body_class', 'twentytwelve_body_class' );