bp_buffer_template_part

Put a template part into an output buffer, and return it.

Description

(string|null) bp_buffer_template_part( (string) $slug, (constant) $name = null, (bool) $echo = true ); 

Returns (string|null)

If $echo, returns the template content.

Parameters (3)

0. $slug (string)
The slug.
1. $name — Optional. (constant) => null
The name.
2. $echo — Optional. (bool) => true
If true, template content will be echoed. If false, returned. Default: true.

Usage

  1. if ( !function_exists( 'bp_buffer_template_part' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-template-loader.php'; 
  3.  
  4. // The slug. 
  5. $slug = ''; 
  6.  
  7. // The name. 
  8. $name = null; 
  9.  
  10. // If true, template content will be echoed. If false, 
  11. // returned. Default: true. 
  12. $echo = true; 
  13.  
  14. // NOTICE! Understand what this does before running. 
  15. $result = bp_buffer_template_part($slug, $name, $echo); 
  16.  

Defined (1)

The function is defined in the following location(s).

/bp-core/bp-core-template-loader.php  
  1. function bp_buffer_template_part( $slug, $name = null, $echo = true ) { 
  2. ob_start(); 
  3.  
  4. // Remove 'bp_replace_the_content' filter to prevent infinite loops. 
  5.  
  6. bp_get_template_part( $slug, $name ); 
  7.  
  8. // Remove 'bp_replace_the_content' filter to prevent infinite loops. 
  9.  
  10. // Get the output buffer contents. 
  11. $output = ob_get_clean(); 
  12.  
  13. // Echo or return the output buffer contents. 
  14. if ( true === $echo ) { 
  15. echo $output; 
  16. } else { 
  17. return $output;