Make WordPress Core

Changeset 48039


Ignore:
Timestamp:
06/14/2020 10:00:47 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Accessibility: Themes: Don't link to the home page in get_custom_logo() when it's displayed on the home page.

Props Soean, audrasjb, sabernhardt, FlorianBrinkmann, rianrietveld, afercia, joedolson, samful, knutsp, SergeyBiryukov.
See #37011.

File:
1 edited

Legend:

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

    r47808 r48039  
    941941
    942942/**
    943  * Returns a custom logo, linked to home.
     943 * Returns a custom logo, linked to home when on another page.
    944944 *
    945945 * @since 4.5.0
     946 * @since 5.5.0 Removed the link on the home page.
    946947 *
    947948 * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
     
    966967
    967968        /*
    968          * If the logo alt attribute is empty, get the site title and explicitly
    969          * pass it to the attributes used by wp_get_attachment_image().
     969         * If the logo alt attribute is empty, get the site title and explicitly pass it
     970         * to the attributes used by wp_get_attachment_image().
    970971         */
    971972        $image_alt = get_post_meta( $custom_logo_id, '_wp_attachment_image_alt', true );
     
    975976
    976977        /*
    977          * If the alt attribute is not empty, there's no need to explicitly pass
    978          * it because wp_get_attachment_image() already adds the alt attribute.
     978         * If the alt attribute is not empty, there's no need to explicitly pass it
     979         * because wp_get_attachment_image() already adds the alt attribute.
    979980         */
    980         $html = sprintf(
    981             '<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>',
    982             esc_url( home_url( '/' ) ),
    983             wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr )
    984         );
     981        $image = wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr );
     982
     983        if ( is_front_page() ) {
     984            // If on the home page, don't link the logo to home.
     985            $html = sprintf(
     986                '<span class="custom-logo-link">%1$s</span>',
     987                $image
     988            );
     989        } else {
     990            $html = sprintf(
     991                '<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>',
     992                esc_url( home_url( '/' ) ),
     993                $image
     994            );
     995        }
    985996    } elseif ( is_customize_preview() ) {
    986997        // If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
     
    10081019
    10091020/**
    1010  * Displays a custom logo, linked to home.
     1021 * Displays a custom logo, linked to home when on another page.
    10111022 *
    10121023 * @since 4.5.0
Note: See TracChangeset for help on using the changeset viewer.