Ticket #12877: 12877.5.patch
File 12877.5.patch, 4.2 KB (added by , 14 years ago) |
---|
-
wp-includes/template-loader.php
18 18 return; 19 19 endif; 20 20 21 /** 22 * Locates and loads the template for current page ($wp_query). 23 * 24 * @since 3.1.0 25 */ 26 function template_loader() { 21 27 if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) : 22 28 $template = false; 23 29 if ( is_404() && $template = get_404_template() ) : … … 40 46 $template = get_index_template(); 41 47 endif; 42 48 if ( $template = apply_filters( 'template_include', $template ) ) 43 include( $template );49 load_template( $template ); 44 50 return; 45 51 endif; 52 } 46 53 54 update_template_hierarchy(); 55 template_loader(); 56 47 57 ?> -
wp-includes/theme.php
1077 1077 * @return string The template filename if one is located. 1078 1078 */ 1079 1079 function locate_template($template_names, $load = false, $require_once = true ) { 1080 $template_names = apply_filters( 'locate_template', $template_names ); 1081 1080 1082 $located = ''; 1081 1083 foreach ( (array) $template_names as $template_name ) { 1082 1084 if ( !$template_name ) … … 1121 1123 } 1122 1124 1123 1125 /** 1126 * Creates a global variable that contains the template hierarchy for the current page. 1127 * 1128 * Calling update_template_hierarchy() will recalculate the template hierarchy for $wp_query. 1129 * 1130 * @uses template_loader() Calculates the template hierarchy. 1131 * @since 3.1.0 1132 */ 1133 function update_template_hierarchy() { 1134 global $wp_template_hierarchy; 1135 1136 add_filter('locate_template', '_record_template_hierarchy'); 1137 add_filter('template_include', '__return_false'); 1138 $wp_template_hierarchy = array(); 1139 template_loader(); 1140 remove_filter('locate_template', '_record_template_hierarchy'); 1141 remove_filter('template_include', '__return_false'); 1142 $wp_template_hierarchy = call_user_func_array('array_merge', $wp_template_hierarchy); 1143 } 1144 1145 /** 1146 * Returns the template hierarchy for the current page. 1147 * 1148 * @since 3.1.0 1149 * 1150 * @return array 1151 */ 1152 function get_template_hierarchy() { 1153 global $wp_template_hierarchy; 1154 return $wp_template_hierarchy; 1155 } 1156 1157 /** 1158 * Private function to modify locate_template() when updating the 1159 * template hierarchy. 1160 * 1161 * Records $template_names in $wp_template_hierarchy, then returns false 1162 * which causes locate_template() to fail. 1163 * 1164 * @since 3.1.0 1165 * @access private 1166 * 1167 * @param array $template_names Template files to look for in locate_template. 1168 * @return array 1169 */ 1170 function _record_template_hierarchy( $template_names ) { 1171 global $wp_template_hierarchy; 1172 $wp_template_hierarchy[] = $template_names; 1173 return false; 1174 } 1175 1176 /** 1124 1177 * Display localized stylesheet link element. 1125 1178 * 1126 1179 * @since 2.1.0 -
wp-includes/general-template.php
129 129 } 130 130 131 131 /** 132 * Load a template from a folder based upon the best match from the template hierarchy. 133 * 134 * Makes it easy for a theme to reuse sections of code in a easy to overload way 135 * for child themes. 136 * 137 * Includes a template from a folder within a theme based upon the most specific 138 * match from the template hierarchy. If the folder contains no matching files 139 * then no template will be included. 140 * 141 * @uses get_template_hierarchy() To build template file names. 142 * @uses locate_template() To search for template files. 143 * @since 3.1.0 144 * 145 * @param string $folder The name of the folder to be searched. 146 * @return string The file path to the loaded file. The empty string if no file was found. 147 */ 148 function get_template_module( $folder ) { 149 $template_hierarchy = get_template_hierarchy(); 150 $template_names = array(); 151 foreach( $template_hierarchy as $template_name ) { 152 $template_names[] = $folder . '/' . $template_name; 153 } 154 155 return locate_template($template_names, true); 156 } 157 158 /** 132 159 * Display search form. 133 160 * 134 161 * Will first attempt to locate the searchform.php file in either the child or