- Timestamp:
- 01/22/2015 05:47:27 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.