mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
Themes: Improve the theme Custom Logo accessibility.
Uses the Site title as fallback value for the Custom Logo alt attribute when the original alt attribute is empty. Props sami.keijonen, joedolson, sstoqnov, nobremarcos, gma992, LiamMcArthur, jjcomack. Fixes #38768. git-svn-id: https://develop.svn.wordpress.org/trunk@40817 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -307,11 +307,20 @@ class Tests_General_Template extends WP_UnitTestCase {
|
||||
switch_to_blog( $blog_id );
|
||||
|
||||
$this->_set_custom_logo();
|
||||
|
||||
$custom_logo_attr = array(
|
||||
'class' => 'custom-logo',
|
||||
'itemprop' => 'logo',
|
||||
);
|
||||
|
||||
// If the logo alt attribute is empty, use the site title.
|
||||
$image_alt = get_post_meta( $this->custom_logo_id, '_wp_attachment_image_alt', true );
|
||||
if ( empty( $image_alt ) ) {
|
||||
$custom_logo_attr['alt'] = get_bloginfo( 'name', 'display' );
|
||||
}
|
||||
|
||||
$home_url = get_home_url( $blog_id, '/' );
|
||||
$image = wp_get_attachment_image( $this->custom_logo_id, 'full', false, array(
|
||||
'class' => 'custom-logo',
|
||||
'itemprop' => 'logo',
|
||||
) );
|
||||
$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>';
|
||||
@@ -328,9 +337,38 @@ class Tests_General_Template extends WP_UnitTestCase {
|
||||
the_custom_logo();
|
||||
|
||||
$this->_set_custom_logo();
|
||||
|
||||
$custom_logo_attr = array(
|
||||
'class' => 'custom-logo',
|
||||
'itemprop' => 'logo',
|
||||
);
|
||||
|
||||
// If the logo alt attribute is empty, use the site title.
|
||||
$image_alt = get_post_meta( $this->custom_logo_id, '_wp_attachment_image_alt', true );
|
||||
if ( empty( $image_alt ) ) {
|
||||
$custom_logo_attr['alt'] = get_bloginfo( 'name', 'display' );
|
||||
}
|
||||
|
||||
$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>' );
|
||||
the_custom_logo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @group custom_logo
|
||||
* @ticket 38768
|
||||
*/
|
||||
function test_the_custom_logo_with_alt() {
|
||||
$this->_set_custom_logo();
|
||||
|
||||
$image_alt = 'My alt attribute';
|
||||
|
||||
update_post_meta( $this->custom_logo_id, '_wp_attachment_image_alt', $image_alt );
|
||||
|
||||
$image = wp_get_attachment_image( $this->custom_logo_id, 'full', false, array(
|
||||
'class' => 'custom-logo',
|
||||
'itemprop' => 'logo',
|
||||
'class' => 'custom-logo',
|
||||
'itemprop' => 'logo',
|
||||
) );
|
||||
|
||||
$this->expectOutputString( '<a href="http://' . WP_TESTS_DOMAIN . '/" class="custom-logo-link" rel="home" itemprop="url">' . $image . '</a>' );
|
||||
|
||||
Reference in New Issue
Block a user