llms_locate_template( string $template_name, string $template_path = '', string $default_path = '' )
Locate Template
Parameters Parameters
- $template_name
-
(string) (Required) Name of template.
- $template_path
-
(string) (Optional) Dir path to template. Default is empty string. If not supplied the one retrived from
llms()->template_path()will be used.Default value: ''
- $default_path
-
(string) (Optional) Default path is empty string. If not supplied the template path is
llms()->plugin_path() . '/templates/'.Default value: ''
Return Return
(string)
Source Source
File: includes/functions/llms.functions.template.php
function llms_locate_template( $template_name, $template_path = '', $default_path = '' ) {
if ( ! $template_path ) {
$template_path = llms()->template_path();
}
if ( ! $default_path ) {
$default_path = llms()->plugin_path() . '/templates/';
}
// Check theme and template directories for the template.
$override_path = llms_get_template_override( $template_name );
// Get default template.
$path = ( $override_path ) ? $override_path : $default_path;
$template = $path . $template_name;
if ( ! file_exists( $template ) ) {
$template = '';
}
/**
* Filters the maybe located template file path
*
* Allow 3rd party plugin filter template file from their plugin.
*
* @since Unknown
*
* @param string $template The path to the template file. Empty string if no template found.
* @param string $template_name Name of template.
* @param string $template_path Dir path to template.
*/
return apply_filters( 'lifterlms_locate_template', $template, $template_name, $template_path );
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.0.0 | Only returns path if template exists. |
| 1.0.0 | Introduced. |