Ticket #4546: 4546.01.patch
File 4546.01.patch, 3.3 KB (added by , 12 years ago) |
---|
-
bp-core/bp-core-template-loader.php
function bp_get_template_part( $slug, $name = null ) { 46 46 /** 47 47 * Retrieve the name of the highest priority template file that exists. 48 48 * 49 * Searches in the STYLESHEETPATH before TEMPLATEPATH so that themes which50 * inherit from a parent theme can just overload one file. If the template is51 * not found in either of those, it looks in the theme-compat folderlast.49 * Searches in the current theme's folder (child or parent) to see if a 50 * template was overriden. If the template is not found in the current theme, 51 * it uses our theme-compat template last. 52 52 * 53 53 * @since BuddyPress (1.7) 54 54 * … … function bp_locate_template( $template_names, $load = false, $require_once = tru 72 72 73 73 // Trim off any slashes from the template name 74 74 $template_name = ltrim( $template_name, '/' ); 75 $child_theme = get_stylesheet_directory();76 $parent_theme = get_template_directory();77 75 $fallback_theme = bp_get_theme_compat_dir(); 78 76 79 // Check child theme first 80 if ( file_exists( trailingslashit( $child_theme ) . $template_name ) ) { 81 $located = trailingslashit( $child_theme ) . $template_name; 82 break; 77 // Use locate_template() to check the current theme (both child and parent) 78 // for a BP template 79 $located = locate_template( (array) $template_name ); 83 80 84 // Check parent theme next 85 } elseif ( file_exists( trailingslashit( $parent_theme ) . $template_name ) ) { 86 $located = trailingslashit( $child_theme ) . $template_name; 81 // we've located a template in the current theme, so stop! 82 if ( ! empty( $located ) ) { 87 83 break; 88 84 89 // Check theme compatibility last 90 } elseif ( file_exists( trailingslashit( $fallback_theme ) . $template_name ) ) { 91 $located = trailingslashit( $fallback_theme ) . $template_name; 92 break; 85 // if no override template, use theme compatibility template last 86 } else { 87 // 3rd-party plugin devs can hook into the 'bp_locate_fallback_template' filter to load custom templates if desired 88 $fallback_template = apply_filters( 'bp_locate_fallback_template', trailingslashit( $fallback_theme ) . $template_name, $template_name ); 89 90 if ( file_exists( $fallback_template ) ) { 91 $located = $fallback_template; 92 break; 93 } 93 94 } 95 94 96 } 95 97 98 // one final filter just in case someone wants to go crazy and override a theme's template from a plugin! 99 $located = apply_filters( 'bp_locate_template', $located, $template_names ); 100 96 101 if ( ( true == $load ) && !empty( $located ) ) 97 102 load_template( $located, $require_once ); 98 103 … … function bp_get_template_locations( $templates = array() ) { 188 193 * @since BuddyPress (1.7) 189 194 * 190 195 * @param array $templates 191 * @return array() 196 * @return array() 192 197 */ 193 198 function bp_add_template_locations( $templates = array() ) { 194 199 $retval = array(); … … function bp_parse_query( $posts_query ) { 234 239 * 235 240 * Listens to the 'template_include' filter and waits for any BuddyPress specific 236 241 * template condition to be met. If one is met and the template file exists, 237 * it will be used; otherwise 242 * it will be used; otherwise 238 243 * 239 244 * Note that the _edit() checks are ahead of their counterparts, to prevent them 240 245 * from being stomped on accident.