Ticket #6065: 6065.02.patch
File 6065.02.patch, 2.2 KB (added by , 10 years ago) |
---|
-
src/bp-core/bp-core-template-loader.php
442 442 * @return array Array of possible root level wrapper template files. 443 443 */ 444 444 function bp_get_theme_compat_templates() { 445 return bp_get_query_template( 'buddypress', array( 446 'plugin-buddypress.php', 447 'buddypress.php', 448 'community.php', 449 'generic.php', 450 'page.php', 451 'single.php', 452 'index.php' 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 445 475 $page_id = 0; 446 476 447 477 // Get the WordPress Page ID for the current view. … … 458 488 } 459 489 460 490 // The Members component requires an explicit check due to overlapping components. 461 if ( bp_is_user() && 'members' === $component) {491 if ( bp_is_user() && ( 'members' === $component ) ) { 462 492 $page_id = (int) $bp_page->id; 463 493 break; 464 494 } 465 495 } 466 496 467 $templates = array( 468 'plugin-buddypress.php', 469 'buddypress.php', 470 'community.php', 471 'generic.php', 472 'page.php', 473 'single.php', 474 'index.php' 475 ); 497 // Bail if no directory page set 498 if ( 0 === $page_id ) { 499 return $templates; 500 } 476 501 477 // If the Page has a Page Template set, use that. 478 if ( $page_id ) { 479 $template_file = get_page_template_slug( $page_id ); 502 // Check for page template 503 $page_template = get_page_template_slug( $page_id ); 480 504 481 if ( $template_file ) { 482 $templates = array( $template_file ); 483 } 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 ); 484 509 } 485 510 486 return bp_get_query_template( 'buddypress', $templates );511 return $templates; 487 512 } 513 add_filter( 'bp_get_buddypress_template', 'bp_theme_compat_page_templates' );