bp_gifts_load_template_filter

Bp_gifts_load_template_filter().

Description

bp_gifts_load_template_filter( $found_template, $templates ); 

You can define a custom load template filter for your component. This will allow

you to store and load template files from your plugin directory.

Parameters (2)

0. $found_template
The found template.
1. $templates
The templates.

Usage

  1. if ( !function_exists( 'bp_gifts_load_template_filter' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-gifts-latest-2014/includes/bp-gifts-core.php'; 
  3.  
  4. // The found template. 
  5. $found_template = null; 
  6.  
  7. // The templates. 
  8. $templates = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_gifts_load_template_filter($found_template, $templates); 
  12.  

Defined (1)

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

/includes/bp-gifts-core.php  
  1. function bp_gifts_load_template_filter( $found_template, $templates ) { 
  2.  
  3. global $bp; 
  4.  
  5.  
  6.  
  7. /** 
  8.   
  9. * Only filter the template location when we're on the gifts component pages. 
  10.   
  11. */ 
  12.  
  13. if ( $bp->current_component != $bp->gifts->slug ) 
  14.  
  15. return $found_template; 
  16.  
  17.  
  18.  
  19. foreach ( (array) $templates as $template ) { 
  20.  
  21. if ( file_exists( STYLESHEETPATH . '/' . $template ) ) 
  22.  
  23. $filtered_templates[] = STYLESHEETPATH . '/' . $template; 
  24.  
  25. else 
  26.  
  27. $filtered_templates[] = dirname( __FILE__ ) . '/templates/' . $template; 
  28.  
  29.  
  30.  
  31.  
  32. $found_template = $filtered_templates[0]; 
  33.  
  34.  
  35.  
  36. return apply_filters( 'bp_gifts_load_template_filter', $found_template ); 
  37.