Skip to:
Content

BuddyPress.org

Ticket #4639: 4639.001.patch

File 4639.001.patch, 3.7 KB (added by DJPaul, 8 years ago)
  • bp-core/bp-core-filters.php

    diff --git a/bp-core/bp-core-filters.php b/bp-core/bp-core-filters.php
    index 595fb0a..ca16bd8 100644
    a b add_filter( 'bp_core_render_message_content', 'shortcode_unautop' ); 
    6161add_filter( 'bp_template_include', 'bp_template_include_theme_supports', 2, 1 );
    6262add_filter( 'bp_template_include', 'bp_template_include_theme_compat',   4, 2 );
    6363
    64 // Run all template parts through additional template locations
    65 add_filter( 'bp_locate_template',   'bp_add_template_locations' );
    66 add_filter( 'bp_get_template_part', 'bp_add_template_locations' );
     64// Set up the template hierarchy and run all template parts through additional template locations
     65add_filter( 'bp_get_template_part', 'bp_template_hierarchy',     8, 3 );
     66add_filter( 'bp_get_template_part', 'bp_add_template_locations', 10   );
     67//add_filter( 'bp_locate_template',   'bp_add_template_locations', 10   );
    6768
    6869// Turn comments off for BuddyPress pages
    6970add_filter( 'comments_open', 'bp_comments_open', 10, 2 );
  • bp-core/bp-core-template-loader.php

    diff --git a/bp-core/bp-core-template-loader.php b/bp-core/bp-core-template-loader.php
    index afd7677..8a11e67 100644
    a b function bp_get_query_template( $type, $templates = array() ) { 
    171171}
    172172
    173173/**
     174 * Implements a template hierarchy by adding possible template locations for single object templates.
     175 *
     176 * @param array $templates
     177 * @param string $slug The slug name for the generic template.
     178 * @param string $name Optional. The name of the specialised template.
     179 * @since BuddyPress (1.7)
     180 * @return array
     181 */
     182function bp_template_hierarchy( $templates, $slug, $name = null ) {
     183        $new_templates = array();
     184
     185        // Get the directory/file name of the requested template (no file extension)
     186        $requested_template = "{$slug}-";
     187        if ( isset( $name ) )
     188                $requested_template = "{$slug}-{$name}-";
     189
     190        // Is this a request for a user-specific template? e.g. example.com/members/paulgibbs/*
     191        if ( bp_is_user() ) {
     192
     193                // User ID
     194                $new_templates[] = $requested_template . bp_displayed_user_id() . '.php';
     195                // @todo Consider using member slugs for user-specific templates. Problems: sanitisation, people with identical names.
     196
     197
     198        // Is this a request for a single group template? e.g. example.com/groups/pauls-fanclub/*
     199        } elseif ( bp_is_group() ) {
     200
     201                // Group ID
     202                $new_templates[] = $requested_template . buddypress()->groups->current_group->id . '.php';
     203
     204                // Group type (private, public, protected)
     205                $new_templates[] = $requested_template . buddypress()->groups->current_group->status  . '.php';
     206
     207                // @todo Consider using group slugs for specific templates. Problems: sanitisation, groups with identical names.
     208
     209
     210        // Is this a request for activity templates, and are we in the loop? e.g. example.com/activity/*
     211        } elseif ( bp_is_activity_component() && isset( $GLOBALS['activities_template'] ) && $GLOBALS['activities_template']->in_the_loop ) {
     212
     213                // Activity type
     214                $new_templates[] = $requested_template . str_replace( '_', '-', bp_get_activity_type() ) . '.php';
     215        }
     216
     217        // Set the template hierarchy
     218        $templates = array_merge( $new_templates, $templates );
     219
     220        return $templates;
     221}
     222
     223/**
    174224 * Get the possible subdirectories to check for templates in
    175225 *
    176226 * @since BuddyPress (1.7)
    function bp_get_query_template( $type, $templates = array() ) { 
    179229 */
    180230function bp_get_template_locations( $templates = array() ) {
    181231        $locations = array(
    182                 'buddypress',
     232                '',
    183233                'community',
    184                 ''
     234                'buddypress',
    185235        );
    186236        return apply_filters( 'bp_get_template_locations', $locations, $templates );
    187237}
    188238
    189 /**
     239 /**
    190240 * Add template locations to template files being searched for
    191241 *
    192242 * @since BuddyPress (1.7)