lp__get_path( $file = '', $plugin_name = LP__NAME )

The lp__get_path function is used to obtain the normalized file path of a plugin file based on the provided file path or filename and plugin name. The function also applies filters to allow modifications to the file path before returning it.

Plugin

Namespace

Launchpad

Parameters

string

$file

The file to get the file path.

string

$plugin_name

Plugin name to get the file from.

Return

string

Normalized plugin file path.

Source

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

function lp__get_path( $file  = '', $plugin_name = LP__NAME ) {

    /**
     * Filter: lp__get_path
     * 
     * This filter hook is for modifying file paths 
     * before returning them, offering flexibility to manipulate file paths 
     * either globally or specifically for a particular plugin. 
     * It then normalizes and returns the modified file path based on the provided parameters.
     *
     * @param string $file The file path or filename to get the file path.
     * @param string $plugin_name Plugin name to get the file from.
     */
    $file = apply_filters("lp__get_path", $file, $plugin_name);

    /**
     * Filter: lp__get_path/{$plugin_name}
     * 
     * This filter hook is for modifying file paths 
     * before returning them, offering flexibility to manipulate file paths 
     * either globally or specifically for a particular plugin. 
     * It then normalizes and returns the modified file path based on the provided parameters.
     *
     * The dynamic portion of the hook, `$plugin_name`, refers to the specific plugin name
     * to allow more granular control over the file path for different plugins.
     *
     * @param string $file The file path or filename to get the file path.
     */
    $file = apply_filters("lp__get_path/{$plugin_name}", $file);

    $plugin_name = is_string($plugin_name) && !empty($plugin_name)  ?  $plugin_name : LP__NAME;
    return lp__normalize_path(WP_PLUGIN_DIR . '/' . $plugin_name . '/' . ltrim($file, '/'));

}

Related

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

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 search for template files in theme and plugin directories.

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

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