[wp-trac] [WordPress Trac] #35982: The new feature 'site logo' is not working on-the-fly (postMessage)
WordPress Trac
noreply at wordpress.org
Wed Mar 2 18:08:58 UTC 2016
#35982: The new feature 'site logo' is not working on-the-fly (postMessage)
-------------------------------+--------------------------
Reporter: sidati | Owner: westonruter
Type: defect (bug) | Status: accepted
Priority: normal | Milestone: 4.5
Component: Customize | Version: trunk
Severity: normal | Resolution:
Keywords: reporter-feedback | Focuses: javascript
-------------------------------+--------------------------
Changes (by westonruter):
* keywords: => reporter-feedback
* owner: => westonruter
* status: new => accepted
* milestone: Awaiting Review => 4.5
Comment:
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`:
{{{#!php
<?php
$this->add_setting( 'site_logo', array(
'theme_supports' => array( 'site-logo' ),
'transport' => 'postMessage',
) );
}}}
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()`:
{{{#!php
<?php
$this->selective_refresh->add_partial( 'site_logo', array(
'settings' => array( 'site_logo' ),
'selector' => '.site-logo-link',
'render_callback' => array( $this, '_render_site_logo_partial'
),
'container_inclusive' => true,
) );
}}}
If Selective Refresh doesn't find the element indicated by the `selector`,
it will trigger a refresh by default.
Two options I see for you to try:
1) Adjust the selector to match what your theme is actually using if you
have modified the output of `get_the_site_logo`:
{{{#!php
<?php
add_action( 'customize_register', function( $wp_customize ) {
$new_selector = '.my-site-logo';
$wp_customize->selective_refresh->get_partial( 'site_logo' )->selector
= $new_selector;
}, 20 );
}}}
2) Or, you can disable `fallback_refresh` entirely (which might be what we
want to do in Core):
{{{#!php
<?php
add_action( 'customize_register', function( $wp_customize ) {
$wp_customize->selective_refresh->get_partial( 'site_logo'
)->fallback_refresh = false;
}, 20 );
}}}
The downside if the selector isn't fixed is that the “Shift+click” to edit
won't work, and there will be an extra Ajax request to render the partial
but there won't be anything to render it into, so it will be wasted.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35982#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list