[buddypress-trac] [BuddyPress] #4855: Method to override a plugins use of plugins.php or add filters to bp_template_title and bp_template_content

buddypress-trac noreply at wordpress.org
Sun Mar 3 18:59:45 UTC 2013


#4855: Method to override a plugins use of plugins.php or add filters to
bp_template_title and bp_template_content
-------------------------------------------+----------------------
 Reporter:  modemlooper                    |       Owner:
     Type:  enhancement                    |      Status:  closed
 Priority:  normal                         |   Milestone:
Component:  Core                           |     Version:
 Severity:  normal                         |  Resolution:  invalid
 Keywords:  2nd-opinion reporter-feedback  |
-------------------------------------------+----------------------
Changes (by boonebgorges):

 * status:  new => closed
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


Comment:

 I think you're overthinking things.

 First, I've confirmed that bp_get_template_part works fine:

 {{{
 function bp4855( $templates, $name ) {
         if ( 'members/single/plugins' == $name ) {
                 $templates = array( 'foo.php' );
         }

         return $templates;
 }
 add_filter( 'bp_get_template_part', 'bp4855', 10, 2 );
 }}}

 This loads [my-theme]/foo.php rather than plugins.php.

 Of course, foo.php does not contain any of the plugin content (in this
 case, bbPress). That's because bbPress has hooked its content to
 `bp_template_content`. So if I put the following line into foo.php, it
 works:

 {{{
 <?php do_action( 'bp_template_content' ); ?>
 }}}

 So, if you want to display totally different content from what bbPress is
 displaying, then you don't need to use the `bp_template_content` and
 `bp_template_title` hooks at all. Just put your new content directly in
 the replacement template. On the other hand, if all you want to do is add
 some additional content or markup, you can do so by making sure that your
 replacement template contains the `do_action()` line above. Finally, if
 you wish to continue using the plugins.php *template* but you don't want
 bbPress to show its *content* there, then unhook bbPress's display methods
 using `remove_action()`.

 I think this pretty much covers all the possible use cases, at least the
 ones I can see. If I've misunderstood, or if I'm missing something, please
 feel free to leave additional details on precisely what it is that you
 want to do. Until then, I'm marking this ticket invalid, as I believe
 you're asking for an enhancement that would introduce unnecessary
 complication to accomplish something that's already easily achievable in
 our template system.

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4855#comment:4>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list