Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video 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 338 to 361

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);
        }

    
$config_ser_json mysqli_real_escape_string($db["read_write"], $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);

    
sql_query("UPDATE plugins SET config='$config_ser_bin', config_json='$config_ser_json' WHERE name='$plugin_name'");

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

    return 
true;
    }

This article was last updated 26th November 2020 04:05 Europe/London time based on the source file dated 9th October 2020 10:20 Europe/London time.