Collections functions
General functions
Render functions
Theme permission functions
Resource functions

set_plugin_config()

Description

Store a plugin's configuration in the database.

Serializes the $config parameter and stores in the config
and config_json columns of the plugins table.
<code>
<?php
$plugin_config['a'] = 1;
$plugin_config['b'] = 2;
set_plugin_config('myplugin', $plugin_config);
?>
</code>

@see get_plugin_config

Parameters

ColumnTypeDefaultDescription
$plugin_name string Plugin name
$config mixed Configuration variable to store.

Location

include/plugin_functions.php lines 324 to 345

Definition

 
function set_plugin_config($plugin_name$config)
    {
    global 
$db$mysql_charset;
    
$config config_clean($config);
    
$config_ser_bin =  base64_encode(serialize($config));
    
$config_ser_json config_json_encode($config);
    if (!isset(
$mysql_charset))
        {
        
$config_ser_json iconv('UTF-8''ISO-8859-1//TRANSLIT'$config_ser_json);
        }

    
// We record the activity before running the query because log_activity() is trying to be clever and figure out the old value
    // which will make the new value also show up (incorrectly) as the old value.
    
log_activity(nullLOG_CODE_EDITED$config_ser_json'plugins''config_json'$plugin_name'name'nullnulltrue);

    
ps_query("UPDATE plugins SET config = ?, config_json = ? WHERE name = ?", array("s"$config_ser_bin"s"$config_ser_json"s"$plugin_name));

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

    return 
true;
    }

This article was last updated 2nd October 2022 17:05 Europe/London time based on the source file dated 2nd September 2022 14:25 Europe/London time.