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/twentyfifteen/inc/customizer.php

    r34791 r36797  
    2020    $wp_customize->get_setting( 'blogname' )->transport        = 'postMessage';
    2121    $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
     22
     23    if ( isset( $wp_customize->selective_refresh ) ) {
     24        $wp_customize->selective_refresh->add_partial( 'blogname', array(
     25            'selector' => '.site-title a',
     26            'container_inclusive' => false,
     27            'render_callback' => 'twentyfifteen_customize_partial_blogname',
     28        ) );
     29        $wp_customize->selective_refresh->add_partial( 'blogdescription', array(
     30            'selector' => '.site-description',
     31            'container_inclusive' => false,
     32            'render_callback' => 'twentyfifteen_customize_partial_blogdescription',
     33        ) );
     34    }
    2235
    2336    // Add color scheme setting and control.
     
    6982}
    7083add_action( 'customize_register', 'twentyfifteen_customize_register', 11 );
     84
     85/**
     86 * Render the site title for the selective refresh partial.
     87 *
     88 * @since Twenty Fifteen 1.5
     89 * @see twentyfifteen_customize_register()
     90 *
     91 * @return void
     92 */
     93function twentyfifteen_customize_partial_blogname() {
     94    bloginfo( 'name' );
     95}
     96
     97/**
     98 * Render the site tagline for the selective refresh partial.
     99 *
     100 * @since Twenty Fifteen 1.5
     101 * @see twentyfifteen_customize_register()
     102 *
     103 * @return void
     104 */
     105function twentyfifteen_customize_partial_blogdescription() {
     106    bloginfo( 'description' );
     107}
    71108
    72109/**
Note: See TracChangeset for help on using the changeset viewer.