@@ -24,13 +24,13 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @param array $config |
| 26 | 26 | */ |
| 27 | - public function __construct( array $config = array() ) |
|
| 27 | + public function __construct(array $config = array()) |
|
| 28 | 28 | { |
| 29 | 29 | $this->config = array_merge($this->default_args(), $config); |
| 30 | 30 | $this->form = new \Amarkal\UI\Form($this->config['fields']); |
| 31 | 31 | |
| 32 | - \add_action('admin_menu', array($this,'add_submenu_page')); |
|
| 33 | - \add_action('admin_enqueue_scripts', array($this,'enqueue_scripts')); |
|
| 32 | + \add_action('admin_menu', array($this, 'add_submenu_page')); |
|
| 33 | + \add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | public function enqueue_scripts() |
| 56 | 56 | { |
| 57 | 57 | // Only enqueue styles & scripts if this is a settings page |
| 58 | - if($this->config['slug'] === filter_input(INPUT_GET, 'page')) |
|
| 58 | + if ($this->config['slug'] === filter_input(INPUT_GET, 'page')) |
|
| 59 | 59 | { |
| 60 | 60 | \wp_enqueue_style('amarkal-settings'); |
| 61 | 61 | \wp_enqueue_script('amarkal-settings'); |
@@ -79,15 +79,15 @@ discard block |
||
| 79 | 79 | * @param array $new_instance |
| 80 | 80 | * @return array |
| 81 | 81 | */ |
| 82 | - public function update( $new_instance ) |
|
| 82 | + public function update($new_instance) |
|
| 83 | 83 | { |
| 84 | - if($this->can_update()) |
|
| 84 | + if ($this->can_update()) |
|
| 85 | 85 | { |
| 86 | 86 | $old_instance = $this->get_old_instance(); |
| 87 | 87 | $final_instance = $this->form->update($new_instance, $old_instance); |
| 88 | - foreach($final_instance as $name => $value) |
|
| 88 | + foreach ($final_instance as $name => $value) |
|
| 89 | 89 | { |
| 90 | - \update_option($name,$value); |
|
| 90 | + \update_option($name, $value); |
|
| 91 | 91 | } |
| 92 | 92 | return $this->results_array( |
| 93 | 93 | $this->get_errors(), |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function reset() |
| 109 | 109 | { |
| 110 | - if($this->can_update()) |
|
| 110 | + if ($this->can_update()) |
|
| 111 | 111 | { |
| 112 | - foreach($this->config['fields'] as $field) |
|
| 112 | + foreach ($this->config['fields'] as $field) |
|
| 113 | 113 | { |
| 114 | 114 | \delete_option($field['name']); |
| 115 | 115 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | private function get_errors() |
| 140 | 140 | { |
| 141 | 141 | $errors = array(); |
| 142 | - foreach($this->form->get_errors() as $name => $error) |
|
| 142 | + foreach ($this->form->get_errors() as $name => $error) |
|
| 143 | 143 | { |
| 144 | 144 | $component = $this->form->get_component($name); |
| 145 | 145 | $errors[$name] = "<strong>{$component->title}</strong> $error"; |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @param array $values The list of values |
| 155 | 155 | * @return array |
| 156 | 156 | */ |
| 157 | - private function results_array( $errors = array(), $values = '' ) |
|
| 157 | + private function results_array($errors = array(), $values = '') |
|
| 158 | 158 | { |
| 159 | 159 | return array( |
| 160 | 160 | 'values' => $values, |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | private function get_old_instance() |
| 182 | 182 | { |
| 183 | 183 | $old_instance = array(); |
| 184 | - foreach($this->form->get_components() as $component) |
|
| 184 | + foreach ($this->form->get_components() as $component) |
|
| 185 | 185 | { |
| 186 | 186 | $old_instance[$component->name] = \get_option($component->name, $component->default); |
| 187 | 187 | } |