WordPress.org

Make WordPress Core

Ticket #21694: 21694.diff

File 21694.diff, 1.5 KB (added by lancewillett, 6 years ago)

Enable body_class with wp_script_is check

  • 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

     
    105105         */
    106106        $protocol = is_ssl() ? 'https' : 'http';
    107107        wp_enqueue_style( 'twentytwelve-fonts', "$protocol://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700", array(), null );
     108        // To disable
     109        // add_action( 'wp_enqueue_scripts', function() { wp_dequeue_style( 'twentytwelve-fonts' ); }, 11 );
    108110
    109111        /*
    110112         * Loads our main stylesheet.
     
    373375        elseif ( in_array( $background_color, array( 'fff', 'ffffff' ) ) )
    374376                $classes[] = 'custom-background-white';
    375377
     378        // Enable custom font class only if the font CSS is loaded.
     379        if ( wp_script_is( 'twentytwelve-fonts', 'queue' ) )
     380                $classes[] = 'custom-font-enabled';
     381
    376382        return $classes;
    377383}
    378384add_filter( 'body_class', 'twentytwelve_body_class' );