lp__get_template_path( $template_names, $load = false, $require_once = true, $args = array(), $plugin_name = LP__NAME )

This function searches for the template file in the theme directory and the plugin directory. It allows you to provide a list of template names and attempts to locate the template file in the following order: first in the theme directory for overrides, and then in the plugin directory.

Plugin

Namespace

Launchpad

Parameters

array

$template_names

List of template names.

array

$args

Template arguments to pass.

bool

$load

Whether to load the template.

bool

$require_once

Whether to load the template once.

string

$plugin_name

Plugin name to get the file from.

Return

string

Located file path.

Source

File: \includes\lp-utility-functions.php

function lp__get_template_path($template_names, $load = false, $require_once = true, $args = array(), $plugin_name = LP__NAME ) {
    $located = ''; 
    foreach ( (array) $template_names as $template_name ) { 
    if ( !$template_name ) 
        continue; 

        // Search template file in the theme folder for overrides.
        $theme_template = locate_template( array(
            $plugin_name . '/' . $template_name,
            $template_name
        ) ); 

        if($theme_template){
            $theme_template = lp__normalize_path( $theme_template );
            if ( file_exists( $theme_template ) ) {
                $located = $theme_template;
                break;
            }
        } else {
            // Search template file within the plugin.
            $template_file = lp__get_path( $template_name, $plugin_name );
            if ( file_exists( $template_file ) ) { 
                $located = $template_file; 
                break; 
            }
        } 
    }

    if ( $load && '' != $located )
        load_template( $located, $require_once, $args );

    return $located;
}

Related

Used to standardize file paths by replacing backslashes and removing duplicates.

Used to retrieve the normalized file path of a plugin file.

Used to include Launchpad plugin files via require_once based on filename and plugin name.

Used to retrieve and load plugin template based on slug and name.

Use to load multiple template parts based on slugs and names.

Use to load multiple template parts based on slugs and names.