Changeset 17220
- Timestamp:
- 01/04/2011 08:55:59 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/theme.php
r17214 r17220 729 729 * Retrieve path to a template 730 730 * 731 * Used to quickly retrieve the path of file without including the file732 * extension. It will also check the parent t emplate, if the file exists, with733 * the use of {@link locate_template()}. Allows for more generic file location731 * 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 734 734 * without the use of the other get_*_template() functions. 735 735 * 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 with742 * <code>743 * if( '' != get_404_template() )744 * include( get_404_template() );745 * </code>746 *747 736 * @since 1.5.0 748 737 * 749 738 * @param string $type Filename without extension. 739 * @param array $templates An optional list of template candidates 750 740 * @return string Full path to file. 751 741 */ 752 function get_query_template( $type) {742 function get_query_template( $type, $templates = array() ) { 753 743 $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 ) ); 755 751 } 756 752 … … 812 808 $templates[] = 'author.php'; 813 809 814 $template = locate_template( $templates ); 815 return apply_filters( 'author_template', $template ); 810 return get_query_template( 'author', $templates ); 816 811 } 817 812 … … 837 832 $templates[] = "category.php"; 838 833 839 $template = locate_template($templates); 840 return apply_filters('category_template', $template); 834 return get_query_template( 'category', $templates ); 841 835 } 842 836 … … 862 856 $templates[] = "tag.php"; 863 857 864 $template = locate_template($templates); 865 return apply_filters('tag_template', $template); 858 return get_query_template( 'tag', $templates ); 866 859 } 867 860 … … 893 886 $templates[] = "taxonomy.php"; 894 887 895 $template = locate_template($templates); 896 return apply_filters('taxonomy_template', $template); 888 return get_query_template( 'taxonomy', $templates ); 897 889 } 898 890 … … 921 913 */ 922 914 function 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 ); 925 918 } 926 919 … … 936 929 */ 937 930 function 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 ); 939 934 } 940 935 … … 973 968 $templates[] = "page.php"; 974 969 975 return apply_filters('page_template', locate_template($templates));970 return get_query_template( 'page', $templates ); 976 971 } 977 972 … … 1056 1051 */ 1057 1052 function get_comments_popup_template() { 1058 $template = locate_template(array("comments-popup.php"));1053 $template = get_query_template( 'comments_popup', array( 'comments-popup.php' ) ); 1059 1054 1060 1055 // Backward compat code will be removed in a future release … … 1062 1057 $template = ABSPATH . WPINC . '/theme-compat/comments-popup.php'; 1063 1058 1064 return apply_filters('comments_popup_template', $template);1059 return $template; 1065 1060 } 1066 1061
Note: See TracChangeset
for help on using the changeset viewer.