Make WordPress Core


Ignore:
Timestamp:
01/15/2016 07:55:19 AM (9 years ago)
Author:
swissspidy
Message:

Embeds: Allow embedding static front pages and pages having a child page with an embed slug.

This makes embed a special slug that can't be used for new pages/posts. When https://example.com/foo/embed/ is an existing page, embeds fall back to https://example.com/foo/?embed=true.
Adds unit tests.

Fixes #34971.

File:
1 edited

Legend:

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

    r36059 r36307  
    346346    $output = '';
    347347
    348     if ( is_singular() && ! is_front_page() ) {
     348    if ( is_singular() ) {
    349349        $output .= '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
    350350
     
    388388    }
    389389
    390     if ( get_option( 'permalink_structure' ) ) {
    391         $embed_url = trailingslashit( get_permalink( $post ) ) . user_trailingslashit( 'embed' );
    392     } else {
     390    $embed_url     = trailingslashit( get_permalink( $post ) ) . user_trailingslashit( 'embed' );
     391    $path_conflict = get_page_by_path( str_replace( home_url(), '', $embed_url ), OBJECT, get_post_types( array( 'public' => true ) ) );
     392
     393    if ( ! get_option( 'permalink_structure' ) || $path_conflict ) {
    393394        $embed_url = add_query_arg( array( 'embed' => 'true' ), get_permalink( $post ) );
    394395    }
Note: See TracChangeset for help on using the changeset viewer.