@@ -47,15 +47,15 @@ discard block |
||
| 47 | 47 | * |
| 48 | 48 | * @param array $config |
| 49 | 49 | */ |
| 50 | - public function __construct( array $config = array() ) |
|
| 50 | + public function __construct(array $config = array()) |
|
| 51 | 51 | { |
| 52 | 52 | $this->config = array_merge($this->default_args(), $config); |
| 53 | 53 | $this->fields = new \Amarkal\UI\ComponentList(); |
| 54 | 54 | $this->sections = array(); |
| 55 | 55 | $this->form = new \Amarkal\UI\Form($this->fields); |
| 56 | 56 | |
| 57 | - \add_action('admin_menu', array($this,'add_submenu_page')); |
|
| 58 | - \add_action('admin_enqueue_scripts', array($this,'enqueue_scripts')); |
|
| 57 | + \add_action('admin_menu', array($this, 'add_submenu_page')); |
|
| 58 | + \add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | * @param array $args |
| 65 | 65 | * @return void |
| 66 | 66 | */ |
| 67 | - public function add_section( array $args ) |
|
| 67 | + public function add_section(array $args) |
|
| 68 | 68 | { |
| 69 | 69 | $args = \array_merge($this->default_section_args(), $args); |
| 70 | 70 | $slug = $args['slug']; |
| 71 | - if(array_key_exists($slug, $this->sections)) |
|
| 71 | + if (array_key_exists($slug, $this->sections)) |
|
| 72 | 72 | { |
| 73 | 73 | throw new \RuntimeException("A section with '$slug' has already been created for this page."); |
| 74 | 74 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @param array $args |
| 82 | 82 | * @return void |
| 83 | 83 | */ |
| 84 | - public function add_field( array $args ) |
|
| 84 | + public function add_field(array $args) |
|
| 85 | 85 | { |
| 86 | 86 | $this->fields->add_component($args); |
| 87 | 87 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function get_field_values() |
| 95 | 95 | { |
| 96 | - if(!isset($this->values)) |
|
| 96 | + if (!isset($this->values)) |
|
| 97 | 97 | { |
| 98 | 98 | $this->values = array_merge($this->form->reset(), $this->get_old_instance()); |
| 99 | 99 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @param string $name |
| 107 | 107 | * @return any |
| 108 | 108 | */ |
| 109 | - public function get_field_value( $name ) |
|
| 109 | + public function get_field_value($name) |
|
| 110 | 110 | { |
| 111 | 111 | $values = $this->get_field_values(); |
| 112 | 112 | return $values[$name]; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | public function enqueue_scripts() |
| 135 | 135 | { |
| 136 | 136 | // Only enqueue styles & scripts if this is a settings page |
| 137 | - if($this->config['slug'] === filter_input(INPUT_GET, 'page')) |
|
| 137 | + if ($this->config['slug'] === filter_input(INPUT_GET, 'page')) |
|
| 138 | 138 | { |
| 139 | 139 | \wp_enqueue_style('amarkal-settings'); |
| 140 | 140 | \wp_enqueue_script('amarkal-settings'); |
@@ -158,9 +158,9 @@ discard block |
||
| 158 | 158 | * @param array $new_instance |
| 159 | 159 | * @return array |
| 160 | 160 | */ |
| 161 | - public function update( $new_instance ) |
|
| 161 | + public function update($new_instance) |
|
| 162 | 162 | { |
| 163 | - if($this->can_update()) |
|
| 163 | + if ($this->can_update()) |
|
| 164 | 164 | { |
| 165 | 165 | $old_instance = $this->get_old_instance(); |
| 166 | 166 | $this->values = $this->form->update($new_instance, $old_instance); |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | public function reset() |
| 187 | 187 | { |
| 188 | - if($this->can_update()) |
|
| 188 | + if ($this->can_update()) |
|
| 189 | 189 | { |
| 190 | 190 | \delete_option($this->config['slug']); |
| 191 | 191 | $this->values = $this->form->reset(); |
@@ -207,9 +207,9 @@ discard block |
||
| 207 | 207 | * @param string $slug |
| 208 | 208 | * @return void |
| 209 | 209 | */ |
| 210 | - public function reset_section( $slug ) |
|
| 210 | + public function reset_section($slug) |
|
| 211 | 211 | { |
| 212 | - if($this->can_update()) |
|
| 212 | + if ($this->can_update()) |
|
| 213 | 213 | { |
| 214 | 214 | $old_instance = $this->get_old_instance(); |
| 215 | 215 | $final_instance = $this->form->reset_components($this->get_section_fields($slug)); |
@@ -258,9 +258,9 @@ discard block |
||
| 258 | 258 | private function get_section_fields($slug) |
| 259 | 259 | { |
| 260 | 260 | $fields = array(); |
| 261 | - foreach($this->fields->get_all() as $c) |
|
| 261 | + foreach ($this->fields->get_all() as $c) |
|
| 262 | 262 | { |
| 263 | - if($c->section === $slug) |
|
| 263 | + if ($c->section === $slug) |
|
| 264 | 264 | { |
| 265 | 265 | $fields[] = $c; |
| 266 | 266 | } |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | private function get_errors() |
| 277 | 277 | { |
| 278 | 278 | $errors = array(); |
| 279 | - foreach($this->form->get_errors() as $name => $error) |
|
| 279 | + foreach ($this->form->get_errors() as $name => $error) |
|
| 280 | 280 | { |
| 281 | 281 | $errors[$name] = $error; |
| 282 | 282 | } |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * @param array $values The list of values |
| 291 | 291 | * @return array |
| 292 | 292 | */ |
| 293 | - private function results_array( $errors = array(), $values = '' ) |
|
| 293 | + private function results_array($errors = array(), $values = '') |
|
| 294 | 294 | { |
| 295 | 295 | return array( |
| 296 | 296 | 'values' => $values, |