PluginProbe ʕ •ᴥ•ʔ
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel / trunk
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel vtrunk
trunk 0.9.0 0.9.1 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0 1.2.1 1.2.10 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.14 1.4.15 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0
wp-all-export / classes / config.php
wp-all-export / classes Last commit date
partner-discount-sdk 3 weeks ago CdataStrategy.php 3 weeks ago CdataStrategyAlways.php 3 weeks ago CdataStrategyFactory.php 3 weeks ago CdataStrategyIllegalCharacters.php 3 weeks ago CdataStrategyIllegalCharactersHtmlEntities.php 3 weeks ago CdataStrategyNever.php 3 weeks ago XMLWriter.php 3 weeks ago chunk.php 3 weeks ago config.php 3 years ago download.php 3 weeks ago handler.php 3 weeks ago helper.php 3 weeks ago input.php 3 weeks ago installer.php 3 weeks ago session.php 10 years ago wpallimport.php 3 weeks ago zip.php 4 years ago
config.php
100 lines
1 <?php
2
3 /**
4 * Class to load config files
5 *
6 * @author Pavel Kulbakin <p.kulbakin@gmail.com>
7 */
8 class PMXE_Config implements IteratorAggregate {
9
10 /**
11 * Config variables stored
12 * @var array
13 */
14 protected $config = array();
15
16 /**
17 * List of loaded files in order to avoid loading same file several times
18 * @var array
19 */
20 protected $loaded = array();
21
22 /**
23 * Static method to create config instance from file on disc
24 * @param string $filePath
25 * @param string[optional] $section
26 * @return PMXE_Config
27 */
28 public static function createFromFile($filePath, $section = NULL) {
29 $config = new self();
30 return $config->loadFromFile($filePath, $section);
31 }
32
33 /**
34 * Load config file
35 * @param string $filePath
36 * @param string [optional] $section
37 * @return PMXE_Config
38 */
39 public function loadFromFile($filePath, $section = NULL)
40 {
41 if (!is_null($section)) {
42 $this->config[$section] = self::createFromFile($filePath);
43 } else {
44 $filePath = realpath($filePath);
45 if ($filePath and !in_array($filePath, $this->loaded)) {
46
47 require $filePath;
48
49 if (!isset($config)) {
50 $config = array();
51 }
52 }
53 $this->loaded[] = $filePath;
54 $this->config = array_merge($this->config, $config);
55 }
56 return $this;
57 }
58
59 /**
60 * Return value of setting with specified name
61 * @param string $field Setting name
62 * @param string[optional] $section Section name to look setting in
63 * @return mixed
64 */
65 public function get($field, $section = NULL) {
66 return ! is_null($section) ? $this->config[$section]->get($field) : $this->config[$field];
67 }
68
69 /**
70 * Magic method for checking whether some config option are set
71 * @param string $field
72 * @return bool
73 */
74 public function __isset($field) {
75 return isset($this->config[$field]);
76 }
77
78 /**
79 * Magic method to implement object-like access to config parameters
80 * @param string $field
81 * @return mixed
82 */
83 public function __get($field) {
84 return $this->config[$field];
85 }
86
87 /**
88 * Return all config options as array
89 * @return array
90 */
91 public function toArray($section = NULL): array
92 {
93 return ! is_null($section) ? $this->config[$section]->toArray() : $this->config;
94 }
95
96 public function getIterator(): \Traversable {
97 return new ArrayIterator($this->config);
98 }
99
100 }