From 01eb2907a73dd96daae6de7683681c0a12969315 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 14 Jun 2020 10:02:11 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@48039 git-svn-id: http://core.svn.wordpress.org/trunk@47806 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/general-template.php | 33 +++++++++++++++++++++----------- wp-includes/version.php | 2 +- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 82c138cef7..5e9ce46f09 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -940,9 +940,10 @@ function has_custom_logo( $blog_id = 0 ) { } /** - * Returns a custom logo, linked to home. + * Returns a custom logo, linked to home when on another page. * * @since 4.5.0 + * @since 5.5.0 Removed the link on the home page. * * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog. * @return string Custom logo markup. @@ -965,8 +966,8 @@ function get_custom_logo( $blog_id = 0 ) { ); /* - * If the logo alt attribute is empty, get the site title and explicitly - * pass it to the attributes used by wp_get_attachment_image(). + * If the logo alt attribute is empty, get the site title and explicitly pass it + * to the attributes used by wp_get_attachment_image(). */ $image_alt = get_post_meta( $custom_logo_id, '_wp_attachment_image_alt', true ); if ( empty( $image_alt ) ) { @@ -974,14 +975,24 @@ function get_custom_logo( $blog_id = 0 ) { } /* - * If the alt attribute is not empty, there's no need to explicitly pass - * it because wp_get_attachment_image() already adds the alt attribute. + * If the alt attribute is not empty, there's no need to explicitly pass it + * because wp_get_attachment_image() already adds the alt attribute. */ - $html = sprintf( - '%2$s', - esc_url( home_url( '/' ) ), - wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr ) - ); + $image = wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr ); + + if ( is_front_page() ) { + // If on the home page, don't link the logo to home. + $html = sprintf( + '%1$s', + $image + ); + } else { + $html = sprintf( + '%2$s', + esc_url( home_url( '/' ) ), + $image + ); + } } elseif ( is_customize_preview() ) { // If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview). $html = sprintf( @@ -1007,7 +1018,7 @@ function get_custom_logo( $blog_id = 0 ) { } /** - * Displays a custom logo, linked to home. + * Displays a custom logo, linked to home when on another page. * * @since 4.5.0 * diff --git a/wp-includes/version.php b/wp-includes/version.php index b1d29f1ce9..9cd49de85c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-48038'; +$wp_version = '5.5-alpha-48039'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.