Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

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 1584 to 1602

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 4th December 2024 09:05 Europe/London time based on the source file dated 29th November 2024 10:35 Europe/London time.