psm_get_conf(): auto-load config if it hasnt been loaded yet

pull/116/head
Pepijn Over 2014-07-31 16:06:20 +02:00
parent 77e295a465
commit 4d92e9c0c1
1 changed files with 3 additions and 1 deletions

View File

@ -111,7 +111,6 @@ function psm_get_langs() {
/** /**
* Get a setting from the config. * Get a setting from the config.
* The config must have been loaded first using psm_load_conf()
* *
* @param string $key * @param string $key
* @param mixed $alt if not set, return this alternative * @param mixed $alt if not set, return this alternative
@ -119,6 +118,9 @@ function psm_get_langs() {
* @see psm_load_conf() * @see psm_load_conf()
*/ */
function psm_get_conf($key, $alt = null) { function psm_get_conf($key, $alt = null) {
if(!isset($GLOBALS['sm_config'])) {
psm_load_conf();
}
$result = (isset($GLOBALS['sm_config'][$key])) ? $GLOBALS['sm_config'][$key] : $alt; $result = (isset($GLOBALS['sm_config'][$key])) ? $GLOBALS['sm_config'][$key] : $alt;
return $result; return $result;