From 2460e1b0c842e703f254f2444547eaacfa941a2c Mon Sep 17 00:00:00 2001 From: whyisjake Date: Fri, 7 Aug 2020 19:20:07 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/branches/5.5@48755 git-svn-id: http://core.svn.wordpress.org/branches/5.5@48517 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/general-template.php | 11 ++++++++--- wp-includes/theme.php | 12 +++++++----- wp-includes/version.php | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index f88e342ce2..6aa84ff654 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -1021,7 +1021,9 @@ function get_custom_logo( $blog_id = 0 ) { 'class' => 'custom-logo', ); - if ( is_front_page() ) { + $unlink_homepage_logo = (bool) get_theme_support( 'custom-logo', 'unlink-homepage-logo' ); + + if ( $unlink_homepage_logo && is_front_page() && ! is_paged() ) { /* * If on the home page, set the logo alt attribute to an empty string, * as the image is decorative and doesn't need its purpose to be described. @@ -1055,16 +1057,19 @@ function get_custom_logo( $blog_id = 0 ) { */ $image = wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr ); - if ( is_front_page() ) { + if ( $unlink_homepage_logo && is_front_page() && ! is_paged() ) { // If on the home page, don't link the logo to home. $html = sprintf( '%1$s', $image ); } else { + $aria_current = is_front_page() && ! is_paged() ? ' aria-current="page"' : ''; + $html = sprintf( - '%2$s', + '%3$s', esc_url( home_url( '/' ) ), + $aria_current, $image ); } diff --git a/wp-includes/theme.php b/wp-includes/theme.php index bdd1ec3f60..5ae5856e37 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -2472,6 +2472,7 @@ function get_theme_starter_content() { * @since 5.3.0 Formalized the existing and already documented `...$args` parameter * by adding it to the function signature. * @since 5.5.0 The `core-block-patterns` feature was added and is enabled by default. + * @since 5.5.0 The `custom-logo` feature now also accepts 'unlink-homepage-logo'. * * @global array $_wp_theme_features * @@ -2538,11 +2539,12 @@ function add_theme_support( $feature, ...$args ) { $args = array( 0 => array() ); } $defaults = array( - 'width' => null, - 'height' => null, - 'flex-width' => false, - 'flex-height' => false, - 'header-text' => '', + 'width' => null, + 'height' => null, + 'flex-width' => false, + 'flex-height' => false, + 'header-text' => '', + 'unlink-homepage-logo' => false, ); $args[0] = wp_parse_args( array_intersect_key( $args[0], $defaults ), $defaults ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 13f7231530..c5da3266fe 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-RC2-48752'; +$wp_version = '5.5-RC2-48755'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.