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
This commit is contained in:
Sergey Biryukov 2020-06-14 10:02:11 +00:00
parent e6ee3f742e
commit 01eb2907a7
2 changed files with 23 additions and 12 deletions

View File

@ -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(
'<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>',
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(
'<span class="custom-logo-link">%1$s</span>',
$image
);
} else {
$html = sprintf(
'<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>',
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
*

View File

@ -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.