get_plugin_path()

Description

Retrieves the file path for a specified plugin.

This function checks both the standard plugin directory and the user-uploaded filestore directory to locate
the plugin. It can return either the file path on disk or a URL to the plugin based on the provided parameter.

Parameters

ColumnTypeDefaultDescription
$plugin string The short name of the plugin to locate.
$url bool false Optional. If true, return the URL to the plugin instead of the file path. Default is false.

Return

string|false The path to the plugin on disk or the URL to the plugin, or false if the plugin is not found.

Location

include/plugin_functions.php lines 1592 to 1610

Definition

 
function get_plugin_path($plugin,$url=false)
    {
    
# For the given plugin shortname, return the path on disk
    # Supports plugins being in the filestore folder (for user uploaded plugins)
    
global $baseurl_short,$storagedir,$storageurl;

    
# Sanitise $plugin
    
$plugin=safe_file_name($plugin);

    
# Standard location
    
$pluginpath=__DIR__ "/../plugins/" $plugin;
    if (
file_exists($pluginpath)) {return $url $baseurl_short "plugins/" $plugin $pluginpath;}

    
# Filestore location
    
$pluginpath=$storagedir "/plugins/" $plugin;
    if (
file_exists($pluginpath)) {return $url $storageurl "/plugins/" $plugin $pluginpath;}

    return 
false;
    }

This article was last updated 6th April 2025 21:35 Europe/London time based on the source file dated 1st April 2025 12:20 Europe/London time.