yith_wcwl_locate_template

Locate the templates and return the path of the file found.

Description

yith_wcwl_locate_template( (string) $path, (null) $var = null ); 

Parameters (2)

0. $path (string)
The path.
1. $var — Optional. (null) => null
The var.

Usage

  1. if ( !function_exists( 'yith_wcwl_locate_template' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'yith-woocommerce-wishlist/includes/functions.yith-wcwl.php'; 
  3.  
  4. // The path. 
  5. $path = ''; 
  6.  
  7. // The var. 
  8. $var = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = yith_wcwl_locate_template($path, $var); 
  12.  

Defined (1)

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

/includes/functions.yith-wcwl.php  
  1. function yith_wcwl_locate_template( $path, $var = NULL ) { 
  2. $woocommerce_base = WC()->template_path(); 
  3.  
  4. $template_woocommerce_path = $woocommerce_base . $path; 
  5. $template_path = '/' . $path; 
  6. $plugin_path = YITH_WCWL_DIR . 'templates/' . $path; 
  7.  
  8. $located = locate_template( array( 
  9. $template_woocommerce_path, // Search in <theme>/woocommerce/ 
  10. $template_path, // Search in <theme>/ 
  11. ) ); 
  12.  
  13. if( ! $located && file_exists( $plugin_path ) ) { 
  14. return apply_filters( 'yith_wcwl_locate_template', $plugin_path, $path ); 
  15.  
  16. return apply_filters( 'yith_wcwl_locate_template', $located, $path );