Make WordPress Core

Changeset 36059


Ignore:
Timestamp:
12/22/2015 10:49:20 AM (11 years ago)
Author:
pento
Message:

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.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/embed.php

    r35718 r36059  
    346346        $output = '';
    347347
    348         if ( is_singular() ) {
     348        if ( is_singular() && ! is_front_page() ) {
    349349                $output .= '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
    350350
  • trunk/tests/phpunit/tests/oembed/discovery.php

    r35436 r36059  
    77        function test_add_oembed_discovery_links_non_singular() {
    88                $this->assertSame( '', get_echo( 'wp_oembed_add_discovery_links' ) );
     9        }
     10
     11        function test_add_oembed_discovery_links_front_page() {
     12                $this->go_to( home_url('/') );
     13                $this->assertSame( '', get_echo( 'wp_oembed_add_discovery_links' ) );
     14        }
     15
     16        function test_add_oembed_discovery_links_static_front_page() {
     17                update_option( 'show_on_front', 'page' );
     18                update_option( 'page_for_posts', self::factory()->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page' ) ) );
     19                update_option( 'page_on_front', self::factory()->post->create( array( 'post_title' => 'front-page', 'post_type' => 'page' ) ) );
     20
     21                $this->go_to( home_url('/') );
     22                $this->assertSame( '', get_echo( 'wp_oembed_add_discovery_links' ) );
     23
     24                update_option( 'show_on_front', 'posts' );
    925        }
    1026
Note: See TracChangeset for help on using the changeset viewer.