Make WordPress Core


Ignore:
Timestamp:
05/27/2024 04:39:13 PM (2 years ago)
Author:
joedolson
Message:

Themes: Accessibility: Logo block returns empty link when image not set.

The logo block does not use theme mods, and instead saves a site-wide option site_logo to use as the site logo.

Add handling for cases where the logo image does not exist and delete the site_logo option when the attachment configured as site logo is deleted.

Props afercia, joedolson, khokansardar, SergeyBiryukov.
Fixes #60922.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/theme.php

    r57987 r58213  
    34353435 * @since 4.3.0 Also removes `header_image_data`.
    34363436 * @since 4.5.0 Also removes custom logo theme mods.
     3437 * @since 6.6.0 Also removes `site_logo` option set by the site logo block.
    34373438 *
    34383439 * @param int $id The attachment ID.
    … …  
    34433444        $background_image = get_background_image();
    34443445        $custom_logo_id   = get_theme_mod( 'custom_logo' );
     3446        $site_logo_id     = get_option( 'site_logo' );
    34453447
    34463448        if ( $custom_logo_id && $custom_logo_id == $id ) {
    34473449                remove_theme_mod( 'custom_logo' );
    34483450                remove_theme_mod( 'header_text' );
     3451        }
     3452
     3453        if ( $site_logo_id && $site_logo_id == $id ) {
     3454                delete_option( 'site_logo' );
    34493455        }
    34503456
Note: See TracChangeset for help on using the changeset viewer.