Theme Compat: Port over new bbPress template stack functionality
|Reported by:||r-a-y||Owned by:||johnjamesjacoby|
Description (last modified by r-a-y)
r6490 introduced a fix to override template parts in BP's custom directory locations.
For example, I want to override /members/single/member-header.php and place it in /wp-content/themes/twentytwelve/buddypress/members/single/member-header.php
Before r6490, this wasn't possible.
However, JJJ noted that bbPress introduced the new method of the template stack in [BB4324], which is more flexible for developers and we should look into using that instead.
The first patch does this verbatim with a tiny change from bbPress that reverts [BB4326].
However, I've also attached a second patch, which includes the first patch plus a fix when using bp_locate_template() by itself.
If you used bp_locate_template() by itself, it would not use the custom directory locations as set in bp_get_template_locations() because only bp_get_template_part() has a filter that is hooked in by bp_add_template_locations().
Second patch removes this:
add_filter( 'bp_get_template_part', 'bp_add_template_locations' );
And hooks into the later-running filter, 'bp_get_template_stack', to add the custom directory locations.
This fixes problems when using such functions as bp_has_custom_signup_page() and bp_has_custom_activation_page(), which both rely on bp_locate_template().
If the second patch is not deemed acceptable, what we need is an approach that makes sure both bp_get_template_part() and bp_locate_template() references the same templates at all times.