Make WordPress Core

Ticket #48175: 48175-allow-tra-to-be-replaceable.diff

File 48175-allow-tra-to-be-replaceable.diff, 3.8 KB (added by dhurlburtusa, 4 years ago)

Initial patch.

  • src/wp-includes/template-loader.php

    diff --git a/src/wp-includes/template-loader.php b/src/wp-includes/template-loader.php
    index 42519a22ad..7eaa56eb4b 100644
    a b if ( is_robots() ) { 
    4646
    4747if ( wp_using_themes() ) {
    4848
    49         $tag_templates = array(
    50                 'is_embed'             => 'get_embed_template',
    51                 'is_404'               => 'get_404_template',
    52                 'is_search'            => 'get_search_template',
    53                 'is_front_page'        => 'get_front_page_template',
    54                 'is_home'              => 'get_home_template',
    55                 'is_privacy_policy'    => 'get_privacy_policy_template',
    56                 'is_post_type_archive' => 'get_post_type_archive_template',
    57                 'is_tax'               => 'get_taxonomy_template',
    58                 'is_attachment'        => 'get_attachment_template',
    59                 'is_single'            => 'get_single_template',
    60                 'is_page'              => 'get_page_template',
    61                 'is_singular'          => 'get_singular_template',
    62                 'is_category'          => 'get_category_template',
    63                 'is_tag'               => 'get_tag_template',
    64                 'is_author'            => 'get_author_template',
    65                 'is_date'              => 'get_date_template',
    66                 'is_archive'           => 'get_archive_template',
    67         );
    68         $template      = false;
    69 
    70         // Loop through each of the template conditionals, and find the appropriate template file.
    71         foreach ( $tag_templates as $tag => $template_getter ) {
    72                 if ( call_user_func( $tag ) ) {
    73                         $template = call_user_func( $template_getter );
    74                 }
    75 
    76                 if ( $template ) {
    77                         if ( 'is_attachment' === $tag ) {
    78                                 remove_filter( 'the_content', 'prepend_attachment' );
    79                         }
    80 
    81                         break;
    82                 }
    83         }
    84 
    85         if ( ! $template ) {
    86                 $template = get_index_template();
    87         }
     49        $template_resolution_algorithm = apply_filters( 'template_resolution_algorithm', 'resolve_template_hierarchy' );
     50        $template = call_user_func( $template_resolution_algorithm );
    8851
    8952        /**
    9053         * Filters the path of the current template before including it.
  • src/wp-includes/template.php

    diff --git a/src/wp-includes/template.php b/src/wp-includes/template.php
    index 860cbda179..14faa4a54f 100644
    a b function load_template( $_template_file, $require_once = true ) { 
    724724                require( $_template_file );
    725725        }
    726726}
     727
     728/**
     729 * Determines which theme template to use based on the template hierarchy
     730 * algorithm.
     731 *
     732 * @since 5.3.0
     733 */
     734function resolve_template_hierarchy () {
     735        $tag_templates = array(
     736                'is_embed'             => 'get_embed_template',
     737                'is_404'               => 'get_404_template',
     738                'is_search'            => 'get_search_template',
     739                'is_front_page'        => 'get_front_page_template',
     740                'is_home'              => 'get_home_template',
     741                'is_privacy_policy'    => 'get_privacy_policy_template',
     742                'is_post_type_archive' => 'get_post_type_archive_template',
     743                'is_tax'               => 'get_taxonomy_template',
     744                'is_attachment'        => 'get_attachment_template',
     745                'is_single'            => 'get_single_template',
     746                'is_page'              => 'get_page_template',
     747                'is_singular'          => 'get_singular_template',
     748                'is_category'          => 'get_category_template',
     749                'is_tag'               => 'get_tag_template',
     750                'is_author'            => 'get_author_template',
     751                'is_date'              => 'get_date_template',
     752                'is_archive'           => 'get_archive_template',
     753        );
     754        $template = false;
     755
     756        // Loop through each of the template conditionals, and find the appropriate template file.
     757        foreach ( $tag_templates as $tag => $template_getter ) {
     758                if ( call_user_func( $tag ) ) {
     759                        $template = call_user_func( $template_getter );
     760                }
     761
     762                if ( $template ) {
     763                        if ( 'is_attachment' === $tag ) {
     764                                remove_filter( 'the_content', 'prepend_attachment' );
     765                        }
     766
     767                        break;
     768                }
     769        }
     770
     771        if ( ! $template ) {
     772                $template = get_index_template();
     773        }
     774
     775        return $template;
     776}