PluginProbe ʕ •ᴥ•ʔ
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets / 2.12
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets v2.12
3.9.5 3.9.6 4.0.0 4.0.1 4.1.0 trunk 2.12 2.13 2.14 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.5.7 3.5.8 3.5.9 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9 3.7.0 3.7.1 3.7.2 3.7.3 3.7.3-beta-1.0 3.7.4 3.7.4-beta-1.0 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4
wp-all-import / classes / config.php
wp-all-import / classes Last commit date
config.php 13 years ago helper.php 13 years ago input.php 13 years ago
config.php
91 lines
1 <?php
2 /**
3 * Class to load config files
4 *
5 * @author Pavel Kulbakin <p.kulbakin@gmail.com>
6 */
7 class PMXI_Config implements IteratorAggregate {
8 /**
9 * Config variables stored
10 * @var array
11 */
12 protected $config = array();
13 /**
14 * List of loaded files in order to avoid loading same file several times
15 * @var array
16 */
17 protected $loaded = array();
18
19 /**
20 * Static method to create config instance from file on disc
21 * @param string $filePath
22 * @param string[optional] $section
23 * @return PMXI_Config
24 */
25 public static function createFromFile($filePath, $section = NULL) {
26 $config = new self();
27 return $config->loadFromFile($filePath, $section);
28 }
29
30 /**
31 * Load config file
32 * @param string $filePath
33 * @param string[optional] $section
34 * @return PMXI_Config
35 */
36 public function loadFromFile($filePath, $section = NULL) {
37 if ( ! is_null($section)) {
38 $this->config[$section] = self::createFromFile($filePath);
39 } else {
40 $filePath = realpath($filePath);
41 if ($filePath and ! in_array($filePath, $this->loaded)) {
42 require $filePath;
43
44 $sandbox = create_function('', "require '$filePath'; if(array_keys(get_defined_vars()) != array('config')) return array(); return \$config;");
45 $config = $sandbox();
46 $this->loaded[] = $filePath;
47 $this->config = array_merge($this->config, $config);
48 }
49 }
50 return $this;
51 }
52 /**
53 * Return value of setting with specified name
54 * @param string $field Setting name
55 * @param string[optional] $section Section name to look setting in
56 * @return mixed
57 */
58 public function get($field, $section = NULL) {
59 return ! is_null($section) ? $this->config[$section]->get($field) : $this->config[$field];
60 }
61
62 /**
63 * Magic method for checking whether some config option are set
64 * @param string $field
65 * @return bool
66 */
67 public function __isset($field) {
68 return isset($this->config[$field]);
69 }
70 /**
71 * Magic method to implement object-like access to config parameters
72 * @param string $field
73 * @return mixed
74 */
75 public function __get($field) {
76 return $this->config[$field];
77 }
78
79 /**
80 * Return all config options as array
81 * @return array
82 */
83 public function toArray($section = NULL) {
84 return ! is_null($section) ? $this->config[$section]->toArray() : $this->config;
85 }
86
87 public function getIterator() {
88 return new ArrayIterator($this->config);
89 }
90
91 }