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.

git-svn-id: https://develop.svn.wordpress.org/trunk@36876 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler
2016-03-07 19:33:01 +00:00
parent ae79b4f91f
commit bae3fb43a5
2 changed files with 33 additions and 16 deletions

View File

@@ -404,6 +404,37 @@ function get_single_template() {
return get_query_template( 'single', $templates );
}
/**
* Retrieve path of embed template in current or parent template.
* By default the WordPress-template is returned.
*
* The template path is filterable via the dynamic {@see '$type_template'} hook,
* e.g. 'embed_template'.
*
* @since 4.5.0
*
* @see get_query_template()
*
* @return string Full path to embed template file.
*/
function get_embed_template() {
$object = get_queried_object();
$templates = array();
if ( ! empty( $object->post_type ) ) {
$post_format = get_post_format( $object );
if ( $post_format ) {
$templates[] = "embed-{$object->post_type}-{$post_format}.php";
}
$templates[] = "embed-{$object->post_type}.php";
}
$templates[] = "embed.php";
return get_query_template( 'embed', $templates );
}
/**
* Retrieves the path of the singular template in current or parent template.
*