Make WordPress Core


Ignore:
Timestamp:
08/28/2012 02:18:43 AM (12 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.
File:
1 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' );
Note: See TracChangeset for help on using the changeset viewer.