Collections functions
General functions
Render functions
Theme permission functions
Resource functions

activate_plugin()

Parameters

ColumnTypeDefaultDescription
$name

Location

include/plugin_functions.php lines 19 to 61

Definition

 
function activate_plugin($name)
    {
    
$plugin_dir get_plugin_path($name);
    if (
file_exists($plugin_dir))
        {
        
$plugin_yaml get_plugin_yaml("$plugin_dir/$name.yaml"false);
        
# 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 26th June 2022 02:05 Europe/London time based on the source file dated 17th June 2022 14:45 Europe/London time.