@@ -11,132 +11,132 @@ |
||
11 | 11 | * @subpackage Core |
12 | 12 | */ |
13 | 13 | class Config { |
14 | - /** |
|
15 | - * Configuration type. |
|
16 | - * |
|
17 | - * @var ConfigType |
|
18 | - */ |
|
19 | - public $type; |
|
20 | - |
|
21 | - /** |
|
22 | - * App entry file. |
|
23 | - * |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - public $file; |
|
27 | - |
|
28 | - /** |
|
29 | - * App url. |
|
30 | - * |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - public $url; |
|
34 | - |
|
35 | - /** |
|
36 | - * App path. |
|
37 | - * |
|
38 | - * @var string |
|
39 | - */ |
|
40 | - public $path; |
|
41 | - |
|
42 | - /** |
|
43 | - * App slug. |
|
44 | - * |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - public $slug; |
|
48 | - |
|
49 | - /** |
|
50 | - * App basename. |
|
51 | - * |
|
52 | - * @var string |
|
53 | - */ |
|
54 | - public $basename; |
|
55 | - |
|
56 | - /** |
|
57 | - * Loaded JSON configuration files. |
|
58 | - * |
|
59 | - * @var array |
|
60 | - */ |
|
61 | - private $json = array(); |
|
62 | - |
|
63 | - /** |
|
64 | - * Loaded PHP configuration files. |
|
65 | - * |
|
66 | - * @var array |
|
67 | - */ |
|
68 | - private $php = array(); |
|
69 | - |
|
70 | - /** |
|
71 | - * Config constructor. |
|
72 | - * |
|
73 | - * @param string $type |
|
74 | - * @param string $file |
|
75 | - */ |
|
76 | - public function __construct( $type, $file ) { |
|
77 | - $this->type = new ConfigType( $type ); |
|
78 | - $this->file = $file; |
|
79 | - |
|
80 | - switch ( $this->type->getValue() ) { |
|
81 | - case ConfigType::PLUGIN: |
|
82 | - case ConfigType::MU_PLUGIN: |
|
83 | - $this->url = plugin_dir_url( $file ); |
|
84 | - $this->path = plugin_dir_path( $file ); |
|
85 | - $this->slug = dirname( $this->basename = plugin_basename( $file ) ); |
|
86 | - break; |
|
87 | - case ConfigType::THEME: |
|
88 | - $this->url = get_stylesheet_directory_uri() . '/'; |
|
89 | - $this->path = get_stylesheet_directory() . '/'; |
|
90 | - $this->slug = dirname( $this->basename = plugin_basename( $file ) ); |
|
91 | - break; |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Load a configuration JSON file from the config folder. |
|
97 | - * |
|
98 | - * @param string $filename |
|
99 | - * |
|
100 | - * @return array|null |
|
101 | - */ |
|
102 | - public function get_config_json( $filename ) { |
|
103 | - if ( isset( $this->json[ $filename ] ) ) { |
|
104 | - return $this->json[ $filename ]; |
|
105 | - } |
|
106 | - |
|
107 | - $path = $this->path . 'config/' . $filename . '.json'; |
|
108 | - |
|
109 | - if ( ! file_exists( $path ) ) { |
|
110 | - return null; |
|
111 | - } |
|
112 | - |
|
113 | - $contents = file_get_contents( $path ); |
|
114 | - |
|
115 | - if ( false === $contents ) { |
|
116 | - return null; |
|
117 | - } |
|
118 | - |
|
119 | - return $this->json[ $filename ] = json_decode( $contents, true ); |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Load a configuration PHP file from the config folder. |
|
124 | - * |
|
125 | - * @param string $filename |
|
126 | - * |
|
127 | - * @return array|null |
|
128 | - */ |
|
129 | - public function get_config_php( $filename ) { |
|
130 | - if ( isset( $this->php[ $filename ] ) ) { |
|
131 | - return $this->php[ $filename ]; |
|
132 | - } |
|
133 | - |
|
134 | - $path = $this->path . 'config/' . $filename . '.php'; |
|
135 | - |
|
136 | - if ( ! file_exists( $path ) ) { |
|
137 | - return null; |
|
138 | - } |
|
139 | - |
|
140 | - return $this->php[ $filename ] = require $path; |
|
141 | - } |
|
14 | + /** |
|
15 | + * Configuration type. |
|
16 | + * |
|
17 | + * @var ConfigType |
|
18 | + */ |
|
19 | + public $type; |
|
20 | + |
|
21 | + /** |
|
22 | + * App entry file. |
|
23 | + * |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + public $file; |
|
27 | + |
|
28 | + /** |
|
29 | + * App url. |
|
30 | + * |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + public $url; |
|
34 | + |
|
35 | + /** |
|
36 | + * App path. |
|
37 | + * |
|
38 | + * @var string |
|
39 | + */ |
|
40 | + public $path; |
|
41 | + |
|
42 | + /** |
|
43 | + * App slug. |
|
44 | + * |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + public $slug; |
|
48 | + |
|
49 | + /** |
|
50 | + * App basename. |
|
51 | + * |
|
52 | + * @var string |
|
53 | + */ |
|
54 | + public $basename; |
|
55 | + |
|
56 | + /** |
|
57 | + * Loaded JSON configuration files. |
|
58 | + * |
|
59 | + * @var array |
|
60 | + */ |
|
61 | + private $json = array(); |
|
62 | + |
|
63 | + /** |
|
64 | + * Loaded PHP configuration files. |
|
65 | + * |
|
66 | + * @var array |
|
67 | + */ |
|
68 | + private $php = array(); |
|
69 | + |
|
70 | + /** |
|
71 | + * Config constructor. |
|
72 | + * |
|
73 | + * @param string $type |
|
74 | + * @param string $file |
|
75 | + */ |
|
76 | + public function __construct( $type, $file ) { |
|
77 | + $this->type = new ConfigType( $type ); |
|
78 | + $this->file = $file; |
|
79 | + |
|
80 | + switch ( $this->type->getValue() ) { |
|
81 | + case ConfigType::PLUGIN: |
|
82 | + case ConfigType::MU_PLUGIN: |
|
83 | + $this->url = plugin_dir_url( $file ); |
|
84 | + $this->path = plugin_dir_path( $file ); |
|
85 | + $this->slug = dirname( $this->basename = plugin_basename( $file ) ); |
|
86 | + break; |
|
87 | + case ConfigType::THEME: |
|
88 | + $this->url = get_stylesheet_directory_uri() . '/'; |
|
89 | + $this->path = get_stylesheet_directory() . '/'; |
|
90 | + $this->slug = dirname( $this->basename = plugin_basename( $file ) ); |
|
91 | + break; |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Load a configuration JSON file from the config folder. |
|
97 | + * |
|
98 | + * @param string $filename |
|
99 | + * |
|
100 | + * @return array|null |
|
101 | + */ |
|
102 | + public function get_config_json( $filename ) { |
|
103 | + if ( isset( $this->json[ $filename ] ) ) { |
|
104 | + return $this->json[ $filename ]; |
|
105 | + } |
|
106 | + |
|
107 | + $path = $this->path . 'config/' . $filename . '.json'; |
|
108 | + |
|
109 | + if ( ! file_exists( $path ) ) { |
|
110 | + return null; |
|
111 | + } |
|
112 | + |
|
113 | + $contents = file_get_contents( $path ); |
|
114 | + |
|
115 | + if ( false === $contents ) { |
|
116 | + return null; |
|
117 | + } |
|
118 | + |
|
119 | + return $this->json[ $filename ] = json_decode( $contents, true ); |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * Load a configuration PHP file from the config folder. |
|
124 | + * |
|
125 | + * @param string $filename |
|
126 | + * |
|
127 | + * @return array|null |
|
128 | + */ |
|
129 | + public function get_config_php( $filename ) { |
|
130 | + if ( isset( $this->php[ $filename ] ) ) { |
|
131 | + return $this->php[ $filename ]; |
|
132 | + } |
|
133 | + |
|
134 | + $path = $this->path . 'config/' . $filename . '.php'; |
|
135 | + |
|
136 | + if ( ! file_exists( $path ) ) { |
|
137 | + return null; |
|
138 | + } |
|
139 | + |
|
140 | + return $this->php[ $filename ] = require $path; |
|
141 | + } |
|
142 | 142 | } |
@@ -73,21 +73,21 @@ discard block |
||
73 | 73 | * @param string $type |
74 | 74 | * @param string $file |
75 | 75 | */ |
76 | - public function __construct( $type, $file ) { |
|
77 | - $this->type = new ConfigType( $type ); |
|
76 | + public function __construct($type, $file) { |
|
77 | + $this->type = new ConfigType($type); |
|
78 | 78 | $this->file = $file; |
79 | 79 | |
80 | - switch ( $this->type->getValue() ) { |
|
80 | + switch ($this->type->getValue()) { |
|
81 | 81 | case ConfigType::PLUGIN: |
82 | 82 | case ConfigType::MU_PLUGIN: |
83 | - $this->url = plugin_dir_url( $file ); |
|
84 | - $this->path = plugin_dir_path( $file ); |
|
85 | - $this->slug = dirname( $this->basename = plugin_basename( $file ) ); |
|
83 | + $this->url = plugin_dir_url($file); |
|
84 | + $this->path = plugin_dir_path($file); |
|
85 | + $this->slug = dirname($this->basename = plugin_basename($file)); |
|
86 | 86 | break; |
87 | 87 | case ConfigType::THEME: |
88 | - $this->url = get_stylesheet_directory_uri() . '/'; |
|
89 | - $this->path = get_stylesheet_directory() . '/'; |
|
90 | - $this->slug = dirname( $this->basename = plugin_basename( $file ) ); |
|
88 | + $this->url = get_stylesheet_directory_uri().'/'; |
|
89 | + $this->path = get_stylesheet_directory().'/'; |
|
90 | + $this->slug = dirname($this->basename = plugin_basename($file)); |
|
91 | 91 | break; |
92 | 92 | } |
93 | 93 | } |
@@ -99,24 +99,24 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return array|null |
101 | 101 | */ |
102 | - public function get_config_json( $filename ) { |
|
103 | - if ( isset( $this->json[ $filename ] ) ) { |
|
104 | - return $this->json[ $filename ]; |
|
102 | + public function get_config_json($filename) { |
|
103 | + if (isset($this->json[$filename])) { |
|
104 | + return $this->json[$filename]; |
|
105 | 105 | } |
106 | 106 | |
107 | - $path = $this->path . 'config/' . $filename . '.json'; |
|
107 | + $path = $this->path.'config/'.$filename.'.json'; |
|
108 | 108 | |
109 | - if ( ! file_exists( $path ) ) { |
|
109 | + if (!file_exists($path)) { |
|
110 | 110 | return null; |
111 | 111 | } |
112 | 112 | |
113 | - $contents = file_get_contents( $path ); |
|
113 | + $contents = file_get_contents($path); |
|
114 | 114 | |
115 | - if ( false === $contents ) { |
|
115 | + if (false === $contents) { |
|
116 | 116 | return null; |
117 | 117 | } |
118 | 118 | |
119 | - return $this->json[ $filename ] = json_decode( $contents, true ); |
|
119 | + return $this->json[$filename] = json_decode($contents, true); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -126,17 +126,17 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return array|null |
128 | 128 | */ |
129 | - public function get_config_php( $filename ) { |
|
130 | - if ( isset( $this->php[ $filename ] ) ) { |
|
131 | - return $this->php[ $filename ]; |
|
129 | + public function get_config_php($filename) { |
|
130 | + if (isset($this->php[$filename])) { |
|
131 | + return $this->php[$filename]; |
|
132 | 132 | } |
133 | 133 | |
134 | - $path = $this->path . 'config/' . $filename . '.php'; |
|
134 | + $path = $this->path.'config/'.$filename.'.php'; |
|
135 | 135 | |
136 | - if ( ! file_exists( $path ) ) { |
|
136 | + if (!file_exists($path)) { |
|
137 | 137 | return null; |
138 | 138 | } |
139 | 139 | |
140 | - return $this->php[ $filename ] = require $path; |
|
140 | + return $this->php[$filename] = require $path; |
|
141 | 141 | } |
142 | 142 | } |