Changeset 7432 for trunk/bp-core/bp-core-theme-compatibility.php
- Timestamp:
- 10/16/2013 12:52:42 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-theme-compatibility.php
r7266 r7432 63 63 64 64 /** 65 * Set up the BuddyPress-specific theme compat methods 66 * 65 67 * Themes shoud use this method in their constructor. 66 68 * 67 * In this method, we check all types of conditions where theme compatibility68 * should *not* run.69 *70 * If we pass all conditions, then we setup some additional methods to use.71 *72 69 * @since BuddyPress (1.7) 73 70 */ 74 71 protected function start() { 75 76 // If the theme supports 'buddypress', bail. 77 if ( current_theme_supports( 'buddypress' ) ) { 72 // Sanity check 73 if ( ! bp_use_theme_compat_with_current_theme() ) { 78 74 return; 79 80 // If the theme doesn't support BP, do some additional checks81 } else {82 // Bail if theme is a derivative of bp-default83 if ( in_array( 'bp-default', array( get_template(), get_stylesheet() ) ) ) {84 return;85 }86 87 // Bruteforce check for a BP template88 // Examples are clones of bp-default89 if ( locate_template( 'members/members-loop.php', false, false ) ) {90 return;91 }92 75 } 93 76 … … 224 207 function bp_get_theme_compat_url() { 225 208 return apply_filters( 'bp_get_theme_compat_url', buddypress()->theme_compat->theme->url ); 209 } 210 211 /** 212 * Should we use theme compat for this theme? 213 * 214 * If the current theme's need for theme compat hasn't yet been detected, we 215 * do so using bp_detect_theme_compat_with_current_theme() 216 * 217 * @since BuddyPress (1.9.0) 218 * 219 * @uses bp_detect_theme_compat_with_current_theme() 220 * 221 * @return bool True if the current theme needs theme compatibility 222 */ 223 function bp_use_theme_compat_with_current_theme() { 224 if ( ! isset( buddypress()->theme_compat->use_with_current_theme ) ) { 225 bp_detect_theme_compat_with_current_theme(); 226 } 227 228 return buddypress()->theme_compat->use_with_current_theme; 229 } 230 231 /** 232 * Set our flag to determine whether theme compat should be enabled. 233 * 234 * Theme compat is disabled when a theme meets one of the following criteria: 235 * 1) It declares BP support with add_theme_support( 'buddypress' ) 236 * 2) It is bp-default, or a child theme of bp-default 237 * 3) A legacy template is found at members/members-loop.php. This is a 238 * fallback check for themes that were derived from bp-default, and have 239 * not been updated for BP 1.7+; we make the assumption that any theme in 240 * this category will have the members-loop.php template, and so use its 241 * presence as an indicator that theme compatibility is not required 242 * 243 * @since BuddyPress (1.9.0) 244 * 245 * @return bool True if the current theme needs theme compatibility. 246 */ 247 function bp_detect_theme_compat_with_current_theme() { 248 if ( isset( buddypress()->theme_compat->use_with_current_theme ) ) { 249 return buddypress()->theme_compat->use_with_current_theme; 250 } 251 252 // theme compat enabled by default 253 $theme_compat = true; 254 255 // If the theme supports 'buddypress', bail. 256 if ( current_theme_supports( 'buddypress' ) ) { 257 $theme_compat = false; 258 259 // If the theme doesn't support BP, do some additional checks 260 } else { 261 // Bail if theme is a derivative of bp-default 262 if ( in_array( 'bp-default', array( get_template(), get_stylesheet() ) ) ) { 263 $theme_compat = false; 264 265 // Bruteforce check for a BP template 266 // Examples are clones of bp-default 267 } else if ( locate_template( 'members/members-loop.php', false, false ) ) { 268 $theme_compat = false; 269 } 270 } 271 272 // set a flag in the buddypress() singleton so we don't have to run this again 273 buddypress()->theme_compat->use_with_current_theme = $theme_compat; 274 275 return $theme_compat; 226 276 } 227 277 … … 498 548 function bp_template_include_theme_compat( $template = '' ) { 499 549 550 // If the current theme doesn't need theme compat, bail at this point. 551 if ( ! bp_use_theme_compat_with_current_theme() ) { 552 return $template; 553 } 554 500 555 /** 501 556 * Use this action to execute code that will communicate to BuddyPress's
Note: See TracChangeset
for help on using the changeset viewer.