From afdf1c9ec17bbd8eb9ee52252ee9c99d92fed550 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 7 Mar 2016 09:59:02 +0000 Subject: [PATCH] Embeds: Adjust the iframe title attribute for improved accessibility. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/wp-includes/embed.php | 9 ++++++++- tests/phpunit/tests/oembed/template.php | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/embed.php b/src/wp-includes/embed.php index 8c79cc8722..b002b5cc95 100644 --- a/src/wp-includes/embed.php +++ b/src/wp-includes/embed.php @@ -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' ) + ) + ) ); /** diff --git a/tests/phpunit/tests/oembed/template.php b/tests/phpunit/tests/oembed/template.php index 21fd4851e8..fd9fddd2b7 100644 --- a/tests/phpunit/tests/oembed/template.php +++ b/tests/phpunit/tests/oembed/template.php @@ -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 = ''; + $expected = ''; $this->assertStringEndsWith( $expected, get_post_embed_html( 200, 200, $post_id ) ); }