Make WordPress Core

Ticket #19910: twentyeleven-customize.diff

File twentyeleven-customize.diff, 1.5 KB (added by Otto42, 13 years ago)

Patch for twentyeleven to support postMessage updating of title, description, and header text-color

  • wp-content/themes/twentyeleven/functions.php

     
    586586}
    587587add_filter( 'body_class', 'twentyeleven_body_classes' );
    588588
     589function twentyeleven_customize_include() {
     590        global $wp_customize;
     591        if ( !isset( $wp_customize ) )
     592                return;
     593
     594        $sett = $wp_customize->get_setting('blogname');
     595        $sett->transport='postMessage';
     596
     597        $sett = $wp_customize->get_setting('blogdescription');
     598        $sett->transport='postMessage';
     599       
     600        $sett = $wp_customize->get_setting('header_textcolor');
     601        $sett->transport='postMessage';
     602}
     603add_action( 'customize_register', 'twentyeleven_customize_include' );
     604
     605function twentyeleven_customize_footer() {
     606        add_action( 'wp_footer', 'twentyeleven_customize_preview', 21);
     607}
     608add_action( 'customize_preview_init', 'twentyeleven_customize_footer' );
     609
     610function twentyeleven_customize_preview() {
     611        ?>
     612        <script type="text/javascript">
     613        wp.customize('blogname',function( value ) {
     614                value.bind(function(to) {
     615                        jQuery('#site-title a').html(to);
     616                });
     617        });
     618        wp.customize('blogdescription',function( value ) {
     619                value.bind(function(to) {
     620                        jQuery('#site-description').html(to);
     621                });
     622        });
     623        wp.customize( 'header_textcolor', function( value ) {
     624                value.bind( function( to ) {
     625                        jQuery('#site-title a, #site-description').css('color', to ? '#' + to : '' );
     626                });
     627        });
     628        </script>
     629        <?php
     630}