Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/22/2015 05:47:27 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Move page-template support into BP Legacy template pack. Props imath. See #6065.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-template-loader.php

    r9391 r9399  
    463463    ) );
    464464}
    465 
    466 /**
    467  * Filter the default theme compatibility root template hierarchy, and prepend
    468  * a page template to the front if it's set.
    469  *
    470  * @see https://buddypress.trac.wordpress.org/ticket/6065
    471  *
    472  * @since BuddyPress (2.2.0)
    473  *
    474  * @param  array $templates
    475  * @return array
    476  */
    477 function bp_theme_compat_page_templates( $templates = array() ) {
    478 
    479     // Bail if not looking at a directory
    480     if ( ! bp_is_directory() ) {
    481         return $templates;
    482     }
    483 
    484     // No page ID yet
    485     $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 set
    508     if ( 0 === $page_id ) {
    509         return $templates;
    510     }
    511 
    512     // Check for page template
    513     $page_template = get_page_template_slug( $page_id );
    514 
    515     // Add it to the beginning of the templates array so it takes precedence
    516     // over the default hierarchy.
    517     if ( ! empty( $page_template ) ) {
    518         array_unshift( $templates, $page_template );
    519     }
    520 
    521     return $templates;
    522 }
Note: See TracChangeset for help on using the changeset viewer.