. */ namespace Cforms2; /** * A Singleton to give access to all settings of cformsII. */ class Settings { private static $settings; private $cfs; private function __construct() { $this->cfs = get_option('cforms_settings'); } /** * Returns a setting. Has variable arguments, which are used as indexes of the settings array. */ public function get() { $ret = $this->cfs; foreach(func_get_args() as $arg) { if (!isset($ret[$arg])) { return null; } $ret = $ret[$arg]; } return $ret; } /** * Gives access to this Singleton. * * @return Settings the Settings Singleton */ public static function instance() { if (empty(Settings::$settings)) { Settings::$settings = new Settings(); } return Settings::$settings; } /** * Resets the static fields. */ public static function reset() { Settings::$settings = new Settings(); } }