Changeset 9389
- Timestamp:
- 01/21/2015 07:31:58 PM (10 years ago)
- Location:
- trunk/src/bp-core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-filters.php
r9351 r9389 64 64 65 65 // Filter BuddyPress template locations 66 add_filter( 'bp_get_template_stack', 'bp_add_template_stack_locations' ); 66 add_filter( 'bp_get_template_stack', 'bp_add_template_stack_locations' ); 67 68 // Filter BuddyPress template hierarchy and look for page templates 69 add_filter( 'bp_get_buddypress_template', 'bp_theme_compat_page_templates' ); 67 70 68 71 // Turn comments off for BuddyPress pages -
trunk/src/bp-core/bp-core-template-loader.php
r9351 r9389 443 443 */ 444 444 function bp_get_theme_compat_templates() { 445 $page_id = 0; 446 447 // Get the WordPress Page ID for the current view. 448 foreach ( (array) buddypress()->pages as $component => $bp_page ) { 449 450 // Handles the majority of components. 451 if ( bp_is_current_component( $component ) ) { 452 $page_id = (int) $bp_page->id; 453 } 454 455 // Stop if not on a user page. 456 if ( ! bp_is_user() && ! empty( $page_id ) ) { 457 break; 458 } 459 460 // The Members component requires an explicit check due to overlapping components. 461 if ( bp_is_user() && 'members' === $component ) { 462 $page_id = (int) $bp_page->id; 463 break; 464 } 465 } 466 467 $templates = array( 445 return bp_get_query_template( 'buddypress', array( 468 446 'plugin-buddypress.php', 469 447 'buddypress.php', … … 473 451 'single.php', 474 452 'index.php' 475 ); 476 477 // If the Page has a Page Template set, use that. 478 if ( $page_id ) { 479 $template_file = get_page_template_slug( $page_id ); 480 481 if ( $template_file ) { 482 $templates = array( $template_file ); 453 ) ); 454 } 455 456 /** 457 * Filter the default theme compatibility root template hierarchy, and prepend 458 * a page template to the front if it's set. 459 * 460 * @see https://buddypress.trac.wordpress.org/ticket/6065 461 * 462 * @since BuddyPress (2.2.0) 463 * 464 * @param array $templates 465 * @return array 466 */ 467 function bp_theme_compat_page_templates( $templates = array() ) { 468 469 // Bail if not looking at a directory 470 if ( ! bp_is_directory() ) { 471 return $templates; 472 } 473 474 // No page ID yet 475 $page_id = 0; 476 477 // Get the WordPress Page ID for the current view. 478 foreach ( (array) buddypress()->pages as $component => $bp_page ) { 479 480 // Handles the majority of components. 481 if ( bp_is_current_component( $component ) ) { 482 $page_id = (int) $bp_page->id; 483 483 } 484 } 485 486 return bp_get_query_template( 'buddypress', $templates ); 487 } 484 485 // Stop if not on a user page. 486 if ( ! bp_is_user() && ! empty( $page_id ) ) { 487 break; 488 } 489 490 // The Members component requires an explicit check due to overlapping components. 491 if ( bp_is_user() && ( 'members' === $component ) ) { 492 $page_id = (int) $bp_page->id; 493 break; 494 } 495 } 496 497 // Bail if no directory page set 498 if ( 0 === $page_id ) { 499 return $templates; 500 } 501 502 // Check for page template 503 $page_template = get_page_template_slug( $page_id ); 504 505 // Add it to the beginning of the templates array so it takes precedence 506 // over the default hierarchy. 507 if ( ! empty( $page_template ) ) { 508 array_unshift( $templates, $page_template ); 509 } 510 511 return $templates; 512 }
Note: See TracChangeset
for help on using the changeset viewer.