Skip to:
Content

BuddyPress.org

Ticket #6065: 6065.1.patch

File 6065.1.patch, 1.6 KB (added by DJPaul, 10 years ago)
  • src/bp-core/bp-core-template-loader.php

    diff --git a/src/bp-core/bp-core-template-loader.php b/src/bp-core/bp-core-template-loader.php
    index 89ee7b7..5df0ded 100644
    a b function bp_load_theme_functions() { 
    442442 * @return array Array of possible root level wrapper template files.
    443443 */
    444444function bp_get_theme_compat_templates() {
    445         $templates = array(
     445        $page_id       = 0;
     446        $page_template = array();
     447
     448        // Get the WordPress Page ID for the current view.
     449        foreach ( (array) buddypress()->pages as $component => $bp_page ) {
     450
     451                // Handles the majority of components.
     452                if ( bp_is_current_component( $component ) ) {
     453                        $page_id = (int) $bp_page->id;
     454                }
     455
     456                // Stop if not on a user page.
     457                if ( ! bp_is_user() && ! empty( $page_id ) ) {
     458                        break;
     459                }
     460
     461                // The Members component requires an explicit check due to overlapping components.
     462                if ( bp_is_user() && 'members' === $component ) {
     463                        $page_id = (int) $bp_page->id;
     464                        break;
     465                }
     466        }
     467
     468        if ( $page_id ) {
     469                // If the WP Page has a Page Template set, let's add it to the stack.
     470                $template_file = get_page_template_slug( $page_id );
     471
     472                if ( $template_file ) {
     473                        $page_template = array( $template_file );
     474                }
     475        }
     476
     477        $primary_templates = array(
    446478                'plugin-buddypress.php',
    447479                'buddypress.php',
    448480                'community.php',
    449481                'generic.php',
     482        );
     483
     484        $fallback_templates = array(
    450485                'page.php',
    451486                'single.php',
    452487                'index.php'
    453488        );
    454         return bp_get_query_template( 'buddypress', $templates );
     489
     490        return bp_get_query_template( 'buddypress', array_merge(
     491                $primary_templates,
     492                $page_template,
     493                $fallback_templates
     494        ) );
    455495}