Themes: Remove `itemprop="url"` from `get_custom_logo()` output.

Making incorrect assumptions about microdata used in a theme results in invalid markup.

The attribute can still be added using the `get_custom_logo` or `wp_get_attachment_image_attributes` filter, but it should not be added by default.

Props henry.wright, tfrommen, afercia, markcallen, zodiac1978.
Fixes #37305.

git-svn-id: https://develop.svn.wordpress.org/trunk@45028 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2019-03-27 12:15:15 +00:00
parent 716fa97607
commit 7ad9fb7e7c
2 changed files with 8 additions and 12 deletions

View File

@ -948,8 +948,7 @@ function get_custom_logo( $blog_id = 0 ) {
// We have a logo. Logo is go.
if ( $custom_logo_id ) {
$custom_logo_attr = array(
'class' => 'custom-logo',
'itemprop' => 'logo',
'class' => 'custom-logo',
);
/*
@ -966,7 +965,7 @@ function get_custom_logo( $blog_id = 0 ) {
* it because wp_get_attachment_image() already adds the alt attribute.
*/
$html = sprintf(
'<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>',
'<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 )
);

View File

@ -308,8 +308,7 @@ class Tests_General_Template extends WP_UnitTestCase {
$this->_set_custom_logo();
$custom_logo_attr = array(
'class' => 'custom-logo',
'itemprop' => 'logo',
'class' => 'custom-logo',
);
// If the logo alt attribute is empty, use the site title.
@ -322,7 +321,7 @@ class Tests_General_Template extends WP_UnitTestCase {
$image = wp_get_attachment_image( $this->custom_logo_id, 'full', false, $custom_logo_attr );
restore_current_blog();
$expected_custom_logo = '<a href="' . $home_url . '" class="custom-logo-link" rel="home" itemprop="url">' . $image . '</a>';
$expected_custom_logo = '<a href="' . $home_url . '" class="custom-logo-link" rel="home">' . $image . '</a>';
$this->assertEquals( $expected_custom_logo, get_custom_logo( $blog_id ) );
}
@ -338,8 +337,7 @@ class Tests_General_Template extends WP_UnitTestCase {
$this->_set_custom_logo();
$custom_logo_attr = array(
'class' => 'custom-logo',
'itemprop' => 'logo',
'class' => 'custom-logo',
);
// If the logo alt attribute is empty, use the site title.
@ -350,7 +348,7 @@ class Tests_General_Template extends WP_UnitTestCase {
$image = wp_get_attachment_image( $this->custom_logo_id, 'full', false, $custom_logo_attr );
$this->expectOutputString( '<a href="http://' . WP_TESTS_DOMAIN . '/" class="custom-logo-link" rel="home" itemprop="url">' . $image . '</a>' );
$this->expectOutputString( '<a href="http://' . WP_TESTS_DOMAIN . '/" class="custom-logo-link" rel="home">' . $image . '</a>' );
the_custom_logo();
}
@ -370,12 +368,11 @@ class Tests_General_Template extends WP_UnitTestCase {
'full',
false,
array(
'class' => 'custom-logo',
'itemprop' => 'logo',
'class' => 'custom-logo',
)
);
$this->expectOutputString( '<a href="http://' . WP_TESTS_DOMAIN . '/" class="custom-logo-link" rel="home" itemprop="url">' . $image . '</a>' );
$this->expectOutputString( '<a href="http://' . WP_TESTS_DOMAIN . '/" class="custom-logo-link" rel="home">' . $image . '</a>' );
the_custom_logo();
}