Changeset 15611
- Timestamp:
- 09/12/2010 06:46:18 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/theme.php
r15590 r15611 688 688 689 689 /** 690 * Retrieve path to file without the use of extension.691 * 692 * Used to quickly retrieve the path of file without including the file693 * extension. It will also check the parent t emplate, if the file exists, with694 * the use of {@link locate_template()}. Allows for more generic file location690 * Retrieve path to a template 691 * 692 * Used to quickly retrieve the path of a template without including the file 693 * extension. It will also check the parent theme, if the file exists, with 694 * the use of {@link locate_template()}. Allows for more generic template location 695 695 * without the use of the other get_*_template() functions. 696 696 * 697 * Can be used with include() or require() to retrieve path.698 * <code>699 * if( '' != get_query_template( '404' ) )700 * include( get_query_template( '404' ) );701 * </code>702 * or the same can be accomplished with703 * <code>704 * if( '' != get_404_template() )705 * include( get_404_template() );706 * </code>707 *708 697 * @since 1.5.0 709 698 * 710 699 * @param string $type Filename without extension. 700 * @param array $templates An optional list of template candidates 711 701 * @return string Full path to file. 712 702 */ 713 function get_query_template( $type) {703 function get_query_template( $type, $templates = array() ) { 714 704 $type = preg_replace( '|[^a-z0-9-]+|', '', $type ); 715 return apply_filters("{$type}_template", locate_template(array("{$type}.php"))); 705 706 if ( empty( $templates ) ) 707 $templates = array("{$type}.php"); 708 709 $templates = apply_filters( "{$type}_template_hierarchy", $templates ); 710 711 return apply_filters( "{$type}_template", locate_template( $templates ) ); 716 712 } 717 713 … … 769 765 $templates[] = 'author.php'; 770 766 771 $template = locate_template( $templates ); 772 return apply_filters( 'author_template', $template ); 767 return get_query_template( 'author', $templates ); 773 768 } 774 769 … … 791 786 $templates = array(); 792 787 793 if ( !is_wp_error( $category) )788 if ( !is_wp_error( $category ) ) 794 789 $templates[] = "category-{$category->slug}.php"; 795 790 … … 797 792 $templates[] = "category.php"; 798 793 799 $template = locate_template($templates); 800 return apply_filters('category_template', $template); 794 return get_query_template( 'category', $templates ); 801 795 } 802 796 … … 825 819 $templates[] = "tag.php"; 826 820 827 $template = locate_template($templates); 828 return apply_filters('tag_template', $template); 821 return get_query_template( 'tag', $templates ); 829 822 } 830 823 … … 858 851 $templates[] = "taxonomy.php"; 859 852 860 $template = locate_template($templates); 861 return apply_filters('taxonomy_template', $template); 853 return get_query_template( 'taxonomy', $templates ); 862 854 } 863 855 … … 886 878 */ 887 879 function get_home_template() { 888 $template = locate_template(array('home.php', 'index.php')); 889 return apply_filters('home_template', $template); 880 $templates = array( 'home.php', 'index.php' ); 881 882 return get_query_template( 'home', $templates ); 890 883 } 891 884 … … 901 894 */ 902 895 function get_front_page_template() { 903 return apply_filters( 'front_page_template', locate_template( array('front-page.php') ) ); 896 $templates = array('front-page.php'); 897 898 return get_query_template( 'front_page', $templates ); 904 899 } 905 900 … … 940 935 $templates[] = "page.php"; 941 936 942 return apply_filters('page_template', locate_template($templates));937 return get_query_template( 'page', $templates ); 943 938 } 944 939 … … 977 972 $object = $wp_query->get_queried_object(); 978 973 $templates = array('single-' . $object->post_type . '.php', 'single.php'); 979 return apply_filters('single_template', locate_template($templates)); 974 975 return get_query_template( 'single', $templates ); 980 976 } 981 977 … … 1020 1016 */ 1021 1017 function get_comments_popup_template() { 1022 $template = locate_template(array("comments-popup.php"));1018 $template = get_query_template( 'comments_popup', array( 'comments-popup.php' ) ); 1023 1019 1024 1020 // Backward compat code will be removed in a future release … … 1026 1022 $template = ABSPATH . WPINC . '/theme-compat/comments-popup.php'; 1027 1023 1028 return apply_filters('comments_popup_template', $template);1024 return $template; 1029 1025 } 1030 1026
Note: See TracChangeset
for help on using the changeset viewer.