Make WordPress Core

Opened 7 years ago

Closed 5 years ago

Last modified 4 years ago

#43081 closed defect (bug) (invalid)

Custom logo issue in Customizer

Reported by: guido07111975's profile Guido07111975 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Customize Keywords:
Focuses: Cc:

Description

Hi,

Almost 2 years ago I've started a thread about an issue with the custom logo in customizer. Link: https://wordpress.org/support/topic/custom-logo-issue-in-customizer/

Until now it's not fixed.

In short, this doesn't behave as expected:

<?php if ( has_custom_logo() ) : ?>
	<?php the_custom_logo(); ?>
<?php else : ?>
	<h1>Site Title</h1>
	<h2>Tagline</h2>
<?php endif; ?>

Once a custom logo is set, and removed again in the same session, Site Title and Tagline aren't displayed. You need to close and re-visit the customizer, to make Site Title and Tagline visible again.

It seems the custom logo stays active, after removing the logo (image) in the same session.

Guido

Change History (4)

#1 @lrdn
7 years ago

The custom logo setting uses the postMessage transport by default which requires changes to be handled manually using JavaScript. You can however simply override the transport setting with refresh to automatically reload the preview. In my opinion that's not a bug and won't require any changes to the WordPress core.

<?php

function custom_logo_setup()
{
        add_theme_support('custom-logo', array
        (
                'width' => 250,
                'height' => 250,
                'flex-width' => true
        ));
}
add_action('after_setup_theme', 'custom_logo_setup');

function custom_logo_settings($wp_customize)
{
        $wp_customize->get_setting('custom_logo')->transport = 'refresh';
}
add_action('customize_register', 'custom_logo_settings');

#2 @Guido07111975
7 years ago

Hi @lrdn

Your fix works fine, so thank you for that.

I don't have enough knowledge to determine whether this should be fixed in core or not.. so let's wait what others say.

Thanks again :-)

Guido

#3 @dlh
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
  • Version 4.9.1 deleted

I agree with comment:1 that the current behavior is expected given the use of the postMessage transport. Changing the setting to refresh is one way to work around the behavior if the theme isn't set up for postMessage. The default themes also showcase how the custom logo can be integrated with the Customizer's selective refresh framework.

#4 @dlh
4 years ago

#51015 was marked as a duplicate.

Note: See TracTickets for help on using tickets.