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/twentythirteen/functions.php

    r35885 r36797  
    536536    $wp_customize->get_setting( 'blogdescription' )->transport  = 'postMessage';
    537537    $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
     538
     539    if ( isset( $wp_customize->selective_refresh ) ) {
     540        $wp_customize->selective_refresh->add_partial( 'blogname', array(
     541            'selector' => '.site-title',
     542            'container_inclusive' => false,
     543            'render_callback' => 'twentythirteen_customize_partial_blogname',
     544        ) );
     545        $wp_customize->selective_refresh->add_partial( 'blogdescription', array(
     546            'selector' => '.site-description',
     547            'container_inclusive' => false,
     548            'render_callback' => 'twentythirteen_customize_partial_blogdescription',
     549        ) );
     550    }
    538551}
    539552add_action( 'customize_register', 'twentythirteen_customize_register' );
     553
     554/**
     555 * Render the site title for the selective refresh partial.
     556 *
     557 * @since Twenty Thirteen 1.9
     558 * @see twentythirteen_customize_register()
     559 *
     560 * @return void
     561 */
     562function twentythirteen_customize_partial_blogname() {
     563    bloginfo( 'name' );
     564}
     565
     566/**
     567 * Render the site tagline for the selective refresh partial.
     568 *
     569 * @since Twenty Thirteen 1.9
     570 * @see twentythirteen_customize_register()
     571 *
     572 * @return void
     573 */
     574function twentythirteen_customize_partial_blogdescription() {
     575    bloginfo( 'description' );
     576}
    540577
    541578/**
Note: See TracChangeset for help on using the changeset viewer.