Skip to:
Content

BuddyPress.org

Ticket #4639: 4639-alt.01.patch

File 4639-alt.01.patch, 3.2 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 bdb95f0..30e169d 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' );
     64// Theme compatibililty template parts
    6665add_filter( 'bp_get_template_part', 'bp_add_template_locations' );
    6766
    6867// Turn comments off for BuddyPress pages
  • bp-members/bp-members-filters.php

    diff --git a/bp-members/bp-members-filters.php b/bp-members/bp-members-filters.php
    index 5889164..29219a8 100644
    a b function bp_members_edit_profile_url( $url, $user_id, $scheme = 'admin' ) { 
    7676        return apply_filters( 'bp_members_edit_profile_url', $profile_link, $url, $user_id, $scheme );
    7777}
    7878add_filter( 'edit_profile_url', 'bp_members_edit_profile_url', 10, 3 );
     79
     80/**
     81 * Implements a template hierarchy for the members component by adding possible template locations for single object templates.
     82 *
     83 * We only add a hierarchy for normal WordPress template files. BuddyPress Theme Compatibility template parts are not included.
     84 *
     85 * @link http://codex.buddypress.org/theme-development/template-hierarchy/
     86 * @param array|string $located_templates Templates that WordPress has already found
     87 * @param array|string $requested_templates The template(s) that was originally requested by {@link bp_core_load_template()}
     88 * @return array
     89 * @since BuddyPress (1.7)
     90 */
     91function bp_members_template_hierarchy( $located_templates, $requested_templates ) {
     92        $retval = array();
     93
     94        // Are we on a single member page?
     95        if ( ! bp_displayed_user_id() ) { // Can't use bp_is_user() here. See https://buddypress.trac.wordpress.org/ticket/4329
     96                $retval = $located_templates;
     97
     98        // Activity component handles members/admin/activity/
     99        } elseif ( bp_is_active( 'activity' ) && bp_is_single_activity() ) {
     100                $retval = $located_templates;
     101
     102        } else {
     103                $component     = sanitize_file_name( bp_current_component() );
     104                $user_id       = bp_displayed_user_id();
     105                $user_nicename = sanitize_file_name( buddypress()->displayed_user->userdata->user_nicename );
     106
     107                // Ask WordPress to find templates in this order of priority
     108                $retval[] = 'members/single/home-' . $user_nicename . '.php';
     109                $retval[] = 'members/single/home-' . $user_id       . '.php';
     110                $retval[] = 'members/single/home-' . $component     . '.php';
     111                $retval[] = 'members/single/home.php';
     112
     113                // If we've only matched a file in the Theme Compatibility directory, we don't want to load it as a regular WP template.
     114                $retval = bp_locate_template( bp_add_template_locations( $retval ) );
     115                if ( false !== strpos( $retval, bp_get_theme_compat_dir() ) )
     116                        $retval = '';
     117        }
     118
     119        return apply_filters( 'bp_members_template_hierarchy', $retval, $located_templates, $requested_templates );
     120}
     121add_filter( 'bp_located_template', 'bp_members_template_hierarchy', 10, 2 );