Changeset 9399
- Timestamp:
- 01/22/2015 05:47:27 PM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-filters.php
r9393 r9399 65 65 // Filter BuddyPress template locations 66 66 add_filter( 'bp_get_template_stack', 'bp_add_template_stack_locations' ); 67 68 // Filter BuddyPress template hierarchy and look for page templates69 add_filter( 'bp_get_buddypress_template', 'bp_theme_compat_page_templates' );70 67 71 68 // Turn comments off for BuddyPress pages -
trunk/src/bp-core/bp-core-template-loader.php
r9391 r9399 463 463 ) ); 464 464 } 465 466 /**467 * Filter the default theme compatibility root template hierarchy, and prepend468 * a page template to the front if it's set.469 *470 * @see https://buddypress.trac.wordpress.org/ticket/6065471 *472 * @since BuddyPress (2.2.0)473 *474 * @param array $templates475 * @return array476 */477 function bp_theme_compat_page_templates( $templates = array() ) {478 479 // Bail if not looking at a directory480 if ( ! bp_is_directory() ) {481 return $templates;482 }483 484 // No page ID yet485 $page_id = 0;486 487 // Get the WordPress Page ID for the current view.488 foreach ( (array) buddypress()->pages as $component => $bp_page ) {489 490 // Handles the majority of components.491 if ( bp_is_current_component( $component ) ) {492 $page_id = (int) $bp_page->id;493 }494 495 // Stop if not on a user page.496 if ( ! bp_is_user() && ! empty( $page_id ) ) {497 break;498 }499 500 // The Members component requires an explicit check due to overlapping components.501 if ( bp_is_user() && ( 'members' === $component ) ) {502 $page_id = (int) $bp_page->id;503 break;504 }505 }506 507 // Bail if no directory page set508 if ( 0 === $page_id ) {509 return $templates;510 }511 512 // Check for page template513 $page_template = get_page_template_slug( $page_id );514 515 // Add it to the beginning of the templates array so it takes precedence516 // over the default hierarchy.517 if ( ! empty( $page_template ) ) {518 array_unshift( $templates, $page_template );519 }520 521 return $templates;522 } -
trunk/src/bp-templates/bp-legacy/buddypress-functions.php
r9351 r9399 81 81 add_filter( 'bp_get_activity_action_pre_meta', array( $this, 'secondary_avatars' ), 10, 2 ); 82 82 83 // Filter BuddyPress template hierarchy and look for page templates 84 add_filter( 'bp_get_buddypress_template', array( $this, 'theme_compat_page_templates' ), 10, 1 ); 85 83 86 /** Scripts ***********************************************************/ 84 87 … … 88 91 add_action( 'bp_head', array( $this, 'head_scripts' ) ); // Output some extra JS in the <head> 89 92 90 /** Body no-js Class ********************************************************/ 93 /** Body no-js Class **************************************************/ 94 91 95 add_filter( 'body_class', array( $this, 'add_nojs_body_class' ), 20, 1 ); 92 96 … … 120 124 add_action( 'bp_blogs_directory_blog_types', 'bp_legacy_theme_blog_create_nav', 999 ); 121 125 } 122 123 124 126 } 125 127 … … 441 443 return $action; 442 444 } 445 446 /** 447 * Filter the default theme compatibility root template hierarchy, and prepend 448 * a page template to the front if it's set. 449 * 450 * @see https://buddypress.trac.wordpress.org/ticket/6065 451 * 452 * @since BuddyPress (2.2.0) 453 * 454 * @param array $templates 455 * @uses apply_filters() call 'bp_legacy_theme_compat_page_templates_directory_only' and return false 456 * to use the defined page template for component's directory and its single items 457 * @return array 458 */ 459 public function theme_compat_page_templates( $templates = array() ) { 460 461 // Bail if not looking at a directory 462 if ( true === (bool) apply_filters( 'bp_legacy_theme_compat_page_templates_directory_only', ! bp_is_directory() ) ) { 463 return $templates; 464 } 465 466 // No page ID yet 467 $page_id = 0; 468 469 // Get the WordPress Page ID for the current view. 470 foreach ( (array) buddypress()->pages as $component => $bp_page ) { 471 472 // Handles the majority of components. 473 if ( bp_is_current_component( $component ) ) { 474 $page_id = (int) $bp_page->id; 475 } 476 477 // Stop if not on a user page. 478 if ( ! bp_is_user() && ! empty( $page_id ) ) { 479 break; 480 } 481 482 // The Members component requires an explicit check due to overlapping components. 483 if ( bp_is_user() && ( 'members' === $component ) ) { 484 $page_id = (int) $bp_page->id; 485 break; 486 } 487 } 488 489 // Bail if no directory page set 490 if ( 0 === $page_id ) { 491 return $templates; 492 } 493 494 // Check for page template 495 $page_template = get_page_template_slug( $page_id ); 496 497 // Add it to the beginning of the templates array so it takes precedence 498 // over the default hierarchy. 499 if ( ! empty( $page_template ) ) { 500 array_unshift( $templates, $page_template ); 501 } 502 503 return $templates; 504 } 443 505 } 444 506 new BP_Legacy();
Note: See TracChangeset
for help on using the changeset viewer.