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, '/'));
}