bbp_register_template_stack

This is really cool.

Description

bbp_register_template_stack( (string) $location_callback = '', (int) $priority = 10 ); 

This function registers a new template stack location, using WordPress's built in filters API.

This allows for templates to live in places beyond just the parent/child relationship, to allow for custom template locations. Used in conjunction with bbp_locate_template(), this allows for easy template overrides.

Parameters (2)

0. $location_callback — Optional. (string) => ''
Callback function that returns the
1. $priority — Optional. (int) => 10
The priority.

Usage

  1. if ( !function_exists( 'bbp_register_template_stack' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/core/template-functions.php'; 
  3.  
  4. // Callback function that returns the 
  5. $location_callback = ''; 
  6.  
  7. // The priority. 
  8. $priority = 10; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bbp_register_template_stack($location_callback, $priority); 
  12.  

Defined (1)

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

/includes/core/template-functions.php  
  1. function bbp_register_template_stack( $location_callback = '', $priority = 10 ) { 
  2.  
  3. // Bail if no location, or function does not exist 
  4. if ( empty( $location_callback ) || ! function_exists( $location_callback ) ) 
  5. return false; 
  6.  
  7. // Add location callback to template stack 
  8. return add_filter( 'bbp_template_stack', $location_callback, (int) $priority );