From 7ad9fb7e7c0866611cfe33b5455abac6c24c5954 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 27 Mar 2019 12:15:15 +0000 Subject: [PATCH] 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 --- src/wp-includes/general-template.php | 5 ++--- tests/phpunit/tests/general/template.php | 15 ++++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index ae207d2715..837770f519 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -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( - '', + '%2$s', esc_url( home_url( '/' ) ), wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr ) ); diff --git a/tests/phpunit/tests/general/template.php b/tests/phpunit/tests/general/template.php index 8e0567c82e..daa77da5b9 100644 --- a/tests/phpunit/tests/general/template.php +++ b/tests/phpunit/tests/general/template.php @@ -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 = ''; + $expected_custom_logo = '' . $image . ''; $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( '' ); + $this->expectOutputString( '' . $image . '' ); 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( '' ); + $this->expectOutputString( '' . $image . '' ); the_custom_logo(); }