Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #35982, comment 1


Ignore:
Timestamp:
07/28/2016 08:22:23 PM (9 years ago)
Author:
westonruter
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #35982, comment 1

    initial v1  
    1 This sounds an issue related to Selective Refresh (#27355), where the site logo gets rendered with PHP filters applied after an initial purely JS preview. I haven't been able to reproduce the issue with the entire preview not refreshing in Twenty Sixteen. Note that in Core, the `site_logo` setting is already added with `postMessage`:
     1This sounds an issue related to Selective Refresh (#27355), where the site logo gets rendered with PHP filters applied after an initial purely JS preview. I haven't been able to reproduce the issue with the entire preview not refreshing in Twenty Sixteen. Note that in Core, the `custom_logo` setting is already added with `postMessage`:
    22
    33{{{#!php
    44<?php
    5 $this->add_setting( 'site_logo', array(
    6         'theme_supports' => array( 'site-logo' ),
     5$this->add_setting( 'custom_logo', array(
     6        'theme_supports' => array( 'custom-logo' ),
    77        'transport'      => 'postMessage',
    88) );
    99}}}
    1010
    11 Is your site logo including the `site-logo-link` CSS class name as is output by `get_the_site_logo()`? Selective refresh will be looking for an element with this class. Here is how the `site_logo` partial is registered in `WP_Customize_Manager::register_controls()`:
     11Is your site logo including the `custom-logo-link` CSS class name as is output by `get_custom_logo()`? Selective refresh will be looking for an element with this class. Here is how the `custom_logo` partial is registered in `WP_Customize_Manager::register_controls()`:
    1212
    1313{{{#!php
    1414<?php
    15 $this->selective_refresh->add_partial( 'site_logo', array(
    16         'settings'            => array( 'site_logo' ),
    17         'selector'            => '.site-logo-link',
    18         'render_callback'     => array( $this, '_render_site_logo_partial' ),
     15$this->selective_refresh->add_partial( 'custom_logo', array(
     16        'settings'            => array( 'custom_logo' ),
     17        'selector'            => '.custom-logo-link',
     18        'render_callback'     => array( $this, '_render_custom_logo_partial' ),
    1919        'container_inclusive' => true,
    2020) );
     
    2525Two options I see for you to try:
    2626
    27 1) Adjust the selector to match what your theme is actually using if you have modified the output of `get_the_site_logo`:
     271) Adjust the selector to match what your theme is actually using if you have modified the output of `get_custom_logo`:
    2828
    2929{{{#!php
    3030<?php
    3131add_action( 'customize_register', function( $wp_customize ) {
    32     $new_selector = '.my-site-logo';
    33     $wp_customize->selective_refresh->get_partial( 'site_logo' )->selector = $new_selector;
     32    $new_selector = '.my-custom-logo';
     33    $wp_customize->selective_refresh->get_partial( 'custom_logo' )->selector = $new_selector;
    3434}, 20 );
    3535}}}
     
    4040<?php
    4141add_action( 'customize_register', function( $wp_customize ) {
    42     $wp_customize->selective_refresh->get_partial( 'site_logo' )->fallback_refresh = false;
     42    $wp_customize->selective_refresh->get_partial( 'custom_logo' )->fallback_refresh = false;
    4343}, 20 );
    4444}}}