BP_Nouveau::theme_compat_page_templates( array $templates = array() )
Filter the default theme compatibility root template hierarchy, and prepend a page template to the front if it’s set.
Description
See also
Parameters
- $templates
-
(Optional) Array of templates.
Default value: array()
Return
(array)
Source
File: bp-templates/bp-nouveau/buddypress-functions.php
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 | public function theme_compat_page_templates( $templates = array () ) { /** * Filters whether or not we are looking at a directory to determine if to return early. * * @since BuddyPress 3.0.0 * * @param bool $value Whether or not we are viewing a directory. */ if ( true === (bool) apply_filters( 'bp_nouveau_theme_compat_page_templates_directory_only' , ! bp_is_directory() ) ) { return $templates ; } // No page ID yet. $page_id = 0; // Get the WordPress Page ID for the current view. foreach ( ( array ) buddypress()->pages as $component => $bp_page ) { // Handles the majority of components. if ( bp_is_current_component( $component ) ) { $page_id = (int) $bp_page ->id; } // Stop if not on a user page. if ( ! bp_is_user() && ! empty ( $page_id ) ) { break ; } // The Members component requires an explicit check due to overlapping components. if ( bp_is_user() && ( 'members' === $component ) ) { $page_id = (int) $bp_page ->id; break ; } } // Bail if no directory page set. if ( 0 === $page_id ) { return $templates ; } // Check for page template. $page_template = get_page_template_slug( $page_id ); // Add it to the beginning of the templates array so it takes precedence over the default hierarchy. if ( ! empty ( $page_template ) ) { /** * Check for existence of template before adding it to template * stack to avoid accidentally including an unintended file. * */ if ( '' !== locate_template( $page_template ) ) { array_unshift ( $templates , $page_template ); } } return $templates ; } |
Changelog
Version | Description |
---|---|
BuddyPress 3.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.