WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/01/2016 10:17:20 PM (6 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/twentyfourteen/inc/customizer.php

    r32116 r36797  
    2020    $wp_customize->get_setting( 'blogdescription' )->transport  = 'postMessage';
    2121    $wp_customize->get_setting( 'header_textcolor' )->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' => 'twentyfourteen_customize_partial_blogname',
     28        ) );
     29        $wp_customize->selective_refresh->add_partial( 'blogdescription', array(
     30            'selector' => '.site-description',
     31            'container_inclusive' => false,
     32            'render_callback' => 'twentyfourteen_customize_partial_blogdescription',
     33        ) );
     34    }
    2235
    2336    // Rename the label to "Site Title Color" because this only affects the site title in this theme.
     
    6477}
    6578add_action( 'customize_register', 'twentyfourteen_customize_register' );
     79
     80/**
     81 * Render the site title for the selective refresh partial.
     82 *
     83 * @since Twenty Fourteen 1.7
     84 * @see twentyfourteen_customize_register()
     85 *
     86 * @return void
     87 */
     88function twentyfourteen_customize_partial_blogname() {
     89    bloginfo( 'name' );
     90}
     91
     92/**
     93 * Render the site tagline for the selective refresh partial.
     94 *
     95 * @since Twenty Fourteen 1.7
     96 * @see twentyfourteen_customize_register()
     97 *
     98 * @return void
     99 */
     100function twentyfourteen_customize_partial_blogdescription() {
     101    bloginfo( 'description' );
     102}
    66103
    67104/**
Note: See TracChangeset for help on using the changeset viewer.