WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/07/2020 07:18:19 PM (6 months ago)
Author:
whyisjake
Message:

Accessibility: Themes: Only unlink custom logo on the home page if the theme declares support for that.

To accommodate for the change, the custom-logo theme feature now accepts the unlink-homepage-logo parameter.

If and when the logo is linked on the home page, the link has the aria-current attribute for better accessibility.

Follow-up to [48039], [48283], see [48749].

This brings the changes to the 5.5 branch.

Props sabernhardt, audrasjb, johnstonphilip, demetris, SergeyBiryukov.
Fixes #37011.

Location:
branches/5.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.5

  • branches/5.5/src/wp-includes/general-template.php

    r48674 r48755  
    10221022        );
    10231023
    1024         if ( is_front_page() ) {
     1024        $unlink_homepage_logo = (bool) get_theme_support( 'custom-logo', 'unlink-homepage-logo' );
     1025
     1026        if ( $unlink_homepage_logo && is_front_page() && ! is_paged() ) {
    10251027            /*
    10261028             * If on the home page, set the logo alt attribute to an empty string,
     
    10561058        $image = wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr );
    10571059
    1058         if ( is_front_page() ) {
     1060        if ( $unlink_homepage_logo && is_front_page() && ! is_paged() ) {
    10591061            // If on the home page, don't link the logo to home.
    10601062            $html = sprintf(
     
    10631065            );
    10641066        } else {
     1067            $aria_current = is_front_page() && ! is_paged() ? ' aria-current="page"' : '';
     1068
    10651069            $html = sprintf(
    1066                 '<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>',
     1070                '<a href="%1$s" class="custom-logo-link" rel="home"%2$s>%3$s</a>',
    10671071                esc_url( home_url( '/' ) ),
     1072                $aria_current,
    10681073                $image
    10691074            );
Note: See TracChangeset for help on using the changeset viewer.