@@ -56,7 +56,6 @@ |
||
56 | 56 | /** |
57 | 57 | * Get the value of the given settings field |
58 | 58 | * |
59 | - * @param [array] $args |
|
60 | 59 | * @return void |
61 | 60 | */ |
62 | 61 | function amarkal_get_settings_value( $slug, $field_name ) |
@@ -13,15 +13,15 @@ discard block |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // Prevent direct file access |
16 | -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
|
16 | +defined('ABSPATH') or die('No script kiddies please!'); |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Prevent loading the library more than once |
20 | 20 | */ |
21 | -if( defined( 'AMARKAL_SETTINGS' ) ) return false; |
|
22 | -define( 'AMARKAL_SETTINGS', true ); |
|
21 | +if (defined('AMARKAL_SETTINGS')) return false; |
|
22 | +define('AMARKAL_SETTINGS', true); |
|
23 | 23 | |
24 | -if(!function_exists('amarkal_add_settings_page')) |
|
24 | +if (!function_exists('amarkal_add_settings_page')) |
|
25 | 25 | { |
26 | 26 | /** |
27 | 27 | * Add a new settings page |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | * @param [array] $args |
30 | 30 | * @return void |
31 | 31 | */ |
32 | - function amarkal_add_settings_page( $args ) |
|
32 | + function amarkal_add_settings_page($args) |
|
33 | 33 | { |
34 | 34 | $manager = Amarkal\Settings\Manager::get_instance(); |
35 | 35 | return $manager->add_settings_page($args); |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | -if(!function_exists('amarkal_get_settings_page')) |
|
39 | +if (!function_exists('amarkal_get_settings_page')) |
|
40 | 40 | { |
41 | 41 | /** |
42 | 42 | * Get a settings page instance |
@@ -44,14 +44,14 @@ discard block |
||
44 | 44 | * @param string $slug |
45 | 45 | * @return Amarkal\Settings\SettingsPage |
46 | 46 | */ |
47 | - function amarkal_get_settings_page( $slug ) |
|
47 | + function amarkal_get_settings_page($slug) |
|
48 | 48 | { |
49 | 49 | $manager = Amarkal\Settings\Manager::get_instance(); |
50 | 50 | return $manager->get_settings_page($slug); |
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | -if(!function_exists('amarkal_get_settings_value')) |
|
54 | +if (!function_exists('amarkal_get_settings_value')) |
|
55 | 55 | { |
56 | 56 | /** |
57 | 57 | * Get the value of the given settings field |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param [array] $args |
60 | 60 | * @return void |
61 | 61 | */ |
62 | - function amarkal_get_settings_value( $slug, $field_name ) |
|
62 | + function amarkal_get_settings_value($slug, $field_name) |
|
63 | 63 | { |
64 | 64 | $manager = Amarkal\Settings\Manager::get_instance(); |
65 | 65 | $page = $manager->get_settings_page($slug); |
@@ -226,7 +226,7 @@ |
||
226 | 226 | /** |
227 | 227 | * Get the component corresponding to the given name |
228 | 228 | * |
229 | - * @param [string] $name |
|
229 | + * @param string $name |
|
230 | 230 | * @throws RuntimeException when the component cannot be found |
231 | 231 | * @return void |
232 | 232 | */ |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param array $config |
42 | 42 | */ |
43 | - public function __construct( array $config = array() ) |
|
43 | + public function __construct(array $config = array()) |
|
44 | 44 | { |
45 | 45 | $this->config = array_merge($this->default_args(), $config); |
46 | 46 | $this->fields = new \Amarkal\UI\ComponentList(); |
47 | 47 | $this->sections = array(); |
48 | 48 | $this->form = new \Amarkal\UI\Form($this->fields); |
49 | 49 | |
50 | - \add_action('admin_menu', array($this,'add_submenu_page')); |
|
51 | - \add_action('admin_enqueue_scripts', array($this,'enqueue_scripts')); |
|
50 | + \add_action('admin_menu', array($this, 'add_submenu_page')); |
|
51 | + \add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | * @param array $args |
58 | 58 | * @return void |
59 | 59 | */ |
60 | - public function add_section( array $args ) |
|
60 | + public function add_section(array $args) |
|
61 | 61 | { |
62 | 62 | $args = \array_merge($this->default_section_args(), $args); |
63 | 63 | $slug = $args['slug']; |
64 | - if(array_key_exists($slug, $this->sections)) |
|
64 | + if (array_key_exists($slug, $this->sections)) |
|
65 | 65 | { |
66 | 66 | throw new \RuntimeException("A section with '$slug' has already been created for this page."); |
67 | 67 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param array $args |
75 | 75 | * @return void |
76 | 76 | */ |
77 | - public function add_field( array $args ) |
|
77 | + public function add_field(array $args) |
|
78 | 78 | { |
79 | 79 | $this->fields->add_component($args); |
80 | 80 | } |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | * @param string $name |
86 | 86 | * @return void |
87 | 87 | */ |
88 | - public function get_field_value( $name ) |
|
88 | + public function get_field_value($name) |
|
89 | 89 | { |
90 | 90 | $old_instance = $this->get_old_instance(); |
91 | 91 | |
92 | - if(\array_key_exists($name, $old_instance)) |
|
92 | + if (\array_key_exists($name, $old_instance)) |
|
93 | 93 | { |
94 | 94 | return $old_instance[$name]; |
95 | 95 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | public function enqueue_scripts() |
121 | 121 | { |
122 | 122 | // Only enqueue styles & scripts if this is a settings page |
123 | - if($this->config['slug'] === filter_input(INPUT_GET, 'page')) |
|
123 | + if ($this->config['slug'] === filter_input(INPUT_GET, 'page')) |
|
124 | 124 | { |
125 | 125 | \wp_enqueue_style('amarkal-settings'); |
126 | 126 | \wp_enqueue_script('amarkal-settings'); |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | * @param array $new_instance |
145 | 145 | * @return array |
146 | 146 | */ |
147 | - public function update( $new_instance ) |
|
147 | + public function update($new_instance) |
|
148 | 148 | { |
149 | - if($this->can_update()) |
|
149 | + if ($this->can_update()) |
|
150 | 150 | { |
151 | 151 | $old_instance = $this->get_old_instance(); |
152 | 152 | $final_instance = $this->form->update($new_instance, $old_instance); |
153 | 153 | |
154 | - \update_option($this->config['slug'],$final_instance); |
|
154 | + \update_option($this->config['slug'], $final_instance); |
|
155 | 155 | |
156 | 156 | return $this->results_array( |
157 | 157 | $this->get_errors(), |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function reset() |
173 | 173 | { |
174 | - if($this->can_update()) |
|
174 | + if ($this->can_update()) |
|
175 | 175 | { |
176 | 176 | \delete_option($this->config['slug']); |
177 | 177 | |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | * @param string $slug |
193 | 193 | * @return void |
194 | 194 | */ |
195 | - public function reset_section( $slug ) |
|
195 | + public function reset_section($slug) |
|
196 | 196 | { |
197 | - if($this->can_update()) |
|
197 | + if ($this->can_update()) |
|
198 | 198 | { |
199 | 199 | $old_instance = $this->get_old_instance(); |
200 | 200 | $final_instance = $this->form->reset_components($this->get_section_fields($slug)); |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | private function get_section_fields($slug) |
245 | 245 | { |
246 | 246 | $fields = array(); |
247 | - foreach($this->fields->get_all() as $c) |
|
247 | + foreach ($this->fields->get_all() as $c) |
|
248 | 248 | { |
249 | - if($c->section === $slug) |
|
249 | + if ($c->section === $slug) |
|
250 | 250 | { |
251 | 251 | $fields[] = $c; |
252 | 252 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | private function get_errors() |
263 | 263 | { |
264 | 264 | $errors = array(); |
265 | - foreach($this->form->get_errors() as $name => $error) |
|
265 | + foreach ($this->form->get_errors() as $name => $error) |
|
266 | 266 | { |
267 | 267 | $errors[$name] = $error; |
268 | 268 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * @param array $values The list of values |
277 | 277 | * @return array |
278 | 278 | */ |
279 | - private function results_array( $errors = array(), $values = '' ) |
|
279 | + private function results_array($errors = array(), $values = '') |
|
280 | 280 | { |
281 | 281 | return array( |
282 | 282 | 'values' => $values, |