Embeds: Don't show embed discovery link on a static front page.
There's currently no iframe content being generated for a static front page. Giving out a link to that isn't an ideal user experience. Props peterwilsoncc. Fixes #35194 for trunk. git-svn-id: https://develop.svn.wordpress.org/trunk@36059 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1bf73525e8
commit
0b9d32a614
|
@ -345,7 +345,7 @@ function wp_oembed_register_route() {
|
|||
function wp_oembed_add_discovery_links() {
|
||||
$output = '';
|
||||
|
||||
if ( is_singular() ) {
|
||||
if ( is_singular() && ! is_front_page() ) {
|
||||
$output .= '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
|
||||
|
||||
if ( class_exists( 'SimpleXMLElement' ) ) {
|
||||
|
|
|
@ -8,6 +8,22 @@ class Tests_oEmbed_Discovery extends WP_UnitTestCase {
|
|||
$this->assertSame( '', get_echo( 'wp_oembed_add_discovery_links' ) );
|
||||
}
|
||||
|
||||
function test_add_oembed_discovery_links_front_page() {
|
||||
$this->go_to( home_url('/') );
|
||||
$this->assertSame( '', get_echo( 'wp_oembed_add_discovery_links' ) );
|
||||
}
|
||||
|
||||
function test_add_oembed_discovery_links_static_front_page() {
|
||||
update_option( 'show_on_front', 'page' );
|
||||
update_option( 'page_for_posts', self::factory()->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page' ) ) );
|
||||
update_option( 'page_on_front', self::factory()->post->create( array( 'post_title' => 'front-page', 'post_type' => 'page' ) ) );
|
||||
|
||||
$this->go_to( home_url('/') );
|
||||
$this->assertSame( '', get_echo( 'wp_oembed_add_discovery_links' ) );
|
||||
|
||||
update_option( 'show_on_front', 'posts' );
|
||||
}
|
||||
|
||||
function test_add_oembed_discovery_links_to_post() {
|
||||
$post_id = self::factory()->post->create();
|
||||
$this->go_to( get_permalink( $post_id ) );
|
||||
|
|
Loading…
Reference in New Issue