Making WordPress.org

Changeset 4111


Ignore:
Timestamp:
09/20/2016 07:06:47 PM (9 years ago)
Author:
ocean90
Message:

Breathe: Restore postMessage support for site title and and description in the customizer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe/functions.php

    r4109 r4111  
    22namespace WordPressdotorg\Make\Breathe;
    33
     4/**
     5 * Sets up theme defaults.
     6 */
    47function after_setup_theme() {
    58    remove_theme_support( 'custom-header' );
     
    912    remove_action( 'customize_preview_init', 'breathe_customize_preview_js' );
    1013    remove_filter( 'wp_head', 'breathe_color_styles' );
     14
     15    add_action( 'customize_register', __NAMESPACE__ . '\customize_register' );
    1116}
    1217add_action( 'after_setup_theme', __NAMESPACE__ . '\after_setup_theme', 11 );
     18
     19/**
     20 * Add postMessage support for site title and description in the customizer.
     21 *
     22 * @param WP_Customize_Manager $wp_customize The customizer object.
     23 */
     24function customize_register( $wp_customize ) {
     25    $wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
     26    $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
     27
     28    if ( isset( $wp_customize->selective_refresh ) ) {
     29        $wp_customize->selective_refresh->add_partial( 'blogname', [
     30            'selector'            => '.site-title a',
     31            'container_inclusive' => false,
     32            'render_callback'     => __NAMESPACE__ . '\customize_partial_blogname',
     33        ] );
     34    }
     35}
     36
     37/**
     38 * Renders the site title for the selective refresh partial.
     39 */
     40function customize_partial_blogname() {
     41    bloginfo( 'name' );
     42}
    1343
    1444function styles() {
Note: See TracChangeset for help on using the changeset viewer.