WordPress.org

Make WordPress Core

Changeset 21639


Ignore:
Timestamp:
08/28/2012 02:18:43 AM (6 years ago)
Author:
lancewillett
Message:

Twenty Twelve: simplify custom font loading behavior, see #21694.

  • Remove theme options code and support from theme.
  • Keep Open Sans font first in the stack and make it always loaded.
  • Move Customizer pieces from Theme Options out of class structure and into functions.php.
Location:
trunk/wp-content/themes/twentytwelve
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentytwelve/functions.php

    r21620 r21639  
    4343 */
    4444function twentytwelve_setup() {
    45     global $twentytwelve_options;
    46 
    4745    /*
    4846     * Makes Twenty Twelve available for translation.
     
    5452    load_theme_textdomain( 'twentytwelve', get_template_directory() . '/languages' );
    5553
    56     // Load up our theme options page and related code.
    57     require( get_template_directory() . '/inc/theme-options.php' );
    58     $twentytwelve_options = new Twenty_Twelve_Options();
    59 
    6054    // This theme styles the visual editor with editor-style.css to match the theme style.
    6155    add_editor_style();
     
    9589 */
    9690function twentytwelve_scripts_styles() {
    97     global $twentytwelve_options;
    98 
    9991    /*
    10092     * Adds JavaScript to pages with the comment form to support
     
    111103    /*
    112104     * Loads our special font CSS file.
    113      * Depends on Theme Options setting.
    114105     */
    115     $options = $twentytwelve_options->get_theme_options();
    116     if ( $options['enable_fonts'] )
    117         wp_enqueue_style( 'twentytwelve-fonts', $twentytwelve_options->custom_fonts_url(), array(), null );
     106    $protocol = is_ssl() ? 'https' : 'http';
     107    wp_enqueue_style( 'twentytwelve-fonts', "$protocol://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700", array(), null );
    118108
    119109    /*
     
    401391}
    402392add_action( 'template_redirect', 'twentytwelve_content_width' );
     393
     394/**
     395 * Add postMessage support for site title and description for the Theme Customizer.
     396 *
     397 * @since Twenty Twelve 1.0
     398 *
     399 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
     400 * @return void
     401 */
     402function twentytwelve_customize_register( $wp_customize ) {
     403    $wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
     404    $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
     405}
     406add_action( 'customize_register', 'twentytwelve_customize_register' );
     407
     408/**
     409 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
     410 *
     411 * @since Twenty Twelve 1.0
     412 */
     413function twentytwelve_customize_preview_js() {
     414    wp_enqueue_script( 'twentytwelve-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20120827', true );
     415}
     416add_action( 'customize_preview_init', 'twentytwelve_customize_preview_js' );
  • trunk/wp-content/themes/twentytwelve/js/theme-customizer.js

    r21622 r21639  
    33 *
    44 * Contains handlers to make Theme Customizer preview reload changes asynchronously.
    5  * Things like fonts, site title and description, and background color changes.
     5 * Things like site title, description, and background color changes.
    66 *
    7  * See related settings in Twenty_Twelve_Options::customize_preview_js()
     7 * See related settings in twentytwelve_customize_preview_js()
    88 */
    99
     
    2121    } );
    2222
    23     // Custom fonts.
    24     wp.customize( twentytwelve_customizer.option_key + '[enable_fonts]', function( value ) {
    25         value.bind( function( to ) {
    26             if ( to ) {
    27                 $( 'head' ).append( '<link rel="stylesheet" id="twentytwelve-fonts-css" href="' + twentytwelve_customizer.link + '" type="text/css" media="all" />' );
    28             } else {
    29                 $( '#twentytwelve-fonts-css' ).remove();
    30             }
    31         } );
    32     } );
    33 
    3423    // Hook into background color change and adjust body class value as needed.
    3524    wp.customize( 'background_color', function( value ) {
  • trunk/wp-content/themes/twentytwelve/style.css

    r21637 r21639  
    298298    max-width: 100%;
    299299}
    300 .entry-content .twitter-tweet-rendered { 
     300.entry-content .twitter-tweet-rendered {
    301301    max-width: 100% !important; /* Override the Twitter embed fixed width */
    302302}
Note: See TracChangeset for help on using the changeset viewer.