wc_ps_get_template

Get templates passing attributes and including the file.

Description

wc_ps_get_template( (string) $template_name, (array) $args = array() ); 

Parameters (2)

0. $template_name (string)
The template name.
1. $args — Optional. (array) => array()
(default: array())

Usage

  1. if ( !function_exists( 'wc_ps_get_template' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-predictive-search-lite/includes/wc-predictive-template-functions.php'; 
  3.  
  4. // The template name. 
  5. $template_name = ''; 
  6.  
  7. // (default: array()) 
  8. $args = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wc_ps_get_template($template_name, $args); 
  12.  

Defined (1)

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

/includes/wc-predictive-template-functions.php  
  1. function wc_ps_get_template( $template_name, $args = array() ) { 
  2. if ( $args && is_array( $args ) ) { 
  3. extract( $args ); 
  4.  
  5. $template_file_path = wc_ps_get_template_file_path( $template_name ); 
  6.  
  7. if ( ! file_exists( $template_file_path ) ) { 
  8. _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $template_file_path ), '1.0.0' ); 
  9. return; 
  10.  
  11. // Allow 3rd party plugin filter template file from their plugin 
  12. $template_file_path = apply_filters( 'wc_ps_get_template', $template_file_path, $template_name, $args ); 
  13.  
  14. do_action( 'wc_ps_before_template_part', $template_name, $template_file_path, $args ); 
  15.  
  16. include( $template_file_path ); 
  17.  
  18. do_action( 'wc_ps_after_template_part', $template_name, $template_file_path, $args );