Make WordPress Core

Ticket #21443: 21443.diff

File 21443.diff, 5.4 KB (added by obenland, 13 years ago)
  • wp-content/themes/twentytwelve/inc/theme-options.php

     
    3737                if ( 'twentytwelve' != get_stylesheet() )
    3838                        $this->option_key = get_stylesheet() . '_theme_options';
    3939
    40                 add_action( 'admin_init',         array( $this, 'options_init'       ) );
    41                 add_action( 'admin_menu',         array( $this, 'add_page'           ) );
    42                 add_action( 'customize_register', array( $this, 'customize_register' ) );
     40                add_action( 'admin_init',             array( $this, 'options_init'         ) );
     41                add_action( 'admin_menu',             array( $this, 'add_page'             ) );
     42                add_action( 'customize_register',     array( $this, 'customize_register'   ) );
     43                add_action( 'customize_preview_init', array( $this, 'customize_preview_js' ) );
    4344        }
    4445
    4546        /**
     
    203204         * @return void
    204205         */
    205206        public function customize_register( $wp_customize ) {
     207               
     208                // Add postMessage support for site title and tagline
     209                $wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
     210                $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
     211               
    206212                // Enable Web Fonts
    207213                $wp_customize->add_section( $this->option_key . '_enable_fonts', array(
    208214                        'title'    => __( 'Fonts', 'twentytwelve' ),
     
    215221                        'default'    => $defaults['enable_fonts'],
    216222                        'type'       => 'option',
    217223                        'capability' => 'edit_theme_options',
     224                        'transport'  => 'postMessage',
    218225                ) );
    219226
    220227                $wp_customize->add_control( $this->option_key . '_enable_fonts', array(
     
    224231                        'type'     => 'checkbox',
    225232                ) );
    226233        }
     234       
     235        /**
     236         * Bind JS handlers to make Theme Customizer preview reload changes asynchronously.
     237         *
     238         * @since Twenty Twelve 1.0
     239         * @access public
     240         *
     241         * @return void
     242         */
     243        public function customize_preview_js() {
     244                wp_enqueue_script( 'twentytwelve-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20120725', true );
     245                wp_localize_script( 'twentytwelve-customizer', 'twentytwelve_customizer', array(
     246                        'option_key' => $this->option_key,
     247                        'style'      => "
     248@font-face {
     249  font-family: 'Open Sans';
     250  font-style: normal;
     251  font-weight: 700;
     252  src: local('Open Sans Bold'), local('OpenSans-Bold'), url(http://themes.googleusercontent.com/static/fonts/opensans/v6/k3k702ZOKiLJc3WVjuplzKRDOzjiPcYnFooOUGCOsRk.woff) format('woff');
     253}
     254@font-face {
     255  font-family: 'Open Sans';
     256  font-style: italic;
     257  font-weight: 700;
     258  src: local('Open Sans Bold Italic'), local('OpenSans-BoldItalic'), url(http://themes.googleusercontent.com/static/fonts/opensans/v6/PRmiXeptR36kaC0GEAetxhbnBKKEOwRKgsHDreGcocg.woff) format('woff');
     259}
     260@font-face {
     261  font-family: 'Open Sans';
     262  font-style: italic;
     263  font-weight: 400;
     264  src: local('Open Sans Italic'), local('OpenSans-Italic'), url(http://themes.googleusercontent.com/static/fonts/opensans/v6/xjAJXh38I15wypJXxuGMBrrIa-7acMAeDBVuclsi6Gc.woff) format('woff');
     265}
     266@font-face {
     267  font-family: 'Open Sans';
     268  font-style: normal;
     269  font-weight: 400;
     270  src: local('Open Sans'), local('OpenSans'), url(http://themes.googleusercontent.com/static/fonts/opensans/v6/cJZKeOuBrn4kERxqtaUH3bO3LdcAZYWl9Si6vvxL-qU.woff) format('woff');
     271}"
     272                ) );
     273        }
    227274}
     275 No newline at end of file
  • wp-content/themes/twentytwelve/functions.php

     
    369369                $content_width = 960;
    370370        }
    371371}
    372 add_action( 'template_redirect', 'twentytwelve_content_width' );
    373 
    374 /**
    375  * Bind JS handler to make Theme Customizer preview reload
    376  * custom background `body_class` value changes asynchronously.
    377  *
    378  * @since Twenty Twelve 1.0
    379  */
    380 function twentytwelve_customize_preview_js() {
    381         wp_enqueue_script( 'twentytwelve-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20120725', true );
    382 }
    383 add_action( 'customize_preview_init', 'twentytwelve_customize_preview_js' );
    384  No newline at end of file
     372add_action( 'template_redirect', 'twentytwelve_content_width' );
     373 No newline at end of file
  • wp-content/themes/twentytwelve/js/theme-customizer.js

     
    11( function( $ ){
     2        wp.customize( 'blogname', function( value ) {
     3                value.bind( function( to ) {
     4                        $( '.site-title a' ).html( to );
     5                } );
     6        } );
     7       
     8        wp.customize( 'blogdescription', function( value ) {
     9                value.bind( function( to ) {
     10                        $( '.site-description' ).html( to );
     11                } );
     12        } );
     13       
     14        wp.customize( twentytwelve_customizer.option_key + '[enable_fonts]', function( value ) {
     15                value.bind( function( to ) {
     16                        if ( to )
     17                                $( 'head' ).prepend('<style id="twentytwelve-fonts-css" type="text/css">' + twentytwelve_customizer.style + '</style>');
     18                        else
     19                                $( '#twentytwelve-fonts-css' ).remove();
     20                } );
     21        } );
     22       
    223        // Hook into background color change and adjust body class value as needed.
    324        wp.customize( 'background_color', function( value ) {
    425                var body = $( 'body' );