Embeds: Adjust the iframe title attribute for improved accessibility.
Changes the title attribute from `Embedded WordPress Post` to `"Post name" — site title`. Props ramiy. Fixes #35804. git-svn-id: https://develop.svn.wordpress.org/trunk@36873 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e9dbf32553
commit
afdf1c9ec1
@ -490,7 +490,14 @@ JS;
|
||||
esc_url( $embed_url ),
|
||||
absint( $width ),
|
||||
absint( $height ),
|
||||
esc_attr__( 'Embedded WordPress Post' )
|
||||
esc_attr(
|
||||
sprintf(
|
||||
/* translators: 1: post title, 2: site name */
|
||||
__( '“%1$s” — %2$s' ),
|
||||
get_the_title( $post ),
|
||||
get_bloginfo( 'name' )
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -242,8 +242,15 @@ class Tests_Embed_Template extends WP_UnitTestCase {
|
||||
|
||||
function test_get_post_embed_html() {
|
||||
$post_id = self::factory()->post->create();
|
||||
$title = esc_attr(
|
||||
sprintf(
|
||||
__( '“%1$s” — %2$s' ),
|
||||
get_the_title( $post_id ),
|
||||
get_bloginfo( 'name' )
|
||||
)
|
||||
);
|
||||
|
||||
$expected = '<iframe sandbox="allow-scripts" security="restricted" src="' . esc_url( get_post_embed_url( $post_id ) ) . '" width="200" height="200" title="Embedded WordPress Post" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe>';
|
||||
$expected = '<iframe sandbox="allow-scripts" security="restricted" src="' . esc_url( get_post_embed_url( $post_id ) ) . '" width="200" height="200" title="' . $title . '" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe>';
|
||||
|
||||
$this->assertStringEndsWith( $expected, get_post_embed_html( 200, 200, $post_id ) );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user