bb_load_template

The BuddyPress bb load template function.

Description

bb_load_template( $files, (constant) $globals = false, (null) $action_arg = null ); 

Parameters (3)

0. $files
The files.
1. $globals — Optional. (constant) => false
The globals.
2. $action_arg — Optional. (null) => null
The action arg.

Usage

  1. if ( !function_exists( 'bb_load_template' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-template.php'; 
  3.  
  4. // The files. 
  5. $files = null; 
  6.  
  7. // The globals. 
  8. $globals = false; 
  9.  
  10. // The action arg. 
  11. $action_arg = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bb_load_template($files, $globals, $action_arg); 
  15.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-template.php  
  1. function bb_load_template( $files, $globals = false, $action_arg = null ) 
  2. global $bb, $bbdb, $bb_current_user, $page, $bb_cache,  
  3. $posts, $bb_post, $post_id, $topics, $topic, $topic_id,  
  4. $forums, $forum, $forum_id, $tags, $tag, $tag_name, $user, $user_id, $view,  
  5. $del_class, $bb_alt; 
  6.  
  7. if ( $globals ) { 
  8. foreach ( $globals as $global => $v ) { 
  9. if ( !is_numeric($global) ) { 
  10. $$global = $v; 
  11. } else { 
  12. global $$v; 
  13.  
  14. $files = (array) $files; 
  15. $template = false; 
  16. $default_template = false; 
  17. $file_used = false; 
  18. $default_file_used = false; 
  19.  
  20. foreach ( $files as $file ) { 
  21. do_action( 'bb_' . $file, $action_arg ); 
  22. if ( false !== $template = bb_get_template( $file, false ) ) { 
  23. $file_used = $file; 
  24. break; 
  25. if ( !$default_template ) { 
  26. if ( false !== $default_template = bb_get_default_template( $file ) ) { 
  27. $default_file_used = $file; 
  28.  
  29. if ( !$template && $default_template ) { 
  30. $template = $default_template; 
  31. $file_used = $default_file_used; 
  32.  
  33. $template = apply_filters( 'bb_template', $template, $file_used ); 
  34. include( $template ); 
  35.