PluginProbe
WP Ultimate Post Grid / 2.5.0
WP Ultimate Post Grid v2.5.0
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / vendor / vafpress / classes / util / config.php

config.php in WP Ultimate Post Grid 2.5.0, at vendor/vafpress/classes/util/config.php

63 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Config files loader
5 */
6
7 class VP_Util_Config
8 {
9
10 private static $_instance;
11
12 private $_configs;
13
14 private function __construct()
15 {
16 $this->_configs = array();
17 }
18
19 public static function instance()
20 {
21 if (is_null(self::$_instance))
22 {
23 self::$_instance = new self();
24 }
25 return self::$_instance;
26 }
27
28
29 public function load($config_name, $key = '')
30 {
31 // get the config, try to get in memory cache
32 if (array_key_exists($config_name, $this->_configs))
33 {
34 $config = $this->_configs[$config_name];
35 }
36 else
37 {
38 if(is_file(VP_CONFIG_DIR . '/'. $config_name . '.php'))
39 {
40 $config = require VP_CONFIG_DIR . '/'. $config_name . '.php';
41 }
42 else
43 {
44 throw new Exception("$config_name file not found.\n", 1);
45 }
46 // cache 'em
47 $this->_configs[$config_name] = $config;
48 }
49
50 // if key supplied, get the specific index of config array
51 $temp = $config;
52 if($key !== '')
53 {
54 $keys = explode('.', $key);
55 foreach ($keys as $key)
56 {
57 $temp = $temp[$key];
58 }
59 }
60 return $temp;
61 }
62
63 }