Make WordPress Core


Ignore:
Timestamp:
03/01/2016 10:17:20 PM (9 years ago)
Author:
westonruter
Message:

Customize: Use selective refresh to preview changes to site title and tagline in core themes.

Fixes issue where wptexturize and other filters fail to apply when previewing changes via postMessage transport.

See #27355.
Fixes #33738.

File:
1 edited

Legend:

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

    r36709 r36797  
    481481    $wp_customize->get_setting( 'blogdescription' )->transport  = 'postMessage';
    482482    $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
     483
     484    if ( isset( $wp_customize->selective_refresh ) ) {
     485        $wp_customize->selective_refresh->add_partial( 'blogname', array(
     486            'selector' => '.site-title > a',
     487            'container_inclusive' => false,
     488            'render_callback' => 'twentytwelve_customize_partial_blogname',
     489        ) );
     490        $wp_customize->selective_refresh->add_partial( 'blogdescription', array(
     491            'selector' => '.site-description',
     492            'container_inclusive' => false,
     493            'render_callback' => 'twentytwelve_customize_partial_blogdescription',
     494        ) );
     495    }
    483496}
    484497add_action( 'customize_register', 'twentytwelve_customize_register' );
     498
     499/**
     500 * Render the site title for the selective refresh partial.
     501 *
     502 * @since Twenty Twelve 2.0
     503 * @see twentytwelve_customize_register()
     504 *
     505 * @return void
     506 */
     507function twentytwelve_customize_partial_blogname() {
     508    bloginfo( 'name' );
     509}
     510
     511/**
     512 * Render the site tagline for the selective refresh partial.
     513 *
     514 * @since Twenty Twelve 2.0
     515 * @see twentytwelve_customize_register()
     516 *
     517 * @return void
     518 */
     519function twentytwelve_customize_partial_blogdescription() {
     520    bloginfo( 'description' );
     521}
    485522
    486523/**
Note: See TracChangeset for help on using the changeset viewer.