bp_get_template_stack

Get the "template stack", a list of registered directories where templates can be found.

Description

(array) bp_get_template_stack(); 

Calls the functions added to the bp_template_stack filter hook, and return an array of the template locations.

Returns (array)

The filtered value after all hooked functions are applied to it.


Usage

  1. if ( !function_exists( 'bp_get_template_stack' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-template-loader.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_get_template_stack(); 
  7.  

Defined (1)

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

/bp-core/bp-core-template-loader.php  
  1. function bp_get_template_stack() { 
  2. global $wp_filter, $merged_filters, $wp_current_filter; 
  3.  
  4. // Setup some default variables. 
  5. $tag = 'bp_template_stack'; 
  6. $args = $stack = array(); 
  7.  
  8. // Add 'bp_template_stack' to the current filter array. 
  9. $wp_current_filter[] = $tag; 
  10.  
  11. // Sort. 
  12. if ( class_exists( 'WP_Hook' ) ) { 
  13. $filter = $wp_filter[ $tag ]->callbacks; 
  14. } else { 
  15. $filter = &$wp_filter[ $tag ]; 
  16.  
  17. if ( ! isset( $merged_filters[ $tag ] ) ) { 
  18. ksort( $filter ); 
  19. $merged_filters[ $tag ] = true; 
  20.  
  21. // Ensure we're always at the beginning of the filter array. 
  22. reset( $filter ); 
  23.  
  24. // Loop through 'bp_template_stack' filters, and call callback functions. 
  25. do { 
  26. foreach( (array) current( $filter ) as $the_ ) { 
  27. if ( ! is_null( $the_['function'] ) ) { 
  28. $args[1] = $stack; 
  29. $stack[] = call_user_func_array( $the_['function'], array_slice( $args, 1, (int) $the_['accepted_args'] ) ); 
  30. } while ( next( $filter ) !== false ); 
  31.  
  32. // Remove 'bp_template_stack' from the current filter array. 
  33. array_pop( $wp_current_filter ); 
  34.  
  35. // Remove empties and duplicates. 
  36. $stack = array_unique( array_filter( $stack ) ); 
  37.  
  38. /** 
  39. * Filters the "template stack" list of registered directories where templates can be found. 
  40. * @since 1.7.0 
  41. * @param array $stack Array of registered directories for template locations. 
  42. */ 
  43. return (array) apply_filters( 'bp_get_template_stack', $stack ) ;