WordPress.org

Make WordPress Core

Changeset 36797


Ignore:
Timestamp:
03/01/16 22:17:20 (20 months 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.

Location:
trunk/src/wp-content/themes
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyeleven/inc/theme-options.php

    r32314 r36797  
    511511    $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; 
    512512 
     513    if ( isset( $wp_customize->selective_refresh ) ) { 
     514        $wp_customize->selective_refresh->add_partial( 'blogname', array( 
     515            'selector' => '#site-title a', 
     516            'container_inclusive' => false, 
     517            'render_callback' => 'twentyeleven_customize_partial_blogname', 
     518        ) ); 
     519        $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 
     520            'selector' => '#site-description', 
     521            'container_inclusive' => false, 
     522            'render_callback' => 'twentyeleven_customize_partial_blogdescription', 
     523        ) ); 
     524    } 
     525 
    513526    $options  = twentyeleven_get_theme_options(); 
    514527    $defaults = twentyeleven_get_default_theme_options(); 
     
    576589 
    577590/** 
     591 * Render the site title for the selective refresh partial. 
     592 * 
     593 * @since Twenty Eleven 2.4 
     594 * @see twentyeleven_customize_register() 
     595 * 
     596 * @return void 
     597 */ 
     598function twentyeleven_customize_partial_blogname() { 
     599    bloginfo( 'name' ); 
     600} 
     601 
     602/** 
     603 * Render the site tagline for the selective refresh partial. 
     604 * 
     605 * @since Twenty Eleven 2.4 
     606 * @see twentyeleven_customize_register() 
     607 * 
     608 * @return void 
     609 */ 
     610function twentyeleven_customize_partial_blogdescription() { 
     611    bloginfo( 'description' ); 
     612} 
     613 
     614/** 
    578615 * Bind JS handlers to make Customizer preview reload changes asynchronously. 
    579616 * 
  • 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/** 
  • 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/** 
  • 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/** 
  • 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.