Make WordPress Core

Ticket #34278: 34278.get_embed_template.patch

File 34278.get_embed_template.patch, 2.6 KB (added by ChriCo, 9 years ago)

added get_embed_template() function with template hierarchy for embed-{$object->post_type}-{$object->post_name}.php, embed-{$object->post_type}.php, embed.php and fallback to WP-default ABSPATH . WPINC . '/embed-template.php'

  • wp-includes/template-loader.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    3939elseif ( is_trackback() ) :
    4040        include( ABSPATH . 'wp-trackback.php' );
    4141        return;
    42 elseif ( is_embed() ) :
    43         $template = ABSPATH . WPINC . '/embed-template.php';
    44 
    45         /**
    46          * Filter the template used for embedded posts.
    47          *
    48          * @since 4.4.0
    49          *
    50          * @param string $template Path to the template file.
    51          */
    52         $template = apply_filters( 'embed_template', $template );
    53 
    54         include ( $template );
    55         return;
    5642endif;
    5743
    5844if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) :
    5945        $template = false;
    60         if     ( is_404()            && $template = get_404_template()            ) :
     46        if     ( is_embed()          && $template = get_embed_template()          ) :
     47        elseif ( is_404()            && $template = get_404_template()            ) :
    6148        elseif ( is_search()         && $template = get_search_template()         ) :
    6249        elseif ( is_front_page()     && $template = get_front_page_template()     ) :
    6350        elseif ( is_home()           && $template = get_home_template()           ) :
  • wp-includes/template.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    405405}
    406406
    407407/**
     408 * Retrieve path of embed template in current or parent template.
     409 * By default the WordPress-template is returned.
     410 *
     411 * The template path is filterable via the dynamic {@see '$type_template'} hook,
     412 * e.g. 'embed_template'.
     413 *
     414 * @since 4.5.0
     415 *
     416 * @see get_query_template()
     417 *
     418 * @return string Full path to embed template file.
     419 */
     420function get_embed_template() {
     421
     422        $object     = get_queried_object();
     423        $templates  = array();
     424        if ( ! empty( $object->post_type ) ) {
     425                $templates[] = "embed-{$object->post_type}-{$object->post_name}.php";
     426                $templates[] = "embed-{$object->post_type}.php";
     427        }
     428
     429        $templates[] = "embed.php";
     430
     431        $template = get_query_template( 'embed', $templates );
     432
     433        // Fallback to default WordPress-template.
     434        if ( $template === '' ) {
     435                $template = ABSPATH . WPINC . '/embed-template.php';
     436        }
     437
     438        return $template;
     439}
     440
     441/**
    408442 * Retrieves the path of the singular template in current or parent template.
    409443 *
    410444 * The template path is filterable via the dynamic {@see '$type_template'} hook,