WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/07/2016 07:33:01 PM (3 years ago)
Author:
swissspidy
Message:

Embeds: Add support for embeds in the theme template hierarchy.

This allows themes to directly override the default template. The order in which the template is retrieved is as follows: embed-$post_type-$post_format.php -> embed-$post_type.php -> embed.php.

The embed_template filter gets replaced by the dynamic {$type}_template filter in get_query_template().

Props ChriCo, swissspidy.
See #34561. Fixes #34278.

File:
1 edited

Legend:

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

    r36693 r36876  
    4040    include( ABSPATH . 'wp-trackback.php' );
    4141    return;
    42 elseif ( is_embed() ) :
    43     $template = ABSPATH . WPINC . '/theme-compat/embed.php';
    44 
    45     /**
    46      * Filter the template used for embedded posts.
    47      *
    48      * @since 4.4.0
    49      * @since 4.5.0 The default template path changed to wp-includes/theme-compat/embed.php
    50      *
    51      * @param string $template Path to the template file.
    52      */
    53     $template = apply_filters( 'embed_template', $template );
    54 
    55     include ( $template );
    56     return;
    5742endif;
    5843
    5944if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) :
    6045    $template = false;
    61     if     ( is_404()            && $template = get_404_template()            ) :
     46    if     ( is_embed()          && $template = get_embed_template()          ) :
     47    elseif ( is_404()            && $template = get_404_template()            ) :
    6248    elseif ( is_search()         && $template = get_search_template()         ) :
    6349    elseif ( is_front_page()     && $template = get_front_page_template()     ) :
Note: See TracChangeset for help on using the changeset viewer.