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

activate_plugin()

Description

Activate a named plugin.

Parses the plugins directory to look for a pluginname.yaml
file and adds the plugin to the plugins database, setting
the inst_version field to the version specified in the yaml file.

@see deactivate_plugin

Parameters

ColumnTypeDefaultDescription
$name string Name of plugin to be activated.

Return

bool Returns true if plugin directory was found.

Location

include/plugin_functions.php lines 17 to 59

Definition

 
function activate_plugin($name)
    {
    
$plugin_dir get_plugin_path($name);
    if (
file_exists($plugin_dir))
        {
        
$plugin_yaml get_plugin_yaml($namefalse);
        
# If no yaml, or yaml file but no description present, attempt to read an 'about.txt' file
        
if ('' == $plugin_yaml['desc'])
            {
            
$about $plugin_dir $name '/about.txt';
            if(
file_exists($about))
                {
                
$plugin_yaml['desc'] = substr(file_get_contents($about), 095) . '...';
                }
            }

        
# Add/Update plugin information.
        # Check if the plugin is already in the table.
        
$c ps_value("SELECT name as value FROM plugins WHERE name = ?", array("s"$name), '');

        if (
$c == '')
            {
            
ps_query("INSERT INTO plugins (name) VALUE (?)", array("s"$name));
            }

        
ps_query("UPDATE plugins SET config_url = ?, descrip = ?, author = ?, inst_version = ?, priority = ?, update_url = ?, info_url = ?, disable_group_select = ?,
        title = ?, icon = ? WHERE name = ?"
, array("s"$plugin_yaml['config_url'], "s"$plugin_yaml['desc'], "s"$plugin_yaml['author'], "d"$plugin_yaml['version'],
        
"i"$plugin_yaml['default_priority'], "s"$plugin_yaml['update_url'], "s"$plugin_yaml['info_url'], "i"$plugin_yaml['disable_group_select'], "s",
        
$plugin_yaml['title'], "s"$plugin_yaml['icon'], "s"$plugin_yaml['name']));

        
log_activity(nullLOG_CODE_ENABLED$plugin_yaml['version'], 'plugins''inst_version'$plugin_yaml['name'], 'name'''nulltrue);

        
// Clear query cache
        
clear_query_cache("plugins");

        
hook("after_activate_plugin","",array($name));
        return 
true;
        }
    else
        {
        return 
false;
        }
    }

This article was last updated 14th January 2025 20:35 Europe/London time based on the source file dated 13th January 2025 17:00 Europe/London time.