Make WordPress Core

Changeset 17220


Ignore:
Timestamp:
01/04/2011 08:55:59 PM (16 years ago)
Author:
markjaquith
Message:

I bungled [17214]. Reverting the revert, so it can be reverted properly! see #14310

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/theme.php

    r17214 r17220  
    729729 * Retrieve path to a template
    730730 *
    731  * Used to quickly retrieve the path of file without including the file
    732  * extension. It will also check the parent template, if the file exists, with
    733  * the use of {@link locate_template()}. Allows for more generic file location
     731 * Used to quickly retrieve the path of a template without including the file
     732 * extension. It will also check the parent theme, if the file exists, with
     733 * the use of {@link locate_template()}. Allows for more generic template location
    734734 * without the use of the other get_*_template() functions.
    735735 *
    736  * Can be used with include() or require() to retrieve path.
    737  * <code>
    738  * if( '' != get_query_template( '404' ) )
    739  *     include( get_query_template( '404' ) );
    740  * </code>
    741  * or the same can be accomplished with
    742  * <code>
    743  * if( '' != get_404_template() )
    744  *     include( get_404_template() );
    745  * </code>
    746  *
    747736 * @since 1.5.0
    748737 *
    749738 * @param string $type Filename without extension.
     739 * @param array $templates An optional list of template candidates
    750740 * @return string Full path to file.
    751741 */
    752 function get_query_template($type) {
     742function get_query_template( $type, $templates = array() ) {
    753743        $type = preg_replace( '|[^a-z0-9-]+|', '', $type );
    754         return apply_filters("{$type}_template", locate_template(array("{$type}.php")));
     744
     745        if ( empty( $templates ) )
     746                $templates = array("{$type}.php");
     747
     748        $templates = apply_filters( "{$type}_template_hierarchy", $templates );
     749
     750        return apply_filters( "{$type}_template", locate_template( $templates ) );
    755751}
    756752
     
    812808        $templates[] = 'author.php';
    813809
    814         $template = locate_template( $templates );
    815         return apply_filters( 'author_template', $template );
     810        return get_query_template( 'author', $templates );
    816811}
    817812
     
    837832        $templates[] = "category.php";
    838833
    839         $template = locate_template($templates);
    840         return apply_filters('category_template', $template);
     834        return get_query_template( 'category', $templates );
    841835}
    842836
     
    862856        $templates[] = "tag.php";
    863857
    864         $template = locate_template($templates);
    865         return apply_filters('tag_template', $template);
     858        return get_query_template( 'tag', $templates );
    866859}
    867860
     
    893886        $templates[] = "taxonomy.php";
    894887
    895         $template = locate_template($templates);
    896         return apply_filters('taxonomy_template', $template);
     888        return get_query_template( 'taxonomy', $templates );
    897889}
    898890
     
    921913 */
    922914function get_home_template() {
    923         $template = locate_template(array('home.php', 'index.php'));
    924         return apply_filters('home_template', $template);
     915        $templates = array( 'home.php', 'index.php' );
     916
     917        return get_query_template( 'home', $templates );
    925918}
    926919
     
    936929 */
    937930function get_front_page_template() {
    938         return apply_filters( 'front_page_template', locate_template( array('front-page.php') ) );
     931        $templates = array('front-page.php');
     932
     933        return get_query_template( 'front_page', $templates );
    939934}
    940935
     
    973968        $templates[] = "page.php";
    974969
    975         return apply_filters('page_template', locate_template($templates));
     970        return get_query_template( 'page', $templates );
    976971}
    977972
     
    10561051 */
    10571052function get_comments_popup_template() {
    1058         $template = locate_template(array("comments-popup.php"));
     1053        $template = get_query_template( 'comments_popup', array( 'comments-popup.php' ) );
    10591054
    10601055        // Backward compat code will be removed in a future release
     
    10621057                $template = ABSPATH . WPINC . '/theme-compat/comments-popup.php';
    10631058
    1064         return apply_filters('comments_popup_template', $template);
     1059        return $template;
    10651060}
    10661061
Note: See TracChangeset for help on using the changeset viewer.